mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 15:54:35 +01:00
fix: ssh session not inited
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 473;
|
||||
static const int build = 474;
|
||||
static const String engine = "3.10.6";
|
||||
static const String buildAt = "2023-08-15 23:06:31.430481";
|
||||
static const int modifications = 2;
|
||||
static const String buildAt = "2023-08-16 15:42:48.857532";
|
||||
static const int modifications = 24;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
"plzSelectKey": "Wähle einen Key.",
|
||||
"port": "Port",
|
||||
"preview": "Vorschau",
|
||||
"primaryColor": "Farbschema",
|
||||
"primaryColorSeed": "Farbschema",
|
||||
"privateKey": "Private Key",
|
||||
"process": "Prozess",
|
||||
"pushToken": "Push Token",
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
"plzSelectKey": "Please select a key.",
|
||||
"port": "Port",
|
||||
"preview": "Preview",
|
||||
"primaryColor": "Primary color",
|
||||
"primaryColorSeed": "Primary color seed",
|
||||
"privateKey": "Private Key",
|
||||
"process": "Process",
|
||||
"pushToken": "Push token",
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
"plzSelectKey": "Pilih kunci.",
|
||||
"port": "Port",
|
||||
"preview": "Pratinjau",
|
||||
"primaryColor": "Warna utama",
|
||||
"primaryColorSeed": "Warna utama",
|
||||
"privateKey": "Kunci Pribadi",
|
||||
"process": "Proses",
|
||||
"pushToken": "Dorong token",
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
"plzSelectKey": "请选择私钥",
|
||||
"port": "端口",
|
||||
"preview": "预览",
|
||||
"primaryColor": "主题色",
|
||||
"primaryColorSeed": "主题色种子",
|
||||
"privateKey": "私钥",
|
||||
"process": "进程",
|
||||
"pushToken": "消息推送 Token",
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
"plzSelectKey": "請選擇私鑰",
|
||||
"port": "端口",
|
||||
"preview": "預覽",
|
||||
"primaryColor": "主要色調",
|
||||
"primaryColorSeed": "主要色調種子",
|
||||
"privateKey": "私鑰",
|
||||
"process": "進程",
|
||||
"pushToken": "消息推送 Token",
|
||||
|
||||
@@ -437,10 +437,12 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
),
|
||||
],
|
||||
)));
|
||||
return RoundRectCard(Padding(
|
||||
padding: roundRectCardPadding,
|
||||
child: Column(children: children),
|
||||
),);
|
||||
return RoundRectCard(
|
||||
Padding(
|
||||
padding: roundRectCardPadding,
|
||||
child: Column(children: children),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAnimatedText(Key key, String text, TextStyle style) {
|
||||
|
||||
@@ -274,14 +274,12 @@ class _SettingPageState extends State<SettingPage> {
|
||||
width: 27,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
_s.primaryColor,
|
||||
),
|
||||
title: Text(_s.primaryColorSeed),
|
||||
onTap: () async {
|
||||
final ctrl = TextEditingController(text: primaryColor.toHex);
|
||||
await showRoundDialog(
|
||||
context: context,
|
||||
title: Text(_s.primaryColor),
|
||||
title: Text(_s.primaryColorSeed),
|
||||
child: Input(
|
||||
onSubmitted: _onSaveColor,
|
||||
controller: ctrl,
|
||||
@@ -674,7 +672,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
},
|
||||
).toList();
|
||||
return ListTile(
|
||||
title: Text(_s.light + _s.theme),
|
||||
title: Text('${_s.light} ${_s.theme.toLowerCase()}'),
|
||||
trailing: ValueBuilder(
|
||||
listenable: _editorTheme,
|
||||
build: () => PopupMenuButton(
|
||||
@@ -707,7 +705,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
},
|
||||
).toList();
|
||||
return ListTile(
|
||||
title: Text(_s.dark + _s.theme),
|
||||
title: Text('${_s.dark} ${_s.theme.toLowerCase()}'),
|
||||
trailing: ValueBuilder(
|
||||
listenable: _editorDarkTheme,
|
||||
build: () => PopupMenuButton(
|
||||
|
||||
@@ -40,7 +40,6 @@ class _SSHPageState extends State<SSHPage> {
|
||||
final _setting = locator<SettingStore>();
|
||||
late final _terminal = Terminal(inputHandler: _keyboard);
|
||||
final TerminalController _terminalController = TerminalController();
|
||||
final ContextMenuController _menuController = ContextMenuController();
|
||||
final List<List<VirtKey>> _virtKeysList = [];
|
||||
|
||||
late MediaQueryData _media;
|
||||
@@ -48,13 +47,13 @@ class _SSHPageState extends State<SSHPage> {
|
||||
late TerminalStyle _terminalStyle;
|
||||
late TerminalTheme _terminalTheme;
|
||||
late TextInputType _keyboardType;
|
||||
late SSHSession _session;
|
||||
late double _virtKeyWidth;
|
||||
late double _virtKeysHeight;
|
||||
|
||||
bool _isDark = false;
|
||||
Timer? _virtKeyLongPressTimer;
|
||||
SSHClient? _client;
|
||||
SSHSession? _session;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -76,10 +75,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
_virtKeyLongPressTimer?.cancel();
|
||||
_terminalController.dispose();
|
||||
_client?.close();
|
||||
// ignore: unnecessary_null_comparison
|
||||
if (_session != null) {
|
||||
_session.close();
|
||||
}
|
||||
_session?.close();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -116,16 +112,18 @@ class _SSHPageState extends State<SSHPage> {
|
||||
_virtKeysHeight -
|
||||
_media.padding.bottom -
|
||||
_media.padding.top,
|
||||
child: TerminalView(
|
||||
_terminal,
|
||||
onTapUp: _onTapUp,
|
||||
controller: _terminalController,
|
||||
keyboardType: _keyboardType,
|
||||
textStyle: _terminalStyle,
|
||||
theme: _terminalTheme,
|
||||
deleteDetection: isIOS,
|
||||
autofocus: true,
|
||||
keyboardAppearance: _isDark ? Brightness.dark : Brightness.light,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: _media.padding.top),
|
||||
child: TerminalView(
|
||||
_terminal,
|
||||
controller: _terminalController,
|
||||
keyboardType: _keyboardType,
|
||||
textStyle: _terminalStyle,
|
||||
theme: _terminalTheme,
|
||||
deleteDetection: isIOS,
|
||||
autofocus: true,
|
||||
keyboardAppearance: _isDark ? Brightness.dark : Brightness.light,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -268,13 +266,8 @@ class _SSHPageState extends State<SSHPage> {
|
||||
);
|
||||
return;
|
||||
}
|
||||
AppRoute(
|
||||
SftpPage(
|
||||
widget.spi,
|
||||
initPath: initPath,
|
||||
),
|
||||
'SSH SFTP')
|
||||
.go(context);
|
||||
final page = SftpPage(widget.spi, initPath: initPath);
|
||||
AppRoute(page, 'SSH SFTP').go(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,76 +331,42 @@ class _SSHPageState extends State<SSHPage> {
|
||||
),
|
||||
);
|
||||
|
||||
if (_session == null) {
|
||||
showSnackBar(context, const Text('Null session'));
|
||||
return;
|
||||
}
|
||||
|
||||
_terminal.buffer.clear();
|
||||
_terminal.buffer.setCursor(0, 0);
|
||||
|
||||
_terminal.onOutput = (data) {
|
||||
_session.write(utf8.encode(data) as Uint8List);
|
||||
_session?.write(utf8.encode(data) as Uint8List);
|
||||
};
|
||||
_terminal.onResize = (width, height, pixelWidth, pixelHeight) {
|
||||
_session?.resizeTerminal(width, height);
|
||||
};
|
||||
|
||||
_listen(_session.stdout);
|
||||
_listen(_session.stderr);
|
||||
_listen(_session?.stdout);
|
||||
_listen(_session?.stderr);
|
||||
|
||||
if (widget.initCmd != null) {
|
||||
_terminal.textInput(widget.initCmd!);
|
||||
_terminal.keyInput(TerminalKey.enter);
|
||||
}
|
||||
|
||||
await _session.done;
|
||||
await _session?.done;
|
||||
if (mounted) {
|
||||
context.pop();
|
||||
}
|
||||
}
|
||||
|
||||
void _listen(Stream<Uint8List> stream) {
|
||||
void _listen(Stream<Uint8List>? stream) {
|
||||
if (stream == null) {
|
||||
return;
|
||||
}
|
||||
stream
|
||||
.cast<List<int>>()
|
||||
.transform(const Utf8Decoder())
|
||||
.listen(_terminal.write);
|
||||
}
|
||||
|
||||
void _onTapUp(TapUpDetails details, CellOffset offset) {
|
||||
if (_menuController.isShown) {
|
||||
_menuController.remove();
|
||||
return;
|
||||
}
|
||||
final selected = terminalSelected;
|
||||
final children = <Widget>[
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// _paste();
|
||||
// },
|
||||
// child: Text(_s.paste),
|
||||
// ),
|
||||
];
|
||||
if (selected?.trim().isNotEmpty ?? false) {
|
||||
children.add(
|
||||
TextButton(
|
||||
child: Text(
|
||||
_s.copy,
|
||||
),
|
||||
onPressed: () {
|
||||
_terminalController.setSelection(CellAnchor(0), CellAnchor(0));
|
||||
if (selected != null) {
|
||||
copy2Clipboard(selected);
|
||||
}
|
||||
_menuController.remove();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
if (children.isEmpty) {
|
||||
return;
|
||||
}
|
||||
_menuController.show(
|
||||
context: context,
|
||||
contextMenuBuilder: (context) {
|
||||
return TextSelectionToolbar(
|
||||
anchorAbove: details.globalPosition,
|
||||
anchorBelow: details.globalPosition,
|
||||
children: children,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user