docs(course): polish all lesson text and remove mismatched troubleshooting details
This commit is contained in:
1 parent
c9707129da
commit
a68d4193bf
2 files changed
+18
-19
No files matched your search
+14
-14
@@ -1,7 +1,7 @@
|
||||
# 第6节|KMP 商城实操讲稿
|
||||
## 主题:shared 共享层网络 + 本地持久化(把数据链路真正跑通)
|
||||
|
||||
> 这份讲稿是“边讲边敲”的版本。按步骤走,课堂上能稳定跑出:
|
||||
> 按步骤完成后可稳定实现:
|
||||
> 1)商品列表加载;2)加入购物车;3)重启后购物车不丢。
|
||||
|
||||
---
|
||||
@@ -33,11 +33,8 @@ kmp-mini-shopping/
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
```
|
||||
|
||||
如果仅在本地联调 HTTP(局域网后端),`application` 里加:
|
||||
|
||||
```xml
|
||||
android:usesCleartextTraffic="true"
|
||||
```
|
||||
> 课程已统一使用 HTTPS 地址:`https://shopneu.hmos.site`。
|
||||
> 仅当你改回本地 HTTP 联调时,才需要 `usesCleartextTraffic=true`。
|
||||
|
||||
---
|
||||
|
||||
@@ -343,19 +340,22 @@ class ProductRepository(
|
||||
|
||||
## 九、本节常见报错与处理
|
||||
|
||||
### 1)`Unresolved reference install`(Ktor)
|
||||
补 import:
|
||||
### 1)`Unresolved reference: ContentNegotiation`(Ktor Client)
|
||||
检查两件事:
|
||||
- 依赖是否存在:`ktor-client-content-negotiation` 与 `ktor-serialization-kotlinx-json`
|
||||
- import 是否正确:
|
||||
```kotlin
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||
import io.ktor.serialization.kotlinx.json.json
|
||||
```
|
||||
|
||||
### 2)Android 真机请求 HTTP 不通
|
||||
- Manifest 是否有 `usesCleartextTraffic=true`
|
||||
- 后端地址必须是局域网 IP,不是 `localhost`
|
||||
### 2)接口可在浏览器打开,但 App 仍无数据
|
||||
- `baseUrl` 是否为:`https://shopneu.hmos.site/api`
|
||||
- 是否误开了搜索过滤(输入框残留空格/关键词)
|
||||
|
||||
### 3)商品返回有数据,但 UI 显示“没有匹配”
|
||||
- 搜索词有空格残留(`trim()`)
|
||||
- 过滤逻辑误伤
|
||||
- 搜索词先 `trim()`
|
||||
- 先打印“服务总数 vs 当前显示数”定位是否是过滤导致
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in new issue
Block a user