docs(course): set production backend to shopneu.hmos.site and clean draft notes
This commit is contained in:
1 parent
dc2e32c437
commit
24945ee3fe
2 files changed
+20
-11
No files matched your search
@@ -33,7 +33,7 @@ kmp-mini-shopping/
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
```
|
||||
|
||||
如果课堂接 HTTP(局域网后端),`application` 里加:
|
||||
如果仅在本地联调 HTTP(局域网后端),`application` 里加:
|
||||
|
||||
```xml
|
||||
android:usesCleartextTraffic="true"
|
||||
@@ -75,6 +75,16 @@ Android 侧引擎(`shared/androidMain`)需要:
|
||||
- Ktor Serialization 官方说明(ContentNegotiation/JSON 的用途):
|
||||
`https://ktor.io/docs/server-serialization.html`
|
||||
|
||||
### 2.1 课程统一后端地址(已部署)
|
||||
- 线上地址:`https://shopneu.hmos.site`
|
||||
- 商品接口:`https://shopneu.hmos.site/api/products`(推荐)
|
||||
|
||||
Android 端 `baseUrl` 建议写:
|
||||
|
||||
```kotlin
|
||||
ProductApi(baseUrl = "https://shopneu.hmos.site/api", useMock = false)
|
||||
```
|
||||
|
||||
### 3. `content-negotiation` 是干什么的?(给学生讲)
|
||||
`ktor-client-content-negotiation` + `ktor-serialization-kotlinx-json` 这两个依赖,
|
||||
就是让 Ktor 能把接口返回的 JSON 自动反序列化成 Kotlin 数据类(例如 `List<Product>`)。
|
||||
@@ -101,8 +111,6 @@ install(ContentNegotiation) {
|
||||
- 后端额外返回 `tag/extra`
|
||||
- 开启 `ignoreUnknownKeys = true` 后,`id/title` 仍可正常解析。
|
||||
|
||||
> 你在官方文档里看到的 `prettyPrint`、`isLenient` 只是配置示例,
|
||||
> `ignoreUnknownKeys` 同样是 JsonBuilder 的常用配置项。
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in new issue
Block a user