mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: virt keys loading
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
- 感谢贡献者们!
|
||||
|
||||
|
||||
|
||||
@@ -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<VirtKey> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,17 +385,7 @@ class SSHPageState extends State<SSHPage>
|
||||
}
|
||||
|
||||
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<SSHPage>
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<List<String>?> _onKeyboardInteractive(SSHUserInfoRequest req) {
|
||||
return KeybordInteractive.defaultHandle(widget.spi, ctx: context);
|
||||
}
|
||||
|
||||
Future<void> _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');
|
||||
|
||||
Reference in New Issue
Block a user