1.更换软件协议为AGPL

2.切换项目名称为Hua.Todo
This commit is contained in:
ShaoHua
2026-04-06 22:06:30 +08:00
parent 40a91e39b6
commit 758f6772c6
147 changed files with 1203 additions and 644 deletions
+10 -10
View File
@@ -1,4 +1,4 @@
# Android 端显示 “Not Found” 排查计划(TodoList.Maui
# Android 端显示 “Not Found” 排查计划(Hua.Todo.Maui
## 目标
@@ -7,16 +7,16 @@
## 背景(当前实现快速定位)
- Android 使用自建 TCP HTTP Server,静态资源从 APK 的 `Assets/wwwroot/*` 读取:[MobileEmbeddedWebServerService](file:///d:/Proj/TodoList/src/TodoList.Maui/Platforms/Android/MobileEmbeddedWebServerService.cs)
- WebView 默认加载内嵌服务器地址(`IsUsingStatic=true` 时):[MainPage.xaml.cs](file:///d:/Proj/TodoList/src/TodoList.Maui/Views/MainPage.xaml.cs)
- Android 端静态文件找不到时返回纯文本 `Not Found`[HandleStaticAsync](file:///d:/Proj/TodoList/src/TodoList.Maui/Platforms/Android/MobileEmbeddedWebServerService.cs#L214-L255)
- Android 使用自建 TCP HTTP Server,静态资源从 APK 的 `Assets/wwwroot/*` 读取:[MobileEmbeddedWebServerService](file:///d:/Proj/Hua.Todo/src/Hua.Todo.Maui/Platforms/Android/MobileEmbeddedWebServerService.cs)
- WebView 默认加载内嵌服务器地址(`IsUsingStatic=true` 时):[MainPage.xaml.cs](file:///d:/Proj/Hua.Todo/src/Hua.Todo.Maui/Views/MainPage.xaml.cs)
- Android 端静态文件找不到时返回纯文本 `Not Found`[HandleStaticAsync](file:///d:/Proj/Hua.Todo/src/Hua.Todo.Maui/Platforms/Android/MobileEmbeddedWebServerService.cs#L214-L255)
## 排查顺序(从“最可能 & 最省时间”到“深入原因”)
### 1) 确认 WebView 实际加载的 URL
- 在 Android Debug 输出里确认 WebView Source(期望是 `http://localhost:5057``http://localhost:5057/`
- 如果不是内嵌地址,检查 `appsettings.json``WebServer.IsUsingStatic``ForEndUrl` 配置:[appsettings.json](file:///d:/Proj/TodoList/src/TodoList.Maui/appsettings.json)
- 如果不是内嵌地址,检查 `appsettings.json``WebServer.IsUsingStatic``ForEndUrl` 配置:[appsettings.json](file:///d:/Proj/Hua.Todo/src/Hua.Todo.Maui/appsettings.json)
判定:
- 若加载的是内嵌地址 → 继续第 2 步
@@ -24,8 +24,8 @@
### 2) 确认前端 dist 是否存在且可用于打包
- 检查 `src/TodoList.Web/dist/index.html` 是否存在
- 如果不存在:在 `src/TodoList.Web` 下执行 `npm ci` + `npm run build`,确保产物生成
- 检查 `src/Hua.Todo.Web/dist/index.html` 是否存在
- 如果不存在:在 `src/Hua.Todo.Web` 下执行 `npm ci` + `npm run build`,确保产物生成
判定:
- dist 不存在/为空 → “Not Found”高概率来自 Android 静态资源根本没被构建或没被打进 APK
@@ -35,7 +35,7 @@
- 重点验证打包结果是否存在:
- `assets/wwwroot/index.html`
- `assets/wwwroot/assets/*`(至少有 js/css
- 项目里通过 MSBuild 目标把 `TodoList.Web/dist` 映射为 AndroidAssetLink 到 `wwwroot/...`):[TodoList.Maui.csproj](file:///d:/Proj/TodoList/src/TodoList.Maui/TodoList.Maui.csproj#L150-L175)
- 项目里通过 MSBuild 目标把 `Hua.Todo.Web/dist` 映射为 AndroidAssetLink 到 `wwwroot/...`):[Hua.Todo.Maui.csproj](file:///d:/Proj/Hua.Todo/src/Hua.Todo.Maui/Hua.Todo.Maui.csproj#L150-L175)
判定:
- APK 内没有 `wwwroot/index.html` → 修复构建/打包流程(第 6 步会给方案)
@@ -57,7 +57,7 @@
- 如果看到的不是纯文本 `Not Found`,而是加载错误/空白:
- 检查 Android 明文 HTTP`http://localhost`)是否被允许
- 检查 `network_security_config.xml` 与 Manifest 配置:[network_security_config.xml](file:///d:/Proj/TodoList/src/TodoList.Maui/Platforms/Android/Resources/xml/network_security_config.xml)、[AndroidManifest.xml](file:///d:/Proj/TodoList/src/TodoList.Maui/Platforms/Android/AndroidManifest.xml)
- 检查 `network_security_config.xml` 与 Manifest 配置:[network_security_config.xml](file:///d:/Proj/Hua.Todo/src/Hua.Todo.Maui/Platforms/Android/Resources/xml/network_security_config.xml)、[AndroidManifest.xml](file:///d:/Proj/Hua.Todo/src/Hua.Todo.Maui/Platforms/Android/AndroidManifest.xml)
### 6) 修复与验证(根据前面判定选择)
@@ -65,7 +65,7 @@
- 让构建流程更“硬性”:
- 若 dist 不存在则强制构建,或在 Debug 也保证 `AndroidAsset` 包含 dist
- 可选:把 dist 复制进 `TodoList.Maui/wwwroot` 再用 `<Content Include="wwwroot\**" />`/`<MauiAsset />` 统一打包(减少条件目标的不确定性)
- 可选:把 dist 复制进 `Hua.Todo.Maui/wwwroot` 再用 `<Content Include="wwwroot\**" />`/`<MauiAsset />` 统一打包(减少条件目标的不确定性)
验证:
- APK 内能看到 `assets/wwwroot/index.html`,启动后不再返回 `Not Found`