new: pick from file to add key #9

This commit is contained in:
lollipopkit
2023-02-16 12:55:23 +08:00
parent 28a6067033
commit 1aac166c43
9 changed files with 143 additions and 79 deletions

View File

@@ -44,12 +44,12 @@ get _initSwap => Swap(
cached: 0,
);
get initStatus => ServerStatus(
cpu: initCpuStatus,
mem: _initMemory,
sysVer: 'Loading...',
uptime: '',
disk: [DiskInfo('/', '/', 0, '0', '0', '0')],
tcp: TcpStatus(0, 0, 0, 0),
netSpeed: initNetSpeed,
swap: _initSwap,
);
cpu: initCpuStatus,
mem: _initMemory,
sysVer: 'Loading...',
uptime: '',
disk: [DiskInfo('/', '/', 0, '0', '0', '0')],
tcp: TcpStatus(0, 0, 0, 0),
netSpeed: initNetSpeed,
swap: _initSwap,
);

View File

@@ -2,6 +2,13 @@ const backendUrl = 'https://res.lolli.tech';
const baseUrl = '$backendUrl/toolbox';
const joinQQGroupUrl = 'https://jq.qq.com/?_wv=1027&k=G0hUmPAq';
const myGithub = 'https://github.com/lollipopkit';
const rainSunMeGithub = 'https://github.com/RainSunMe';
const fectureGithub = 'https://github.com/fecture';
const issueUrl = '$myGithub/flutter_server_box/issues';
// Thanks
const thanksMap = {
'RainSunMe': 'https://github.com/RainSunMe',
'fecture': 'https://github.com/fecture',
'Tao173': 'https://github.com/Tao173',
'QingAnLe': 'https://github.com/QingAnLe',
'wxdjs': 'https://github.com/wxdjs',
};

View File

