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
|
## 🔖 Feature
|
||||||
- `Status chart` (CPU, Sensors, GPU...), `SSH` Term, `SFTP`, `Docker & Process & Systemd`...
|
- `Status chart` (CPU, Sensors, GPU...), `SSH` Term, `SFTP`, `Docker & Process & Systemd`...
|
||||||
- Platform specific: `Bio auth`、`Msg push`、`Home widget`、`watchOS App`...
|
- 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
|
## 🆘 Help
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ Linux / Windows | [GitHub](https://github.com/lollipopkit/flutter_server_box/rel
|
|||||||
- 本地化
|
- 本地化
|
||||||
- English, 简体中文
|
- English, 简体中文
|
||||||
- Español, Русский язык, Português, 日本語 (Generated by GPT)
|
- 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:flutter/material.dart';
|
||||||
import 'package:hive_flutter/hive_flutter.dart';
|
import 'package:hive_flutter/hive_flutter.dart';
|
||||||
import 'package:server_box/core/extension/context/locale.dart';
|
import 'package:server_box/core/extension/context/locale.dart';
|
||||||
|
import 'package:server_box/data/res/store.dart';
|
||||||
import 'package:xterm/core.dart';
|
import 'package:xterm/core.dart';
|
||||||
|
|
||||||
part 'virtual_key.g.dart';
|
part 'virtual_key.g.dart';
|
||||||
@@ -187,4 +189,18 @@ extension VirtKeyX on VirtKey {
|
|||||||
VirtKey.ime => l10n.virtKeyHelpIME,
|
VirtKey.ime => l10n.virtKeyHelpIME,
|
||||||
_ => null,
|
_ => 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() {
|
void _initVirtKeys() {
|
||||||
final virtKeys = () {
|
final virtKeys = VirtKeyX.loadFromStore();
|
||||||
try {
|
|
||||||
return Stores.setting.sshVirtKeys
|
|
||||||
.fetch()
|
|
||||||
.map((e) => VirtKey.values[e])
|
|
||||||
.toList();
|
|
||||||
} catch (_) {
|
|
||||||
return VirtKey.values;
|
|
||||||
}
|
|
||||||
}();
|
|
||||||
|
|
||||||
for (int len = 0; len < virtKeys.length; len += 7) {
|
for (int len = 0; len < virtKeys.length; len += 7) {
|
||||||
if (len + 7 > virtKeys.length) {
|
if (len + 7 > virtKeys.length) {
|
||||||
_virtKeysList.add(virtKeys.sublist(len));
|
_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 {
|
Future<void> _initTerminal() async {
|
||||||
_writeLn(libL10n.content);
|
_writeLn(l10n.waitConnection);
|
||||||
_client ??= await genClient(
|
_client ??= await genClient(
|
||||||
widget.spi,
|
widget.spi,
|
||||||
onStatus: (p0) {
|
onStatus: (p0) {
|
||||||
_writeLn(p0.toString());
|
_writeLn(p0.toString());
|
||||||
},
|
},
|
||||||
onKeyboardInteractive: (_) =>
|
onKeyboardInteractive: _onKeyboardInteractive,
|
||||||
KeybordInteractive.defaultHandle(widget.spi),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
_writeLn('${libL10n.execute}: Shell');
|
_writeLn('${libL10n.execute}: Shell');
|
||||||
|
|||||||
Reference in New Issue
Block a user