79 lines
2.8 KiB
Dart
79 lines
2.8 KiB
Dart
import 'package:common_utils/common_utils.dart';
|
|
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:forui/forui.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:pj_supermarket_cloud/common/index.dart';
|
|
|
|
import '../controller.dart';
|
|
import 'setting_components.dart';
|
|
|
|
Widget settingBackup(BuildContext context) {
|
|
final controller = Get.find<SettingController>();
|
|
return Obx(() {
|
|
final sys = controller.sysSetting.value;
|
|
if (sys == null) return const SettingEmpty(message: '暂无备份信息');
|
|
final path = ObjectUtil.isEmpty(sys.externalPath)
|
|
? '--'
|
|
: '${sys.externalPath}/pj_cashier/backup';
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
SettingGroup(
|
|
title: '备份',
|
|
child: Column(
|
|
children: [
|
|
SettingInfoRow(
|
|
icon: FAssets.icons.folderOpen,
|
|
label: '备份路径',
|
|
value: path,
|
|
actionLabel: '复制',
|
|
onTap: path == '--' ? null : () => KeywordTool.copy(path),
|
|
),
|
|
SettingInfoRow(
|
|
icon: FAssets.icons.database,
|
|
label: 'SQL 备份',
|
|
value: _backupTime(controller.sqlBackupTime.value),
|
|
actionLabel: '立即备份',
|
|
onTap: controller.backupsSql,
|
|
),
|
|
SettingInfoRow(
|
|
icon: FAssets.icons.fileArchive,
|
|
label: '日志备份',
|
|
value: _backupTime(controller.logBackupTime.value),
|
|
actionLabel: '立即备份',
|
|
onTap: controller.backupsLog,
|
|
showDivider: false,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
if (controller.lastBackupMessage.isNotEmpty) ...[
|
|
SizedBox(height: XfjDesignTokens.cardGap.h),
|
|
SettingNotice(
|
|
text: controller.lastBackupMessage.value,
|
|
color: XfjDesignTokens.success,
|
|
background: const Color(0xFFECFBF3),
|
|
borderColor: XfjDesignTokens.success.withValues(alpha: 0.3),
|
|
icon: FAssets.icons.circleCheck,
|
|
),
|
|
],
|
|
SizedBox(height: XfjDesignTokens.cardGap.h),
|
|
SettingNotice(
|
|
text: '备份文件可能包含订单和设备诊断信息,导出后请妥善保管,不要通过非安全渠道传输。',
|
|
background: const Color(0xFFFFF9E8),
|
|
borderColor: XfjDesignTokens.warning.withValues(alpha: 0.3),
|
|
icon: FAssets.icons.triangleAlert,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
String _backupTime(DateTime? time) {
|
|
if (time == null) return '尚未备份';
|
|
return '上次备份:${DateUtil.formatDate(time, format: DateFormats.full)}';
|
|
}
|