hi-client/lib/app/modules/kr_splash/views/kr_splash_view.dart
Rust 442ea458b7 1. /lib/app/common/app_config.dart
- P0: 限制递归重试次数(最多5次)
    - P1: 减少超时时间(3s→2s, 6s→4s)
    - P1: 移除重复域名配置
  2.  /lib/app/services/kr_site_config_service.dart
    - P1: 减少网络超时(10s→5s)
  3.  /lib/app/modules/kr_splash/controllers/kr_splash_controller.dart
    - P0: 总体超时保护(30秒)
    - P2: 非阻塞初始化
    - P2: 后台任务超时保护(网站配置10s, 设备登录8s)
    - P2: 完善错误处理(区分超时/网络/HTTP错误)
    - P3: 跳过初始化功能
  4.  /lib/app/modules/kr_splash/views/kr_splash_view.dart
    - P3: 添加"跳过"按钮

(cherry picked from commit 0a9fe429919fe9ae85b7769df123b72d7e33c6b1)
2025-10-31 19:21:18 -07:00

123 lines
4.5 KiB
Dart
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'dart:io' show Platform;
import '../controllers/kr_splash_controller.dart';
import 'package:kaer_with_panels/app/widgets/kr_local_image.dart';
import 'package:kaer_with_panels/app/widgets/kr_app_text_style.dart';
import '../../../widgets/kr_simple_loading.dart';
import 'package:kaer_with_panels/app/localization/app_translations.dart';
class KRSplashView extends GetView<KRSplashController> {
const KRSplashView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final bool isMobile = Platform.isIOS || Platform.isAndroid;
return Scaffold(
backgroundColor: theme.scaffoldBackgroundColor,
body: Container(
decoration: isMobile ? BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color.fromRGBO(23, 151, 255, 0.15), // 渐变开始颜色
Color.fromRGBO(23, 151, 255, 0.05), // 中间过渡颜色
],
stops: [0.0, 0.28], // 调整渐变结束位置
),
) : null,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// 图片区域
KrLocalImage(
imageName: "splash_illustration-hi",
width: 286.w,
height: 101.w,
fit: BoxFit.contain,
),
SizedBox(height: 24.h),
// 加载指示器或错误信息
Obx(() {
if (controller.kr_hasError.value) {
return Column(
children: [
Text(
controller.kr_errorMessage.value,
style: KrAppTextStyle(
fontSize: 14,
color: theme.textTheme.bodySmall?.color,
),
),
SizedBox(height: 16.h),
ElevatedButton(
onPressed: controller.kr_retry,
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).primaryColor,
foregroundColor: Colors.black,
padding: EdgeInsets.symmetric(
horizontal: 32.w,
vertical: 12.h,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24.r),
),
),
child: Text(AppTranslations.kr_splash.kr_retry),
),
],
);
}
if (controller.kr_isLoading.value) {
return Column(
children: [
KRSimpleLoading(
color: Theme.of(context).primaryColor,
size: 24.0,
),
SizedBox(height: 16.h),
Text(
AppTranslations.kr_splash.initializing,
style: KrAppTextStyle(
fontSize: 14,
color: Theme.of(context).primaryColor,
),
),
SizedBox(height: 16.h),
// 🔧 P3优化添加跳过按钮
TextButton(
onPressed: controller.kr_skipInitialization,
style: TextButton.styleFrom(
foregroundColor: Colors.grey,
padding: EdgeInsets.symmetric(
horizontal: 24.w,
vertical: 8.h,
),
),
child: Text(
'跳过',
style: KrAppTextStyle(
fontSize: 14,
color: Colors.grey,
),
),
),
],
);
}
return const SizedBox.shrink();
}),
],
),
),
),
);
}
}