Skip to content

Commit

Permalink
feat(debug): copy database dir path
Browse files Browse the repository at this point in the history
  • Loading branch information
realth000 committed Jan 13, 2025
1 parent 3ef82aa commit 2547070
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
12 changes: 12 additions & 0 deletions lib/features/settings/view/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import 'package:tsdm_client/i18n/strings.g.dart';
import 'package:tsdm_client/instance.dart';
import 'package:tsdm_client/routes/screen_paths.dart';
import 'package:tsdm_client/shared/models/models.dart';
import 'package:tsdm_client/shared/providers/storage_provider/models/database/connection/native.dart';
import 'package:tsdm_client/utils/clipboard.dart';
import 'package:tsdm_client/utils/platform.dart';
import 'package:tsdm_client/utils/show_bottom_sheet.dart';
import 'package:tsdm_client/utils/show_toast.dart';
Expand Down Expand Up @@ -764,6 +766,16 @@ class _SettingsPageState extends State<SettingsPage> {
}
},
),
SectionListTile(
title: Text(tr.copyDatabaseDir),
onTap: () async {
final path = (await databaseFile).parent.path;
if (!context.mounted) {
return;
}
await copyToClipboard(context, path);
},
),
],
),
];
Expand Down
3 changes: 2 additions & 1 deletion lib/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@
},
"viewLog": {
"title": "View log"
}
},
"copyDatabaseDir": "Copy database path"
},
"othersSection": {
"title": "Others",
Expand Down
3 changes: 2 additions & 1 deletion lib/i18n/zh-CN.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@
},
"viewLog": {
"title": "查看日志"
}
},
"copyDatabaseDir": "复制数据库路径"
},
"othersSection": {
"title": "其他",
Expand Down
3 changes: 2 additions & 1 deletion lib/i18n/zh-TW.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@
},
"viewLog": {
"title": "查看日誌"
}
},
"copyDatabaseDir": "複製資料庫路徑"
},
"othersSection": {
"title": "其他",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import 'package:tsdm_client/instance.dart';

/// Get the database storage file.
Future<File> get databaseFile async {
final sep = Platform.pathSeparator;
final dbPath =
'${(await getApplicationSupportDirectory()).path}/db/mainV2.db';
'${(await getApplicationSupportDirectory()).path}${sep}db${sep}mainV2.db';
talker.debug('init database file at $dbPath');
return File(dbPath);
}
Expand Down

0 comments on commit 2547070

Please sign in to comment.