@@ -31,38 +31,40 @@ class MessageLookup extends MessageLookupByLibrary {
static String m4(percent, size) => "${percent}% of ${size}";
static String m5(count) => "Found ${count} update";
static String m5(file) => "${file} not exist";
static String m6(code) => "request failed, status code: ${code}";
static String m6(count) => "Found ${count} update";
static String m7(url) =>
static String m7(code) => "request failed, status code: ${code}";
static String m8(url) =>
"Please make sure that docker is installed correctly, or that you are using a non-self-compiled version. If you don\'t have the above issues, please submit an issue on ${url}.";
static String m8(myGithub) => "\nMade with ❤️ by ${myGithub}";
static String m9(myGithub) => "\nMade with ❤️ by ${myGithub}";
static String m9(url) => "Please report bugs on ${url}";
static String m10(url) => "Please report bugs on ${url}";
static String m10(date) => "Are you sure to restore from ${date} ?";
static String m11(date) => "Are you sure to restore from ${date} ?";
static String m11(time) => "Spent time: ${time}";
static String m12(time) => "Spent time: ${time}";
static String m12(url) =>
static String m13(url) =>
"This function is now in the experimental stage.\n\nPlease report bugs on ${url} or join our development.";
static String m13(name) => "Are you sure to delete [${name}]?";
static String m14(name) => "Are you sure to delete [${name}]?";
static String m14(server) => "Are you sure to delete server [${server}]?";
static String m15(server) => "Are you sure to delete server [${server}]?";
static String m15(newest) => "Update: v1.0.${newest}";
static String m16(newest) => "Update: v1.0.${newest}";
static String m16(newest) =>
static String m17(newest) =>
"Current version is too low, please update to v1.0.${newest}";
static String m17(build) => "Found: v1.0.${build}, click to update";
static String m18(build) => "Found: v1.0.${build}, click to update";
static String m18(build) => "Current: v1.0.${build}";
static String m19(build) => "Current: v1.0.${build}";
static String m19(build) => "Current: v1.0.${build}, is up to date";
static String m20(build) => "Current: v1.0.${build}, is up to date";
final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
@@ -135,12 +137,13 @@ class MessageLookup extends MessageLookupByLibrary {
"If you have any questions, please feedback on Github."),
"fieldMustNotEmpty": MessageLookupByLibrary.simpleMessage(
"These fields must not be empty."),
"fileNotExist": m5,
"files": MessageLookupByLibrary.simpleMessage("Files"),
"foundNUpdate": m5,
"foundNUpdate": m6,
"go": MessageLookupByLibrary.simpleMessage("Go"),
"goto": MessageLookupByLibrary.simpleMessage("Go to"),
"host": MessageLookupByLibrary.simpleMessage("Host"),
"httpFailedWithCode": m6,
"httpFailedWithCode": m7,
"imagesList": MessageLookupByLibrary.simpleMessage("Images list"),
"import": MessageLookupByLibrary.simpleMessage("Import"),
"importAndExport":
@@ -153,7 +156,7 @@ class MessageLookup extends MessageLookupByLibrary {
"invalidJson": MessageLookupByLibrary.simpleMessage("Invalid JSON"),
"invalidVersion":
MessageLookupByLibrary.simpleMessage("Invalid version"),
"invalidVersionHelp": m7,
"invalidVersionHelp": m8,
"isBusy": MessageLookupByLibrary.simpleMessage("Is busy now"),
"keepForeground":
MessageLookupByLibrary.simpleMessage("Keep app foreground!"),
@@ -164,7 +167,7 @@ class MessageLookup extends MessageLookupByLibrary {
"loadingFiles":
MessageLookupByLibrary.simpleMessage("Loading files..."),
"loss": MessageLookupByLibrary.simpleMessage("loss"),
"madeWithLove": m8,
"madeWithLove": m9,
"max": MessageLookupByLibrary.simpleMessage("max"),
"maxRetryCount": MessageLookupByLibrary.simpleMessage(
"Number of server reconnection"),
@@ -190,6 +193,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("On server detail page"),
"open": MessageLookupByLibrary.simpleMessage("Open"),
"path": MessageLookupByLibrary.simpleMessage("Path"),
"pickFile": MessageLookupByLibrary.simpleMessage("Pick file"),
"ping": MessageLookupByLibrary.simpleMessage("Ping"),
"pingAvg": MessageLookupByLibrary.simpleMessage("Avg:"),
"pingInputIP": MessageLookupByLibrary.simpleMessage(
@@ -208,11 +212,11 @@ class MessageLookup extends MessageLookupByLibrary {
"privateKey": MessageLookupByLibrary.simpleMessage("Private Key"),
"pwd": MessageLookupByLibrary.simpleMessage("Password"),
"rename": MessageLookupByLibrary.simpleMessage("Rename"),
"reportBugsOnGithubIssue": m9,
"reportBugsOnGithubIssue": m10,
"restore": MessageLookupByLibrary.simpleMessage("Restore"),
"restoreSuccess": MessageLookupByLibrary.simpleMessage(
"Restore success. Restart app to apply."),
"restoreSureWithDate": m10,
"restoreSureWithDate": m11,
"result": MessageLookupByLibrary.simpleMessage("Result"),
"run": MessageLookupByLibrary.simpleMessage("Run"),
"save": MessageLookupByLibrary.simpleMessage("Save"),
@@ -238,14 +242,14 @@ class MessageLookup extends MessageLookupByLibrary {
"showDistLogo":
MessageLookupByLibrary.simpleMessage("Show distribution logo"),
"snippet": MessageLookupByLibrary.simpleMessage("Snippet"),
"spentTime": m11,
"sshTip": m12,
"spentTime": m12,
"sshTip": m13,
"start": MessageLookupByLibrary.simpleMessage("Start"),
"stop": MessageLookupByLibrary.simpleMessage("Stop"),
"sureDelete": m13,
"sureDelete": m14,
"sureNoPwd": MessageLookupByLibrary.simpleMessage(
"Are you sure to use no password?"),
"sureToDeleteServer": m14,
"sureToDeleteServer": m15,
"termTheme": MessageLookupByLibrary.simpleMessage("Terminal theme"),
"times": MessageLookupByLibrary.simpleMessage("Times"),
"ttl": MessageLookupByLibrary.simpleMessage("ttl"),
@@ -259,14 +263,14 @@ class MessageLookup extends MessageLookupByLibrary {
"You set to 0, will not update automatically.\nCan\'t calculate CPU status."),
"updateServerStatusInterval": MessageLookupByLibrary.simpleMessage(
"Server status update interval"),
"updateTip": m15,
"updateTipTooLow": m16,
"updateTip": m16,
"updateTipTooLow": m17,
"upsideDown": MessageLookupByLibrary.simpleMessage("Upside Down"),
"urlOrJson": MessageLookupByLibrary.simpleMessage("URL or JSON"),
"user": MessageLookupByLibrary.simpleMessage("User"),
"versionHaveUpdate": m17,
"versionUnknownUpdate": m18,
"versionUpdated": m19,
"versionHaveUpdate": m18,
"versionUnknownUpdate": m19,
"versionUpdated": m20,
"waitConnection": MessageLookupByLibrary.simpleMessage(
"Please wait for the connection to be established."),
"willTakEeffectImmediately":

View File

@@ -31,36 +31,38 @@ class MessageLookup extends MessageLookupByLibrary {
static String m4(percent, size) => "${size}${percent}%";
static String m5(count) => "找到 ${count} 个更新";
static String m5(file) => "${file} 不存在";
static String m6(code) => "请求失败, 状态码: ${code}";
static String m6(count) => "找到 ${count} 个更新";
static String m7(url) =>
static String m7(code) => "请求失败, 状态码: ${code}";
static String m8(url) =>
"请确保正确安装了docker或者使用的非自编译版本。如果没有以上问题请在 ${url} 提交问题。";
static String m8(myGithub) => "\n用❤️制作 by ${myGithub}";
static String m9(myGithub) => "\n用❤️制作 by ${myGithub}";
static String m9(url) => "请到 ${url} 提交问题";
static String m10(url) => "请到 ${url} 提交问题";
static String m10(date) => "确定恢复 ${date} 的备份吗?";
static String m11(date) => "确定恢复 ${date} 的备份吗?";
static String m11(time) => "耗时: ${time}";
static String m12(time) => "耗时: ${time}";
static String m12(url) => "该功能目前处于测试阶段。\n\n请在 ${url} 反馈问题,或者加入我们开发。";
static String m13(url) => "该功能目前处于测试阶段。\n\n请在 ${url} 反馈问题,或者加入我们开发。";
static String m13(name) => "确定删除[${name}]";
static String m14(name) => "确定删除[${name}]";
static String m14(server) => "你确定要删除服务器 [${server}] 吗?";
static String m15(server) => "你确定要删除服务器 [${server}] 吗?";
static String m15(newest) => "新版本: v1.0.${newest}";
static String m16(newest) => "新版本: v1.0.${newest}";
static String m16(newest) => "当前版本过低,请升级至 v1.0.${newest}";
static String m17(newest) => "当前版本过低,请升级至 v1.0.${newest}";
static String m17(build) => "找到新版本v1.0.${build}, 点击更新";
static String m18(build) => "找到新版本v1.0.${build}, 点击更新";
static String m18(build) => "当前v1.0.${build}";
static String m19(build) => "当前v1.0.${build}";
static String m19(build) => "当前v1.0.${build}, 已是最新版本";
static String m20(build) => "当前v1.0.${build}, 已是最新版本";
final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
@@ -122,12 +124,13 @@ class MessageLookup extends MessageLookupByLibrary {
"feedbackOnGithub":
MessageLookupByLibrary.simpleMessage("如果你有任何问题请在GitHub反馈"),
"fieldMustNotEmpty": MessageLookupByLibrary.simpleMessage("这些输入框不能为空。"),
"fileNotExist": m5,
"files": MessageLookupByLibrary.simpleMessage("文件"),
"foundNUpdate": m5,
"foundNUpdate": m6,
"go": MessageLookupByLibrary.simpleMessage("开始"),
"goto": MessageLookupByLibrary.simpleMessage("前往"),
"host": MessageLookupByLibrary.simpleMessage("主机"),
"httpFailedWithCode": m6,
"httpFailedWithCode": m7,
"imagesList": MessageLookupByLibrary.simpleMessage("镜像列表"),
"import": MessageLookupByLibrary.simpleMessage("导入"),
"importAndExport": MessageLookupByLibrary.simpleMessage("导入或导出"),
@@ -137,7 +140,7 @@ class MessageLookup extends MessageLookupByLibrary {
"请先 https://docs.docker.com/engine/install docker"),
"invalidJson": MessageLookupByLibrary.simpleMessage("无效的json存在格式问题"),
"invalidVersion": MessageLookupByLibrary.simpleMessage("不支持的版本"),
"invalidVersionHelp": m7,
"invalidVersionHelp": m8,
"isBusy": MessageLookupByLibrary.simpleMessage("当前正忙"),
"keepForeground": MessageLookupByLibrary.simpleMessage("请保持应用处于前台!"),
"keyAuth": MessageLookupByLibrary.simpleMessage("公钥认证"),
@@ -146,7 +149,7 @@ class MessageLookup extends MessageLookupByLibrary {
"license": MessageLookupByLibrary.simpleMessage("开源证书"),
"loadingFiles": MessageLookupByLibrary.simpleMessage("正在加载目录。。。"),
"loss": MessageLookupByLibrary.simpleMessage("丢包率"),
"madeWithLove": m8,
"madeWithLove": m9,
"max": MessageLookupByLibrary.simpleMessage("最大"),
"maxRetryCount": MessageLookupByLibrary.simpleMessage("服务器尝试重连次数"),
"maxRetryCountEqual0": MessageLookupByLibrary.simpleMessage("会无限重试"),
@@ -165,6 +168,7 @@ class MessageLookup extends MessageLookupByLibrary {
"onServerDetailPage": MessageLookupByLibrary.simpleMessage("在服务器详情页"),
"open": MessageLookupByLibrary.simpleMessage("打开"),
"path": MessageLookupByLibrary.simpleMessage("路径"),
"pickFile": MessageLookupByLibrary.simpleMessage("选择文件"),
"ping": MessageLookupByLibrary.simpleMessage("Ping"),
"pingAvg": MessageLookupByLibrary.simpleMessage("平均:"),
"pingInputIP": MessageLookupByLibrary.simpleMessage("请输入目标IP或域名"),
@@ -180,11 +184,11 @@ class MessageLookup extends MessageLookupByLibrary {
"privateKey": MessageLookupByLibrary.simpleMessage("私钥"),
"pwd": MessageLookupByLibrary.simpleMessage("密码"),
"rename": MessageLookupByLibrary.simpleMessage("重命名"),
"reportBugsOnGithubIssue": m9,
"reportBugsOnGithubIssue": m10,
"restore": MessageLookupByLibrary.simpleMessage("恢复"),
"restoreSuccess":
MessageLookupByLibrary.simpleMessage("恢复成功需要重启App来应用更改"),
"restoreSureWithDate": m10,
"restoreSureWithDate": m11,
"result": MessageLookupByLibrary.simpleMessage("结果"),
"run": MessageLookupByLibrary.simpleMessage("运行"),
"save": MessageLookupByLibrary.simpleMessage("保存"),
@@ -204,13 +208,13 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("SFTP 已连接,即将开始下载..."),
"showDistLogo": MessageLookupByLibrary.simpleMessage("显示发行版 Logo"),
"snippet": MessageLookupByLibrary.simpleMessage("代码片段"),
"spentTime": m11,
"sshTip": m12,
"spentTime": m12,
"sshTip": m13,
"start": MessageLookupByLibrary.simpleMessage("开始"),
"stop": MessageLookupByLibrary.simpleMessage("停止"),
"sureDelete": m13,
"sureDelete": m14,
"sureNoPwd": MessageLookupByLibrary.simpleMessage("确认使用无密码?"),
"sureToDeleteServer": m14,
"sureToDeleteServer": m15,
"termTheme": MessageLookupByLibrary.simpleMessage("终端主题"),
"times": MessageLookupByLibrary.simpleMessage(""),
"ttl": MessageLookupByLibrary.simpleMessage("缓存时间"),
@@ -223,14 +227,14 @@ class MessageLookup extends MessageLookupByLibrary {
"你设置为0服务器状态不会自动刷新。\n且不能计算CPU使用情况。"),
"updateServerStatusInterval":
MessageLookupByLibrary.simpleMessage("服务器状态刷新间隔"),
"updateTip": m15,
"updateTipTooLow": m16,
"updateTip": m16,
"updateTipTooLow": m17,
"upsideDown": MessageLookupByLibrary.simpleMessage("上下交换"),
"urlOrJson": MessageLookupByLibrary.simpleMessage("链接或JSON"),
"user": MessageLookupByLibrary.simpleMessage("用户"),
"versionHaveUpdate": m17,
"versionUnknownUpdate": m18,
"versionUpdated": m19,
"versionHaveUpdate": m18,
"versionUnknownUpdate": m19,
"versionUpdated": m20,
"waitConnection": MessageLookupByLibrary.simpleMessage("请等待连接建立"),
"willTakEeffectImmediately":
MessageLookupByLibrary.simpleMessage("更改将会立即生效")

View File

@@ -571,6 +571,16 @@ class S {
);
}
/// `{file} not exist`
String fileNotExist(Object file) {
return Intl.message(
'$file not exist',
name: 'fileNotExist',
desc: '',
args: [file],
);
}
/// `Files`
String get files {
return Intl.message(
@@ -991,6 +1001,16 @@ class S {
);
}
/// `Pick file`
String get pickFile {
return Intl.message(
'Pick file',
name: 'pickFile',
desc: '',
args: [],
);
}
/// `Ping`
String get ping {
return Intl.message(

View File

@@ -51,6 +51,7 @@
"feedback": "Feedback",
"feedbackOnGithub": "If you have any questions, please feedback on Github.",
"fieldMustNotEmpty": "These fields must not be empty.",
"fileNotExist": "{file} not exist",
"files": "Files",
"foundNUpdate": "Found {count} update",
"go": "Go",
@@ -93,6 +94,7 @@
"onServerDetailPage": "On server detail page",
"open": "Open",
"path": "Path",
"pickFile": "Pick file",
"ping": "Ping",
"pingAvg": "Avg:",
"pingInputIP": "Please input a target IP/domain.",

View File

@@ -51,6 +51,7 @@
"feedback": "反馈",
"feedbackOnGithub": "如果你有任何问题请在GitHub反馈",
"fieldMustNotEmpty": "这些输入框不能为空。",
"fileNotExist": "{file} 不存在",
"files": "文件",
"foundNUpdate": "找到 {count} 个更新",
"go": "开始",
@@ -93,6 +94,7 @@
"onServerDetailPage": "在服务器详情页",
"open": "打开",
"path": "路径",
"pickFile": "选择文件",
"ping": "Ping",
"pingAvg": "平均:",
"pingInputIP": "请输入目标IP或域名",

View File

@@ -249,7 +249,7 @@ class _MyHomePageState extends State<MyHomePage>
),
AboutListTile(
icon: const Icon(Icons.text_snippet),
applicationName: BuildData.name,
applicationName: '\n${BuildData.name}',
applicationVersion: _versionStr,
applicationIcon: _buildIcon(),
aboutBoxChildren: [
@@ -259,13 +259,12 @@ class _MyHomePageState extends State<MyHomePage>
UrlText(
text: _s.aboutThanks,
),
const UrlText(
text: rainSunMeGithub,
replace: 'RainSunMe',
),
const UrlText(
text: fectureGithub,
replace: 'fecture',
// Thanks
...thanksMap.keys.map(
(key) => UrlText(
text: thanksMap[key] ?? '',
replace: key,
),
)
],
child: Text(_s.license),

View File

@@ -1,5 +1,8 @@
import 'dart:io';
import 'package:after_layout/after_layout.dart';
import 'package:dartssh2/dartssh2.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -90,6 +93,29 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
enableSuggestions: false,
decoration: buildDecoration(_s.privateKey, icon: Icons.vpn_key),
),
TextButton(
onPressed: () async {
final result = await FilePicker.platform.pickFiles();
if (result == null) {
return;
}
final path = result.files.single.path;
if (path == null) {
showSnackBar(context, const Text('path is null'));
return;
}
final file = File(path);
if (!file.existsSync()) {
showSnackBar(context, Text(_s.fileNotExist(path)));
return;
}
_keyController.text = await file.readAsString();
},
child: Text(_s.pickFile),
),
TextField(
controller: _pwdController,
autocorrect: false,