diff --git a/README.md b/README.md index dd408fdca..01b1e1737 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Please only download pkgs from the source that **you trust**! ## 🔖 Feature - `Status chart` (CPU, Sensors, GPU...), `SSH` Term, `SFTP`, `Docker & Process & Systemd`... - Platform specific: `Bio auth`、`Msg push`、`Home widget`、`watchOS App`... -- English, 简体中文; Deutsch [@its-tom](https://github.com/its-tom), 繁體中文 [@kalashnikov](https://github.com/kalashnikov), Indonesian [@azkadev](https://github.com/azkadev), Français [@FrancXPT](https://github.com/FrancXPT), Dutch [@QazCetelic](https://github.com/QazCetelic), Türkçe [@mikropsoft](https://github.com/mikropsoft), українська мова [@CakesTwix](https://github.com/CakesTwix); Español, Русский язык, Português, 日本語 (Generated by GPT) +- English, 简体中文; Deutsch [@its-tom](https://github.com/its-tom), 繁體中文 [@kalashnikov](https://github.com/kalashnikov), Indonesian [@azkadev](https://github.com/azkadev), Français [@FrancXPT](https://github.com/FrancXPT), Dutch [@QazCetelic](https://github.com/QazCetelic), Türkçe [@mikropsoft](https://github.com/mikropsoft), Українська мова [@CakesTwix](https://github.com/CakesTwix); Español, Русский язык, Português, 日本語 (Generated by GPT) ## 🆘 Help diff --git a/README_zh.md b/README_zh.md index 371385a03..c1809994f 100644 --- a/README_zh.md +++ b/README_zh.md @@ -43,7 +43,7 @@ Linux / Windows | [GitHub](https://github.com/lollipopkit/flutter_server_box/rel - 本地化 - English, 简体中文 - Español, Русский язык, Português, 日本語 (Generated by GPT) - - Deutsch [@its-tom](https://github.com/its-tom), 繁體中文 [@kalashnikov](https://github.com/kalashnikov), Indonesian [@azkadev](https://github.com/azkadev), Français [@FrancXPT](https://github.com/FrancXPT), Dutch [@QazCetelic](https://github.com/QazCetelic), Türkçe [@mikropsoft](https://github.com/mikropsoft), українська мова [@CakesTwix](https://github.com/CakesTwix); + - Deutsch [@its-tom](https://github.com/its-tom), 繁體中文 [@kalashnikov](https://github.com/kalashnikov), Indonesian [@azkadev](https://github.com/azkadev), Français [@FrancXPT](https://github.com/FrancXPT), Dutch [@QazCetelic](https://github.com/QazCetelic), Türkçe [@mikropsoft](https://github.com/mikropsoft), Українська мова [@CakesTwix](https://github.com/CakesTwix); - 感谢贡献者们! diff --git a/lib/data/model/ssh/virtual_key.dart b/lib/data/model/ssh/virtual_key.dart index 7d2211a11..1c70d6cec 100644 --- a/lib/data/model/ssh/virtual_key.dart +++ b/lib/data/model/ssh/virtual_key.dart @@ -1,6 +1,8 @@ +import 'package:fl_lib/fl_lib.dart'; import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:server_box/core/extension/context/locale.dart'; +import 'package:server_box/data/res/store.dart'; import 'package:xterm/core.dart'; part 'virtual_key.g.dart'; @@ -187,4 +189,18 @@ extension VirtKeyX on VirtKey { VirtKey.ime => l10n.virtKeyHelpIME, _ => null, }; + + /// - [saveDefaultIfErr] if the stored raw values is invalid, save default order to store + static List loadFromStore({bool saveDefaultIfErr = true}) { + try { + final ints = Stores.setting.sshVirtKeys.fetch(); + return ints.map((e) => VirtKey.values[e]).toList(); + } on RangeError { + final ints = defaultOrder.map((e) => e.index).toList(); + Stores.setting.sshVirtKeys.put(ints); + } catch (e, s) { + Loggers.app.warning('Failed to load sshVirtKeys', e, s); + } + return defaultOrder; + } } diff --git a/lib/view/page/ssh/page.dart b/lib/view/page/ssh/page.dart index b3842619a..b9f43a33d 100644 --- a/lib/view/page/ssh/page.dart +++ b/lib/view/page/ssh/page.dart @@ -385,17 +385,7 @@ class SSHPageState extends State } void _initVirtKeys() { - final virtKeys = () { - try { - return Stores.setting.sshVirtKeys - .fetch() - .map((e) => VirtKey.values[e]) - .toList(); - } catch (_) { - return VirtKey.values; - } - }(); - + final virtKeys = VirtKeyX.loadFromStore(); for (int len = 0; len < virtKeys.length; len += 7) { if (len + 7 > virtKeys.length) { _virtKeysList.add(virtKeys.sublist(len)); @@ -405,15 +395,18 @@ class SSHPageState extends State } } + FutureOr?> _onKeyboardInteractive(SSHUserInfoRequest req) { + return KeybordInteractive.defaultHandle(widget.spi, ctx: context); + } + Future _initTerminal() async { - _writeLn(libL10n.content); + _writeLn(l10n.waitConnection); _client ??= await genClient( widget.spi, onStatus: (p0) { _writeLn(p0.toString()); }, - onKeyboardInteractive: (_) => - KeybordInteractive.defaultHandle(widget.spi), + onKeyboardInteractive: _onKeyboardInteractive, ); _writeLn('${libL10n.execute}: Shell');