mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
opt. for ssh
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 186;
|
||||
static const int build = 187;
|
||||
static const String engine =
|
||||
"Flutter 3.7.0 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision b06b8b2710 (4 days ago) • 2023-01-23 16:55:55 -0800\nEngine • revision b24591ed32\nTools • Dart 2.19.0 • DevTools 2.20.1\n";
|
||||
static const String buildAt = "2023-01-28 00:10:21.021365";
|
||||
static const int modifications = 8;
|
||||
static const String buildAt = "2023-01-28 13:54:17.985459";
|
||||
static const int modifications = 13;
|
||||
}
|
||||
|
||||
54
lib/data/res/terminal_theme.dart
Normal file
54
lib/data/res/terminal_theme.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:xterm/ui.dart';
|
||||
|
||||
const termDarkTheme = TerminalTheme(
|
||||
cursor: Color(0XAAAEAFAD),
|
||||
selection: Color(0XAAAEAFAD),
|
||||
foreground: Color(0XFFCCCCCC),
|
||||
background: Colors.black,
|
||||
black: Color(0XFF000000),
|
||||
red: Color(0XFFCD3131),
|
||||
green: Color(0XFF0DBC79),
|
||||
yellow: Color(0XFFE5E510),
|
||||
blue: Color(0XFF2472C8),
|
||||
magenta: Color(0XFFBC3FBC),
|
||||
cyan: Color(0XFF11A8CD),
|
||||
white: Color(0XFFE5E5E5),
|
||||
brightBlack: Color(0XFF666666),
|
||||
brightRed: Color(0XFFF14C4C),
|
||||
brightGreen: Color(0XFF23D18B),
|
||||
brightYellow: Color(0XFFF5F543),
|
||||
brightBlue: Color(0XFF3B8EEA),
|
||||
brightMagenta: Color(0XFFD670D6),
|
||||
brightCyan: Color(0XFF29B8DB),
|
||||
brightWhite: Color(0XFFFFFFFF),
|
||||
searchHitBackground: Color(0XFFFFFF2B),
|
||||
searchHitBackgroundCurrent: Color(0XFF31FF26),
|
||||
searchHitForeground: Color(0XFF000000),
|
||||
);
|
||||
|
||||
const termLightTheme = TerminalTheme(
|
||||
cursor: Color(0XFFAEAFAD),
|
||||
selection: Color(0XFFAEAFAD),
|
||||
foreground: Color(0XFF000000),
|
||||
background: Color(0XFFFFFFFF),
|
||||
black: Color(0XFF000000),
|
||||
red: Color(0XFFCD3131),
|
||||
green: Color(0XFF0DBC79),
|
||||
yellow: Color(0XFFE5E510),
|
||||
blue: Color(0XFF2472C8),
|
||||
magenta: Color(0XFFBC3FBC),
|
||||
cyan: Color(0XFF11A8CD),
|
||||
white: Color(0XFFE5E5E5),
|
||||
brightBlack: Color(0XFF666666),
|
||||
brightRed: Color(0XFFF14C4C),
|
||||
brightGreen: Color(0XFF23D18B),
|
||||
brightYellow: Color(0XFFF5F543),
|
||||
brightBlue: Color(0XFF3B8EEA),
|
||||
brightMagenta: Color(0XFFD670D6),
|
||||
brightCyan: Color(0XFF29B8DB),
|
||||
brightWhite: Color(0XFFFFFFFF),
|
||||
searchHitBackground: Color(0XFFFFFF2B),
|
||||
searchHitBackgroundCurrent: Color(0XFF31FF26),
|
||||
searchHitForeground: Color(0XFF000000),
|
||||
);
|
||||
@@ -46,15 +46,18 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
|
||||
static String m11(time) => "Spent time: ${time}";
|
||||
|
||||
static String m12(name) => "Are you sure to delete [${name}]?";
|
||||
static String m12(url) =>
|
||||
"This function is now in the experimental stage. \nPlease report bugs on ${url} or join our development.";
|
||||
|
||||
static String m13(server) => "Are you sure to delete server [${server}]?";
|
||||
static String m13(name) => "Are you sure to delete [${name}]?";
|
||||
|
||||
static String m14(build) => "Found: v1.0.${build}, click to update";
|
||||
static String m14(server) => "Are you sure to delete server [${server}]?";
|
||||
|
||||
static String m15(build) => "Current: v1.0.${build}";
|
||||
static String m15(build) => "Found: v1.0.${build}, click to update";
|
||||
|
||||
static String m16(build) => "Current: v1.0.${build}, is up to date";
|
||||
static String m16(build) => "Current: v1.0.${build}";
|
||||
|
||||
static String m17(build) => "Current: v1.0.${build}, is up to date";
|
||||
|
||||
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
|
||||
@@ -228,12 +231,13 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
MessageLookupByLibrary.simpleMessage("Show distribution logo"),
|
||||
"snippet": MessageLookupByLibrary.simpleMessage("Snippet"),
|
||||
"spentTime": m11,
|
||||
"sshTip": m12,
|
||||
"start": MessageLookupByLibrary.simpleMessage("Start"),
|
||||
"stop": MessageLookupByLibrary.simpleMessage("Stop"),
|
||||
"sureDelete": m12,
|
||||
"sureDelete": m13,
|
||||
"sureNoPwd": MessageLookupByLibrary.simpleMessage(
|
||||
"Are you sure to use no password?"),
|
||||
"sureToDeleteServer": m13,
|
||||
"sureToDeleteServer": m14,
|
||||
"ttl": MessageLookupByLibrary.simpleMessage("ttl"),
|
||||
"unknown": MessageLookupByLibrary.simpleMessage("unknown"),
|
||||
"unknownError": MessageLookupByLibrary.simpleMessage("Unknown error"),
|
||||
@@ -248,9 +252,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"upsideDown": MessageLookupByLibrary.simpleMessage("Upside Down"),
|
||||
"urlOrJson": MessageLookupByLibrary.simpleMessage("URL or JSON"),
|
||||
"user": MessageLookupByLibrary.simpleMessage("User"),
|
||||
"versionHaveUpdate": m14,
|
||||
"versionUnknownUpdate": m15,
|
||||
"versionUpdated": m16,
|
||||
"versionHaveUpdate": m15,
|
||||
"versionUnknownUpdate": m16,
|
||||
"versionUpdated": m17,
|
||||
"waitConnection": MessageLookupByLibrary.simpleMessage(
|
||||
"Please wait for the connection to be established."),
|
||||
"willTakEeffectImmediately":
|
||||
|
||||
@@ -46,15 +46,17 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
|
||||
static String m11(time) => "耗时: ${time}";
|
||||
|
||||
static String m12(name) => "确定删除[${name}]?";
|
||||
static String m12(url) => "该功能目前处于测试阶段,请在 ${url} 反馈问题,或者加入我们开发。";
|
||||
|
||||
static String m13(server) => "你确定要删除服务器 [${server}] 吗?";
|
||||
static String m13(name) => "确定删除[${name}]?";
|
||||
|
||||
static String m14(build) => "找到新版本:v1.0.${build}, 点击更新";
|
||||
static String m14(server) => "你确定要删除服务器 [${server}] 吗?";
|
||||
|
||||
static String m15(build) => "当前:v1.0.${build}";
|
||||
static String m15(build) => "找到新版本:v1.0.${build}, 点击更新";
|
||||
|
||||
static String m16(build) => "当前:v1.0.${build}, 已是最新版本";
|
||||
static String m16(build) => "当前:v1.0.${build}";
|
||||
|
||||
static String m17(build) => "当前:v1.0.${build}, 已是最新版本";
|
||||
|
||||
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
|
||||
@@ -197,11 +199,12 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"showDistLogo": MessageLookupByLibrary.simpleMessage("显示发行版 Logo"),
|
||||
"snippet": MessageLookupByLibrary.simpleMessage("代码片段"),
|
||||
"spentTime": m11,
|
||||
"sshTip": m12,
|
||||
"start": MessageLookupByLibrary.simpleMessage("开始"),
|
||||
"stop": MessageLookupByLibrary.simpleMessage("停止"),
|
||||
"sureDelete": m12,
|
||||
"sureDelete": m13,
|
||||
"sureNoPwd": MessageLookupByLibrary.simpleMessage("确认使用无密码?"),
|
||||
"sureToDeleteServer": m13,
|
||||
"sureToDeleteServer": m14,
|
||||
"ttl": MessageLookupByLibrary.simpleMessage("缓存时间"),
|
||||
"unknown": MessageLookupByLibrary.simpleMessage("未知"),
|
||||
"unknownError": MessageLookupByLibrary.simpleMessage("未知错误"),
|
||||
@@ -215,9 +218,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"upsideDown": MessageLookupByLibrary.simpleMessage("上下交换"),
|
||||
"urlOrJson": MessageLookupByLibrary.simpleMessage("链接或JSON"),
|
||||
"user": MessageLookupByLibrary.simpleMessage("用户"),
|
||||
"versionHaveUpdate": m14,
|
||||
"versionUnknownUpdate": m15,
|
||||
"versionUpdated": m16,
|
||||
"versionHaveUpdate": m15,
|
||||
"versionUnknownUpdate": m16,
|
||||
"versionUpdated": m17,
|
||||
"waitConnection": MessageLookupByLibrary.simpleMessage("请等待连接建立"),
|
||||
"willTakEeffectImmediately":
|
||||
MessageLookupByLibrary.simpleMessage("更改将会立即生效")
|
||||
|
||||
@@ -1530,6 +1530,16 @@ class S {
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `This function is now in the experimental stage. \nPlease report bugs on {url} or join our development.`
|
||||
String sshTip(Object url) {
|
||||
return Intl.message(
|
||||
'This function is now in the experimental stage. \nPlease report bugs on $url or join our development.',
|
||||
name: 'sshTip',
|
||||
desc: '',
|
||||
args: [url],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppLocalizationDelegate extends LocalizationsDelegate<S> {
|
||||
|
||||
@@ -146,5 +146,6 @@
|
||||
"goto": "Go to",
|
||||
"showDistLogo": "Show distribution logo",
|
||||
"onServerDetailPage": "On server detail page",
|
||||
"addOne": "Add one"
|
||||
"addOne": "Add one",
|
||||
"sshTip": "This function is now in the experimental stage. \nPlease report bugs on {url} or join our development."
|
||||
}
|
||||
@@ -146,5 +146,6 @@
|
||||
"goto": "前往",
|
||||
"showDistLogo": "显示发行版 Logo",
|
||||
"onServerDetailPage": "在服务器详情页",
|
||||
"addOne": "前去新增"
|
||||
"addOne": "前去新增",
|
||||
"sshTip": "该功能目前处于测试阶段,请在 {url} 反馈问题,或者加入我们开发。"
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import 'package:toolbox/data/provider/server.dart';
|
||||
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/generated/l10n.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
import 'package:toolbox/view/page/pkg.dart';
|
||||
@@ -25,6 +26,8 @@ import 'package:toolbox/view/page/ssh.dart';
|
||||
import 'package:toolbox/view/widget/picker.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
|
||||
import '../../widget/url_text.dart';
|
||||
|
||||
class ServerPage extends StatefulWidget {
|
||||
const ServerPage({Key? key}) : super(key: key);
|
||||
|
||||
@@ -203,7 +206,22 @@ class _ServerPageState extends State<ServerPage>
|
||||
Icons.terminal,
|
||||
size: 21,
|
||||
),
|
||||
onTap: () => AppRoute(SSHPage(spi: spi), 'ssh page').go(context),
|
||||
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),
|
||||
)
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,13 @@ import 'dart:convert';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:toolbox/data/res/font_style.dart';
|
||||
import 'package:xterm/xterm.dart';
|
||||
|
||||
import '../../core/utils.dart';
|
||||
import '../../data/model/server/server_private_info.dart';
|
||||
import '../../data/provider/server.dart';
|
||||
import '../../data/res/terminal_theme.dart';
|
||||
import '../../locator.dart';
|
||||
import '../widget/virtual_keyboard.dart';
|
||||
|
||||
@@ -20,10 +23,11 @@ class SSHPage extends StatefulWidget {
|
||||
|
||||
class _SSHPageState extends State<SSHPage> {
|
||||
late final terminal = Terminal(inputHandler: keyboard);
|
||||
|
||||
late final SSHSession session;
|
||||
final keyboard = VirtualKeyboard(defaultInputHandler);
|
||||
|
||||
var title = '';
|
||||
var isDark = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -31,6 +35,18 @@ class _SSHPageState extends State<SSHPage> {
|
||||
initTerminal();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
isDark = isDarkMode(context);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
session.close();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> initTerminal() async {
|
||||
terminal.write('Connecting...\r\n');
|
||||
|
||||
@@ -46,7 +62,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
|
||||
terminal.write('Connected\r\n');
|
||||
|
||||
final session = await client.shell(
|
||||
session = await client.shell(
|
||||
pty: SSHPtyConfig(
|
||||
width: terminal.viewWidth,
|
||||
height: terminal.viewHeight,
|
||||
@@ -83,14 +99,17 @@ class _SSHPageState extends State<SSHPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
backgroundColor:
|
||||
Theme.of(context).appBarTheme.backgroundColor?.withOpacity(0.5),
|
||||
title: Text(title, style: textSize18),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TerminalView(terminal, keyboardType: TextInputType.none),
|
||||
child: TerminalView(
|
||||
terminal,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
theme: isDark ? termDarkTheme : termLightTheme,
|
||||
keyboardAppearance: isDark ? Brightness.dark : Brightness.light,
|
||||
),
|
||||
),
|
||||
VirtualKeyboardView(keyboard),
|
||||
],
|
||||
|
||||
@@ -11,6 +11,7 @@ class VirtualKeyboardView extends StatelessWidget {
|
||||
return AnimatedBuilder(
|
||||
animation: keyboard,
|
||||
builder: (context, child) => ToggleButtons(
|
||||
renderBorder: false,
|
||||
isSelected: [keyboard.ctrl, keyboard.alt, keyboard.shift],
|
||||
onPressed: (index) {
|
||||
switch (index) {
|
||||
|
||||
Reference in New Issue
Block a user