|
|
@@ -68,6 +68,24 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
|
|
|
_webdavConfigured = false; _showWebdavForm = false;
|
|
|
}
|
|
|
|
|
|
+ Future<void> _triggerFullBackup() async {
|
|
|
+ final api = ref.read(apiServiceProvider);
|
|
|
+ try {
|
|
|
+ await api.triggerFullBackup();
|
|
|
+ if (mounted) {
|
|
|
+ ScaffoldMessenger.of(context).showSnackBar(
|
|
|
+ const SnackBar(content: Text('全量备份已触发')),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ if (mounted) {
|
|
|
+ ScaffoldMessenger.of(context).showSnackBar(
|
|
|
+ SnackBar(content: Text('备份失败: $e')),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Future<void> _saveWebDAV() async {
|
|
|
final api = ref.read(apiServiceProvider);
|
|
|
try {
|
|
|
@@ -239,6 +257,34 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
|
|
|
),
|
|
|
],
|
|
|
|
|
|
+ // 全量备份
|
|
|
+ if (isConfigured) ...[
|
|
|
+ const SizedBox(height: 16),
|
|
|
+ Card(
|
|
|
+ child: Padding(
|
|
|
+ padding: const EdgeInsets.all(16),
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Text('数据备份', style: Theme.of(context).textTheme.titleMedium),
|
|
|
+ const SizedBox(height: 8),
|
|
|
+ Text('备份 bank.db + 全部 docx 到本地和 WebDAV',
|
|
|
+ style: Theme.of(context).textTheme.bodySmall),
|
|
|
+ const SizedBox(height: 12),
|
|
|
+ SizedBox(
|
|
|
+ width: double.infinity,
|
|
|
+ child: OutlinedButton.icon(
|
|
|
+ onPressed: _triggerFullBackup,
|
|
|
+ icon: const Icon(Icons.backup),
|
|
|
+ label: const Text('全量备份'),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+
|
|
|
const SizedBox(height: 24),
|
|
|
// 关于
|
|
|
Card(
|