mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt. for ssh page
This commit is contained in:
@@ -18,4 +18,12 @@ class SettingStore extends PersistentStore {
|
||||
/// Show logo on server detail page
|
||||
StoreProperty<bool> get showDistLogo =>
|
||||
property('showDistLogo', defaultValue: true);
|
||||
|
||||
/// SSH term size
|
||||
StoreProperty<String> get sshTermSize =>
|
||||
property('sshTermSize', defaultValue: '80x24');
|
||||
|
||||
/// First time to use SSH term
|
||||
StoreProperty<bool> get firstTimeUseSshTerm =>
|
||||
property('firstTimeUseSshTerm', defaultValue: true);
|
||||
}
|
||||
|
||||
@@ -236,6 +236,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"sureNoPwd": MessageLookupByLibrary.simpleMessage(
|
||||
"Are you sure to use no password?"),
|
||||
"sureToDeleteServer": m14,
|
||||
"termSize": MessageLookupByLibrary.simpleMessage("SSH Terminal size"),
|
||||
"termSizeFormatError": MessageLookupByLibrary.simpleMessage(
|
||||
"Illegal format, please enter the format of width*height, such as 80*24"),
|
||||
"ttl": MessageLookupByLibrary.simpleMessage("ttl"),
|
||||
"unknown": MessageLookupByLibrary.simpleMessage("unknown"),
|
||||
"unknownError": MessageLookupByLibrary.simpleMessage("Unknown error"),
|
||||
@@ -255,7 +258,8 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"versionUpdated": m17,
|
||||
"waitConnection": MessageLookupByLibrary.simpleMessage(
|
||||
"Please wait for the connection to be established."),
|
||||
"willTakEeffectImmediately":
|
||||
MessageLookupByLibrary.simpleMessage("Will take effect immediately")
|
||||
"willTakEeffectImmediately": MessageLookupByLibrary.simpleMessage(
|
||||
"Will take effect immediately"),
|
||||
"wxh": MessageLookupByLibrary.simpleMessage("Width*Height")
|
||||
};
|
||||
}
|
||||
|
||||
@@ -204,6 +204,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"sureDelete": m13,
|
||||
"sureNoPwd": MessageLookupByLibrary.simpleMessage("确认使用无密码?"),
|
||||
"sureToDeleteServer": m14,
|
||||
"termSize": MessageLookupByLibrary.simpleMessage("SSH 终端大小"),
|
||||
"termSizeFormatError":
|
||||
MessageLookupByLibrary.simpleMessage("格式错误,请输入类似 80x24 的格式"),
|
||||
"ttl": MessageLookupByLibrary.simpleMessage("缓存时间"),
|
||||
"unknown": MessageLookupByLibrary.simpleMessage("未知"),
|
||||
"unknownError": MessageLookupByLibrary.simpleMessage("未知错误"),
|
||||
@@ -222,6 +225,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"versionUpdated": m17,
|
||||
"waitConnection": MessageLookupByLibrary.simpleMessage("请等待连接建立"),
|
||||
"willTakEeffectImmediately":
|
||||
MessageLookupByLibrary.simpleMessage("更改将会立即生效")
|
||||
MessageLookupByLibrary.simpleMessage("更改将会立即生效"),
|
||||
"wxh": MessageLookupByLibrary.simpleMessage("宽度x高度")
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1530,6 +1530,36 @@ class S {
|
||||
args: [url],
|
||||
);
|
||||
}
|
||||
|
||||
/// `SSH Terminal size`
|
||||
String get termSize {
|
||||
return Intl.message(
|
||||
'SSH Terminal size',
|
||||
name: 'termSize',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Width*Height`
|
||||
String get wxh {
|
||||
return Intl.message(
|
||||
'Width*Height',
|
||||
name: 'wxh',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Illegal format, please enter the format of width*height, such as 80*24`
|
||||
String get termSizeFormatError {
|
||||
return Intl.message(
|
||||
'Illegal format, please enter the format of width*height, such as 80*24',
|
||||
name: 'termSizeFormatError',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppLocalizationDelegate extends LocalizationsDelegate<S> {
|
||||
|
||||
@@ -146,5 +146,8 @@
|
||||
"showDistLogo": "Show distribution logo",
|
||||
"onServerDetailPage": "On server detail page",
|
||||
"addOne": "Add one",
|
||||
"sshTip": "This function is now in the experimental stage. \nPlease report bugs on {url} or join our development."
|
||||
"sshTip": "This function is now in the experimental stage. \nPlease report bugs on {url} or join our development.",
|
||||
"termSize": "SSH Terminal size",
|
||||
"wxh": "Width*Height",
|
||||
"termSizeFormatError": "Illegal format, please enter the format of width*height, such as 80*24"
|
||||
}
|
||||
@@ -146,5 +146,8 @@
|
||||
"showDistLogo": "显示发行版 Logo",
|
||||
"onServerDetailPage": "在服务器详情页",
|
||||
"addOne": "前去新增",
|
||||
"sshTip": "该功能目前处于测试阶段,请在 {url} 反馈问题,或者加入我们开发。"
|
||||
"sshTip": "该功能目前处于测试阶段,请在 {url} 反馈问题,或者加入我们开发。",
|
||||
"termSize": "SSH 终端大小",
|
||||
"wxh": "宽度x高度",
|
||||
"termSizeFormatError": "格式错误,请输入类似 80x24 的格式"
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import 'package:toolbox/data/provider/snippet.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
import 'package:toolbox/data/res/font_style.dart';
|
||||
import 'package:toolbox/data/res/url.dart';
|
||||
import 'package:toolbox/data/store/setting.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
import 'package:toolbox/view/page/pkg.dart';
|
||||
@@ -41,12 +42,14 @@ class _ServerPageState extends State<ServerPage>
|
||||
late ThemeData _theme;
|
||||
late Color _primaryColor;
|
||||
late ServerProvider _serverProvider;
|
||||
late SettingStore _settingStore;
|
||||
late S _s;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_serverProvider = locator<ServerProvider>();
|
||||
_settingStore = locator<SettingStore>();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -203,22 +206,30 @@ class _ServerPageState extends State<ServerPage>
|
||||
Icons.terminal,
|
||||
size: 21,
|
||||
),
|
||||
onTap: () => showRoundDialog(
|
||||
context,
|
||||
_s.attention,
|
||||
UrlText(
|
||||
text: _s.sshTip(issueUrl),
|
||||
replace: 'Github Issue',
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
AppRoute(SSHPage(spi: spi), 'ssh page').go(context);
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
)
|
||||
]),
|
||||
onTap: () async {
|
||||
if (_settingStore.firstTimeUseSshTerm.fetch()!) {
|
||||
await showRoundDialog(
|
||||
context,
|
||||
_s.attention,
|
||||
UrlText(
|
||||
text: _s.sshTip(issueUrl),
|
||||
replace: 'Github Issue',
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
AppRoute(SSHPage(spi: spi), 'ssh page').go(context);
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
)
|
||||
],
|
||||
);
|
||||
_settingStore.firstTimeUseSshTerm.put(false);
|
||||
} else {
|
||||
AppRoute(SSHPage(spi: spi), 'ssh page').go(context);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
_buildCheckUpdate(),
|
||||
_buildLaunchPage(),
|
||||
_buildDistLogoSwitch(),
|
||||
_buildTermSize(),
|
||||
].map((e) => RoundRectCard(e)).toList(),
|
||||
),
|
||||
);
|
||||
@@ -240,4 +241,43 @@ class _SettingPageState extends State<SettingPage> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTermSize() {
|
||||
return const SizedBox();
|
||||
// return ListTile(
|
||||
// title: Text(
|
||||
// _s.termSize,
|
||||
// style: textSize13,
|
||||
// ),
|
||||
// trailing: InkWell(
|
||||
// child: Text(
|
||||
// _setting.sshTermSize.fetch()!,
|
||||
// style: textSize13,
|
||||
// textAlign: TextAlign.right,
|
||||
// ),
|
||||
// onTap: () {
|
||||
// showRoundDialog(
|
||||
// context,
|
||||
// _s.termSize,
|
||||
// TextField(
|
||||
// decoration: InputDecoration(hintText: _s.wxh),
|
||||
// onSubmitted: (value) {
|
||||
// if (wxhReg.hasMatch(value)) {
|
||||
// _setting.sshTermSize.put(value);
|
||||
// Navigator.pop(context);
|
||||
// } else {
|
||||
// showSnackBar(context, Text(_s.termSizeFormatError));
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// [],
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
/// RegExp for 'Width*Height', eg: 80x24
|
||||
/// 'Width' and 'Height' must both greater than 0, lesser than 1000
|
||||
final wxhReg = RegExp(r'^(\d{1,3})x(\d{1,3})$');
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:toolbox/data/store/setting.dart';
|
||||
import 'package:toolbox/view/widget/two_line_text.dart';
|
||||
import 'package:xterm/xterm.dart';
|
||||
|
||||
@@ -62,6 +63,12 @@ class _SSHPageState extends State<SSHPage> {
|
||||
|
||||
terminal.write('Connected\r\n');
|
||||
|
||||
final wxh = locator<SettingStore>().sshTermSize.fetch()!;
|
||||
final split = wxh.split('x');
|
||||
final w = int.parse(split.first);
|
||||
final h = int.parse(split.last);
|
||||
terminal.resize(w, h);
|
||||
|
||||
session = await client.shell(
|
||||
pty: SSHPtyConfig(
|
||||
width: terminal.viewWidth,
|
||||
@@ -123,14 +130,10 @@ class _SSHPageState extends State<SSHPage> {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: top
|
||||
.map((e) => _buildVirtualKeyItem(e))
|
||||
.toList(),
|
||||
children: top.map((e) => _buildVirtualKeyItem(e)).toList(),
|
||||
),
|
||||
Row(
|
||||
children: bottom
|
||||
.map((e) => _buildVirtualKeyItem(e))
|
||||
.toList(),
|
||||
children: bottom.map((e) => _buildVirtualKeyItem(e)).toList(),
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -150,8 +153,14 @@ class _SSHPageState extends State<SSHPage> {
|
||||
}
|
||||
|
||||
final child = item.icon != null
|
||||
? Icon(item.icon, color: isDark ? Colors.white : Colors.black, size: 17,)
|
||||
: Text(item.text, style: TextStyle(color: selected ? Colors.blue : null, fontSize: 15));
|
||||
? Icon(
|
||||
item.icon,
|
||||
color: isDark ? Colors.white : Colors.black,
|
||||
size: 17,
|
||||
)
|
||||
: Text(item.text,
|
||||
style:
|
||||
TextStyle(color: selected ? Colors.blue : null, fontSize: 15));
|
||||
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
|
||||
Reference in New Issue
Block a user