add shortcuts

This commit is contained in:
wgh19
2024-06-12 19:17:32 +08:00
parent 70da478044
commit 7c8fabf52c
6 changed files with 39 additions and 9 deletions

View File

@@ -171,7 +171,9 @@
"Choose a way to login": "选择登录方式", "Choose a way to login": "选择登录方式",
"Use Webview: you cannot sign in with Google.": "使用Webview: 无法使用Google登录", "Use Webview: you cannot sign in with Google.": "使用Webview: 无法使用Google登录",
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部浏览器: 可以使用Google登录. 但是, 一些浏览器可能与应用程序不兼容", "Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部浏览器: 可以使用Google登录. 但是, 一些浏览器可能与应用程序不兼容",
"External browser": "外部浏览器" "External browser": "外部浏览器",
"Show comments": "显示评论",
"Show original image": "显示原图"
}, },
"zh_TW": { "zh_TW": {
"Search": "搜索", "Search": "搜索",
@@ -345,6 +347,8 @@
"Choose a way to login": "選擇登錄方式", "Choose a way to login": "選擇登錄方式",
"Use Webview: you cannot sign in with Google.": "使用Webview: 無法使用Google登錄", "Use Webview: you cannot sign in with Google.": "使用Webview: 無法使用Google登錄",
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部瀏覽器: 可以使用Google登錄. 但是, 一些瀏覽器可能與應用程序不兼容", "Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部瀏覽器: 可以使用Google登錄. 但是, 一些瀏覽器可能與應用程序不兼容",
"External browser": "外部瀏覽器" "External browser": "外部瀏覽器",
"Show comments": "顯示評論",
"Show original image": "顯示原圖"
} }
} }

View File

@@ -32,6 +32,8 @@ class _Appdata {
LogicalKeyboardKey.enter.keyId, LogicalKeyboardKey.enter.keyId,
LogicalKeyboardKey.keyD.keyId, LogicalKeyboardKey.keyD.keyId,
LogicalKeyboardKey.keyF.keyId, LogicalKeyboardKey.keyF.keyId,
LogicalKeyboardKey.keyC.keyId,
LogicalKeyboardKey.keyG.keyId,
], ],
"showOriginalImage": false, "showOriginalImage": false,
}; };
@@ -73,10 +75,18 @@ class _Appdata {
var json = jsonDecode(await settingsFile.readAsString()); var json = jsonDecode(await settingsFile.readAsString());
for (var key in json.keys) { for (var key in json.keys) {
if (json[key] != null) { if (json[key] != null) {
if (json[key] is List && settings[key] is List) {
for (int i = 0;
i < json[key].length && i < settings[key].length;
i++) {
settings[key][i] = json[key][i];
}
} else {
settings[key] = json[key]; settings[key] = json[key];
} }
} }
} }
}
if (settings["downloadPath"] == null) { if (settings["downloadPath"] == null) {
settings["downloadPath"] = await _defaultDownloadPath; settings["downloadPath"] = await _defaultDownloadPath;
} }

View File

@@ -40,12 +40,11 @@ class KeyEventListenerState extends State<KeyEventListener> {
focusNode: focusNode, focusNode: focusNode,
autofocus: true, autofocus: true,
onKeyEvent: (node, event) { onKeyEvent: (node, event) {
if (event is! KeyUpEvent) return KeyEventResult.ignored; if (event is! KeyUpEvent) return KeyEventResult.handled;
if (event.logicalKey == LogicalKeyboardKey.escape) { if (event.logicalKey == LogicalKeyboardKey.escape) {
if (App.rootNavigatorKey.currentState?.canPop() ?? false) { if (App.rootNavigatorKey.currentState?.canPop() ?? false) {
App.rootNavigatorKey.currentState?.pop(); App.rootNavigatorKey.currentState?.pop();
} } else if (App.mainNavigatorKey?.currentState?.canPop() ?? false) {
if (App.mainNavigatorKey?.currentState?.canPop() ?? false) {
App.mainNavigatorKey?.currentState?.pop(); App.mainNavigatorKey?.currentState?.pop();
} }
return KeyEventResult.handled; return KeyEventResult.handled;

View File

@@ -62,11 +62,18 @@ class HistoryManager {
illust.width, illust.width,
illust.height illust.height
]); ]);
if(length > 1000) {
_db.execute('''
delete from history where id in (
select id from history order by time asc limit 100
)
''');
}
} }
List<IllustHistory> getHistories(int page) { List<IllustHistory> getHistories(int page) {
var rows = _db.select(''' var rows = _db.select('''
select * from history select * from history order by time desc
limit 20 offset ? limit 20 offset ?
''', [(page - 1) * 20]); ''', [(page - 1) * 20]);
List<IllustHistory> res = []; List<IllustHistory> res = [];

View File

@@ -319,6 +319,14 @@ class _IllustPageState extends State<IllustPage> {
_bottomBarController.download(); _bottomBarController.download();
case 6: case 6:
_bottomBarController.follow(); _bottomBarController.follow();
case 7:
if (ModalRoute.of(context)?.isCurrent ?? true) {
CommentsPage.show(context, widget.illust.id.toString());
} else {
context.pop();
}
case 8:
openImage(0);
} }
} }

View File

@@ -592,6 +592,8 @@ class _ShortcutsSettingsState extends State<ShortcutsSettings> {
"Add to favorites", "Add to favorites",
"Download", "Download",
"Follow the artist", "Follow the artist",
"Show comments",
"Show original image"
]; ];
@override @override