更新沃棣背景适配
This commit is contained in:
@@ -59,7 +59,7 @@
|
||||
|
||||
// final backgroundImage = showNoLoginView
|
||||
// ? 'assets/img/xiaoe.png' // 无设备或无登录时的背景
|
||||
// : 'assets/img/bgNoImg.png';
|
||||
// : getBackgroundImageNoImage();
|
||||
|
||||
// return Stack(
|
||||
// children: [
|
||||
@@ -257,7 +257,7 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
ValueNotifier<String> serverError = ValueNotifier<String>('');
|
||||
RxList deviceList = [].obs;
|
||||
RxString finalUri = RxString('');
|
||||
|
||||
|
||||
// 本地服务器相关
|
||||
HttpServer? _localServer;
|
||||
int _serverPort = 0;
|
||||
@@ -294,7 +294,7 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
try {
|
||||
isServerStarting.value = true;
|
||||
serverError.value = '';
|
||||
|
||||
|
||||
// 1. 从 assets 加载 ZIP 文件
|
||||
final ByteData zipData;
|
||||
try {
|
||||
@@ -303,48 +303,47 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
serverError.value = '找不到小e资源文件: $e';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
final Uint8List zipBytes = zipData.buffer.asUint8List();
|
||||
|
||||
|
||||
// 2. 创建临时目录并解压 ZIP
|
||||
_tempExtractDir = await Directory.systemTemp.createTemp('xiaoe_web_');
|
||||
final bool extractSuccess = await _extractZipToDirectory(zipBytes, _tempExtractDir!);
|
||||
|
||||
final bool extractSuccess =
|
||||
await _extractZipToDirectory(zipBytes, _tempExtractDir!);
|
||||
|
||||
if (!extractSuccess) {
|
||||
serverError.value = '解压小e资源文件失败';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 3. 查找入口文件 (index.html)
|
||||
final File? entryFile = await _findEntryFile(_tempExtractDir!);
|
||||
if (entryFile == null) {
|
||||
serverError.value = '找不到入口文件 (index.html)';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 4. 创建静态文件处理器
|
||||
final staticHandler = createStaticHandler(
|
||||
_tempExtractDir!.path,
|
||||
defaultDocument: 'index.html',
|
||||
serveFilesOutsidePath: false,
|
||||
);
|
||||
|
||||
|
||||
// 5. 添加日志中间件(可选)
|
||||
final handler = Pipeline()
|
||||
.addMiddleware(logRequests())
|
||||
.addHandler(staticHandler);
|
||||
|
||||
final handler =
|
||||
Pipeline().addMiddleware(logRequests()).addHandler(staticHandler);
|
||||
|
||||
// 6. 启动服务器(端口 0 表示自动分配)
|
||||
_localServer = await io.serve(handler, InternetAddress.loopbackIPv4, 0);
|
||||
_serverPort = _localServer!.port;
|
||||
_localServerUrl = 'http://127.0.0.1:$_serverPort';
|
||||
|
||||
|
||||
print('小e本地服务启动成功: $_localServerUrl');
|
||||
print('资源目录: ${_tempExtractDir!.path}');
|
||||
|
||||
|
||||
isServerStarting.value = false;
|
||||
return true;
|
||||
|
||||
} catch (e, stackTrace) {
|
||||
serverError.value = '启动本地服务器失败: $e';
|
||||
print('服务器启动错误: $e\n$stackTrace');
|
||||
@@ -353,27 +352,28 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> _extractZipToDirectory(Uint8List zipBytes, Directory targetDir) async {
|
||||
Future<bool> _extractZipToDirectory(
|
||||
Uint8List zipBytes, Directory targetDir) async {
|
||||
try {
|
||||
// 解码 ZIP 文件
|
||||
final Archive archive = ZipDecoder().decodeBytes(zipBytes);
|
||||
|
||||
|
||||
for (final ArchiveFile file in archive) {
|
||||
final String filename = file.name;
|
||||
|
||||
|
||||
// 跳过目录条目(它们会通过文件创建自动生成)
|
||||
if (file.isFile) {
|
||||
// 确保目录存在
|
||||
final String filePath = p.join(targetDir.path, filename);
|
||||
final File outputFile = File(filePath);
|
||||
await outputFile.parent.create(recursive: true);
|
||||
|
||||
|
||||
// 写入文件内容
|
||||
final List<int> data = file.content as List<int>;
|
||||
await outputFile.writeAsBytes(data, flush: true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print('解压完成,文件数量: ${archive.files.length}');
|
||||
return true;
|
||||
} catch (e, stackTrace) {
|
||||
@@ -391,17 +391,18 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
'main.html',
|
||||
'default.html',
|
||||
];
|
||||
|
||||
|
||||
for (final entry in possibleEntries) {
|
||||
final File file = File(p.join(dir.path, entry));
|
||||
if (await file.exists()) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 如果没有找到标准入口,查找任何 .html 文件
|
||||
try {
|
||||
final List<FileSystemEntity> entities = await dir.list(recursive: false).toList();
|
||||
final List<FileSystemEntity> entities =
|
||||
await dir.list(recursive: false).toList();
|
||||
for (final entity in entities) {
|
||||
if (entity is File && entity.path.toLowerCase().endsWith('.html')) {
|
||||
return entity;
|
||||
@@ -410,7 +411,7 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
} catch (e) {
|
||||
print('查找入口文件失败: $e');
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -421,7 +422,7 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
_localServer = null;
|
||||
print('本地服务器已关闭');
|
||||
}
|
||||
|
||||
|
||||
// 清理临时目录
|
||||
if (_tempExtractDir != null && _tempExtractDir!.existsSync()) {
|
||||
try {
|
||||
@@ -442,9 +443,9 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
return LayoutBuilder(
|
||||
builder: (context, bodySize) => GestureDetector(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgNoImg.png'),
|
||||
image: AssetImage(getBackgroundImageNoImage()),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
@@ -512,7 +513,7 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return ValueListenableBuilder<String>(
|
||||
valueListenable: serverError,
|
||||
builder: (context, error, child) {
|
||||
@@ -571,7 +572,7 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return Obx(() {
|
||||
if (finalUri.isEmpty) {
|
||||
return Center(
|
||||
@@ -696,12 +697,12 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
// 构建最终 URL
|
||||
String baseUrl = _localServerUrl;
|
||||
String queryParams = '?t=${DateTime.now().millisecondsSinceEpoch}';
|
||||
|
||||
|
||||
if (deviceList.isNotEmpty) {
|
||||
String personParam = Uri.encodeComponent(jsonEncode(deviceList));
|
||||
queryParams += '&person=$personParam';
|
||||
}
|
||||
|
||||
|
||||
// 添加语言参数
|
||||
String? language = "";
|
||||
// 这里保持你原来的语言逻辑
|
||||
@@ -720,19 +721,19 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
if (language != null && language.isNotEmpty) {
|
||||
queryParams += '&lang=$language';
|
||||
}
|
||||
|
||||
|
||||
finalUri.value = baseUrl + queryParams;
|
||||
print('最终加载 URL: ${finalUri.value}');
|
||||
|
||||
} else {
|
||||
// API 调用失败,使用基础 URL
|
||||
finalUri.value = '$_localServerUrl?t=${DateTime.now().millisecondsSinceEpoch}';
|
||||
finalUri.value =
|
||||
'$_localServerUrl?t=${DateTime.now().millisecondsSinceEpoch}';
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
print('获取设备列表失败: $e');
|
||||
// 出错时仍然加载基础页面
|
||||
finalUri.value = '$_localServerUrl?t=${DateTime.now().millisecondsSinceEpoch}';
|
||||
finalUri.value =
|
||||
'$_localServerUrl?t=${DateTime.now().millisecondsSinceEpoch}';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgNoImg.png'),
|
||||
image: AssetImage(getBackgroundImageNoImage()),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
@@ -121,7 +121,7 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
if (deviceList.isEmpty) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
NewTopSlideNotification.show(
|
||||
NewTopSlideNotification.show(
|
||||
text: "请先绑定设备".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
|
||||
@@ -233,9 +233,9 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
return LayoutBuilder(
|
||||
builder: (context, bodySize) => GestureDetector(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgNoImg.png'),
|
||||
image: AssetImage(getBackgroundImageNoImage()),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -38,10 +38,16 @@ class _FollowPageState extends State<FollowPage> {
|
||||
// fit: BoxFit.contain, // 填满整个 Container
|
||||
// ),
|
||||
// ),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(getBackgroundImageNoImage()), // 本地图片
|
||||
fit: BoxFit.fill, // 填满整个 Container
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent, // 加上这一行
|
||||
appBar: AppBar(
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
backgroundColor: themeController.currentColor.sc5,
|
||||
// backgroundColor: Colors.transparent,
|
||||
automaticallyImplyLeading: false,
|
||||
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
|
||||
@@ -108,6 +114,7 @@ class _FollowPageState extends State<FollowPage> {
|
||||
1: 'assets/img/followus.png',
|
||||
2: 'assets/img/huanshuiF.png',
|
||||
4: 'assets/img/donghuaF.png',
|
||||
5: 'assets/img/wodiF.png',
|
||||
// 后面继续加
|
||||
};
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class _HelpPageState extends State<HelpPage> {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgNoImg.png'), // 本地图片
|
||||
image: AssetImage(getBackgroundImageNoImage()), // 本地图片
|
||||
fit: BoxFit.fill, // 填满整个 Container
|
||||
),
|
||||
),
|
||||
|
||||
@@ -236,7 +236,7 @@ class _HomePageState extends State<HomePage> {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgImage.png'), // 本地图片
|
||||
image: AssetImage(getBackgroundImage()), // 本地图片
|
||||
fit: BoxFit.fill, // 填满整个 Container
|
||||
),
|
||||
),
|
||||
|
||||
@@ -259,9 +259,9 @@ class MainPageBottomChange extends GetView<MainPageController> {
|
||||
);
|
||||
} else {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgImage.png'),
|
||||
image: AssetImage(getBackgroundImage()),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -565,7 +565,7 @@ class MainPageBottomChange extends GetView<MainPageController> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (AppConstants().ent_type != APPPackageType.MHT.code) {
|
||||
if (AppConstants().ent_type != APPPackageType.MHT.code && isShowPrivacyOriginFromTHAPP()) {
|
||||
Future.delayed(const Duration(milliseconds: 0), () {
|
||||
String? isShowYingShiDialog = getStorage.read("isShowYingShiDialog");
|
||||
if (isShowYingShiDialog == null || isShowYingShiDialog != "true") {
|
||||
@@ -673,9 +673,9 @@ class MainPageBottomChange extends GetView<MainPageController> {
|
||||
);
|
||||
} else {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgImage.png'),
|
||||
image: AssetImage(getBackgroundImage()),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
@@ -773,4 +773,15 @@ class MainPageBottomChange extends GetView<MainPageController> {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//太和e护衍生app是否显示协议
|
||||
bool isShowPrivacyOriginFromTHAPP() {
|
||||
if (AppConstants().ent_type == APPPackageType.TH.code) {
|
||||
return true;
|
||||
}
|
||||
if (AppConstants().ent_type == APPPackageType.DONGHUA.code) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,9 +101,9 @@ class _MessagePageState extends State<MessagePage> {
|
||||
builder: (context, boxConstraints) => GestureDetector(
|
||||
// onTap: () => FocusScope.of(context).unfocus(),,
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgNoImg.png'),
|
||||
image: AssetImage(getBackgroundImageNoImage()),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -91,9 +91,9 @@ class _MessageReturnPageState extends State<MessageReturnPage> {
|
||||
builder: (context, boxConstraints) => GestureDetector(
|
||||
// onTap: () => FocusScope.of(context).unfocus(),,
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgNoImg.png'),
|
||||
image: AssetImage(getBackgroundImageNoImage()),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -47,7 +47,7 @@ class _MinePageState extends State<MinePage> {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgImage.png'), // 本地图片
|
||||
image: AssetImage(getBackgroundImage()), // 本地图片
|
||||
fit: BoxFit.fill, // 填满整个 Container
|
||||
),
|
||||
),
|
||||
@@ -307,7 +307,8 @@ class _MinePageState extends State<MinePage> {
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFF242835),
|
||||
// color: Color(0xFF242835),
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user