机器人的列表接口
This commit is contained in:
136
lib/main.dart
136
lib/main.dart
@@ -35,17 +35,17 @@ void main() async {
|
||||
runZonedGuarded(
|
||||
() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
|
||||
await FlutterPatcher.init();
|
||||
await init();
|
||||
final logger = sl<ILoggerService>();
|
||||
await logger.init();
|
||||
Bloc.observer = AppBlocObserver(logger);
|
||||
|
||||
|
||||
// ⚠️ 注意:不要在启动时清除补丁版本记录!
|
||||
// 补丁版本记录只在整包更新成功后才清除
|
||||
// 如果在启动时清除,会导致差量更新后划掉App再进入时循环更新
|
||||
|
||||
|
||||
runApp(const MyApp());
|
||||
},
|
||||
(error, stack) {
|
||||
@@ -62,7 +62,7 @@ class MyApp extends StatelessWidget {
|
||||
sl<AuthCubit>().appStarted();
|
||||
final deviceStatusBloc = sl<DeviceStatusBloc>();
|
||||
final localeCubit = sl<LocaleCubit>();
|
||||
|
||||
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider<AuthCubit>(create: (_) => sl<AuthCubit>()),
|
||||
@@ -79,8 +79,12 @@ class MyApp extends StatelessWidget {
|
||||
BlocProvider<DeviceStatusBloc>.value(value: deviceStatusBloc),
|
||||
BlocProvider<LocaleCubit>.value(value: localeCubit),
|
||||
BlocProvider<TabConfigCubit>.value(value: sl<TabConfigCubit>()),
|
||||
BlocProvider<PermissionRequestBloc>(create: (_) => sl<PermissionRequestBloc>()),
|
||||
BlocProvider<UpdateCubit>(create: (_) => UpdateCubit(VersionCheckService())),
|
||||
BlocProvider<PermissionRequestBloc>(
|
||||
create: (_) => sl<PermissionRequestBloc>(),
|
||||
),
|
||||
BlocProvider<UpdateCubit>(
|
||||
create: (_) => UpdateCubit(VersionCheckService()),
|
||||
),
|
||||
],
|
||||
child: BlocBuilder<LocaleCubit, Locale>(
|
||||
bloc: localeCubit,
|
||||
@@ -114,7 +118,8 @@ class _LifecycleListener extends StatefulWidget {
|
||||
State<_LifecycleListener> createState() => _LifecycleListenerState();
|
||||
}
|
||||
|
||||
class _LifecycleListenerState extends State<_LifecycleListener> with WidgetsBindingObserver {
|
||||
class _LifecycleListenerState extends State<_LifecycleListener>
|
||||
with WidgetsBindingObserver {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -172,7 +177,10 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
listener: (context, state) {
|
||||
if (state is UpdateFailure) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('更新失败: ${state.error}'), backgroundColor: Colors.red),
|
||||
SnackBar(
|
||||
content: Text('更新失败: ${state.error}'),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -188,23 +196,40 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
child: Center(
|
||||
child: Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 30),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('🎉 发现新版本',
|
||||
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
|
||||
const Text(
|
||||
'🎉 发现新版本',
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text('版本号: ${state.versionInfo.version}',
|
||||
style: const TextStyle(fontSize: 16)),
|
||||
Text('更新类型: ${state.versionInfo.updateType == "patch" ? "差量更新" : "整包更新"}',
|
||||
style: const TextStyle(fontSize: 16, color: Colors.grey)),
|
||||
Text(
|
||||
'版本号: ${state.versionInfo.version}',
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
Text(
|
||||
'更新类型: ${state.versionInfo.updateType == "patch" ? "差量更新" : "整包更新"}',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
if (state.versionInfo.updateDesc.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
const Text('更新内容:', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
const Text(
|
||||
'更新内容:',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(state.versionInfo.updateDesc),
|
||||
],
|
||||
const SizedBox(height: 20),
|
||||
@@ -215,20 +240,28 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue.shade50,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.blue.shade200),
|
||||
border: Border.all(
|
||||
color: Colors.blue.shade200,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'💡 选择下载方式',
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'• 自动安装:App 内下载并调起系统安装\n'
|
||||
'• 手动下载:在浏览器中下载安装',
|
||||
style: TextStyle(fontSize: 13, height: 1.5),
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -240,7 +273,9 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
children: [
|
||||
if (!state.versionInfo.forceUpdate)
|
||||
TextButton(
|
||||
onPressed: () => context.read<UpdateCubit>().cancelUpdate(),
|
||||
onPressed: () => context
|
||||
.read<UpdateCubit>()
|
||||
.cancelUpdate(),
|
||||
child: const Text('稍后'),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
@@ -266,7 +301,11 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
onPressed: () {
|
||||
final info = state.versionInfo;
|
||||
if (info.apkUrl != null) {
|
||||
context.read<UpdateCubit>().downloadAndInstallApk(info.apkUrl!);
|
||||
context
|
||||
.read<UpdateCubit>()
|
||||
.downloadAndInstallApk(
|
||||
info.apkUrl!,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text('手动下载'),
|
||||
@@ -276,7 +315,11 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
onPressed: () {
|
||||
final info = state.versionInfo;
|
||||
if (info.apkUrl != null) {
|
||||
context.read<UpdateCubit>().downloadAndInstallApk(info.apkUrl!);
|
||||
context
|
||||
.read<UpdateCubit>()
|
||||
.downloadAndInstallApk(
|
||||
info.apkUrl!,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text('自动安装'),
|
||||
@@ -307,7 +350,10 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
children: [
|
||||
const Text(
|
||||
'📱 整包更新步骤',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildStepItem(1, '在浏览器中下载 APK', true),
|
||||
@@ -347,7 +393,10 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
children: [
|
||||
Text(
|
||||
state.isPatch ? '⬇️ 正在下载补丁...' : '⬇️ 正在下载 APK...',
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(
|
||||
@@ -362,7 +411,10 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
),
|
||||
Text(
|
||||
'${(state.progress * 100).toInt()}%',
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -370,7 +422,10 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'请稍候...',
|
||||
style: TextStyle(fontSize: 14, color: Colors.grey.shade600),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -392,10 +447,19 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.check_circle, color: Colors.green, size: 60),
|
||||
const Icon(
|
||||
Icons.check_circle,
|
||||
color: Colors.green,
|
||||
size: 60,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text('✅ 更新已完成',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
const Text(
|
||||
'✅ 更新已完成',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const Text(
|
||||
'补丁已成功应用!\n\n请完全关闭 App 后重新打开,\n即可体验新版本功能。',
|
||||
@@ -435,8 +499,13 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text('状态: ${state.runtimeType.toString().replaceAll('Update', '')}',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 12)),
|
||||
Text(
|
||||
'状态: ${state.runtimeType.toString().replaceAll('Update', '')}',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
// 🔥 暂时关闭刷新按钮和点击阴影
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.refresh, color: Colors.white),
|
||||
@@ -452,7 +521,7 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// 构建步骤项
|
||||
Widget _buildStepItem(int step, String text, bool completed) {
|
||||
return Row(
|
||||
@@ -485,8 +554,7 @@ class _UpdateCheckerState extends State<_UpdateChecker> {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (completed)
|
||||
const Icon(Icons.check, color: Colors.green, size: 20),
|
||||
if (completed) const Icon(Icons.check, color: Colors.green, size: 20),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user