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 当前显示数”定位是否是过滤导致
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
# 第7节|KMP 商城实操讲稿
|
||||
## 主题:MVVM 重构 + 全流程整合(结业可演示版本)
|
||||
|
||||
> 这份讲稿是“从第6节基础版迭代到结业版”的步骤脚本。
|
||||
> 跟着写完可以稳定达到:
|
||||
> 从第6节基础版迭代到结业版,按步骤完成可达到:
|
||||
> **两列商品列表 + 详情页 + 购物车底部结算栏 + MVVM 架构 + 后端联调 + 图片兜底**。
|
||||
|
||||
---
|
||||
@@ -171,9 +170,9 @@ ProductApi(baseUrl = "https://shopneu.hmos.site/api", useMock = false)
|
||||
- 过滤前先 `trim()`
|
||||
|
||||
### 3)真机请求不到后端
|
||||
- 后端监听是否 `0.0.0.0:8080`
|
||||
- 手机和电脑是否同一 Wi-Fi
|
||||
- baseUrl 是否写成局域网 IP(不能写 localhost)
|
||||
- `baseUrl` 是否写成:`https://shopneu.hmos.site/api`
|
||||
- 设备网络是否可访问该域名(浏览器先验证)
|
||||
- 证书异常时检查系统时间与网络策略
|
||||
|
||||
### 4)`Only VectorDrawables...`
|
||||
- drawable 资源格式不合法
|
||||
|
||||
Reference in new issue
Block a user