chore: 完成多平台兼容性优化与资源更新

本次提交包含多项改进:
1. 新增Android启动页资源与配色配置,完善多版本主题适配
2. 全量替换Platform.pathSeparator为硬编码斜杠,修复Web平台路径兼容问题
3. 为大量文件系统操作添加kIsWeb守卫,优化Web端表现
4. 替换硬编码平台判断为platform_utils封装,统一平台检测逻辑
5. 移除冗余代码与默认参数,优化小部件性能
6. 新增Web端适配逻辑,处理不支持的原生功能
7. 更新鸿蒙兼容性工具,完善平台识别与路径处理
8. 优化设备注册错误捕获,避免非致命崩溃
9. 添加启动页图标与背景配置,优化首屏体验
This commit is contained in:
Developer
2026-06-05 02:31:34 +08:00
parent a2266913af
commit a5d8483797
79 changed files with 762 additions and 759 deletions

View File

@@ -1,12 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<!-- ============================================================ -->
<!-- 启动页背景API 21+,支持系统暗色模式) -->
<!-- 创建时间: 2026-04-20 -->
<!-- 更新时间: 2026-06-05 -->
<!-- 作用: Flutter引擎初始化期间显示的原生启动页 -->
<!-- 上次更新: 添加居中应用图标,适配暗色模式背景色 -->
<!-- ============================================================ -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<item android:drawable="@color/splash_background" />
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
android:src="@drawable/launch_image" />
</item>
</layer-list>

View File

@@ -1,12 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<!-- ============================================================ -->
<!-- 启动页背景(亮色模式) -->
<!-- 创建时间: 2026-04-20 -->
<!-- 更新时间: 2026-06-05 -->
<!-- 作用: Flutter引擎初始化期间显示的原生启动页 -->
<!-- 上次更新: 添加居中应用图标,消除白屏体验 -->
<!-- ============================================================ -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<item android:drawable="@color/splash_background" />
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
android:src="@drawable/launch_image" />
</item>
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ============================================================ -->
<!-- Android 12+ (API 31+) 启动页主题(暗色模式) -->
<!-- 创建时间: 2026-06-05 -->
<!-- 作用: 暗色模式下SplashScreen API自定义启动页图标和背景色 -->
<!-- ============================================================ -->
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
<!-- Android 12+ SplashScreen API 自定义 -->
<item name="android:windowSplashScreenAnimatedIcon">@drawable/launch_image</item>
<item name="android:windowSplashScreenBackground">@color/splash_background</item>
</style>
</resources>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ============================================================ -->
<!-- 启动页颜色定义(暗色模式覆盖) -->
<!-- 创建时间: 2026-06-05 -->
<!-- 作用: 暗色模式下启动页背景色覆盖 -->
<!-- ============================================================ -->
<resources>
<color name="splash_background">#000000</color>
</resources>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ============================================================ -->
<!-- Android 12+ (API 31+) 启动页主题 -->
<!-- 创建时间: 2026-06-05 -->
<!-- 作用: 使用 SplashScreen API自定义Android 12+启动页图标和背景色 -->
<!-- ============================================================ -->
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
<!-- Android 12+ SplashScreen API 自定义 -->
<item name="android:windowSplashScreenAnimatedIcon">@drawable/launch_image</item>
<item name="android:windowSplashScreenBackground">@color/splash_background</item>
</style>
</resources>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ============================================================ -->
<!-- 启动页颜色定义 -->
<!-- 创建时间: 2026-06-05 -->
<!-- 作用: 定义原生启动页的背景色,亮色/暗色模式统一管理 -->
<!-- ============================================================ -->
<resources>
<!-- 亮色模式启动页背景色 -->
<color name="splash_background">#FFFFFF</color>
<!-- 暗色模式启动页背景色 -->
<color name="splash_background_dark">#000000</color>
</resources>