1
1
import 'dart:io' ;
2
2
3
+ import 'package:file_picker/file_picker.dart' ;
3
4
import 'package:fluent_ui/fluent_ui.dart' as fluent;
4
5
import 'package:flutter/material.dart' ;
5
6
import 'package:flutter_i18n/flutter_i18n.dart' ;
6
7
import 'package:get/get.dart' ;
7
8
import 'package:miru_app/data/providers/tmdb_provider.dart' ;
8
9
import 'package:miru_app/controllers/application_controller.dart' ;
9
10
import 'package:miru_app/router/router.dart' ;
11
+ import 'package:miru_app/utils/log.dart' ;
10
12
import 'package:miru_app/utils/request.dart' ;
11
13
import 'package:miru_app/views/dialogs/bt_dialog.dart' ;
12
14
import 'package:miru_app/controllers/extension/extension_repo_controller.dart' ;
@@ -23,6 +25,7 @@ import 'package:miru_app/utils/miru_storage.dart';
23
25
import 'package:miru_app/utils/application.dart' ;
24
26
import 'package:miru_app/views/widgets/list_title.dart' ;
25
27
import 'package:miru_app/views/widgets/platform_widget.dart' ;
28
+ import 'package:share_plus/share_plus.dart' ;
26
29
import 'package:tmdb_api/tmdb_api.dart' ;
27
30
import 'package:url_launcher/url_launcher.dart' ;
28
31
@@ -398,7 +401,10 @@ class _SettingsPageState extends State<SettingsPage> {
398
401
title: 'settings.tracking' .i18n,
399
402
subTitle: 'settings.tracking-subtitle' .i18n,
400
403
),
401
- const SizedBox (height: 10 ),
404
+ const SizedBox (height: 20 ),
405
+ // 高级
406
+ ListTitle (title: '高级' .i18n),
407
+ const SizedBox (height: 20 ),
402
408
// 网络设置
403
409
SettingsExpanderTile (
404
410
content: Column (
@@ -453,7 +459,55 @@ class _SettingsPageState extends State<SettingsPage> {
453
459
),
454
460
const SizedBox (height: 10 ),
455
461
// Debug
456
- if (! Platform .isAndroid)
462
+ SettingsExpanderTile (
463
+ title: "settings.log" .i18n,
464
+ subTitle: 'settings.log-subtitle' .i18n,
465
+ androidIcon: Icons .report,
466
+ icon: fluent.FluentIcons .report_alert,
467
+ content: Column (
468
+ children: [
469
+ SettingsSwitchTile (
470
+ title: 'settings.save-log' .i18n,
471
+ buildSubtitle: () => 'settings.save-log-subtitle' .i18n,
472
+ buildValue: () {
473
+ return MiruStorage .getSetting (SettingKey .saveLog);
474
+ },
475
+ onChanged: (value) {
476
+ MiruStorage .setSetting (SettingKey .saveLog, value);
477
+ },
478
+ ),
479
+ const SizedBox (height: 10 ),
480
+ // 导出日志
481
+ SettingsTile (
482
+ title: 'settings.export-log' .i18n,
483
+ buildSubtitle: () => 'settings.export-log-subtitle' .i18n,
484
+ trailing: PlatformWidget (
485
+ androidWidget: TextButton (
486
+ onPressed: () {
487
+ Share .shareXFiles ([XFile (MiruLog .logFilePath)]);
488
+ },
489
+ child: Text ('common.export' .i18n),
490
+ ),
491
+ desktopWidget: fluent.FilledButton (
492
+ onPressed: () async {
493
+ final path = await FilePicker .platform.saveFile (
494
+ type: FileType .custom,
495
+ allowedExtensions: ['log' ],
496
+ fileName: 'miru.log' ,
497
+ );
498
+ if (path != null ) {
499
+ File (MiruLog .logFilePath).copy (path);
500
+ }
501
+ },
502
+ child: Text ('common.export' .i18n),
503
+ ),
504
+ ),
505
+ ),
506
+ ],
507
+ ),
508
+ ),
509
+ if (! Platform .isAndroid) ...[
510
+ const SizedBox (height: 10 ),
457
511
Obx (
458
512
() {
459
513
final value = c.extensionLogWindowId.value != - 1 ;
@@ -471,7 +525,8 @@ class _SettingsPageState extends State<SettingsPage> {
471
525
isCard: true ,
472
526
);
473
527
},
474
- ),
528
+ )
529
+ ],
475
530
// 关于
476
531
const SizedBox (height: 20 ),
477
532
ListTitle (title: 'settings.about' .i18n),
0 commit comments