mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-15 04:34:34 +01:00
Compare commits
84 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e3afe98a9 | ||
|
|
7732ce5dbb | ||
|
|
f1ae924724 | ||
|
|
4cc72328a7 | ||
|
|
43e32775a3 | ||
|
|
27e7653587 | ||
|
|
89050daf4e | ||
|
|
2cc52fcee6 | ||
|
|
3f3240040a | ||
|
|
350d248776 | ||
|
|
bb15f34615 | ||
|
|
58b950f814 | ||
|
|
c2e822f49d | ||
|
|
4c4153ef98 | ||
|
|
35b5d1ccb5 | ||
|
|
065fd15429 | ||
|
|
5666a23e00 | ||
|
|
69fae4dd21 | ||
|
|
2986f80f89 | ||
|
|
e423e56152 | ||
|
|
9c00dc8a54 | ||
|
|
558721fa79 | ||
|
|
0c198c23fc | ||
|
|
99aa0fc1f5 | ||
|
|
1aac166c43 | ||
|
|
28a6067033 | ||
|
|
9c3b822311 | ||
|
|
ba44649ce1 | ||
|
|
e7b1773e5c | ||
|
|
3feef3936c | ||
|
|
7837fa4339 | ||
|
|
82a201d3dc | ||
|
|
c479d18714 | ||
|
|
469b9fe8cd | ||
|
|
c47e24ac5b | ||
|
|
1063916474 | ||
|
|
a63e240ce0 | ||
|
|
1a8d572fbd | ||
|
|
21ac323ed1 | ||
|
|
2faea10d61 | ||
|
|
04cf5b65ce | ||
|
|
4d741ac82a | ||
|
|
068089d207 | ||
|
|
5ebb4e6b3e | ||
|
|
19e0b283ae | ||
|
|
7e8600ab6d | ||
|
|
7c0e01d0d5 | ||
|
|
f3c670d82c | ||
|
|
49f9b0b179 | ||
|
|
47861b1e0b | ||
|
|
923667d57c | ||
|
|
e6458a1d7f | ||
|
|
f109aca484 | ||
|
|
a518dca0ca | ||
|
|
be1a162632 | ||
|
|
0e8a8056f8 | ||
|
|
587e0a4640 | ||
|
|
9608c9139c | ||
|
|
913ce312de | ||
|
|
b6ab4b7fde | ||
|
|
7c6649f941 | ||
|
|
7c84957230 | ||
|
|
092c3f522a | ||
|
|
877b93ae3a | ||
|
|
565bc8012a | ||
|
|
96034f9487 | ||
|
|
0522cfef1c | ||
|
|
0ecc321115 | ||
|
|
9c8f9c3b9f | ||
|
|
b2e2d4c603 | ||
|
|
599bd2cfd3 | ||
|
|
6bda94bd7b | ||
|
|
cfd28c3009 | ||
|
|
7e01c4cbb3 | ||
|
|
78b46998d1 | ||
|
|
d43d251d92 | ||
|
|
1c29b76455 | ||
|
|
611518f790 | ||
|
|
62a1122174 | ||
|
|
ca17af30cf | ||
|
|
3998f549e4 | ||
|
|
9541c0c7ab | ||
|
|
475bb8c4b0 | ||
|
|
a0b68862fc |
1171
.dart_tool/flutter_gen/gen_l10n/l10n.dart
Normal file
1171
.dart_tool/flutter_gen/gen_l10n/l10n.dart
Normal file
File diff suppressed because it is too large
Load Diff
572
.dart_tool/flutter_gen/gen_l10n/l10n_en.dart
Normal file
572
.dart_tool/flutter_gen/gen_l10n/l10n_en.dart
Normal file
@@ -0,0 +1,572 @@
|
||||
import 'l10n.dart';
|
||||
|
||||
/// The translations for English (`en`).
|
||||
class SEn extends S {
|
||||
SEn([String locale = 'en']) : super(locale);
|
||||
|
||||
@override
|
||||
String get about => 'About';
|
||||
|
||||
@override
|
||||
String get aboutThanks => '\nThanks to the following people who participated in the test.';
|
||||
|
||||
@override
|
||||
String get addAServer => 'add a server';
|
||||
|
||||
@override
|
||||
String get addOne => 'Add one';
|
||||
|
||||
@override
|
||||
String get addPrivateKey => 'Add private key';
|
||||
|
||||
@override
|
||||
String get alreadyLastDir => 'Already in last directory.';
|
||||
|
||||
@override
|
||||
String get appPrimaryColor => 'App primary color';
|
||||
|
||||
@override
|
||||
String get attention => 'Attention';
|
||||
|
||||
@override
|
||||
String get auto => 'Auto';
|
||||
|
||||
@override
|
||||
String get backDir => 'Back';
|
||||
|
||||
@override
|
||||
String get backup => 'Backup';
|
||||
|
||||
@override
|
||||
String get backupTip => 'The exported data is simply encrypted. \nPlease keep it safe.\nRestoring will not overwrite existing data (except setting).';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch => 'Backup version is not match.';
|
||||
|
||||
@override
|
||||
String get cancel => 'Cancel';
|
||||
|
||||
@override
|
||||
String get choose => 'Choose';
|
||||
|
||||
@override
|
||||
String get chooseDestination => 'Choose destination';
|
||||
|
||||
@override
|
||||
String get chooseFontFile => 'Choose a font file';
|
||||
|
||||
@override
|
||||
String get choosePrivateKey => 'Choose private key';
|
||||
|
||||
@override
|
||||
String get clear => 'Clear';
|
||||
|
||||
@override
|
||||
String get clickSee => 'Click here';
|
||||
|
||||
@override
|
||||
String get close => 'Close';
|
||||
|
||||
@override
|
||||
String get cmd => 'Command';
|
||||
|
||||
@override
|
||||
String get containerStatus => 'Container status';
|
||||
|
||||
@override
|
||||
String get convert => 'Convert';
|
||||
|
||||
@override
|
||||
String get copy => 'Copy';
|
||||
|
||||
@override
|
||||
String get copyPath => 'Copy path';
|
||||
|
||||
@override
|
||||
String get createFile => 'Create file';
|
||||
|
||||
@override
|
||||
String get createFolder => 'Create folder';
|
||||
|
||||
@override
|
||||
String get currentMode => 'Current Mode';
|
||||
|
||||
@override
|
||||
String get dark => 'Dark';
|
||||
|
||||
@override
|
||||
String get debug => 'Debug';
|
||||
|
||||
@override
|
||||
String get decode => 'Decode';
|
||||
|
||||
@override
|
||||
String get delete => 'Delete';
|
||||
|
||||
@override
|
||||
String get disconnected => 'Disconnected';
|
||||
|
||||
@override
|
||||
String dl2Local(Object fileName) {
|
||||
return 'Download [$fileName] to local?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get dockerContainerName => 'Container name';
|
||||
|
||||
@override
|
||||
String get dockerEditHost => 'Edit DOCKER_HOST';
|
||||
|
||||
@override
|
||||
String get dockerEmptyRunningItems => 'No running container. \nIt may be that the env DOCKER_HOST is not read correctly. You can found it by running `echo \$DOCKER_HOST` in terminal.';
|
||||
|
||||
@override
|
||||
String get dockerImage => 'Image';
|
||||
|
||||
@override
|
||||
String dockerImagesFmt(Object count) {
|
||||
return '$count images';
|
||||
}
|
||||
|
||||
@override
|
||||
String get dockerNotInstalled => 'Docker not installed';
|
||||
|
||||
@override
|
||||
String dockerStatusRunningAndStoppedFmt(Object runningCount, Object stoppedCount) {
|
||||
return '$runningCount running, $stoppedCount container stopped.';
|
||||
}
|
||||
|
||||
@override
|
||||
String dockerStatusRunningFmt(Object count) {
|
||||
return '$count container running.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get download => 'Download';
|
||||
|
||||
@override
|
||||
String get downloadFinished => 'Download finished';
|
||||
|
||||
@override
|
||||
String downloadStatus(Object percent, Object size) {
|
||||
return '$percent% of $size';
|
||||
}
|
||||
|
||||
@override
|
||||
String get edit => 'Edit';
|
||||
|
||||
@override
|
||||
String get encode => 'Encode';
|
||||
|
||||
@override
|
||||
String get error => 'Error';
|
||||
|
||||
@override
|
||||
String get exampleName => 'Example name';
|
||||
|
||||
@override
|
||||
String get experimentalFeature => 'Experimental feature';
|
||||
|
||||
@override
|
||||
String get export => 'Export';
|
||||
|
||||
@override
|
||||
String get extraArgs => 'Extra args';
|
||||
|
||||
@override
|
||||
String get failed => 'Failed';
|
||||
|
||||
@override
|
||||
String get feedback => 'Feedback';
|
||||
|
||||
@override
|
||||
String get feedbackOnGithub => 'If you have any questions, please feedback on Github.';
|
||||
|
||||
@override
|
||||
String get fieldMustNotEmpty => 'These fields must not be empty.';
|
||||
|
||||
@override
|
||||
String fileNotExist(Object file) {
|
||||
return '$file not exist';
|
||||
}
|
||||
|
||||
@override
|
||||
String fileTooLarge(Object file, Object size, Object sizeMax) {
|
||||
return 'File \'$file\' too large $size, max $sizeMax';
|
||||
}
|
||||
|
||||
@override
|
||||
String get files => 'Files';
|
||||
|
||||
@override
|
||||
String foundNUpdate(Object count) {
|
||||
return 'Found $count update';
|
||||
}
|
||||
|
||||
@override
|
||||
String get getPushTokenFailed => 'Can\'t fetch push token';
|
||||
|
||||
@override
|
||||
String get gettingToken => 'Getting token...';
|
||||
|
||||
@override
|
||||
String get go => 'Go';
|
||||
|
||||
@override
|
||||
String get goto => 'Go to';
|
||||
|
||||
@override
|
||||
String get host => 'Host';
|
||||
|
||||
@override
|
||||
String httpFailedWithCode(Object code) {
|
||||
return 'request failed, status code: $code';
|
||||
}
|
||||
|
||||
@override
|
||||
String get imagesList => 'Images list';
|
||||
|
||||
@override
|
||||
String get import => 'Import';
|
||||
|
||||
@override
|
||||
String get importAndExport => 'Import and Export';
|
||||
|
||||
@override
|
||||
String get inputDomainHere => 'Input Domain here';
|
||||
|
||||
@override
|
||||
String get install => 'install';
|
||||
|
||||
@override
|
||||
String get installDockerWithUrl => 'Please https://docs.docker.com/engine/install docker first.';
|
||||
|
||||
@override
|
||||
String get invalidJson => 'Invalid JSON';
|
||||
|
||||
@override
|
||||
String get invalidVersion => 'Invalid version';
|
||||
|
||||
@override
|
||||
String invalidVersionHelp(Object url) {
|
||||
return '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.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get isBusy => 'Is busy now';
|
||||
|
||||
@override
|
||||
String get keepForeground => 'Keep app foreground!';
|
||||
|
||||
@override
|
||||
String get keyAuth => 'Key Auth';
|
||||
|
||||
@override
|
||||
String get lastTry => 'Last try!';
|
||||
|
||||
@override
|
||||
String get launchPage => 'Launch page';
|
||||
|
||||
@override
|
||||
String get license => 'License';
|
||||
|
||||
@override
|
||||
String get light => 'Light';
|
||||
|
||||
@override
|
||||
String get loadingFiles => 'Loading files...';
|
||||
|
||||
@override
|
||||
String get loss => 'loss';
|
||||
|
||||
@override
|
||||
String madeWithLove(Object myGithub) {
|
||||
return '\nMade with ❤️ by $myGithub';
|
||||
}
|
||||
|
||||
@override
|
||||
String get max => 'max';
|
||||
|
||||
@override
|
||||
String get maxRetryCount => 'Number of server reconnection';
|
||||
|
||||
@override
|
||||
String get maxRetryCountEqual0 => 'Will retry again and again.';
|
||||
|
||||
@override
|
||||
String get min => 'min';
|
||||
|
||||
@override
|
||||
String get ms => 'ms';
|
||||
|
||||
@override
|
||||
String get name => 'Name';
|
||||
|
||||
@override
|
||||
String get needRestart => 'Need to restart app';
|
||||
|
||||
@override
|
||||
String get newContainer => 'New container';
|
||||
|
||||
@override
|
||||
String get noClient => 'No client';
|
||||
|
||||
@override
|
||||
String get noInterface => 'No interface';
|
||||
|
||||
@override
|
||||
String get noResult => 'No result';
|
||||
|
||||
@override
|
||||
String get noSavedPrivateKey => 'No saved private keys.';
|
||||
|
||||
@override
|
||||
String get noSavedSnippet => 'No saved snippets.';
|
||||
|
||||
@override
|
||||
String get noServerAvailable => 'No server available.';
|
||||
|
||||
@override
|
||||
String get noUpdateAvailable => 'No update available';
|
||||
|
||||
@override
|
||||
String get notSelected => 'Not selected';
|
||||
|
||||
@override
|
||||
String get nullToken => 'Null token';
|
||||
|
||||
@override
|
||||
String get ok => 'OK';
|
||||
|
||||
@override
|
||||
String get onServerDetailPage => 'On server detail page';
|
||||
|
||||
@override
|
||||
String get onlyIOS => 'Only valid on iOS';
|
||||
|
||||
@override
|
||||
String get open => 'Open';
|
||||
|
||||
@override
|
||||
String get path => 'Path';
|
||||
|
||||
@override
|
||||
String get pickFile => 'Pick file';
|
||||
|
||||
@override
|
||||
String get ping => 'Ping';
|
||||
|
||||
@override
|
||||
String get pingAvg => 'Avg:';
|
||||
|
||||
@override
|
||||
String get pingInputIP => 'Please input a target IP/domain.';
|
||||
|
||||
@override
|
||||
String get pingNoServer => 'No server to ping.\nPlease add a server in server tab.';
|
||||
|
||||
@override
|
||||
String get pkg => 'Pkg';
|
||||
|
||||
@override
|
||||
String get platformNotSupportUpdate => 'Current platform does not support in app update.\nPlease build from source and install it.';
|
||||
|
||||
@override
|
||||
String get plzEnterHost => 'Please enter host.';
|
||||
|
||||
@override
|
||||
String get plzSelectKey => 'Please select a key.';
|
||||
|
||||
@override
|
||||
String get port => 'Port';
|
||||
|
||||
@override
|
||||
String get preview => 'Preview';
|
||||
|
||||
@override
|
||||
String get privateKey => 'Private Key';
|
||||
|
||||
@override
|
||||
String get pushToken => 'Push token';
|
||||
|
||||
@override
|
||||
String get pwd => 'Password';
|
||||
|
||||
@override
|
||||
String get rename => 'Rename';
|
||||
|
||||
@override
|
||||
String reportBugsOnGithubIssue(Object url) {
|
||||
return 'Please report bugs on $url';
|
||||
}
|
||||
|
||||
@override
|
||||
String get restart => 'Restart';
|
||||
|
||||
@override
|
||||
String get restore => 'Restore';
|
||||
|
||||
@override
|
||||
String get restoreSuccess => 'Restore success. Restart app to apply.';
|
||||
|
||||
@override
|
||||
String restoreSureWithDate(Object date) {
|
||||
return 'Are you sure to restore from $date ?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get result => 'Result';
|
||||
|
||||
@override
|
||||
String get run => 'Run';
|
||||
|
||||
@override
|
||||
String get save => 'Save';
|
||||
|
||||
@override
|
||||
String get second => 's';
|
||||
|
||||
@override
|
||||
String get server => 'Server';
|
||||
|
||||
@override
|
||||
String get serverTabConnecting => 'Connecting...';
|
||||
|
||||
@override
|
||||
String get serverTabEmpty => 'There is no server.\nClick the fab to add one.';
|
||||
|
||||
@override
|
||||
String get serverTabFailed => 'Failed';
|
||||
|
||||
@override
|
||||
String get serverTabLoading => 'Loading...';
|
||||
|
||||
@override
|
||||
String get serverTabPlzSave => 'Please \'save\' this private key again.';
|
||||
|
||||
@override
|
||||
String get serverTabUnkown => 'Unknown state';
|
||||
|
||||
@override
|
||||
String get setting => 'Setting';
|
||||
|
||||
@override
|
||||
String get sftpDlPrepare => 'Preparing to connect...';
|
||||
|
||||
@override
|
||||
String get sftpNoDownloadTask => 'No download task.';
|
||||
|
||||
@override
|
||||
String get sftpSSHConnected => 'SFTP Connected';
|
||||
|
||||
@override
|
||||
String get showDistLogo => 'Show distribution logo';
|
||||
|
||||
@override
|
||||
String get snippet => 'Snippet';
|
||||
|
||||
@override
|
||||
String spentTime(Object time) {
|
||||
return 'Spent time: $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshTip(Object url) {
|
||||
return 'This function is now in the experimental stage.\n\nPlease report bugs on $url or join our development.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get start => 'Start';
|
||||
|
||||
@override
|
||||
String get stop => 'Stop';
|
||||
|
||||
@override
|
||||
String get success => 'Success';
|
||||
|
||||
@override
|
||||
String sureDelete(Object name) {
|
||||
return 'Are you sure to delete [$name]?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sureNoPwd => 'Are you sure to use no password?';
|
||||
|
||||
@override
|
||||
String sureToDeleteServer(Object server) {
|
||||
return 'Are you sure to delete server [$server]?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get termTheme => 'Terminal theme';
|
||||
|
||||
@override
|
||||
String get themeMode => 'Theme mode';
|
||||
|
||||
@override
|
||||
String get times => 'Times';
|
||||
|
||||
@override
|
||||
String get ttl => 'ttl';
|
||||
|
||||
@override
|
||||
String get unknown => 'unknown';
|
||||
|
||||
@override
|
||||
String get unknownError => 'Unknown error';
|
||||
|
||||
@override
|
||||
String get unkownConvertMode => 'Unknown convert mode';
|
||||
|
||||
@override
|
||||
String get update => 'Update';
|
||||
|
||||
@override
|
||||
String get updateAll => 'Update all';
|
||||
|
||||
@override
|
||||
String get updateIntervalEqual0 => 'You set to 0, will not update automatically.\nCan\'t calculate CPU status.';
|
||||
|
||||
@override
|
||||
String get updateServerStatusInterval => 'Server status update interval';
|
||||
|
||||
@override
|
||||
String updateTip(Object newest) {
|
||||
return 'Update: v1.0.$newest';
|
||||
}
|
||||
|
||||
@override
|
||||
String updateTipTooLow(Object newest) {
|
||||
return 'Current version is too low, please update to v1.0.$newest';
|
||||
}
|
||||
|
||||
@override
|
||||
String get upsideDown => 'Upside Down';
|
||||
|
||||
@override
|
||||
String get urlOrJson => 'URL or JSON';
|
||||
|
||||
@override
|
||||
String get user => 'User';
|
||||
|
||||
@override
|
||||
String versionHaveUpdate(Object build) {
|
||||
return 'Found: v1.0.$build, click to update';
|
||||
}
|
||||
|
||||
@override
|
||||
String versionUnknownUpdate(Object build) {
|
||||
return 'Current: v1.0.$build';
|
||||
}
|
||||
|
||||
@override
|
||||
String versionUpdated(Object build) {
|
||||
return 'Current: v1.0.$build, is up to date';
|
||||
}
|
||||
|
||||
@override
|
||||
String get waitConnection => 'Please wait for the connection to be established.';
|
||||
|
||||
@override
|
||||
String get willTakEeffectImmediately => 'Will take effect immediately';
|
||||
}
|
||||
572
.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart
Normal file
572
.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart
Normal file
@@ -0,0 +1,572 @@
|
||||
import 'l10n.dart';
|
||||
|
||||
/// The translations for Chinese (`zh`).
|
||||
class SZh extends S {
|
||||
SZh([String locale = 'zh']) : super(locale);
|
||||
|
||||
@override
|
||||
String get about => '关于';
|
||||
|
||||
@override
|
||||
String get aboutThanks => '\n感谢以下参与软件测试的各位。';
|
||||
|
||||
@override
|
||||
String get addAServer => '添加服务器';
|
||||
|
||||
@override
|
||||
String get addOne => '前去新增';
|
||||
|
||||
@override
|
||||
String get addPrivateKey => '添加一个私钥';
|
||||
|
||||
@override
|
||||
String get alreadyLastDir => '已经是最上层目录了';
|
||||
|
||||
@override
|
||||
String get appPrimaryColor => 'App主要色';
|
||||
|
||||
@override
|
||||
String get attention => '注意';
|
||||
|
||||
@override
|
||||
String get auto => '自动';
|
||||
|
||||
@override
|
||||
String get backDir => '返回上一级';
|
||||
|
||||
@override
|
||||
String get backup => '备份';
|
||||
|
||||
@override
|
||||
String get backupTip => '导出的数据仅进行了简单加密,请妥善保管。\n除了设置项,恢复的数据不会覆盖现有数据。';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch => '备份版本不匹配,无法恢复';
|
||||
|
||||
@override
|
||||
String get cancel => '取消';
|
||||
|
||||
@override
|
||||
String get choose => '选择';
|
||||
|
||||
@override
|
||||
String get chooseDestination => '选择目标';
|
||||
|
||||
@override
|
||||
String get chooseFontFile => '选择字体文件';
|
||||
|
||||
@override
|
||||
String get choosePrivateKey => '选择私钥';
|
||||
|
||||
@override
|
||||
String get clear => '清除';
|
||||
|
||||
@override
|
||||
String get clickSee => '点击查看';
|
||||
|
||||
@override
|
||||
String get close => '关闭';
|
||||
|
||||
@override
|
||||
String get cmd => '命令';
|
||||
|
||||
@override
|
||||
String get containerStatus => '容器状态';
|
||||
|
||||
@override
|
||||
String get convert => '转换';
|
||||
|
||||
@override
|
||||
String get copy => '复制';
|
||||
|
||||
@override
|
||||
String get copyPath => '复制路径';
|
||||
|
||||
@override
|
||||
String get createFile => '创建文件';
|
||||
|
||||
@override
|
||||
String get createFolder => '创建文件夹';
|
||||
|
||||
@override
|
||||
String get currentMode => '当前模式';
|
||||
|
||||
@override
|
||||
String get dark => '暗';
|
||||
|
||||
@override
|
||||
String get debug => '调试';
|
||||
|
||||
@override
|
||||
String get decode => '解码';
|
||||
|
||||
@override
|
||||
String get delete => '删除';
|
||||
|
||||
@override
|
||||
String get disconnected => '连接断开';
|
||||
|
||||
@override
|
||||
String dl2Local(Object fileName) {
|
||||
return '下载 [$fileName] 到本地?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get dockerContainerName => '容器名';
|
||||
|
||||
@override
|
||||
String get dockerEditHost => '编辑 DOCKER_HOST';
|
||||
|
||||
@override
|
||||
String get dockerEmptyRunningItems => '没有正在运行的容器。\n这可能是因为环境变量 DOCKER_HOST 没有被正确读取。你可以通过在终端内运行 `echo \$DOCKER_HOST` 来获取。';
|
||||
|
||||
@override
|
||||
String get dockerImage => '镜像';
|
||||
|
||||
@override
|
||||
String dockerImagesFmt(Object count) {
|
||||
return '共 $count 个镜像';
|
||||
}
|
||||
|
||||
@override
|
||||
String get dockerNotInstalled => 'Docker未安装';
|
||||
|
||||
@override
|
||||
String dockerStatusRunningAndStoppedFmt(Object runningCount, Object stoppedCount) {
|
||||
return '$runningCount个正在运行, $stoppedCount个已停止';
|
||||
}
|
||||
|
||||
@override
|
||||
String dockerStatusRunningFmt(Object count) {
|
||||
return '$count个容器正在运行';
|
||||
}
|
||||
|
||||
@override
|
||||
String get download => '下载';
|
||||
|
||||
@override
|
||||
String get downloadFinished => '下载完成!';
|
||||
|
||||
@override
|
||||
String downloadStatus(Object percent, Object size) {
|
||||
return '$size 的 $percent%';
|
||||
}
|
||||
|
||||
@override
|
||||
String get edit => '编辑';
|
||||
|
||||
@override
|
||||
String get encode => '编码';
|
||||
|
||||
@override
|
||||
String get error => '出错了';
|
||||
|
||||
@override
|
||||
String get exampleName => '名称示例';
|
||||
|
||||
@override
|
||||
String get experimentalFeature => '实验性功能';
|
||||
|
||||
@override
|
||||
String get export => '导出';
|
||||
|
||||
@override
|
||||
String get extraArgs => '额外参数';
|
||||
|
||||
@override
|
||||
String get failed => '失败';
|
||||
|
||||
@override
|
||||
String get feedback => '反馈';
|
||||
|
||||
@override
|
||||
String get feedbackOnGithub => '如果你有任何问题,请在GitHub反馈';
|
||||
|
||||
@override
|
||||
String get fieldMustNotEmpty => '这些输入框不能为空。';
|
||||
|
||||
@override
|
||||
String fileNotExist(Object file) {
|
||||
return '$file 不存在';
|
||||
}
|
||||
|
||||
@override
|
||||
String fileTooLarge(Object file, Object size, Object sizeMax) {
|
||||
return '文件 \'$file\' 过大 \'$size\',超过了 $sizeMax';
|
||||
}
|
||||
|
||||
@override
|
||||
String get files => '文件';
|
||||
|
||||
@override
|
||||
String foundNUpdate(Object count) {
|
||||
return '找到 $count 个更新';
|
||||
}
|
||||
|
||||
@override
|
||||
String get getPushTokenFailed => '未能获取到推送token';
|
||||
|
||||
@override
|
||||
String get gettingToken => '正在获取Token...';
|
||||
|
||||
@override
|
||||
String get go => '开始';
|
||||
|
||||
@override
|
||||
String get goto => '前往';
|
||||
|
||||
@override
|
||||
String get host => '主机';
|
||||
|
||||
@override
|
||||
String httpFailedWithCode(Object code) {
|
||||
return '请求失败, 状态码: $code';
|
||||
}
|
||||
|
||||
@override
|
||||
String get imagesList => '镜像列表';
|
||||
|
||||
@override
|
||||
String get import => '导入';
|
||||
|
||||
@override
|
||||
String get importAndExport => '导入或导出';
|
||||
|
||||
@override
|
||||
String get inputDomainHere => '在这里输入域名';
|
||||
|
||||
@override
|
||||
String get install => '安装';
|
||||
|
||||
@override
|
||||
String get installDockerWithUrl => '请先 https://docs.docker.com/engine/install docker';
|
||||
|
||||
@override
|
||||
String get invalidJson => '无效的json,存在格式问题';
|
||||
|
||||
@override
|
||||
String get invalidVersion => '不支持的版本';
|
||||
|
||||
@override
|
||||
String invalidVersionHelp(Object url) {
|
||||
return '请确保正确安装了docker,或者使用的非自编译版本。如果没有以上问题,请在 $url 提交问题。';
|
||||
}
|
||||
|
||||
@override
|
||||
String get isBusy => '当前正忙';
|
||||
|
||||
@override
|
||||
String get keepForeground => '请保持应用处于前台!';
|
||||
|
||||
@override
|
||||
String get keyAuth => '公钥认证';
|
||||
|
||||
@override
|
||||
String get lastTry => '最后尝试';
|
||||
|
||||
@override
|
||||
String get launchPage => '启动页';
|
||||
|
||||
@override
|
||||
String get license => '开源证书';
|
||||
|
||||
@override
|
||||
String get light => '亮';
|
||||
|
||||
@override
|
||||
String get loadingFiles => '正在加载目录。。。';
|
||||
|
||||
@override
|
||||
String get loss => '丢包率';
|
||||
|
||||
@override
|
||||
String madeWithLove(Object myGithub) {
|
||||
return '\n用❤️制作 by $myGithub';
|
||||
}
|
||||
|
||||
@override
|
||||
String get max => '最大';
|
||||
|
||||
@override
|
||||
String get maxRetryCount => '服务器尝试重连次数';
|
||||
|
||||
@override
|
||||
String get maxRetryCountEqual0 => '会无限重试';
|
||||
|
||||
@override
|
||||
String get min => '最小';
|
||||
|
||||
@override
|
||||
String get ms => '毫秒';
|
||||
|
||||
@override
|
||||
String get name => '名称';
|
||||
|
||||
@override
|
||||
String get needRestart => '需要重启 App';
|
||||
|
||||
@override
|
||||
String get newContainer => '新建容器';
|
||||
|
||||
@override
|
||||
String get noClient => '没有SSH连接';
|
||||
|
||||
@override
|
||||
String get noInterface => '没有可用的接口';
|
||||
|
||||
@override
|
||||
String get noResult => '无结果';
|
||||
|
||||
@override
|
||||
String get noSavedPrivateKey => '没有已保存的私钥。';
|
||||
|
||||
@override
|
||||
String get noSavedSnippet => '没有已保存的代码片段。';
|
||||
|
||||
@override
|
||||
String get noServerAvailable => '没有可用的服务器。';
|
||||
|
||||
@override
|
||||
String get noUpdateAvailable => '没有可用更新';
|
||||
|
||||
@override
|
||||
String get notSelected => '未选择';
|
||||
|
||||
@override
|
||||
String get nullToken => '无Token';
|
||||
|
||||
@override
|
||||
String get ok => '好';
|
||||
|
||||
@override
|
||||
String get onServerDetailPage => '在服务器详情页';
|
||||
|
||||
@override
|
||||
String get onlyIOS => '仅在iOS上有效';
|
||||
|
||||
@override
|
||||
String get open => '打开';
|
||||
|
||||
@override
|
||||
String get path => '路径';
|
||||
|
||||
@override
|
||||
String get pickFile => '选择文件';
|
||||
|
||||
@override
|
||||
String get ping => 'Ping';
|
||||
|
||||
@override
|
||||
String get pingAvg => '平均:';
|
||||
|
||||
@override
|
||||
String get pingInputIP => '请输入目标IP或域名';
|
||||
|
||||
@override
|
||||
String get pingNoServer => '没有服务器可用于Ping\n请在服务器tab添加服务器后再试';
|
||||
|
||||
@override
|
||||
String get pkg => '包管理';
|
||||
|
||||
@override
|
||||
String get platformNotSupportUpdate => '当前平台不支持更新,请编译最新源码后手动安装';
|
||||
|
||||
@override
|
||||
String get plzEnterHost => '请输入主机';
|
||||
|
||||
@override
|
||||
String get plzSelectKey => '请选择私钥';
|
||||
|
||||
@override
|
||||
String get port => '端口';
|
||||
|
||||
@override
|
||||
String get preview => '预览';
|
||||
|
||||
@override
|
||||
String get privateKey => '私钥';
|
||||
|
||||
@override
|
||||
String get pushToken => '消息推送 Token';
|
||||
|
||||
@override
|
||||
String get pwd => '密码';
|
||||
|
||||
@override
|
||||
String get rename => '重命名';
|
||||
|
||||
@override
|
||||
String reportBugsOnGithubIssue(Object url) {
|
||||
return '请到 $url 提交问题';
|
||||
}
|
||||
|
||||
@override
|
||||
String get restart => '重启';
|
||||
|
||||
@override
|
||||
String get restore => '恢复';
|
||||
|
||||
@override
|
||||
String get restoreSuccess => '恢复成功,需要重启App来应用更改';
|
||||
|
||||
@override
|
||||
String restoreSureWithDate(Object date) {
|
||||
return '确定恢复 $date 的备份吗?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get result => '结果';
|
||||
|
||||
@override
|
||||
String get run => '运行';
|
||||
|
||||
@override
|
||||
String get save => '保存';
|
||||
|
||||
@override
|
||||
String get second => '秒';
|
||||
|
||||
@override
|
||||
String get server => '服务器';
|
||||
|
||||
@override
|
||||
String get serverTabConnecting => '连接中...';
|
||||
|
||||
@override
|
||||
String get serverTabEmpty => '现在没有服务器。\n点击右下方按钮来添加。';
|
||||
|
||||
@override
|
||||
String get serverTabFailed => '失败';
|
||||
|
||||
@override
|
||||
String get serverTabLoading => '加载中...';
|
||||
|
||||
@override
|
||||
String get serverTabPlzSave => '请再次保存该私钥';
|
||||
|
||||
@override
|
||||
String get serverTabUnkown => '未知状态';
|
||||
|
||||
@override
|
||||
String get setting => '设置';
|
||||
|
||||
@override
|
||||
String get sftpDlPrepare => '准备连接至服务器...';
|
||||
|
||||
@override
|
||||
String get sftpNoDownloadTask => '没有下载任务';
|
||||
|
||||
@override
|
||||
String get sftpSSHConnected => 'SFTP 已连接,即将开始下载...';
|
||||
|
||||
@override
|
||||
String get showDistLogo => '显示发行版 Logo';
|
||||
|
||||
@override
|
||||
String get snippet => '代码片段';
|
||||
|
||||
@override
|
||||
String spentTime(Object time) {
|
||||
return '耗时: $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshTip(Object url) {
|
||||
return '该功能目前处于测试阶段。\n\n请在 $url 反馈问题,或者加入我们开发。';
|
||||
}
|
||||
|
||||
@override
|
||||
String get start => '开始';
|
||||
|
||||
@override
|
||||
String get stop => '停止';
|
||||
|
||||
@override
|
||||
String get success => '成功';
|
||||
|
||||
@override
|
||||
String sureDelete(Object name) {
|
||||
return '确定删除[$name]?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sureNoPwd => '确认使用无密码?';
|
||||
|
||||
@override
|
||||
String sureToDeleteServer(Object server) {
|
||||
return '你确定要删除服务器 [$server] 吗?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get termTheme => '终端主题';
|
||||
|
||||
@override
|
||||
String get themeMode => '主题模式';
|
||||
|
||||
@override
|
||||
String get times => '次';
|
||||
|
||||
@override
|
||||
String get ttl => '缓存时间';
|
||||
|
||||
@override
|
||||
String get unknown => '未知';
|
||||
|
||||
@override
|
||||
String get unknownError => '未知错误';
|
||||
|
||||
@override
|
||||
String get unkownConvertMode => '未知转换模式';
|
||||
|
||||
@override
|
||||
String get update => '更新';
|
||||
|
||||
@override
|
||||
String get updateAll => '更新全部';
|
||||
|
||||
@override
|
||||
String get updateIntervalEqual0 => '你设置为0,服务器状态不会自动刷新。\n且不能计算CPU使用情况。';
|
||||
|
||||
@override
|
||||
String get updateServerStatusInterval => '服务器状态刷新间隔';
|
||||
|
||||
@override
|
||||
String updateTip(Object newest) {
|
||||
return '新版本: v1.0.$newest';
|
||||
}
|
||||
|
||||
@override
|
||||
String updateTipTooLow(Object newest) {
|
||||
return '当前版本过低,请升级至 v1.0.$newest';
|
||||
}
|
||||
|
||||
@override
|
||||
String get upsideDown => '上下交换';
|
||||
|
||||
@override
|
||||
String get urlOrJson => '链接或JSON';
|
||||
|
||||
@override
|
||||
String get user => '用户';
|
||||
|
||||
@override
|
||||
String versionHaveUpdate(Object build) {
|
||||
return '找到新版本:v1.0.$build, 点击更新';
|
||||
}
|
||||
|
||||
@override
|
||||
String versionUnknownUpdate(Object build) {
|
||||
return '当前:v1.0.$build';
|
||||
}
|
||||
|
||||
@override
|
||||
String versionUpdated(Object build) {
|
||||
return '当前:v1.0.$build, 已是最新版本';
|
||||
}
|
||||
|
||||
@override
|
||||
String get waitConnection => '请等待连接建立';
|
||||
|
||||
@override
|
||||
String get willTakEeffectImmediately => '更改将会立即生效';
|
||||
}
|
||||
3
.dart_tool/flutter_gen/pubspec.yaml
Normal file
3
.dart_tool/flutter_gen/pubspec.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
# Generated by the flutter tool
|
||||
name: synthetic_package
|
||||
description: The Flutter application's synthetic package.
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"flutterSdkVersion": "3.3.4",
|
||||
"flavors": {}
|
||||
}
|
||||
20
.github/workflows/issue-translator.yml
vendored
Normal file
20
.github/workflows/issue-translator.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: 'issue-translator'
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: usthe/issues-translate-action@v2.7
|
||||
with:
|
||||
# not require, default false.
|
||||
# Decide whether to modify the issue title.
|
||||
# if true, the robot account @Issues-translate-bot must have modification permissions, invite @Issues-translate-bot to your project or use your custom bot.
|
||||
IS_MODIFY_TITLE: false
|
||||
# not require.
|
||||
# Customize the translation robot prefix message.
|
||||
CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -23,7 +23,7 @@
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
**/ios/Flutter/.last_build_id
|
||||
.dart_tool/
|
||||
# .dart_tool/
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
.packages
|
||||
@@ -48,4 +48,8 @@ app.*.map.json
|
||||
/android/app/fjy.androidstudio.key
|
||||
/release
|
||||
test.dart
|
||||
.fvm/flutter_sdk
|
||||
.fvm
|
||||
|
||||
# Keep generated l10n files
|
||||
/.dart_tool/*
|
||||
!/.dart_tool/flutter_gen
|
||||
24
.metadata
24
.metadata
@@ -1,10 +1,30 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
# This file should be version controlled.
|
||||
|
||||
version:
|
||||
revision: 4cc385b4b84ac2f816d939a49ea1f328c4e0b48e
|
||||
revision: 9944297138845a94256f1cf37beb88ff9a8e811a
|
||||
channel: stable
|
||||
|
||||
project_type: app
|
||||
|
||||
# Tracks metadata for the flutter migrate command
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
|
||||
base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
|
||||
- platform: macos
|
||||
create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
|
||||
base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
|
||||
|
||||
# User provided section
|
||||
|
||||
# List of Local paths (relative to this file) that should be
|
||||
# ignored by the migrate tool.
|
||||
#
|
||||
# Files that are not part of the templates will be ignored by default.
|
||||
unmanaged_files:
|
||||
- 'lib/main.dart'
|
||||
- 'ios/Runner.xcodeproj/project.pbxproj'
|
||||
|
||||
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"dart.flutterSdkPath": ".fvm/flutter_sdk",
|
||||
"search.exclude": {
|
||||
"dart.flutterSdkPath": ".fvm",
|
||||
"files.watcherExclude": {
|
||||
"**/.fvm": true
|
||||
},
|
||||
"files.watcherExclude": {
|
||||
"git.ignoredRepositories": [
|
||||
".fvm"
|
||||
],
|
||||
"search.exclude": {
|
||||
"**/.fvm": true
|
||||
}
|
||||
}
|
||||
674
LICENCE
Normal file
674
LICENCE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
69
README.md
69
README.md
@@ -1,3 +1,4 @@
|
||||
English | [简体中文](README_zh.md)
|
||||
<!-- Title-->
|
||||
<p align="center">
|
||||
<h1 align="center">Server Box</h1>
|
||||
@@ -8,56 +9,92 @@
|
||||
<a href="https://apps.apple.com/app/id1586449703">
|
||||
<img style="height: 37px" src="screenshots/appstore.svg">
|
||||
</a>
|
||||
<a href="https://github.com/LollipopKit/flutter_server_box/releases/latest">
|
||||
<a href="https://github.com/lollipopkit/flutter_server_box/releases/latest">
|
||||
<img style="height: 37px" src="screenshots/dl-android.svg">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
A Flutter project which provide charts to display server status and tools to manage server. Especially thanks to <a href="https://github.com/TerminalStudio/dartssh2">dartssh2</a>.
|
||||
<a href="https://count.ly/f/badge" rel="nofollow">
|
||||
<img style="height: 37px" src="https://count.ly/badges/light.svg">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
A Flutter project which provide charts to display server status and tools to manage server.
|
||||
<br>
|
||||
Especially thanks to <a href="https://github.com/TerminalStudio/dartssh2">dartssh2</a> & <a href="https://github.com/TerminalStudio/xterm.dart">xterm.dart</a>.
|
||||
</p>
|
||||
|
||||
|
||||
## 🔖 Milestone
|
||||
- [x] Status chart view
|
||||
- [x] Snippet ~~market~~, Ping, SFTP, Docker, Apt/Yum and etc.
|
||||
## 🔖 Feature
|
||||
- [x] Functions
|
||||
- [x] `SSH` Terminal, `SFTP`
|
||||
- [x] `Docker & Pkg` Manager
|
||||
- [x] Status charts
|
||||
- [x] `Ping` and etc.
|
||||
- [x] i18n (English, Chinese)
|
||||
- **Welcome contribution** :)
|
||||
- [How to contribute?](#l10n-guide)
|
||||
- [x] Desktop support
|
||||
|
||||
|
||||
## 📩 Push
|
||||
You need to install [ServerBoxMonitor](https://github.com/lollipopkit/server_box_monitor) on your servers.
|
||||
And config iOS / Webhook to push server status to your portable device without using ServerBox app.
|
||||
|
||||
|
||||
## 📱 ScreenShots
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img width="200px" src="https://raw.githubusercontent.com/LollipopKit/flutter_server_monitor_toolbox/main/screenshots/server.jpg">
|
||||
<img width="200px" src="screenshots/server.jpg">
|
||||
</td>
|
||||
<td>
|
||||
<img width="200px" src="https://raw.githubusercontent.com/LollipopKit/flutter_server_monitor_toolbox/main/screenshots/server_detail.png">
|
||||
<img width="200px" src="screenshots/detail.jpg">
|
||||
</td>
|
||||
<td>
|
||||
<img width="200px" src="https://raw.githubusercontent.com/LollipopKit/flutter_server_monitor_toolbox/main/screenshots/convert.png">
|
||||
<img width="200px" src="screenshots/ssh.jpg">
|
||||
</td>
|
||||
<td>
|
||||
<img width="200px" src="screenshots/apt.png">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img width="200px" src="https://raw.githubusercontent.com/LollipopKit/flutter_server_monitor_toolbox/main/screenshots/ping.png">
|
||||
<img width="200px" src="screenshots/ping.png">
|
||||
</td>
|
||||
<td>
|
||||
<img width="200px" src="https://raw.githubusercontent.com/LollipopKit/flutter_server_monitor_toolbox/main/screenshots/apt.png">
|
||||
<img width="200px" src="screenshots/sftp.jpg">
|
||||
</td>
|
||||
<td>
|
||||
<img width="200px" src="https://raw.githubusercontent.com/LollipopKit/flutter_server_monitor_toolbox/main/screenshots/docker.png">
|
||||
<img width="200px" src="screenshots/docker.jpg">
|
||||
</td>
|
||||
<td>
|
||||
<img width="200px" src="screenshots/convert.png">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
## 🖥 Platform
|
||||
Status|Platform
|
||||
--|--|
|
||||
Full Support|Android/iOS/macOS
|
||||
Support, but not tested|Windows/Linux
|
||||
Status|Platform
|
||||
--- | ---
|
||||
Full Support|Android/iOS
|
||||
Support, but not tested|macOS/Windows/Linux
|
||||
|
||||
|
||||
## l10n guide
|
||||
1. Fork this repo and clone it to your local machine.
|
||||
2. Create `arb` file in `lib/l10n/` directory
|
||||
- File name should be `intl_XX.arb`, where `XX` is the language code. Such as `intl_en.arb` for English and `intl_zh.arb` for Chinese.
|
||||
3. Add content to the file. You can refer to `intl_en.arb` and `intl_zh.arb` for the format.
|
||||
4. Run `flutter gen-l10n` to generate files.
|
||||
5. Pull commit to your forked repo.
|
||||
6. Request a pull request on my repo.
|
||||
|
||||
|
||||
## 📝 License
|
||||
`LGPL License. LollipopKit 2021`
|
||||
`GPL v3. lollipopkit 2023`
|
||||
|
||||
99
README_zh.md
Normal file
99
README_zh.md
Normal file
@@ -0,0 +1,99 @@
|
||||
简体中文 | [English](README.md)
|
||||
<!-- Title-->
|
||||
<p align="center">
|
||||
<h1 align="center">Server Box</h1>
|
||||
</p>
|
||||
|
||||
<!-- Badges-->
|
||||
<p align="center">
|
||||
<a href="https://apps.apple.com/app/id1586449703">
|
||||
<img style="height: 37px" src="screenshots/appstore.svg">
|
||||
</a>
|
||||
<a href="https://github.com/lollipopkit/flutter_server_box/releases/latest">
|
||||
<img style="height: 37px" src="screenshots/dl-android.svg">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://count.ly/f/badge" rel="nofollow">
|
||||
<img style="height: 37px" src="https://count.ly/badges/light.svg">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
使用Flutter开发的服务器工具箱,提供服务器状态图表和管理工具。
|
||||
<br>
|
||||
特别感谢 <a href="https://github.com/TerminalStudio/dartssh2">dartssh2</a> & <a href="https://github.com/TerminalStudio/xterm.dart">xterm.dart</a>.
|
||||
</p>
|
||||
|
||||
|
||||
## 🔖 特点
|
||||
- [x] 功能
|
||||
- [x] `SSH` 终端, `SFTP`
|
||||
- [x] `Docker & 包` 管理器
|
||||
- [x] 状态图表
|
||||
- [x] `Ping` 和 更多
|
||||
- [x] 本地化 (英语, 中文)
|
||||
- **欢迎贡献** :)
|
||||
- [怎么贡献?](#l10n)
|
||||
- [x] 桌面端支持
|
||||
|
||||
|
||||
## 📩 推送
|
||||
你需要在你的服务器上安装 [ServerBoxMonitor](https://github.com/lollipopkit/server_box_monitor)。
|
||||
并且配置 iOS / Webhook 推送服务,这样,你可以在不使用 ServerBox app 时获取服务器状态。
|
||||
|
||||
## 📱 截屏
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img width="200px" src="screenshots/server.jpg">
|
||||
</td>
|
||||
<td>
|
||||
<img width="200px" src="screenshots/detail.jpg">
|
||||
</td>
|
||||
<td>
|
||||
<img width="200px" src="screenshots/ssh.jpg">
|
||||
</td>
|
||||
<td>
|
||||
<img width="200px" src="screenshots/apt.png">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img width="200px" src="screenshots/ping.png">
|
||||
</td>
|
||||
<td>
|
||||
<img width="200px" src="screenshots/sftp.jpg">
|
||||
</td>
|
||||
<td>
|
||||
<img width="200px" src="screenshots/docker.jpg">
|
||||
</td>
|
||||
<td>
|
||||
<img width="200px" src="screenshots/convert.png">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
## 🖥 平台
|
||||
状态|平台
|
||||
--- | ---
|
||||
完整支持|Android/iOS
|
||||
可能支持,未测试|macOS/Windows/Linux
|
||||
|
||||
|
||||
## l10n
|
||||
1. Fork本项目,并Clone你Fork的项目至你的电脑
|
||||
2. 在 `lib/l10n/` 文件夹内创建 `.arb` 本地化文件
|
||||
- 文件名应该类似 `intl_XX.arb`, `XX` 是语言标识码。 例如 `intl_en.arb` 是给英语的, `intl_zh.arb` 是给中文的
|
||||
3. 向 `.arb` 本地化文件添加内容。 你可以查看 `intl_en.arb` 和 `intl_zh.arb` 的内容,并理解其含义,来创建新的本地化文件
|
||||
4. 运行 `flutter gen-l10n` 来生成所需文件
|
||||
5. Commit 变更到你的 Fork 的 Repo
|
||||
6. 在我的项目中发起 Pull Request.
|
||||
|
||||
|
||||
## 📝 License
|
||||
`GPL v3. lollipopkit 2023`
|
||||
@@ -32,7 +32,7 @@ apply plugin: 'kotlin-android'
|
||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
|
||||
android {
|
||||
compileSdkVersion 31
|
||||
compileSdkVersion 33
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -48,7 +48,6 @@ android {
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId "tech.lolli.toolbox"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
@@ -67,12 +66,18 @@ android {
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig signingConfigs.release
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
debug {
|
||||
applicationIdSuffix '.debug'
|
||||
}
|
||||
|
||||
profile {
|
||||
applicationIdSuffix '.debug'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
BIN
assets/linux/rocky.png
Normal file
BIN
assets/linux/rocky.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
@@ -27,6 +27,10 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe
|
||||
|
||||
flutter_ios_podfile_setup
|
||||
|
||||
# Used for flutter lib "file_picker"
|
||||
Pod::PICKER_MEDIA = false
|
||||
Pod::PICKER_AUDIO = false
|
||||
|
||||
target 'Runner' do
|
||||
use_frameworks!
|
||||
use_modular_headers!
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
PODS:
|
||||
- countly_flutter (21.11.0):
|
||||
- countly_flutter (22.09.0):
|
||||
- Flutter
|
||||
- file_picker (0.0.1):
|
||||
- Flutter
|
||||
- Flutter (1.0.0)
|
||||
- flutter_native_splash (0.0.1):
|
||||
- Flutter
|
||||
- path_provider_ios (0.0.1):
|
||||
- path_provider_foundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- plain_notification_token (0.0.1):
|
||||
- Flutter
|
||||
- r_upgrade (0.0.1):
|
||||
- Flutter
|
||||
@@ -15,9 +20,11 @@ PODS:
|
||||
|
||||
DEPENDENCIES:
|
||||
- countly_flutter (from `.symlinks/plugins/countly_flutter/ios`)
|
||||
- file_picker (from `.symlinks/plugins/file_picker/ios`)
|
||||
- Flutter (from `Flutter`)
|
||||
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
|
||||
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
|
||||
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
|
||||
- plain_notification_token (from `.symlinks/plugins/plain_notification_token/ios`)
|
||||
- r_upgrade (from `.symlinks/plugins/r_upgrade/ios`)
|
||||
- share_plus (from `.symlinks/plugins/share_plus/ios`)
|
||||
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
||||
@@ -25,12 +32,16 @@ DEPENDENCIES:
|
||||
EXTERNAL SOURCES:
|
||||
countly_flutter:
|
||||
:path: ".symlinks/plugins/countly_flutter/ios"
|
||||
file_picker:
|
||||
:path: ".symlinks/plugins/file_picker/ios"
|
||||
Flutter:
|
||||
:path: Flutter
|
||||
flutter_native_splash:
|
||||
:path: ".symlinks/plugins/flutter_native_splash/ios"
|
||||
path_provider_ios:
|
||||
:path: ".symlinks/plugins/path_provider_ios/ios"
|
||||
path_provider_foundation:
|
||||
:path: ".symlinks/plugins/path_provider_foundation/ios"
|
||||
plain_notification_token:
|
||||
:path: ".symlinks/plugins/plain_notification_token/ios"
|
||||
r_upgrade:
|
||||
:path: ".symlinks/plugins/r_upgrade/ios"
|
||||
share_plus:
|
||||
@@ -39,14 +50,16 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/url_launcher_ios/ios"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
countly_flutter: e245f94349d8adf306c22e60c10648c69aae7380
|
||||
countly_flutter: 135f1a4930f8e26ba223a14201d3f265ea7b4c83
|
||||
file_picker: 1d63c4949e05e386da864365f8c13e1e64787675
|
||||
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
|
||||
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
|
||||
path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02
|
||||
path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9
|
||||
plain_notification_token: b36467dc91939a7b6754267c701bbaca14996ee1
|
||||
r_upgrade: 44d715c61914cce3d01ea225abffe894fd51c114
|
||||
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
|
||||
url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de
|
||||
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
|
||||
|
||||
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
|
||||
PODFILE CHECKSUM: 7fb15c416f8685fca4966867a8da218ec592ec2e
|
||||
|
||||
COCOAPODS: 1.11.3
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 51;
|
||||
objectVersion = 54;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
@@ -47,6 +47,7 @@
|
||||
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
9C5314B89F1F73A1900CCAFD /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
|
||||
A775F241DEE026555178AC01 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
E398BF6A29BDB34500FE4FD5 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -104,6 +105,7 @@
|
||||
97C146F01CF9000F007C117D /* Runner */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E398BF6A29BDB34500FE4FD5 /* Runner.entitlements */,
|
||||
97C146FA1CF9000F007C117D /* Main.storyboard */,
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */,
|
||||
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
|
||||
@@ -199,6 +201,7 @@
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
@@ -213,6 +216,7 @@
|
||||
};
|
||||
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
@@ -354,7 +358,8 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 159;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 243;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
@@ -362,7 +367,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.159;
|
||||
MARKETING_VERSION = 1.0.243;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -484,7 +489,8 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 159;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 243;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
@@ -492,7 +498,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.159;
|
||||
MARKETING_VERSION = 1.0.243;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -508,7 +514,8 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 159;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 243;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
@@ -516,7 +523,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.159;
|
||||
MARKETING_VERSION = 1.0.243;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
|
||||
@@ -1,52 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>ServerBox</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<false/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>CFBundleLocalizations</key>
|
||||
<array>
|
||||
<string>en</string>
|
||||
<string>zh</string>
|
||||
</array>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<dict>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleLocalizations</key>
|
||||
<array>
|
||||
<string>en</string>
|
||||
<string>zh</string>
|
||||
</array>
|
||||
<key>CFBundleName</key>
|
||||
<string>ServerBox</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||
<true/>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>fetch</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<false/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
8
ios/Runner/Runner.entitlements
Normal file
8
ios/Runner/Runner.entitlements
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>production</string>
|
||||
</dict>
|
||||
</plist>
|
||||
File diff suppressed because one or more lines are too long
4
l10n.yaml
Normal file
4
l10n.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
arb-dir: lib/l10n
|
||||
template-arb-file: app_en.arb
|
||||
output-localization-file: l10n.dart
|
||||
output-class: S
|
||||
164
lib/app.dart
164
lib/app.dart
@@ -1,89 +1,97 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
import 'package:toolbox/data/res/build_data.dart';
|
||||
import 'package:toolbox/data/store/setting.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
import 'package:toolbox/view/page/home.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/utils/misc.dart';
|
||||
|
||||
import '/core/extension/colorx.dart';
|
||||
import 'core/utils/ui.dart';
|
||||
import 'data/res/build_data.dart';
|
||||
import 'data/res/color.dart';
|
||||
import 'data/store/setting.dart';
|
||||
import 'locator.dart';
|
||||
import 'view/page/home.dart';
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
MyApp({Key? key}) : super(key: key);
|
||||
|
||||
MaterialStateProperty<Color?> getMaterialStateColor(Color primaryColor) {
|
||||
return MaterialStateProperty.resolveWith((states) {
|
||||
const Set<MaterialState> interactiveStates = <MaterialState>{
|
||||
MaterialState.pressed,
|
||||
MaterialState.hovered,
|
||||
MaterialState.focused,
|
||||
MaterialState.selected
|
||||
};
|
||||
if (states.any(interactiveStates.contains)) {
|
||||
return primaryColor;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
final _setting = locator<SettingStore>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
setTransparentNavigationBar(context);
|
||||
final fontName = getFileName(_setting.fontPath.fetch());
|
||||
primaryColor = Color(_setting.primaryColor.fetch()!);
|
||||
|
||||
final textStyle = TextStyle(color: primaryColor);
|
||||
final materialColor = primaryColor.materialStateColor;
|
||||
final materialColorAlpha = primaryColor.withOpacity(0.7).materialStateColor;
|
||||
final fabTheme =
|
||||
FloatingActionButtonThemeData(backgroundColor: primaryColor);
|
||||
final switchTheme = SwitchThemeData(
|
||||
thumbColor: materialColor,
|
||||
trackColor: materialColorAlpha,
|
||||
);
|
||||
final appBarTheme = AppBarTheme(backgroundColor: primaryColor);
|
||||
final iconTheme = IconThemeData(color: primaryColor);
|
||||
final inputDecorationTheme = InputDecorationTheme(
|
||||
labelStyle: textStyle,
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: primaryColor),
|
||||
),
|
||||
);
|
||||
final radioTheme = RadioThemeData(
|
||||
fillColor: materialColor,
|
||||
);
|
||||
final primarySwatch = primaryColor.materialColor;
|
||||
|
||||
return ValueListenableBuilder<int>(
|
||||
valueListenable: locator<SettingStore>().primaryColor.listenable(),
|
||||
builder: (_, value, __) {
|
||||
final primaryColor = Color(value);
|
||||
final textStyle = TextStyle(color: primaryColor);
|
||||
return MaterialApp(
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
title: BuildData.name,
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: ThemeData(
|
||||
primaryColor: primaryColor,
|
||||
appBarTheme: AppBarTheme(backgroundColor: primaryColor),
|
||||
floatingActionButtonTheme:
|
||||
FloatingActionButtonThemeData(backgroundColor: primaryColor),
|
||||
iconTheme: IconThemeData(color: primaryColor),
|
||||
primaryIconTheme: IconThemeData(color: primaryColor),
|
||||
switchTheme: SwitchThemeData(
|
||||
thumbColor: getMaterialStateColor(primaryColor),
|
||||
trackColor:
|
||||
getMaterialStateColor(primaryColor.withOpacity(0.7)),
|
||||
),
|
||||
buttonTheme: ButtonThemeData(splashColor: primaryColor),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
labelStyle: textStyle,
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: primaryColor))),
|
||||
radioTheme: RadioThemeData(
|
||||
fillColor: getMaterialStateColor(primaryColor),
|
||||
),
|
||||
),
|
||||
darkTheme: ThemeData.dark().copyWith(
|
||||
primaryColor: primaryColor,
|
||||
floatingActionButtonTheme: FloatingActionButtonThemeData(
|
||||
backgroundColor: primaryColor),
|
||||
iconTheme: IconThemeData(color: primaryColor),
|
||||
primaryIconTheme: IconThemeData(color: primaryColor),
|
||||
switchTheme: SwitchThemeData(
|
||||
thumbColor: getMaterialStateColor(primaryColor),
|
||||
trackColor:
|
||||
getMaterialStateColor(primaryColor.withOpacity(0.7)),
|
||||
),
|
||||
buttonTheme: ButtonThemeData(splashColor: primaryColor),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
labelStyle: textStyle,
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: primaryColor))),
|
||||
radioTheme: RadioThemeData(
|
||||
fillColor: getMaterialStateColor(primaryColor))),
|
||||
home: MyHomePage(primaryColor: primaryColor),
|
||||
);
|
||||
});
|
||||
valueListenable: _setting.themeMode.listenable(),
|
||||
builder: (_, tMode, __) {
|
||||
final ok = tMode >= 0 && tMode <= ThemeMode.values.length - 1;
|
||||
final themeMode = ok ? ThemeMode.values[tMode] : ThemeMode.system;
|
||||
|
||||
final theme = ThemeData(
|
||||
useMaterial3: false,
|
||||
fontFamily: fontName,
|
||||
primaryColor: primaryColor,
|
||||
primarySwatch: primarySwatch,
|
||||
appBarTheme: appBarTheme,
|
||||
floatingActionButtonTheme: fabTheme,
|
||||
iconTheme: iconTheme,
|
||||
primaryIconTheme: iconTheme,
|
||||
switchTheme: switchTheme,
|
||||
inputDecorationTheme: inputDecorationTheme,
|
||||
radioTheme: radioTheme,
|
||||
);
|
||||
final darkTheme = ThemeData(
|
||||
useMaterial3: false,
|
||||
fontFamily: fontName,
|
||||
primaryColor: primaryColor,
|
||||
primarySwatch: primarySwatch,
|
||||
floatingActionButtonTheme: fabTheme,
|
||||
iconTheme: iconTheme,
|
||||
primaryIconTheme: iconTheme,
|
||||
switchTheme: switchTheme,
|
||||
inputDecorationTheme: inputDecorationTheme,
|
||||
radioTheme: radioTheme,
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: ColorScheme.fromSwatch(
|
||||
primarySwatch: primaryColor.materialColor,
|
||||
brightness: Brightness.dark,
|
||||
accentColor: primaryColor,
|
||||
),
|
||||
);
|
||||
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
localizationsDelegates: S.localizationsDelegates,
|
||||
supportedLocales: S.supportedLocales,
|
||||
title: BuildData.name,
|
||||
themeMode: themeMode,
|
||||
theme: theme,
|
||||
darkTheme: darkTheme,
|
||||
home: const MyHomePage(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,18 +4,24 @@ import 'dart:io';
|
||||
import 'package:countly_flutter/countly_config.dart';
|
||||
import 'package:countly_flutter/countly_flutter.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:toolbox/core/build_mode.dart';
|
||||
|
||||
import 'utils/platform.dart';
|
||||
|
||||
class Analysis {
|
||||
static const _url = 'https://countly.xuty.cc';
|
||||
static const _key = '80372a2a66424b32d0ac8991bfa1ef058bd36b1f';
|
||||
|
||||
static bool _enabled = false;
|
||||
static bool enabled = false;
|
||||
|
||||
static Future<void> init(bool debug) async {
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
_enabled = true;
|
||||
static Future<void> init() async {
|
||||
if (!BuildMode.isRelease) {
|
||||
return;
|
||||
}
|
||||
if (isAndroid || isIOS) {
|
||||
enabled = true;
|
||||
final config = CountlyConfig(_url, _key)
|
||||
.setLoggingEnabled(debug)
|
||||
.setLoggingEnabled(false)
|
||||
.enableCrashReporting();
|
||||
await Countly.initWithConfig(config);
|
||||
await Countly.start();
|
||||
@@ -27,13 +33,13 @@ class Analysis {
|
||||
}
|
||||
|
||||
static void recordView(String view) {
|
||||
if (_enabled) {
|
||||
if (enabled) {
|
||||
Countly.recordView(view);
|
||||
}
|
||||
}
|
||||
|
||||
static void recordException(Object exception, [bool fatal = false]) {
|
||||
if (_enabled) {
|
||||
if (enabled) {
|
||||
Countly.logException(exception.toString(), !fatal, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
const Set<MaterialState> interactiveStates = <MaterialState>{
|
||||
MaterialState.pressed,
|
||||
MaterialState.hovered,
|
||||
MaterialState.focused,
|
||||
MaterialState.selected
|
||||
};
|
||||
|
||||
extension ColorX on Color {
|
||||
bool get isBrightColor {
|
||||
return getBrightnessFromColor == Brightness.light;
|
||||
@@ -8,4 +15,26 @@ extension ColorX on Color {
|
||||
Brightness get getBrightnessFromColor {
|
||||
return ThemeData.estimateBrightnessForColor(this);
|
||||
}
|
||||
|
||||
MaterialStateProperty<Color?> get materialStateColor {
|
||||
return MaterialStateProperty.resolveWith((states) {
|
||||
if (states.any(interactiveStates.contains)) {
|
||||
return this;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
MaterialColor get materialColor => MaterialColor(value, {
|
||||
50: withOpacity(0.05),
|
||||
100: withOpacity(0.1),
|
||||
200: withOpacity(0.2),
|
||||
300: withOpacity(0.3),
|
||||
400: withOpacity(0.4),
|
||||
500: withOpacity(0.5),
|
||||
600: withOpacity(0.6),
|
||||
700: withOpacity(0.7),
|
||||
800: withOpacity(0.8),
|
||||
900: withOpacity(0.9),
|
||||
});
|
||||
}
|
||||
|
||||
49
lib/core/extension/ssh_client.dart
Normal file
49
lib/core/extension/ssh_client.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:toolbox/core/extension/uint8list.dart';
|
||||
|
||||
typedef OnStd = void Function(String data, StreamSink<Uint8List> sink);
|
||||
typedef OnStdin = void Function(StreamSink<Uint8List> sink);
|
||||
|
||||
typedef PwdRequestFunc = Future<String> Function();
|
||||
final pwdRequestWithUserReg = RegExp(r'\[sudo\] password for (.+):');
|
||||
|
||||
extension SSHClientX on SSHClient {
|
||||
Future<int?> exec(String cmd,
|
||||
{OnStd? onStderr, OnStd? onStdout, OnStdin? stdin}) async {
|
||||
final session = await execute(cmd);
|
||||
|
||||
final stdoutDone = Completer<void>();
|
||||
final stderrDone = Completer<void>();
|
||||
|
||||
if (onStdout != null) {
|
||||
session.stdout.listen(
|
||||
(e) => onStdout(e.string, session.stdin),
|
||||
onDone: stdoutDone.complete,
|
||||
);
|
||||
} else {
|
||||
stdoutDone.complete();
|
||||
}
|
||||
|
||||
if (onStderr != null) {
|
||||
session.stderr.listen(
|
||||
(e) => onStderr(e.string, session.stdin),
|
||||
onDone: stderrDone.complete,
|
||||
);
|
||||
} else {
|
||||
stderrDone.complete();
|
||||
}
|
||||
|
||||
if (stdin != null) {
|
||||
stdin(session.stdin);
|
||||
}
|
||||
|
||||
await stdoutDone.future;
|
||||
await stderrDone.future;
|
||||
|
||||
session.close();
|
||||
return session.exitCode;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,11 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/data/model/distribution.dart';
|
||||
|
||||
extension StringX on String {
|
||||
int get i => int.parse(this);
|
||||
|
||||
Distribution get dist {
|
||||
final lower = toLowerCase();
|
||||
for (var dist in debianDistList) {
|
||||
if (lower.contains(dist)) {
|
||||
return Distribution.debian;
|
||||
}
|
||||
}
|
||||
for (var dist in rehlDistList) {
|
||||
if (lower.contains(dist)) {
|
||||
return Distribution.rehl;
|
||||
}
|
||||
}
|
||||
return Distribution.unknown;
|
||||
}
|
||||
|
||||
Uri get uri {
|
||||
return Uri.parse(this);
|
||||
}
|
||||
@@ -32,7 +19,7 @@ extension StringX on String {
|
||||
// Build the textspan
|
||||
var span = TextSpan(
|
||||
text: 'A' * 7 + substring(length - len),
|
||||
style: style ?? Theme.of(context).textTheme.bodyText2,
|
||||
style: style ?? Theme.of(context).textTheme.bodyMedium,
|
||||
);
|
||||
|
||||
// Use a textpainter to determine if it will exceed max lines
|
||||
@@ -60,4 +47,6 @@ extension StringX on String {
|
||||
}
|
||||
|
||||
String get withLangExport => 'export LANG=en_US.UTF-8 && $this';
|
||||
|
||||
Uint8List get uint8List => Uint8List.fromList(utf8.encode(this));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:typed_data';
|
||||
|
||||
extension FutureUint8ListX on Future<Uint8List> {
|
||||
Future<String> get string async => utf8.decode(await this);
|
||||
Future<ByteData> get byteData async => (await this).buffer.asByteData();
|
||||
}
|
||||
|
||||
extension Uint8ListX on Uint8List {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:r_upgrade/r_upgrade.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
import 'package:toolbox/data/provider/app.dart';
|
||||
import 'package:toolbox/data/res/build_data.dart';
|
||||
import 'package:toolbox/data/service/app.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
|
||||
import '../data/model/app/update.dart';
|
||||
import '../data/provider/app.dart';
|
||||
import '../data/res/build_data.dart';
|
||||
import '../data/service/app.dart';
|
||||
import '../locator.dart';
|
||||
import 'utils/platform.dart';
|
||||
import 'utils/ui.dart';
|
||||
|
||||
final _logger = Logger('UPDATE');
|
||||
|
||||
@@ -29,11 +30,11 @@ Future<void> doUpdate(BuildContext context, {bool force = false}) async {
|
||||
locator<AppProvider>().setNewestBuild(update.newest);
|
||||
|
||||
final newest = () {
|
||||
if (Platform.isAndroid) {
|
||||
if (isAndroid) {
|
||||
return update.androidbuild;
|
||||
} else if (Platform.isIOS) {
|
||||
} else if (isIOS) {
|
||||
return update.iosbuild;
|
||||
} else if (Platform.isMacOS) {
|
||||
} else if (isMacOS) {
|
||||
return update.macbuild;
|
||||
}
|
||||
return update.newest;
|
||||
@@ -46,30 +47,51 @@ Future<void> doUpdate(BuildContext context, {bool force = false}) async {
|
||||
}
|
||||
_logger.info('Update available: $newest');
|
||||
|
||||
if (Platform.isAndroid && !await isFileAvailable(update.android)) {
|
||||
if (isAndroid && !await isFileAvailable(update.android)) {
|
||||
_logger.warning('Android update file not available');
|
||||
return;
|
||||
}
|
||||
|
||||
final s = S.of(context);
|
||||
final s = S.of(context)!;
|
||||
|
||||
if (update.min > BuildData.build) {
|
||||
showRoundDialog(
|
||||
context,
|
||||
s.attention,
|
||||
Text(s.updateTipTooLow(newest)),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => _doUpdate(update, context, s),
|
||||
child: Text(s.ok),
|
||||
)
|
||||
],
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
showSnackBarWithAction(
|
||||
context,
|
||||
update.min > BuildData.build
|
||||
? 'Your version is too old. \nPlease update to v1.0.$newest.'
|
||||
: 'Update: v1.0.$newest available. \n${update.changelog}',
|
||||
s.update, () async {
|
||||
if (Platform.isAndroid) {
|
||||
await RUpgrade.upgrade(update.android,
|
||||
fileName: update.android.split('/').last, isAutoRequestInstall: true);
|
||||
} else if (Platform.isIOS) {
|
||||
await RUpgrade.upgradeFromAppStore('1586449703');
|
||||
} else if (Platform.isMacOS) {
|
||||
await RUpgrade.upgradeFromUrl(update.mac);
|
||||
} else {
|
||||
showRoundDialog(context, s.attention, Text(s.platformNotSupportUpdate), [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(), child: Text(s.ok))
|
||||
]);
|
||||
}
|
||||
});
|
||||
context,
|
||||
'${s.updateTip(newest)} \n${update.changelog}',
|
||||
s.update,
|
||||
() => _doUpdate(update, context, s),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _doUpdate(AppUpdate update, BuildContext context, S s) async {
|
||||
if (isAndroid) {
|
||||
await RUpgrade.upgrade(
|
||||
update.android,
|
||||
fileName: update.android.split('/').last,
|
||||
isAutoRequestInstall: true,
|
||||
);
|
||||
} else if (isIOS) {
|
||||
await RUpgrade.upgradeFromAppStore('1586449703');
|
||||
} else {
|
||||
showRoundDialog(context, s.attention, Text(s.platformNotSupportUpdate), [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(s.ok),
|
||||
)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
61
lib/core/utils/misc.dart
Normal file
61
lib/core/utils/misc.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:plain_notification_token/plain_notification_token.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../view/widget/rebuild.dart';
|
||||
import 'platform.dart';
|
||||
|
||||
Future<bool> shareFiles(BuildContext context, List<String> filePaths) async {
|
||||
for (final filePath in filePaths) {
|
||||
if (!await File(filePath).exists()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var text = '';
|
||||
if (filePaths.length == 1) {
|
||||
text = filePaths.first.split('/').last;
|
||||
} else {
|
||||
text = '${filePaths.length} ${S.of(context)!.files}';
|
||||
}
|
||||
final xfiles = filePaths.map((e) => XFile(e)).toList();
|
||||
await Share.shareXFiles(xfiles, text: 'ServerBox -> $text');
|
||||
return filePaths.isNotEmpty;
|
||||
}
|
||||
|
||||
void copy(String text) {
|
||||
Clipboard.setData(ClipboardData(text: text));
|
||||
}
|
||||
|
||||
Future<String?> pickOneFile() async {
|
||||
final result = await FilePicker.platform.pickFiles(type: FileType.any);
|
||||
return result?.files.single.path;
|
||||
}
|
||||
|
||||
Future<String?> getToken() async {
|
||||
if (isIOS) {
|
||||
final plainNotificationToken = PlainNotificationToken();
|
||||
plainNotificationToken.requestPermission();
|
||||
|
||||
// If you want to wait until Permission dialog close,
|
||||
// you need wait changing setting registered.
|
||||
await plainNotificationToken.onIosSettingsRegistered.first;
|
||||
return await plainNotificationToken.getToken();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String? getFileName(String? path) {
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
return path.split('/').last;
|
||||
}
|
||||
|
||||
void rebuildAll(BuildContext context) {
|
||||
RebuildWidget.restartApp(context);
|
||||
}
|
||||
43
lib/core/utils/platform.dart
Normal file
43
lib/core/utils/platform.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
enum PlatformType {
|
||||
android,
|
||||
ios,
|
||||
linux,
|
||||
macos,
|
||||
windows,
|
||||
web,
|
||||
}
|
||||
|
||||
final _p = () {
|
||||
if (kIsWeb) {
|
||||
return PlatformType.web;
|
||||
}
|
||||
if (Platform.isAndroid) {
|
||||
return PlatformType.android;
|
||||
}
|
||||
if (Platform.isIOS) {
|
||||
return PlatformType.ios;
|
||||
}
|
||||
if (Platform.isLinux) {
|
||||
return PlatformType.linux;
|
||||
}
|
||||
if (Platform.isMacOS) {
|
||||
return PlatformType.macos;
|
||||
}
|
||||
if (Platform.isWindows) {
|
||||
return PlatformType.windows;
|
||||
}
|
||||
return PlatformType.web;
|
||||
}();
|
||||
|
||||
PlatformType get platform => _p;
|
||||
|
||||
bool get isAndroid => _p == PlatformType.android;
|
||||
bool get isIOS => _p == PlatformType.ios;
|
||||
bool get isLinux => _p == PlatformType.linux;
|
||||
bool get isMacOS => _p == PlatformType.macos;
|
||||
bool get isWindows => _p == PlatformType.windows;
|
||||
bool get isWeb => _p == PlatformType.web;
|
||||
57
lib/core/utils/server.dart
Normal file
57
lib/core/utils/server.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../data/model/server/server_private_info.dart';
|
||||
import '../../data/store/private_key.dart';
|
||||
import '../../locator.dart';
|
||||
|
||||
/// Must put this func out of any Class.
|
||||
///
|
||||
/// Because of this function is called by [compute] in [ServerProvider.genClient].
|
||||
///
|
||||
/// https://stackoverflow.com/questions/51998995/invalid-arguments-illegal-argument-in-isolate-message-object-is-a-closure
|
||||
List<SSHKeyPair> loadIndentity(String key) {
|
||||
return SSHKeyPair.fromPem(key);
|
||||
}
|
||||
|
||||
/// [args] : [key, pwd]
|
||||
String decyptPem(List<String> args) {
|
||||
/// skip when the key is not encrypted, or will throw exception
|
||||
if (!SSHKeyPair.isEncryptedPem(args[0])) return args[0];
|
||||
final sshKey = SSHKeyPair.fromPem(args[0], args[1]);
|
||||
return sshKey.first.toPem();
|
||||
}
|
||||
|
||||
enum GenSSHClientStatus {
|
||||
socket,
|
||||
key,
|
||||
pwd,
|
||||
}
|
||||
|
||||
Future<SSHClient> genClient(ServerPrivateInfo spi,
|
||||
{void Function(GenSSHClientStatus)? onStatus}) async {
|
||||
final onStatus_ = onStatus ?? (_) {};
|
||||
onStatus_(GenSSHClientStatus.socket);
|
||||
final socket = await SSHSocket.connect(
|
||||
spi.ip,
|
||||
spi.port,
|
||||
timeout: const Duration(seconds: 5),
|
||||
);
|
||||
if (spi.pubKeyId == null) {
|
||||
onStatus_(GenSSHClientStatus.pwd);
|
||||
return SSHClient(
|
||||
socket,
|
||||
username: spi.user,
|
||||
onPasswordRequest: () => spi.pwd,
|
||||
);
|
||||
}
|
||||
final key = locator<PrivateKeyStore>().get(spi.pubKeyId!);
|
||||
onStatus_(GenSSHClientStatus.key);
|
||||
return SSHClient(
|
||||
socket,
|
||||
username: spi.user,
|
||||
identities: await compute(loadIndentity, key.privateKey),
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,16 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:toolbox/core/persistant_store.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:toolbox/view/widget/card_dialog.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/utils/misc.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
|
||||
import '../../view/widget/card_dialog.dart';
|
||||
import '../persistant_store.dart';
|
||||
import 'platform.dart';
|
||||
import '../extension/stringx.dart';
|
||||
import '../extension/uint8list.dart';
|
||||
|
||||
bool isDarkMode(BuildContext context) =>
|
||||
Theme.of(context).brightness == Brightness.dark;
|
||||
@@ -28,15 +30,7 @@ void showSnackBarWithAction(BuildContext context, String content, String action,
|
||||
}
|
||||
|
||||
Future<bool> openUrl(String url) async {
|
||||
final uri = url.uri;
|
||||
if (!await canLaunchUrl(uri)) {
|
||||
return false;
|
||||
}
|
||||
final ok = await launchUrl(uri);
|
||||
if (ok == true) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return await launchUrl(url.uri, mode: LaunchMode.externalApplication);
|
||||
}
|
||||
|
||||
Future<T?>? showRoundDialog<T>(
|
||||
@@ -71,7 +65,7 @@ Widget buildSwitch(BuildContext context, StoreProperty<bool> prop,
|
||||
}
|
||||
|
||||
void setTransparentNavigationBar(BuildContext context) {
|
||||
if (Platform.isAndroid) {
|
||||
if (isAndroid) {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||
systemNavigationBarColor: Colors.transparent,
|
||||
@@ -79,36 +73,6 @@ void setTransparentNavigationBar(BuildContext context) {
|
||||
}
|
||||
}
|
||||
|
||||
String tabTitleName(BuildContext context, int i) {
|
||||
final s = S.of(context);
|
||||
switch (i) {
|
||||
case 0:
|
||||
return s.server;
|
||||
case 1:
|
||||
return s.convert;
|
||||
case 2:
|
||||
return s.ping;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> shareFiles(BuildContext context, List<String> filePaths) async {
|
||||
for (final filePath in filePaths) {
|
||||
if (!await File(filePath).exists()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var text = '';
|
||||
if (filePaths.length == 1) {
|
||||
text = filePaths.first.split('/').last;
|
||||
} else {
|
||||
text = '${filePaths.length} ${S.of(context).files}';
|
||||
}
|
||||
await Share.shareFiles(filePaths, text: 'ServerBox -> $text');
|
||||
return filePaths.isNotEmpty;
|
||||
}
|
||||
|
||||
Widget buildPopuopMenu(
|
||||
{required List<PopupMenuEntry> items,
|
||||
required Function(dynamic) onSelected}) {
|
||||
@@ -126,3 +90,25 @@ Widget buildPopuopMenu(
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String tabTitleName(BuildContext context, int i) {
|
||||
final s = S.of(context)!;
|
||||
switch (i) {
|
||||
case 0:
|
||||
return s.server;
|
||||
case 1:
|
||||
return s.convert;
|
||||
case 2:
|
||||
return s.ping;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadFontFile(String? localPath) async {
|
||||
if (localPath == null) return;
|
||||
final name = getFileName(localPath)!;
|
||||
var fontLoader = FontLoader(name);
|
||||
fontLoader.addFont(File(localPath).readAsBytes().byteData);
|
||||
await fontLoader.load();
|
||||
}
|
||||
15
lib/data/model/app/dynamic_color.dart
Normal file
15
lib/data/model/app/dynamic_color.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../core/utils/ui.dart';
|
||||
|
||||
class DynamicColor {
|
||||
/// 白天模式显示的颜色
|
||||
Color light;
|
||||
|
||||
/// 暗黑模式显示的颜色
|
||||
Color dark;
|
||||
|
||||
DynamicColor(this.light, this.dark);
|
||||
|
||||
Color resolve(BuildContext context) => isDarkMode(context) ? dark : light;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import 'package:toolbox/data/model/distribution.dart';
|
||||
|
||||
class UpgradePkgInfo {
|
||||
final String _raw;
|
||||
final Distribution _dist;
|
||||
|
||||
late String package;
|
||||
late String nowVersion;
|
||||
late String newVersion;
|
||||
late String arch;
|
||||
|
||||
UpgradePkgInfo(this._raw, this._dist) {
|
||||
switch (_dist) {
|
||||
case Distribution.debian:
|
||||
case Distribution.unknown:
|
||||
_parseApt();
|
||||
break;
|
||||
case Distribution.rehl:
|
||||
_parseYum();
|
||||
}
|
||||
}
|
||||
|
||||
void _parseApt() {
|
||||
final split1 = _raw.split("/");
|
||||
package = split1[0];
|
||||
final split2 = split1[1].split(" ");
|
||||
newVersion = split2[1];
|
||||
arch = split2[2];
|
||||
nowVersion = split2[5].replaceFirst(']', '');
|
||||
}
|
||||
|
||||
void _parseYum() {
|
||||
final result = RegExp(r'\S+').allMatches(_raw);
|
||||
final pkgAndArch = result.elementAt(0).group(0) ?? '.';
|
||||
final split1 = pkgAndArch.split('.');
|
||||
package = split1[0];
|
||||
arch = split1[1];
|
||||
newVersion = result.elementAt(1).group(0) ?? 'Unknown';
|
||||
nowVersion = '';
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
enum Distribution {
|
||||
unknown,
|
||||
debian,
|
||||
rehl,
|
||||
}
|
||||
|
||||
const debianDistList = [
|
||||
'debian',
|
||||
'ubuntu',
|
||||
'linuxmint',
|
||||
'elementary',
|
||||
'raspbian',
|
||||
'armbian'
|
||||
];
|
||||
|
||||
const rehlDistList = [
|
||||
'redhat',
|
||||
'fedora',
|
||||
'centos',
|
||||
'scientificlinux',
|
||||
'rhel',
|
||||
'oraclelinux'
|
||||
];
|
||||
47
lib/data/model/docker/image.dart
Normal file
47
lib/data/model/docker/image.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
final _dockerImageReg = RegExp(r'(\S+) +(\S+) +(\S+) +(.+) +(\S+)');
|
||||
|
||||
class DockerImage {
|
||||
final String repo;
|
||||
final String tag;
|
||||
final String id;
|
||||
final String created;
|
||||
final String size;
|
||||
|
||||
static final Map<String, DockerImage> _cache = <String, DockerImage>{};
|
||||
|
||||
DockerImage({
|
||||
required this.repo,
|
||||
required this.tag,
|
||||
required this.id,
|
||||
required this.created,
|
||||
required this.size,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'repo': repo,
|
||||
'tag': tag,
|
||||
'id': id,
|
||||
'created': created,
|
||||
'size': size,
|
||||
};
|
||||
}
|
||||
|
||||
factory DockerImage.fromRawStr(String raw) {
|
||||
return _cache.putIfAbsent(raw, () => _parse(raw));
|
||||
}
|
||||
|
||||
static DockerImage _parse(String raw) {
|
||||
final match = _dockerImageReg.firstMatch(raw);
|
||||
if (match == null) {
|
||||
throw Exception('Invalid docker image: $raw');
|
||||
}
|
||||
return DockerImage(
|
||||
repo: match.group(1)!,
|
||||
tag: match.group(2)!,
|
||||
id: match.group(3)!,
|
||||
created: match.group(4)!,
|
||||
size: match.group(5)!,
|
||||
);
|
||||
}
|
||||
}
|
||||
1
lib/data/model/pkg/manager.dart
Normal file
1
lib/data/model/pkg/manager.dart
Normal file
@@ -0,0 +1 @@
|
||||
enum PkgManager { apt, yum, zypper, pacman, opkg }
|
||||
75
lib/data/model/pkg/upgrade_info.dart
Normal file
75
lib/data/model/pkg/upgrade_info.dart
Normal file
@@ -0,0 +1,75 @@
|
||||
import 'package:toolbox/data/model/pkg/manager.dart';
|
||||
|
||||
class UpgradePkgInfo {
|
||||
final PkgManager? _mgr;
|
||||
|
||||
late String package;
|
||||
late String nowVersion;
|
||||
late String newVersion;
|
||||
late String arch;
|
||||
|
||||
UpgradePkgInfo(String raw, this._mgr) {
|
||||
switch (_mgr) {
|
||||
case PkgManager.apt:
|
||||
_parseApt(raw);
|
||||
break;
|
||||
case PkgManager.yum:
|
||||
_parseYum(raw);
|
||||
break;
|
||||
case PkgManager.zypper:
|
||||
_parseZypper(raw);
|
||||
break;
|
||||
case PkgManager.pacman:
|
||||
_parsePacman(raw);
|
||||
break;
|
||||
case PkgManager.opkg:
|
||||
_parseOpkg(raw);
|
||||
break;
|
||||
default:
|
||||
throw Exception('Unsupported pkg type: $_mgr');
|
||||
}
|
||||
}
|
||||
|
||||
void _parseApt(String raw) {
|
||||
final split1 = raw.split("/");
|
||||
package = split1[0];
|
||||
final split2 = split1[1].split(" ");
|
||||
newVersion = split2[1];
|
||||
arch = split2[2];
|
||||
nowVersion = split2[5].replaceFirst(']', '');
|
||||
}
|
||||
|
||||
void _parseYum(String raw) {
|
||||
final result = RegExp(r'\S+').allMatches(raw);
|
||||
final pkgAndArch = result.elementAt(0).group(0) ?? '.';
|
||||
final split1 = pkgAndArch.split('.');
|
||||
package = split1[0];
|
||||
arch = split1[1];
|
||||
newVersion = result.elementAt(1).group(0) ?? 'Unknown';
|
||||
nowVersion = '';
|
||||
}
|
||||
|
||||
void _parseZypper(String raw) {
|
||||
final cols = raw.split("|");
|
||||
package = cols[2].trim();
|
||||
nowVersion = cols[3].trim();
|
||||
newVersion = cols[4].trim();
|
||||
arch = cols[5].trim();
|
||||
}
|
||||
|
||||
void _parsePacman(String raw) {
|
||||
final parts = raw.split(' ');
|
||||
package = parts[0];
|
||||
nowVersion = parts[1];
|
||||
newVersion = parts[3];
|
||||
arch = '';
|
||||
}
|
||||
|
||||
void _parseOpkg(String raw) {
|
||||
final parts = raw.split(' - ');
|
||||
package = parts[0];
|
||||
nowVersion = parts[1];
|
||||
newVersion = parts[2];
|
||||
arch = '';
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
import 'package:toolbox/data/model/server/cpu_status.dart';
|
||||
|
||||
class Cpu2Status {
|
||||
List<CpuStatus> _pre;
|
||||
List<CpuStatus> _now;
|
||||
String temp;
|
||||
Cpu2Status(this._pre, this._now, this.temp);
|
||||
|
||||
double usedPercent({int coreIdx = 0}) {
|
||||
if (_now.length != _pre.length) return 0;
|
||||
final idleDelta = _now[coreIdx].idle - _pre[coreIdx].idle;
|
||||
final totalDelta = _now[coreIdx].total - _pre[coreIdx].total;
|
||||
final used = idleDelta / totalDelta;
|
||||
return used.isNaN ? 0 : 100 - used * 100;
|
||||
}
|
||||
|
||||
void update(List<CpuStatus> newStatus, String newTemp) {
|
||||
_pre = _now;
|
||||
_now = newStatus;
|
||||
temp = newTemp;
|
||||
}
|
||||
|
||||
int get coresCount => _now.length;
|
||||
|
||||
int get totalDelta => _now[0].total - _pre[0].total;
|
||||
|
||||
double get user {
|
||||
if (_now.length != _pre.length) return 0;
|
||||
final delta = _now[0].user - _pre[0].user;
|
||||
final used = delta / totalDelta;
|
||||
return used.isNaN ? 0 : used * 100;
|
||||
}
|
||||
|
||||
double get sys {
|
||||
if (_now.length != _pre.length) return 0;
|
||||
final delta = _now[0].sys - _pre[0].sys;
|
||||
final used = delta / totalDelta;
|
||||
return used.isNaN ? 0 : used * 100;
|
||||
}
|
||||
|
||||
double get nice {
|
||||
if (_now.length != _pre.length) return 0;
|
||||
final delta = _now[0].nice - _pre[0].nice;
|
||||
final used = delta / totalDelta;
|
||||
return used.isNaN ? 0 : used * 100;
|
||||
}
|
||||
|
||||
double get iowait {
|
||||
if (_now.length != _pre.length) return 0;
|
||||
final delta = _now[0].iowait - _pre[0].iowait;
|
||||
final used = delta / totalDelta;
|
||||
return used.isNaN ? 0 : used * 100;
|
||||
}
|
||||
|
||||
double get idle => 100 - usedPercent();
|
||||
}
|
||||
@@ -1,7 +1,62 @@
|
||||
class CpuStatus {
|
||||
List<OneTimeCpuStatus> _pre;
|
||||
List<OneTimeCpuStatus> _now;
|
||||
String temp;
|
||||
CpuStatus(this._pre, this._now, this.temp);
|
||||
|
||||
double usedPercent({int coreIdx = 0}) {
|
||||
if (_now.length != _pre.length) return 0;
|
||||
final idleDelta = _now[coreIdx].idle - _pre[coreIdx].idle;
|
||||
final totalDelta = _now[coreIdx].total - _pre[coreIdx].total;
|
||||
final used = idleDelta / totalDelta;
|
||||
return used.isNaN ? 0 : 100 - used * 100;
|
||||
}
|
||||
|
||||
void update(List<OneTimeCpuStatus> newStatus, String newTemp) {
|
||||
_pre = _now;
|
||||
_now = newStatus;
|
||||
temp = newTemp;
|
||||
}
|
||||
|
||||
int get coresCount => _now.length;
|
||||
|
||||
int get totalDelta => _now[0].total - _pre[0].total;
|
||||
|
||||
double get user {
|
||||
if (_now.length != _pre.length) return 0;
|
||||
final delta = _now[0].user - _pre[0].user;
|
||||
final used = delta / totalDelta;
|
||||
return used.isNaN ? 0 : used * 100;
|
||||
}
|
||||
|
||||
double get sys {
|
||||
if (_now.length != _pre.length) return 0;
|
||||
final delta = _now[0].sys - _pre[0].sys;
|
||||
final used = delta / totalDelta;
|
||||
return used.isNaN ? 0 : used * 100;
|
||||
}
|
||||
|
||||
double get nice {
|
||||
if (_now.length != _pre.length) return 0;
|
||||
final delta = _now[0].nice - _pre[0].nice;
|
||||
final used = delta / totalDelta;
|
||||
return used.isNaN ? 0 : used * 100;
|
||||
}
|
||||
|
||||
double get iowait {
|
||||
if (_now.length != _pre.length) return 0;
|
||||
final delta = _now[0].iowait - _pre[0].iowait;
|
||||
final used = delta / totalDelta;
|
||||
return used.isNaN ? 0 : used * 100;
|
||||
}
|
||||
|
||||
double get idle => 100 - usedPercent();
|
||||
}
|
||||
|
||||
///
|
||||
/// Code generated by jsonToDartModel https://ashamp.github.io/jsonToDartModel/
|
||||
///
|
||||
class CpuStatus {
|
||||
class OneTimeCpuStatus {
|
||||
/*
|
||||
{
|
||||
"user": 0,
|
||||
@@ -23,7 +78,7 @@ class CpuStatus {
|
||||
late int irq;
|
||||
late int softirq;
|
||||
|
||||
CpuStatus(
|
||||
OneTimeCpuStatus(
|
||||
this.id,
|
||||
this.user,
|
||||
this.sys,
|
||||
@@ -36,3 +91,51 @@ class CpuStatus {
|
||||
|
||||
int get total => user + sys + nice + idle + iowait + irq + softirq;
|
||||
}
|
||||
|
||||
List<OneTimeCpuStatus> parseCPU(String raw) {
|
||||
final List<OneTimeCpuStatus> cpus = [];
|
||||
|
||||
for (var item in raw.split('\n')) {
|
||||
if (item == '') break;
|
||||
final id = item.split(' ').first;
|
||||
final matches = item.replaceFirst(id, '').trim().split(' ');
|
||||
cpus.add(OneTimeCpuStatus(
|
||||
id,
|
||||
int.parse(matches[0]),
|
||||
int.parse(matches[1]),
|
||||
int.parse(matches[2]),
|
||||
int.parse(matches[3]),
|
||||
int.parse(matches[4]),
|
||||
int.parse(matches[5]),
|
||||
int.parse(matches[6])));
|
||||
}
|
||||
return cpus;
|
||||
}
|
||||
|
||||
final cpuTempReg = RegExp(r'(x86_pkg_temp|cpu_thermal)');
|
||||
|
||||
String parseCPUTemp(List<String> segments) {
|
||||
const noMatch = "/sys/class/thermal/thermal_zone*/type";
|
||||
final type = segments[0];
|
||||
final value = segments[1];
|
||||
// Not support to get CPU temperature
|
||||
if (value.contains(noMatch) ||
|
||||
type.contains(noMatch) ||
|
||||
value.isEmpty ||
|
||||
type.isEmpty) {
|
||||
return '';
|
||||
}
|
||||
final split = type.split('\n');
|
||||
int idx = 0;
|
||||
for (var item in split) {
|
||||
if (item.contains(cpuTempReg)) {
|
||||
break;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
final valueSplited = value.split('\n');
|
||||
if (idx >= valueSplited.length) return '';
|
||||
final temp = int.tryParse(valueSplited[idx].trim());
|
||||
if (temp == null) return '';
|
||||
return '${(temp / 1000).toStringAsFixed(1)}°C';
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import '../../res/misc.dart';
|
||||
|
||||
class DiskInfo {
|
||||
/*
|
||||
{
|
||||
@@ -10,19 +12,40 @@ class DiskInfo {
|
||||
}
|
||||
*/
|
||||
|
||||
late String mountPath;
|
||||
late String mountLocation;
|
||||
late String path;
|
||||
late String loc;
|
||||
late int usedPercent;
|
||||
late String used;
|
||||
late String size;
|
||||
late String avail;
|
||||
|
||||
DiskInfo(
|
||||
this.mountPath,
|
||||
this.mountLocation,
|
||||
this.path,
|
||||
this.loc,
|
||||
this.usedPercent,
|
||||
this.used,
|
||||
this.size,
|
||||
this.avail,
|
||||
);
|
||||
}
|
||||
|
||||
List<DiskInfo> parseDisk(String raw) {
|
||||
final list = <DiskInfo>[];
|
||||
final items = raw.split('\n');
|
||||
items.removeAt(0);
|
||||
for (var item in items) {
|
||||
if (item.isEmpty) {
|
||||
continue;
|
||||
}
|
||||
final vals = item.split(numReg);
|
||||
list.add(DiskInfo(
|
||||
vals[0],
|
||||
vals[5],
|
||||
int.parse(vals[4].replaceFirst('%', '')),
|
||||
vals[2],
|
||||
vals[1],
|
||||
vals[3],
|
||||
));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
28
lib/data/model/server/dist.dart
Normal file
28
lib/data/model/server/dist.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
enum Dist {
|
||||
debian,
|
||||
ubuntu,
|
||||
centos,
|
||||
fedora,
|
||||
opensuse,
|
||||
kali,
|
||||
wrt,
|
||||
armbian,
|
||||
arch,
|
||||
rocky;
|
||||
|
||||
String? get iconPath {
|
||||
return 'assets/linux/$name.png';
|
||||
}
|
||||
}
|
||||
|
||||
extension StringX on String {
|
||||
Dist? get dist {
|
||||
final lower = toLowerCase();
|
||||
for (final dist in Dist.values) {
|
||||
if (lower.contains(dist.name)) {
|
||||
return dist;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -11,3 +11,70 @@ class Memory {
|
||||
required this.cache,
|
||||
required this.avail});
|
||||
}
|
||||
|
||||
final memItemReg = RegExp(r'([A-Z].+:)\s+([0-9]+) kB');
|
||||
|
||||
Memory parseMem(String raw) {
|
||||
final items = raw.split('\n').map((e) => memItemReg.firstMatch(e)).toList();
|
||||
|
||||
final total = int.parse(
|
||||
items.firstWhere((e) => e?.group(1) == 'MemTotal:')?.group(2) ?? '1',
|
||||
);
|
||||
final free = int.parse(
|
||||
items.firstWhere((e) => e?.group(1) == 'MemFree:')?.group(2) ?? '0',
|
||||
);
|
||||
final cached = int.parse(
|
||||
items.firstWhere((e) => e?.group(1) == 'Cached:')?.group(2) ?? '0',
|
||||
);
|
||||
final available = int.parse(
|
||||
items.firstWhere((e) => e?.group(1) == 'MemAvailable:')?.group(2) ?? '0',
|
||||
);
|
||||
|
||||
return Memory(
|
||||
total: total,
|
||||
used: total - available,
|
||||
free: free,
|
||||
cache: cached,
|
||||
avail: available,
|
||||
);
|
||||
}
|
||||
|
||||
class Swap {
|
||||
final int total;
|
||||
final int used;
|
||||
final int free;
|
||||
final int cached;
|
||||
|
||||
Swap({
|
||||
required this.total,
|
||||
required this.used,
|
||||
required this.free,
|
||||
required this.cached,
|
||||
});
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Swap{total: $total, used: $used, free: $free, cached: $cached}';
|
||||
}
|
||||
}
|
||||
|
||||
Swap parseSwap(String raw) {
|
||||
final items = raw.split('\n').map((e) => memItemReg.firstMatch(e)).toList();
|
||||
|
||||
final total = int.parse(
|
||||
items.firstWhere((e) => e?.group(1) == 'SwapTotal:')?.group(2) ?? '1',
|
||||
);
|
||||
final free = int.parse(
|
||||
items.firstWhere((e) => e?.group(1) == 'SwapFree:')?.group(2) ?? '0',
|
||||
);
|
||||
final cached = int.parse(
|
||||
items.firstWhere((e) => e?.group(1) == 'SwapCached:')?.group(2) ?? '0',
|
||||
);
|
||||
|
||||
return Swap(
|
||||
total: total,
|
||||
used: total - free,
|
||||
free: free,
|
||||
cached: cached,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ import 'package:toolbox/core/extension/numx.dart';
|
||||
|
||||
class NetSpeedPart {
|
||||
String device;
|
||||
int bytesIn;
|
||||
int bytesOut;
|
||||
int time;
|
||||
BigInt bytesIn;
|
||||
BigInt bytesOut;
|
||||
BigInt time;
|
||||
NetSpeedPart(this.device, this.bytesIn, this.bytesOut, this.time);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class NetSpeed {
|
||||
_now = newOne;
|
||||
}
|
||||
|
||||
int get timeDiff => _now[0].time - _old[0].time;
|
||||
BigInt get timeDiff => _now[0].time - _old[0].time;
|
||||
|
||||
String speedIn({String? device}) {
|
||||
if (_old[0].device == '' || _now[0].device == '') return '0kb/s';
|
||||
@@ -36,6 +36,13 @@ class NetSpeed {
|
||||
return buildStandardOutput(speedInBytesPerSecond);
|
||||
}
|
||||
|
||||
String totalIn({String? device}) {
|
||||
if (_old[0].device == '' || _now[0].device == '') return '0kb';
|
||||
final idx = deviceIdx(device);
|
||||
final totalInBytes = _now[idx].bytesIn;
|
||||
return totalInBytes.toInt().convertBytes;
|
||||
}
|
||||
|
||||
String speedOut({String? device}) {
|
||||
if (_old[0].device == '' || _now[0].device == '') return '0kb/s';
|
||||
final idx = deviceIdx(device);
|
||||
@@ -44,6 +51,13 @@ class NetSpeed {
|
||||
return buildStandardOutput(speedOutBytesPerSecond);
|
||||
}
|
||||
|
||||
String totalOut({String? device}) {
|
||||
if (_old[0].device == '' || _now[0].device == '') return '0kb';
|
||||
final idx = deviceIdx(device);
|
||||
final totalOutBytes = _now[idx].bytesOut;
|
||||
return totalOutBytes.toInt().convertBytes;
|
||||
}
|
||||
|
||||
int deviceIdx(String? device) {
|
||||
if (device != null) {
|
||||
for (var item in _now) {
|
||||
@@ -55,6 +69,31 @@ class NetSpeed {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String buildStandardOutput(double speed) =>
|
||||
'${speed.convertBytes.toLowerCase()}/s';
|
||||
String buildStandardOutput(double speed) => '${speed.convertBytes}/s';
|
||||
}
|
||||
|
||||
/// [raw] example:
|
||||
/// Inter-| Receive | Transmit
|
||||
/// face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
|
||||
/// lo: 45929941 269112 0 0 0 0 0 0 45929941 269112 0 0 0 0 0 0
|
||||
/// eth0: 48481023 505772 0 0 0 0 0 0 36002262 202307 0 0 0 0 0 0
|
||||
/// 1635752901
|
||||
List<NetSpeedPart> parseNetSpeed(String raw) {
|
||||
final split = raw.split('\n');
|
||||
if (split.length < 4) {
|
||||
return [];
|
||||
}
|
||||
|
||||
final time = BigInt.parse(split[split.length - 1]);
|
||||
final results = <NetSpeedPart>[];
|
||||
for (final item in split.sublist(2, split.length - 1)) {
|
||||
final data = item.trim().split(':');
|
||||
final device = data.first;
|
||||
final bytes = data.last.trim().split(' ');
|
||||
bytes.removeWhere((element) => element == '');
|
||||
final bytesIn = BigInt.parse(bytes.first);
|
||||
final bytesOut = BigInt.parse(bytes[8]);
|
||||
results.add(NetSpeedPart(device, bytesIn, bytesOut, time));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -2,13 +2,21 @@ import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:toolbox/data/model/server/server_private_info.dart';
|
||||
import 'package:toolbox/data/model/server/server_status.dart';
|
||||
|
||||
class ServerInfo {
|
||||
ServerPrivateInfo info;
|
||||
class Server {
|
||||
ServerPrivateInfo spi;
|
||||
ServerStatus status;
|
||||
SSHClient? client;
|
||||
ServerConnectionState connectionState;
|
||||
ServerState cs;
|
||||
|
||||
ServerInfo(this.info, this.status, this.client, this.connectionState);
|
||||
Server(this.spi, this.status, this.client, this.cs);
|
||||
}
|
||||
|
||||
enum ServerConnectionState { disconnected, connecting, connected, failed }
|
||||
enum ServerState {
|
||||
disconnected,
|
||||
connecting,
|
||||
connected,
|
||||
failed;
|
||||
|
||||
bool get shouldConnect =>
|
||||
this == ServerState.disconnected || this == ServerState.failed;
|
||||
}
|
||||
|
||||
@@ -31,15 +31,17 @@ class ServerPrivateInfo {
|
||||
@HiveField(5)
|
||||
String? pubKeyId;
|
||||
|
||||
String get id => '$user@$ip:$port';
|
||||
late String id;
|
||||
|
||||
ServerPrivateInfo({
|
||||
required this.name,
|
||||
required this.ip,
|
||||
required this.port,
|
||||
required this.user,
|
||||
required this.pwd,
|
||||
this.pubKeyId,
|
||||
}) : id = '$user@$ip:$port';
|
||||
|
||||
ServerPrivateInfo(
|
||||
{required this.name,
|
||||
required this.ip,
|
||||
required this.port,
|
||||
required this.user,
|
||||
required this.pwd,
|
||||
this.pubKeyId});
|
||||
ServerPrivateInfo.fromJson(Map<String, dynamic> json) {
|
||||
name = json["name"].toString();
|
||||
ip = json["ip"].toString();
|
||||
@@ -47,7 +49,9 @@ class ServerPrivateInfo {
|
||||
user = json["user"].toString();
|
||||
pwd = json["authorization"].toString();
|
||||
pubKeyId = json["pubKeyId"]?.toString();
|
||||
id = '$user@$ip:$port';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data["name"] = name;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:toolbox/data/model/server/cpu_2_status.dart';
|
||||
import 'package:toolbox/data/model/server/cpu_status.dart';
|
||||
import 'package:toolbox/data/model/server/disk_info.dart';
|
||||
import 'package:toolbox/data/model/server/memory.dart';
|
||||
import 'package:toolbox/data/model/server/net_speed.dart';
|
||||
@@ -30,8 +30,9 @@ class ServerStatus {
|
||||
}
|
||||
*/
|
||||
|
||||
Cpu2Status cpu2Status;
|
||||
Memory memory;
|
||||
CpuStatus cpu;
|
||||
Memory mem;
|
||||
Swap swap;
|
||||
String sysVer;
|
||||
String uptime;
|
||||
List<DiskInfo> disk;
|
||||
@@ -39,7 +40,15 @@ class ServerStatus {
|
||||
NetSpeed netSpeed;
|
||||
String? failedInfo;
|
||||
|
||||
ServerStatus(this.cpu2Status, this.memory, this.sysVer, this.uptime,
|
||||
this.disk, this.tcp, this.netSpeed,
|
||||
{this.failedInfo});
|
||||
ServerStatus({
|
||||
required this.cpu,
|
||||
required this.mem,
|
||||
required this.sysVer,
|
||||
required this.uptime,
|
||||
required this.disk,
|
||||
required this.tcp,
|
||||
required this.netSpeed,
|
||||
required this.swap,
|
||||
this.failedInfo,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import '../../../core/extension/stringx.dart';
|
||||
import '../../res/misc.dart';
|
||||
|
||||
///
|
||||
/// Code generated by jsonToDartModel https://ashamp.github.io/jsonToDartModel/
|
||||
///
|
||||
@@ -39,3 +42,14 @@ class TcpStatus {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
TcpStatus? parseTcp(String raw) {
|
||||
final lines = raw.split('\n');
|
||||
final idx = lines.lastWhere((element) => element.startsWith('Tcp:'),
|
||||
orElse: () => '');
|
||||
if (idx != '') {
|
||||
final vals = idx.split(numReg);
|
||||
return TcpStatus(vals[5].i, vals[6].i, vals[7].i, vals[8].i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,29 +1,35 @@
|
||||
class AbsolutePath {
|
||||
String path;
|
||||
String? _prePath;
|
||||
AbsolutePath(this.path);
|
||||
String _path;
|
||||
String get path => _path;
|
||||
final List<String> _prePath;
|
||||
|
||||
AbsolutePath(this._path) : _prePath = ['/'];
|
||||
|
||||
void update(String newPath) {
|
||||
_prePath = path;
|
||||
_prePath.add(_path);
|
||||
if (newPath == '..') {
|
||||
path = path.substring(0, path.lastIndexOf('/'));
|
||||
if (path == '') {
|
||||
path = '/';
|
||||
_path = _path.substring(0, _path.lastIndexOf('/'));
|
||||
if (_path == '') {
|
||||
_path = '/';
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (newPath == '/') {
|
||||
path = '/';
|
||||
_path = '/';
|
||||
return;
|
||||
}
|
||||
path = path + (path.endsWith('/') ? '' : '/') + newPath;
|
||||
if (newPath.startsWith('/')) {
|
||||
_path = newPath;
|
||||
return;
|
||||
}
|
||||
_path = _path + (_path.endsWith('/') ? '' : '/') + newPath;
|
||||
}
|
||||
|
||||
bool undo() {
|
||||
if (_prePath == null || _prePath == path) {
|
||||
if (_prePath.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
path = _prePath!;
|
||||
_path = _prePath.removeLast();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:toolbox/data/model/server/server_private_info.dart';
|
||||
import 'package:toolbox/data/model/sftp/absolute_path.dart';
|
||||
|
||||
class SftpBrowserStatus {
|
||||
bool selected = false;
|
||||
ServerPrivateInfo? spi;
|
||||
List<SftpName>? files;
|
||||
AbsolutePath? path;
|
||||
SftpClient? client;
|
||||
|
||||
16
lib/data/model/sftp/download_item.dart
Normal file
16
lib/data/model/sftp/download_item.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import '../server/server_private_info.dart';
|
||||
|
||||
class DownloadItem {
|
||||
DownloadItem(this.spi, this.remotePath, this.localPath);
|
||||
|
||||
final ServerPrivateInfo spi;
|
||||
final String remotePath;
|
||||
final String localPath;
|
||||
}
|
||||
|
||||
class DownloadItemEvent {
|
||||
DownloadItemEvent(this.item, this.privateKey);
|
||||
|
||||
final DownloadItem item;
|
||||
final String? privateKey;
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:toolbox/data/model/sftp/download_worker.dart';
|
||||
|
||||
import 'download_item.dart';
|
||||
|
||||
class SftpDownloadStatus {
|
||||
final int id;
|
||||
final DownloadItem item;
|
||||
|
||||
@@ -4,16 +4,9 @@ import 'dart:isolate';
|
||||
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:easy_isolate/easy_isolate.dart';
|
||||
import 'package:toolbox/data/model/server/server_private_info.dart';
|
||||
import 'package:toolbox/data/model/sftp/download_status.dart';
|
||||
|
||||
class DownloadItem {
|
||||
DownloadItem(this.spi, this.remotePath, this.localPath);
|
||||
|
||||
final ServerPrivateInfo spi;
|
||||
final String remotePath;
|
||||
final String localPath;
|
||||
}
|
||||
import 'download_item.dart';
|
||||
import 'download_status.dart';
|
||||
|
||||
class SftpDownloadWorker {
|
||||
SftpDownloadWorker(
|
||||
@@ -101,10 +94,3 @@ class SftpDownloadWorker {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DownloadItemEvent {
|
||||
DownloadItemEvent(this.item, this.privateKey);
|
||||
|
||||
final DownloadItem item;
|
||||
final String? privateKey;
|
||||
}
|
||||
|
||||
142
lib/data/model/ssh/terminal_color.dart
Normal file
142
lib/data/model/ssh/terminal_color.dart
Normal file
@@ -0,0 +1,142 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:xterm/ui.dart';
|
||||
import '../../res/terminal.dart';
|
||||
|
||||
class TerminalUITheme {
|
||||
final Color cursor;
|
||||
final Color selection;
|
||||
final Color foreground;
|
||||
final Color background;
|
||||
final Color searchHitBackground;
|
||||
final Color searchHitBackgroundCurrent;
|
||||
final Color searchHitForeground;
|
||||
|
||||
const TerminalUITheme({
|
||||
required this.cursor,
|
||||
required this.selection,
|
||||
required this.foreground,
|
||||
required this.background,
|
||||
required this.searchHitBackground,
|
||||
required this.searchHitBackgroundCurrent,
|
||||
required this.searchHitForeground,
|
||||
});
|
||||
|
||||
TerminalTheme toTerminalTheme(TerminalColors termColor) {
|
||||
return TerminalTheme(
|
||||
cursor: cursor,
|
||||
selection: selection,
|
||||
foreground: foreground,
|
||||
background: background,
|
||||
black: termColor.black,
|
||||
red: termColor.red,
|
||||
green: termColor.green,
|
||||
yellow: termColor.yellow,
|
||||
blue: termColor.blue,
|
||||
magenta: termColor.magenta,
|
||||
cyan: termColor.cyan,
|
||||
white: termColor.white,
|
||||
brightBlack: termColor.brightBlack,
|
||||
brightRed: termColor.brightRed,
|
||||
brightGreen: termColor.brightGreen,
|
||||
brightYellow: termColor.brightYellow,
|
||||
brightBlue: termColor.brightBlue,
|
||||
brightMagenta: termColor.brightMagenta,
|
||||
brightCyan: termColor.brightCyan,
|
||||
brightWhite: termColor.brightWhite,
|
||||
searchHitBackground: searchHitBackground,
|
||||
searchHitBackgroundCurrent: searchHitBackgroundCurrent,
|
||||
searchHitForeground: searchHitForeground,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TerminalColors {
|
||||
final TerminalColorsPlatform platform;
|
||||
final Color black = Colors.black;
|
||||
final Color red;
|
||||
final Color green;
|
||||
final Color yellow;
|
||||
final Color blue;
|
||||
// 品红
|
||||
final Color magenta;
|
||||
// 青
|
||||
final Color cyan;
|
||||
final Color white;
|
||||
|
||||
/// Also called grey
|
||||
final Color brightBlack;
|
||||
final Color brightRed;
|
||||
final Color brightGreen;
|
||||
final Color brightYellow;
|
||||
final Color brightBlue;
|
||||
final Color brightMagenta;
|
||||
final Color brightCyan;
|
||||
final Color brightWhite;
|
||||
|
||||
TerminalColors(
|
||||
this.platform,
|
||||
this.red,
|
||||
this.green,
|
||||
this.yellow,
|
||||
this.blue,
|
||||
this.magenta,
|
||||
this.cyan,
|
||||
this.white,
|
||||
this.brightBlack,
|
||||
this.brightRed,
|
||||
this.brightGreen,
|
||||
this.brightYellow,
|
||||
this.brightBlue,
|
||||
this.brightMagenta,
|
||||
this.brightCyan, {
|
||||
this.brightWhite = Colors.white,
|
||||
});
|
||||
}
|
||||
|
||||
enum TerminalColorsPlatform {
|
||||
macOS,
|
||||
vga,
|
||||
cmd,
|
||||
putty,
|
||||
xterm,
|
||||
ubuntu,
|
||||
;
|
||||
|
||||
String get name {
|
||||
switch (this) {
|
||||
case TerminalColorsPlatform.vga:
|
||||
return 'VGA';
|
||||
case TerminalColorsPlatform.cmd:
|
||||
return 'CMD';
|
||||
case TerminalColorsPlatform.macOS:
|
||||
return 'macOS';
|
||||
case TerminalColorsPlatform.putty:
|
||||
return 'PuTTY';
|
||||
case TerminalColorsPlatform.xterm:
|
||||
return 'XTerm';
|
||||
case TerminalColorsPlatform.ubuntu:
|
||||
return 'Ubuntu';
|
||||
default:
|
||||
return 'Unknown';
|
||||
}
|
||||
}
|
||||
|
||||
TerminalColors get colors {
|
||||
switch (this) {
|
||||
case TerminalColorsPlatform.vga:
|
||||
return VGATerminalColor();
|
||||
case TerminalColorsPlatform.cmd:
|
||||
return CMDTerminalColor();
|
||||
case TerminalColorsPlatform.macOS:
|
||||
return MacOSTerminalColor();
|
||||
case TerminalColorsPlatform.putty:
|
||||
return PuttyTerminalColor();
|
||||
case TerminalColorsPlatform.xterm:
|
||||
return XTermTerminalColor();
|
||||
case TerminalColorsPlatform.ubuntu:
|
||||
return UbuntuTerminalColor();
|
||||
default:
|
||||
return MacOSTerminalColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
15
lib/data/model/ssh/virtual_key.dart
Normal file
15
lib/data/model/ssh/virtual_key.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:xterm/core.dart';
|
||||
|
||||
class VirtualKey {
|
||||
final String text;
|
||||
final bool toggleable;
|
||||
final TerminalKey? key;
|
||||
final IconData? icon;
|
||||
final VirtualKeyFunc? func;
|
||||
|
||||
VirtualKey(this.text,
|
||||
{this.key, this.toggleable = false, this.icon, this.func});
|
||||
}
|
||||
|
||||
enum VirtualKeyFunc { toggleIME, backspace, copy, paste }
|
||||
@@ -1,176 +0,0 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
import 'package:toolbox/core/extension/uint8list.dart';
|
||||
import 'package:toolbox/core/provider_base.dart';
|
||||
import 'package:toolbox/data/model/apt/upgrade_pkg_info.dart';
|
||||
import 'package:toolbox/data/model/distribution.dart';
|
||||
|
||||
typedef PwdRequestFunc = Future<String> Function(
|
||||
int triedTimes, String? userName);
|
||||
final pwdRequestWithUserReg = RegExp(r'\[sudo\] password for (.+):');
|
||||
|
||||
class AptProvider extends BusyProvider {
|
||||
final logger = Logger('AptProvider');
|
||||
|
||||
SSHClient? client;
|
||||
Distribution? dist;
|
||||
Function()? onUpgrade;
|
||||
Function()? onUpdate;
|
||||
PwdRequestFunc? onPasswordRequest;
|
||||
|
||||
String? whoami;
|
||||
List<UpgradePkgInfo>? upgradeable;
|
||||
String? error;
|
||||
String? upgradeLog;
|
||||
String? updateLog;
|
||||
String lastLog = '';
|
||||
int triedTimes = 0;
|
||||
bool isRequestingPwd = false;
|
||||
|
||||
AptProvider();
|
||||
|
||||
Future<void> init(SSHClient client, Distribution dist, Function() onUpgrade,
|
||||
Function() onUpdate, PwdRequestFunc onPasswordRequest) async {
|
||||
this.client = client;
|
||||
this.dist = dist;
|
||||
this.onUpgrade = onUpgrade;
|
||||
this.onPasswordRequest = onPasswordRequest;
|
||||
whoami = (await client.run('whoami').string).trim();
|
||||
}
|
||||
|
||||
bool get isSU => whoami == 'root';
|
||||
|
||||
void clear() {
|
||||
client = null;
|
||||
dist = null;
|
||||
upgradeable = null;
|
||||
error = null;
|
||||
upgradeLog = null;
|
||||
updateLog = whoami = null;
|
||||
onUpgrade = null;
|
||||
onUpdate = null;
|
||||
onPasswordRequest = null;
|
||||
triedTimes = 0;
|
||||
isRequestingPwd = false;
|
||||
}
|
||||
|
||||
Future<void> refreshInstalled() async {
|
||||
if (client == null) {
|
||||
error = 'No client';
|
||||
return;
|
||||
}
|
||||
|
||||
final result = await _update();
|
||||
getUpgradeableList(result);
|
||||
try {} catch (e) {
|
||||
error = '[Server Raw]:\n$result\n[App Error]:\n$e';
|
||||
} finally {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void getUpgradeableList(String? raw) {
|
||||
if (raw == null) return;
|
||||
var list = raw.split('\n');
|
||||
switch (dist) {
|
||||
case Distribution.rehl:
|
||||
list = list.sublist(2);
|
||||
list.removeWhere((element) => element.isEmpty);
|
||||
final endLine = list.lastIndexWhere(
|
||||
(element) => element.contains('Obsoleting Packages'));
|
||||
list = list.sublist(0, endLine);
|
||||
break;
|
||||
default:
|
||||
// avoid other outputs
|
||||
// such as: [Could not chdir to home directory /home/test: No such file or directory, , WARNING: apt does not have a stable CLI interface. Use with caution in scripts., , Listing...]
|
||||
final idx =
|
||||
list.indexWhere((element) => element.contains('[upgradable from:'));
|
||||
if (idx == -1) {
|
||||
upgradeable = [];
|
||||
return;
|
||||
}
|
||||
list = list.sublist(idx);
|
||||
list.removeWhere((element) => element.isEmpty);
|
||||
}
|
||||
upgradeable = list.map((e) => UpgradePkgInfo(e, dist!)).toList();
|
||||
}
|
||||
|
||||
Future<String> _update() async {
|
||||
switch (dist) {
|
||||
case Distribution.rehl:
|
||||
return await client?.run(_wrap('yum check-update')).string ?? '';
|
||||
default:
|
||||
final session = await client!.execute(_wrap('apt update'));
|
||||
session.stderr.listen((event) => _onPwd(event, session.stdin));
|
||||
session.stdout.listen((event) {
|
||||
updateLog = (updateLog ?? '') + event.string;
|
||||
notifyListeners();
|
||||
onUpdate ?? () {}();
|
||||
});
|
||||
await session.done;
|
||||
return await client
|
||||
?.run('apt list --upgradeable'.withLangExport)
|
||||
.string ??
|
||||
'';
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> upgrade() async {
|
||||
if (client == null) {
|
||||
error = 'No client';
|
||||
return;
|
||||
}
|
||||
|
||||
final upgradeCmd = () {
|
||||
switch (dist) {
|
||||
case Distribution.rehl:
|
||||
return 'yum upgrade -y';
|
||||
default:
|
||||
return 'apt upgrade -y';
|
||||
}
|
||||
}();
|
||||
|
||||
final session = await client!.execute(_wrap(upgradeCmd));
|
||||
session.stderr.listen((e) => _onPwd(e, session.stdin));
|
||||
|
||||
session.stdout.listen((data) async {
|
||||
final log = data.string;
|
||||
if (lastLog == log.trim()) return;
|
||||
upgradeLog = (upgradeLog ?? '') + log;
|
||||
lastLog = log.trim();
|
||||
notifyListeners();
|
||||
onUpgrade!();
|
||||
});
|
||||
|
||||
upgradeLog = null;
|
||||
await session.done;
|
||||
refreshInstalled();
|
||||
}
|
||||
|
||||
Future<void> _onPwd(Uint8List e, StreamSink<Uint8List> stdin) async {
|
||||
if (isRequestingPwd) return;
|
||||
isRequestingPwd = true;
|
||||
final event = e.string;
|
||||
if (event.contains('[sudo] password for ')) {
|
||||
final user = pwdRequestWithUserReg.firstMatch(event)?.group(1);
|
||||
logger.info('sudo password request for $user');
|
||||
triedTimes++;
|
||||
final pwd =
|
||||
await (onPasswordRequest ?? (_, __) async => '')(triedTimes, user);
|
||||
if (pwd.isEmpty) {
|
||||
logger.info('sudo password request cancelled');
|
||||
return;
|
||||
}
|
||||
stdin.add(Uint8List.fromList(utf8.encode('$pwd\n')));
|
||||
}
|
||||
isRequestingPwd = false;
|
||||
}
|
||||
|
||||
String _wrap(String cmd) =>
|
||||
'export LANG=en_US.utf-8 && ${isSU ? "" : "sudo -S "}$cmd';
|
||||
}
|
||||
@@ -1,32 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../data/res/misc.dart';
|
||||
|
||||
/// format: [NAME][LEVEL]: MESSAGE
|
||||
final _headReg = RegExp(r'(\[[A-Za-z]+\])(\[[A-Z]+\]): (.*)');
|
||||
const _level2Color = {
|
||||
'[INFO]': Colors.blue,
|
||||
'[WARNING]': Colors.yellow,
|
||||
};
|
||||
|
||||
class DebugProvider extends ChangeNotifier {
|
||||
final widgets = <Widget>[];
|
||||
|
||||
void addText(String text) {
|
||||
_addText(text);
|
||||
notifyListeners();
|
||||
}
|
||||
final match = _headReg.allMatches(text);
|
||||
|
||||
void _addText(String text) {
|
||||
_addWidget(Text(text));
|
||||
}
|
||||
|
||||
void addError(Object error) {
|
||||
_addError(error);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _addError(Object error) {
|
||||
_addMultiline(error, Colors.red);
|
||||
if (match.isNotEmpty) {
|
||||
_addWidget(Text.rich(TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: match.first.group(1),
|
||||
style: const TextStyle(color: Colors.cyan),
|
||||
),
|
||||
TextSpan(
|
||||
text: match.first.group(2),
|
||||
style: TextStyle(color: _level2Color[match.first.group(2)]),
|
||||
),
|
||||
TextSpan(
|
||||
text: '\n${match.first.group(3)}',
|
||||
)
|
||||
],
|
||||
)));
|
||||
} else {
|
||||
_addWidget(Text(text));
|
||||
}
|
||||
}
|
||||
|
||||
void addMultiline(Object data, [Color color = Colors.blue]) {
|
||||
_addMultiline(data, color);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _addMultiline(Object data, [Color color = Colors.blue]) {
|
||||
final widget = Text(
|
||||
'$data',
|
||||
style: TextStyle(
|
||||
@@ -39,23 +49,13 @@ class DebugProvider extends ChangeNotifier {
|
||||
));
|
||||
}
|
||||
|
||||
void addWidget(Widget widget) {
|
||||
_addWidget(widget);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _addWidget(Widget widget) {
|
||||
final outlined = Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.green,
|
||||
),
|
||||
),
|
||||
child: widget,
|
||||
);
|
||||
|
||||
widgets.add(outlined);
|
||||
widgets.add(widget);
|
||||
widgets.add(const SizedBox(height: 13));
|
||||
if (widgets.length > maxDebugLogLines) {
|
||||
widgets.removeRange(0, widgets.length - maxDebugLogLines);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void clear() {
|
||||
|
||||
@@ -1,96 +1,169 @@
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:toolbox/core/extension/ssh_client.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
import 'package:toolbox/core/extension/uint8list.dart';
|
||||
import 'package:toolbox/core/provider_base.dart';
|
||||
import 'package:toolbox/data/model/docker/image.dart';
|
||||
import 'package:toolbox/data/model/docker/ps.dart';
|
||||
import 'package:toolbox/data/res/error.dart';
|
||||
import 'package:toolbox/data/store/docker.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
|
||||
final _dockerNotFound = RegExp(r'command not found|Unknown command');
|
||||
final _versionReg = RegExp(r'(Version:)\s+([0-9]+\.[0-9]+\.[0-9]+)');
|
||||
final _editionReg = RegExp(r'(Client:)\s+(.+-.+)');
|
||||
final _userIdReg = RegExp(r'.+:(\d+:\d+):.+');
|
||||
final _dockerPrefixReg = RegExp(r'(sudo )?docker ');
|
||||
|
||||
const _dockerPS = 'docker ps -a';
|
||||
const _dockerImgs = 'docker images';
|
||||
|
||||
final _logger = Logger('DOCKER');
|
||||
|
||||
class DockerProvider extends BusyProvider {
|
||||
final dockerStore = locator<DockerStore>();
|
||||
|
||||
SSHClient? client;
|
||||
String? userName;
|
||||
List<DockerPsItem>? items;
|
||||
List<DockerImage>? images;
|
||||
String? version;
|
||||
String? edition;
|
||||
String? error;
|
||||
DockerErr? error;
|
||||
PwdRequestFunc? onPwdReq;
|
||||
String? hostId;
|
||||
String? runLog;
|
||||
bool isRequestingPwd = false;
|
||||
|
||||
void init(SSHClient client, String userName) {
|
||||
void init(SSHClient client, String userName, PwdRequestFunc onPwdReq,
|
||||
String hostId) {
|
||||
this.client = client;
|
||||
this.userName = userName;
|
||||
this.onPwdReq = onPwdReq;
|
||||
this.hostId = hostId;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
client = null;
|
||||
userName = null;
|
||||
error = null;
|
||||
items = null;
|
||||
version = null;
|
||||
edition = null;
|
||||
client = userName = error = items = version = edition = onPwdReq = null;
|
||||
isRequestingPwd = false;
|
||||
hostId = runLog = images = null;
|
||||
}
|
||||
|
||||
Future<void> refresh() async {
|
||||
if (client == null) {
|
||||
error = 'no client';
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBusy) return;
|
||||
final verRaw = await client!.run('docker version'.withLangExport).string;
|
||||
if (verRaw.contains(_dockerNotFound)) {
|
||||
error = 'docker not found';
|
||||
notifyListeners();
|
||||
error = DockerErr(type: DockerErrType.notInstalled);
|
||||
setBusyState(false);
|
||||
return;
|
||||
}
|
||||
|
||||
version = _versionReg.firstMatch(verRaw)?.group(2);
|
||||
edition = _editionReg.firstMatch(verRaw)?.group(2);
|
||||
|
||||
final passwd = await client!.run('cat /etc/passwd | grep $userName').string;
|
||||
final userId = _userIdReg.firstMatch(passwd)?.group(1)?.split(':').first;
|
||||
try {
|
||||
version = _versionReg.firstMatch(verRaw)?.group(2);
|
||||
edition = _editionReg.firstMatch(verRaw)?.group(2);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
|
||||
try {
|
||||
final cmd = 'docker ps -a'.withLangExport;
|
||||
final raw = await () async {
|
||||
final raw = await client!.run(cmd).string;
|
||||
if (raw.contains('permission denied')) {
|
||||
return await client!
|
||||
.run(
|
||||
'export DOCKER_HOST=unix:///run/user/${userId ?? 1000}/docker.sock && $cmd')
|
||||
.string;
|
||||
}
|
||||
return raw;
|
||||
}();
|
||||
setBusyState();
|
||||
final cmd = _wrap(_dockerPS);
|
||||
|
||||
// run docker ps
|
||||
var raw = '';
|
||||
await client!.exec(
|
||||
cmd,
|
||||
onStderr: _onPwd,
|
||||
onStdout: (data, _) => raw = '$raw$data',
|
||||
);
|
||||
|
||||
// parse result
|
||||
final lines = raw.split('\n');
|
||||
lines.removeAt(0);
|
||||
lines.removeWhere((element) => element.isEmpty);
|
||||
items = lines.map((e) => DockerPsItem.fromRawString(e)).toList();
|
||||
|
||||
final imageCmd = _wrap(_dockerImgs);
|
||||
raw = '';
|
||||
await client!.exec(
|
||||
imageCmd,
|
||||
onStderr: _onPwd,
|
||||
onStdout: (data, _) => raw = '$raw$data',
|
||||
);
|
||||
|
||||
final imageLines = raw.split('\n');
|
||||
imageLines.removeAt(0);
|
||||
imageLines.removeWhere((element) => element.isEmpty);
|
||||
images = imageLines.map((e) => DockerImage.fromRawStr(e)).toList();
|
||||
} catch (e) {
|
||||
error = e.toString();
|
||||
error = DockerErr(type: DockerErrType.unknown, message: e.toString());
|
||||
rethrow;
|
||||
} finally {
|
||||
notifyListeners();
|
||||
setBusyState(false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> _do(String id, String cmd) async {
|
||||
setBusyState();
|
||||
if (client == null) {
|
||||
error = 'no client';
|
||||
setBusyState(false);
|
||||
return false;
|
||||
Future<void> _onPwd(String event, StreamSink<Uint8List> stdin) async {
|
||||
if (isRequestingPwd) return;
|
||||
isRequestingPwd = true;
|
||||
if (event.contains('[sudo] password for ')) {
|
||||
_logger.info('sudo password request for $userName');
|
||||
final pwd = await onPwdReq!();
|
||||
if (pwd.isEmpty) {
|
||||
_logger.info('sudo password request cancelled');
|
||||
return;
|
||||
}
|
||||
stdin.add('$pwd\n'.uint8List);
|
||||
}
|
||||
isRequestingPwd = false;
|
||||
}
|
||||
|
||||
Future<DockerErr?> stop(String id) async => await run('docker stop $id');
|
||||
|
||||
Future<DockerErr?> start(String id) async => await run('docker start $id');
|
||||
|
||||
Future<DockerErr?> delete(String id) async => await run('docker rm $id');
|
||||
|
||||
Future<DockerErr?> run(String cmd) async {
|
||||
if (!cmd.startsWith(_dockerPrefixReg)) {
|
||||
return DockerErr(type: DockerErrType.cmdNoPrefix);
|
||||
}
|
||||
setBusyState();
|
||||
|
||||
runLog = '';
|
||||
final errs = <String>[];
|
||||
final code = await client!.exec(
|
||||
_wrap(cmd),
|
||||
onStderr: (data, sink) {
|
||||
_onPwd(data, sink);
|
||||
errs.add(data);
|
||||
},
|
||||
onStdout: (data, _) {
|
||||
runLog = '$runLog$data';
|
||||
notifyListeners();
|
||||
},
|
||||
);
|
||||
runLog = null;
|
||||
|
||||
if (code != 0) {
|
||||
setBusyState(false);
|
||||
return DockerErr(
|
||||
type: DockerErrType.unknown, message: errs.join('\n').trim());
|
||||
}
|
||||
final result = await client!.run(cmd).string;
|
||||
await refresh();
|
||||
setBusyState(false);
|
||||
return result.contains(id);
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<bool> stop(String id) async => await _do(id, 'docker stop $id');
|
||||
|
||||
Future<bool> start(String id) async => await _do(id, 'docker start $id');
|
||||
|
||||
Future<bool> delete(String id) async => await _do(id, 'docker rm $id');
|
||||
// judge whether to use DOCKER_HOST / sudo
|
||||
String _wrap(String cmd) {
|
||||
final dockerHost = dockerStore.getDockerHost(hostId!);
|
||||
if (dockerHost == null || dockerHost.isEmpty) {
|
||||
return 'sudo $cmd'.withLangExport;
|
||||
}
|
||||
return 'export DOCKER_HOST=$dockerHost && $cmd'.withLangExport;
|
||||
}
|
||||
}
|
||||
|
||||
216
lib/data/provider/pkg.dart
Normal file
216
lib/data/provider/pkg.dart
Normal file
@@ -0,0 +1,216 @@
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:toolbox/core/extension/ssh_client.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
import 'package:toolbox/core/extension/uint8list.dart';
|
||||
import 'package:toolbox/core/provider_base.dart';
|
||||
import 'package:toolbox/data/model/pkg/manager.dart';
|
||||
import 'package:toolbox/data/model/pkg/upgrade_info.dart';
|
||||
import 'package:toolbox/data/model/server/dist.dart';
|
||||
|
||||
class PkgProvider extends BusyProvider {
|
||||
final logger = Logger('PKG');
|
||||
|
||||
SSHClient? client;
|
||||
Dist? dist;
|
||||
PkgManager? type;
|
||||
Function()? onUpgrade;
|
||||
Function()? onUpdate;
|
||||
PwdRequestFunc? onPasswordRequest;
|
||||
|
||||
String? whoami;
|
||||
List<UpgradePkgInfo>? upgradeable;
|
||||
String? error;
|
||||
String? upgradeLog;
|
||||
String? updateLog;
|
||||
String lastLog = '';
|
||||
bool isRequestingPwd = false;
|
||||
|
||||
PkgProvider();
|
||||
|
||||
Future<void> init(
|
||||
SSHClient client,
|
||||
Dist? dist,
|
||||
Function() onUpgrade,
|
||||
Function() onUpdate,
|
||||
PwdRequestFunc onPasswordRequest,
|
||||
String user) async {
|
||||
this.client = client;
|
||||
this.dist = dist;
|
||||
this.onUpgrade = onUpgrade;
|
||||
this.onPasswordRequest = onPasswordRequest;
|
||||
whoami = user;
|
||||
|
||||
switch (dist) {
|
||||
case Dist.centos:
|
||||
case Dist.rocky:
|
||||
case Dist.fedora:
|
||||
type = PkgManager.yum;
|
||||
break;
|
||||
case Dist.debian:
|
||||
case Dist.ubuntu:
|
||||
case Dist.kali:
|
||||
case Dist.armbian:
|
||||
type = PkgManager.apt;
|
||||
break;
|
||||
case Dist.opensuse:
|
||||
type = PkgManager.zypper;
|
||||
break;
|
||||
case Dist.wrt:
|
||||
type = PkgManager.opkg;
|
||||
break;
|
||||
case Dist.arch:
|
||||
type = PkgManager.pacman;
|
||||
break;
|
||||
case null:
|
||||
error = 'Unsupported dist: $dist';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool get isSU => whoami == 'root';
|
||||
|
||||
void clear() {
|
||||
client = dist = updateLog = upgradeLog = upgradeable =
|
||||
error = whoami = onUpdate = onUpgrade = onPasswordRequest = null;
|
||||
isRequestingPwd = false;
|
||||
}
|
||||
|
||||
Future<void> refresh() async {
|
||||
final result = await _update();
|
||||
try {
|
||||
_parse(result);
|
||||
} catch (e) {
|
||||
error = '[Server Raw]:\n$result\n[App Error]:\n$e';
|
||||
} finally {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void _parse(String? raw) {
|
||||
if (raw == null) return;
|
||||
var list = raw.split('\n');
|
||||
switch (type) {
|
||||
case PkgManager.yum:
|
||||
list = list.sublist(2);
|
||||
list.removeWhere((element) => element.isEmpty);
|
||||
final endLine = list.lastIndexWhere(
|
||||
(element) => element.contains('Obsoleting Packages'));
|
||||
list = list.sublist(0, endLine);
|
||||
break;
|
||||
case PkgManager.apt:
|
||||
// avoid other outputs
|
||||
// such as: [Could not chdir to home directory /home/test: No such file or directory, , WARNING: apt does not have a stable CLI interface. Use with caution in scripts., , Listing...]
|
||||
final idx =
|
||||
list.indexWhere((element) => element.contains('[upgradable from:'));
|
||||
if (idx == -1) {
|
||||
upgradeable = [];
|
||||
return;
|
||||
}
|
||||
list = list.sublist(idx);
|
||||
list.removeWhere((element) => element.isEmpty);
|
||||
break;
|
||||
case PkgManager.zypper:
|
||||
list = list.sublist(4);
|
||||
break;
|
||||
case PkgManager.pacman:
|
||||
case PkgManager.opkg:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
upgradeable = list.map((e) => UpgradePkgInfo(e, type)).toList();
|
||||
}
|
||||
|
||||
Future<String?> _update() async {
|
||||
switch (type) {
|
||||
case PkgManager.yum:
|
||||
return await client?.run(_wrap('yum check-update')).string;
|
||||
case PkgManager.apt:
|
||||
await client!.exec(
|
||||
_wrap('apt update'),
|
||||
onStderr: _onPwd,
|
||||
onStdout: (data, sink) {
|
||||
updateLog = (updateLog ?? '') + data;
|
||||
notifyListeners();
|
||||
if (onUpdate != null) onUpdate!();
|
||||
},
|
||||
);
|
||||
return await client
|
||||
?.run('apt list --upgradeable'.withLangExport)
|
||||
.string;
|
||||
case PkgManager.zypper:
|
||||
return await client?.run(_wrap('zypper lu')).string;
|
||||
case PkgManager.pacman:
|
||||
await client?.run('pacman -Sy');
|
||||
return await client?.run(_wrap('pacman -Qu')).string;
|
||||
case PkgManager.opkg:
|
||||
await client?.run('opkg update');
|
||||
return await client?.run(_wrap('opkg list-upgradable')).string;
|
||||
default:
|
||||
error = 'Unsupported dist: $dist';
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> upgrade() async {
|
||||
final upgradeCmd = () {
|
||||
switch (type) {
|
||||
case PkgManager.yum:
|
||||
return 'yum upgrade -y';
|
||||
case PkgManager.apt:
|
||||
return 'apt upgrade -y';
|
||||
case PkgManager.zypper:
|
||||
return 'zypper up -y';
|
||||
case PkgManager.pacman:
|
||||
return 'pacman -Syu --noconfirm';
|
||||
case PkgManager.opkg:
|
||||
return 'opkg upgrade ${upgradeable?.map((e) => e.package).join(" ")}';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}();
|
||||
|
||||
if (upgradeCmd == null) {
|
||||
error = 'Unsupported dist: $dist';
|
||||
return;
|
||||
}
|
||||
|
||||
await client!.exec(
|
||||
_wrap(upgradeCmd),
|
||||
onStderr: _onPwd,
|
||||
onStdout: (log, sink) {
|
||||
if (lastLog == log.trim()) return;
|
||||
upgradeLog = (upgradeLog ?? '') + log;
|
||||
lastLog = log.trim();
|
||||
notifyListeners();
|
||||
if (onUpgrade != null) onUpgrade!();
|
||||
},
|
||||
);
|
||||
|
||||
upgradeLog = null;
|
||||
refresh();
|
||||
}
|
||||
|
||||
Future<void> _onPwd(String event, StreamSink<Uint8List> stdin) async {
|
||||
if (isRequestingPwd) return;
|
||||
isRequestingPwd = true;
|
||||
if (event.contains('[sudo] password for ')) {
|
||||
final user = pwdRequestWithUserReg.firstMatch(event)?.group(1);
|
||||
logger.info('sudo password request for $user');
|
||||
final pwd = await onPasswordRequest!();
|
||||
if (pwd.isEmpty) {
|
||||
logger.info('sudo password request cancelled');
|
||||
return;
|
||||
}
|
||||
stdin.add('$pwd\n'.uint8List);
|
||||
}
|
||||
isRequestingPwd = false;
|
||||
}
|
||||
|
||||
String _wrap(String cmd) =>
|
||||
'export LANG=en_US.utf-8 && ${isSU ? "" : "sudo -S "}$cmd';
|
||||
}
|
||||
@@ -1,111 +1,58 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
import 'package:toolbox/core/extension/uint8list.dart';
|
||||
import 'package:toolbox/core/provider_base.dart';
|
||||
import 'package:toolbox/data/model/server/cpu_2_status.dart';
|
||||
import 'package:toolbox/data/model/server/cpu_status.dart';
|
||||
import 'package:toolbox/data/model/server/memory.dart';
|
||||
import 'package:toolbox/data/model/server/net_speed.dart';
|
||||
import 'package:toolbox/data/model/server/disk_info.dart';
|
||||
import 'package:toolbox/data/model/server/server.dart';
|
||||
import 'package:toolbox/data/model/server/server_private_info.dart';
|
||||
import 'package:toolbox/data/model/server/server_status.dart';
|
||||
import 'package:toolbox/data/model/server/snippet.dart';
|
||||
import 'package:toolbox/data/model/server/tcp_status.dart';
|
||||
import 'package:toolbox/data/store/private_key.dart';
|
||||
import 'package:toolbox/data/store/server.dart';
|
||||
import 'package:toolbox/data/store/setting.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
|
||||
/// Must put this func out of any Class.
|
||||
/// Because of this function is called by [compute] in [ServerProvider.genClient].
|
||||
/// https://stackoverflow.com/questions/51998995/invalid-arguments-illegal-argument-in-isolate-message-object-is-a-closure
|
||||
List<SSHKeyPair> loadIndentity(String key) {
|
||||
return SSHKeyPair.fromPem(key);
|
||||
}
|
||||
|
||||
const seperator = 'A====A';
|
||||
const shellCmd = "export LANG=en_US.utf-8 \necho '$seperator' \n"
|
||||
"cat /proc/net/dev && date +%s \necho $seperator \n "
|
||||
"cat /etc/os-release | grep PRETTY_NAME \necho $seperator \n"
|
||||
"cat /proc/stat | grep cpu \necho $seperator \n"
|
||||
"uptime \necho $seperator \n"
|
||||
"cat /proc/net/snmp \necho $seperator \n"
|
||||
"df -h \necho $seperator \n"
|
||||
"cat /proc/meminfo \necho $seperator \n"
|
||||
"cat /sys/class/thermal/thermal_zone*/type \necho $seperator \n"
|
||||
"cat /sys/class/thermal/thermal_zone*/temp";
|
||||
const shellPath = '.serverbox.sh';
|
||||
final cpuTempReg = RegExp(r'(x86_pkg_temp|cpu_thermal)');
|
||||
final numReg = RegExp(r'\s{1,}');
|
||||
final memItemReg = RegExp(r'([A-Z].+:)\s+([0-9]+) kB');
|
||||
import '../../core/extension/uint8list.dart';
|
||||
import '../../core/provider_base.dart';
|
||||
import '../../core/utils/server.dart';
|
||||
import '../../locator.dart';
|
||||
import '../model/server/cpu_status.dart';
|
||||
import '../model/server/disk_info.dart';
|
||||
import '../model/server/memory.dart';
|
||||
import '../model/server/net_speed.dart';
|
||||
import '../model/server/server.dart';
|
||||
import '../model/server/server_private_info.dart';
|
||||
import '../model/server/snippet.dart';
|
||||
import '../model/server/tcp_status.dart';
|
||||
import '../res/server_cmd.dart';
|
||||
import '../res/status.dart';
|
||||
import '../store/server.dart';
|
||||
import '../store/setting.dart';
|
||||
|
||||
class ServerProvider extends BusyProvider {
|
||||
List<ServerInfo> _servers = [];
|
||||
List<ServerInfo> get servers => _servers;
|
||||
List<Server> _servers = [];
|
||||
List<Server> get servers => _servers;
|
||||
final _TryLimiter _limiter = _TryLimiter();
|
||||
|
||||
Timer? _timer;
|
||||
|
||||
final logger = Logger('ServerProvider');
|
||||
|
||||
Memory get emptyMemory =>
|
||||
Memory(total: 1, used: 0, free: 1, cache: 0, avail: 1);
|
||||
|
||||
NetSpeedPart get emptyNetSpeedPart => NetSpeedPart('', 0, 0, 0);
|
||||
|
||||
NetSpeed get emptyNetSpeed =>
|
||||
NetSpeed([emptyNetSpeedPart], [emptyNetSpeedPart]);
|
||||
|
||||
CpuStatus get emptyCpuStatus => CpuStatus('cpu', 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
Cpu2Status get emptyCpu2Status =>
|
||||
Cpu2Status([emptyCpuStatus], [emptyCpuStatus], '');
|
||||
|
||||
ServerStatus get emptyStatus => ServerStatus(
|
||||
emptyCpu2Status,
|
||||
emptyMemory,
|
||||
'Loading...',
|
||||
'',
|
||||
[DiskInfo('/', '/', 0, '0', '0', '0')],
|
||||
TcpStatus(0, 0, 0, 0),
|
||||
emptyNetSpeed);
|
||||
final _logger = Logger('SERVER');
|
||||
|
||||
Future<void> loadLocalData() async {
|
||||
setBusyState(true);
|
||||
final infos = locator<ServerStore>().fetch();
|
||||
_servers = List.generate(infos.length, (index) => genInfo(infos[index]));
|
||||
_servers = List.generate(infos.length, (index) => genServer(infos[index]));
|
||||
setBusyState(false);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
ServerInfo genInfo(ServerPrivateInfo spi) {
|
||||
return ServerInfo(
|
||||
spi, emptyStatus, null, ServerConnectionState.disconnected);
|
||||
Server genServer(ServerPrivateInfo spi) {
|
||||
return Server(spi, initStatus, null, ServerState.disconnected);
|
||||
}
|
||||
|
||||
Future<SSHClient> genClient(ServerPrivateInfo spi) async {
|
||||
final socket = await SSHSocket.connect(spi.ip, spi.port);
|
||||
if (spi.pubKeyId == null) {
|
||||
return SSHClient(socket,
|
||||
username: spi.user, onPasswordRequest: () => spi.pwd);
|
||||
}
|
||||
final key = locator<PrivateKeyStore>().get(spi.pubKeyId!);
|
||||
return SSHClient(socket,
|
||||
username: spi.user,
|
||||
identities: await compute(loadIndentity, key.privateKey));
|
||||
}
|
||||
|
||||
Future<void> refreshData({ServerPrivateInfo? spi}) async {
|
||||
Future<void> refreshData(
|
||||
{ServerPrivateInfo? spi, bool onlyFailed = false}) async {
|
||||
if (spi != null) {
|
||||
_getData(spi);
|
||||
await _getData(spi);
|
||||
return;
|
||||
}
|
||||
await Future.wait(_servers.map((s) async {
|
||||
await _getData(s.info);
|
||||
if (onlyFailed) {
|
||||
if (s.cs != ServerState.failed) return;
|
||||
_limiter.resetTryTimes(s.spi.id);
|
||||
}
|
||||
await _getData(s.spi);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -128,262 +75,209 @@ class ServerProvider extends BusyProvider {
|
||||
|
||||
void setDisconnected() {
|
||||
for (var i = 0; i < _servers.length; i++) {
|
||||
_servers[i].connectionState = ServerConnectionState.disconnected;
|
||||
_servers[i].cs = ServerState.disconnected;
|
||||
}
|
||||
_limiter.clear();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void closeServer({ServerPrivateInfo? spi}) {
|
||||
if (spi == null) {
|
||||
for (var i = 0; i < _servers.length; i++) {
|
||||
_servers[i].client?.close();
|
||||
_servers[i].client = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
final idx = getServerIdx(spi.id);
|
||||
_servers[idx].client?.close();
|
||||
_servers[idx].client = null;
|
||||
}
|
||||
|
||||
void addServer(ServerPrivateInfo spi) {
|
||||
_servers.add(genInfo(spi));
|
||||
locator<ServerStore>().put(spi);
|
||||
_servers.add(genServer(spi));
|
||||
notifyListeners();
|
||||
locator<ServerStore>().put(spi);
|
||||
refreshData(spi: spi);
|
||||
}
|
||||
|
||||
void delServer(ServerPrivateInfo info) {
|
||||
final idx = _servers.indexWhere((s) => s.info == info);
|
||||
if (idx == -1) return;
|
||||
void delServer(String id) {
|
||||
final idx = getServerIdx(id);
|
||||
_servers[idx].client?.close();
|
||||
_servers.removeAt(idx);
|
||||
notifyListeners();
|
||||
locator<ServerStore>().delete(info);
|
||||
locator<ServerStore>().delete(id);
|
||||
}
|
||||
|
||||
Future<void> updateServer(
|
||||
ServerPrivateInfo old, ServerPrivateInfo newSpi) async {
|
||||
final idx = _servers.indexWhere((e) => e.info == old);
|
||||
final idx = _servers.indexWhere((e) => e.spi.id == old.id);
|
||||
if (idx < 0) {
|
||||
throw RangeError.index(idx, _servers);
|
||||
}
|
||||
_servers[idx].info = newSpi;
|
||||
_servers[idx].spi = newSpi;
|
||||
locator<ServerStore>().update(old, newSpi);
|
||||
_servers[idx].client = await genClient(newSpi);
|
||||
notifyListeners();
|
||||
refreshData(spi: newSpi);
|
||||
}
|
||||
|
||||
int getServerIdx(String id) {
|
||||
final idx = _servers.indexWhere((s) => s.spi.id == id);
|
||||
if (idx < 0) {
|
||||
throw Exception('Server not found: $id');
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
Server getServer(String id) => _servers[getServerIdx(id)];
|
||||
|
||||
Future<void> _getData(ServerPrivateInfo spi) async {
|
||||
final s = _servers.firstWhere((element) => element.info == spi);
|
||||
final state = s.connectionState;
|
||||
if (state == ServerConnectionState.failed ||
|
||||
state == ServerConnectionState.disconnected) {
|
||||
s.connectionState = ServerConnectionState.connecting;
|
||||
final sid = spi.id;
|
||||
final s = getServer(sid);
|
||||
final state = s.cs;
|
||||
if (state.shouldConnect) {
|
||||
if (!_limiter.shouldTry(sid)) {
|
||||
s.cs = ServerState.failed;
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
s.cs = ServerState.connecting;
|
||||
notifyListeners();
|
||||
final time1 = DateTime.now();
|
||||
|
||||
try {
|
||||
// try to connect
|
||||
final time1 = DateTime.now();
|
||||
s.client = await genClient(spi);
|
||||
final time2 = DateTime.now();
|
||||
logger.info(
|
||||
'Connected to [${spi.name}] in [${time2.difference(time1).toString()}].');
|
||||
s.connectionState = ServerConnectionState.connected;
|
||||
final writeResult = await s.client!
|
||||
.run("echo '$shellCmd' > $shellPath && chmod +x $shellPath")
|
||||
.string;
|
||||
final spentTime = time2.difference(time1).inMilliseconds;
|
||||
_logger.info('Connected to [$sid] in $spentTime ms.');
|
||||
|
||||
// after connected
|
||||
s.cs = ServerState.connected;
|
||||
final writeResult = await s.client!.run(installShellCmd).string;
|
||||
|
||||
// if write failed
|
||||
if (writeResult.isNotEmpty) {
|
||||
throw Exception(writeResult);
|
||||
}
|
||||
_limiter.resetTryTimes(sid);
|
||||
} catch (e) {
|
||||
s.connectionState = ServerConnectionState.failed;
|
||||
s.status.failedInfo = '$e ## ';
|
||||
logger.warning(e);
|
||||
s.cs = ServerState.failed;
|
||||
s.status.failedInfo = '$e';
|
||||
_logger.warning(e);
|
||||
} finally {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// if client is null, return
|
||||
if (s.client == null) return;
|
||||
// run script to get server status
|
||||
final raw = await s.client!.run("sh $shellPath").string;
|
||||
final segments = raw.split(seperator).map((e) => e.trim()).toList();
|
||||
if (raw.isEmpty || segments.length == 1) {
|
||||
s.connectionState = ServerConnectionState.failed;
|
||||
s.cs = ServerState.failed;
|
||||
if (s.status.failedInfo == null || s.status.failedInfo!.isEmpty) {
|
||||
s.status.failedInfo = 'No data received';
|
||||
s.status.failedInfo = 'Seperate segments failed, raw:\n$raw';
|
||||
}
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
// remove first empty segment
|
||||
segments.removeAt(0);
|
||||
|
||||
try {
|
||||
_getCPU(spi, segments[2], segments[7], segments[8]);
|
||||
_getMem(spi, segments[6]);
|
||||
_getSysVer(spi, segments[1]);
|
||||
_getUpTime(spi, segments[3]);
|
||||
_getDisk(spi, segments[5]);
|
||||
_getTcp(spi, segments[4]);
|
||||
_getNetSpeed(spi, segments[0]);
|
||||
_getCPU(sid, segments[2], segments[7], segments[8]);
|
||||
_getMem(sid, segments[6]);
|
||||
_getSysVer(sid, segments[1]);
|
||||
_getUpTime(sid, segments[3]);
|
||||
_getDisk(sid, segments[5]);
|
||||
_getTcp(sid, segments[4]);
|
||||
_getNetSpeed(sid, segments[0]);
|
||||
} catch (e) {
|
||||
s.connectionState = ServerConnectionState.failed;
|
||||
s.cs = ServerState.failed;
|
||||
s.status.failedInfo = e.toString();
|
||||
logger.warning(e);
|
||||
_logger.warning(e);
|
||||
rethrow;
|
||||
} finally {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/// [raw] example:
|
||||
/// Inter-| Receive | Transmit
|
||||
/// face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
|
||||
/// lo: 45929941 269112 0 0 0 0 0 0 45929941 269112 0 0 0 0 0 0
|
||||
/// eth0: 48481023 505772 0 0 0 0 0 0 36002262 202307 0 0 0 0 0 0
|
||||
/// 1635752901
|
||||
Future<void> _getNetSpeed(ServerPrivateInfo spi, String raw) async {
|
||||
final info = _servers.firstWhere((e) => e.info == spi);
|
||||
info.status.netSpeed.update(await compute(_parseNetSpeed, raw));
|
||||
Future<void> _getNetSpeed(String id, String raw) async {
|
||||
final net = await compute(parseNetSpeed, raw);
|
||||
getServer(id).status.netSpeed.update(net);
|
||||
}
|
||||
|
||||
void _getSysVer(ServerPrivateInfo spi, String raw) {
|
||||
final info = _servers.firstWhere((e) => e.info == spi);
|
||||
void _getSysVer(String id, String raw) {
|
||||
final s = raw.split('=');
|
||||
if (s.length == 2) {
|
||||
info.status.sysVer = s[1].replaceAll('"', '').replaceFirst('\n', '');
|
||||
final ver = s[1].replaceAll('"', '').replaceFirst('\n', '');
|
||||
getServer(id).status.sysVer = ver;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _getCPU(ServerPrivateInfo spi, String raw, String tempType,
|
||||
String tempValue) async {
|
||||
final info = _servers.firstWhere((e) => e.info == spi);
|
||||
final cpus = await compute(_parseCPU, raw);
|
||||
Future<void> _getCPU(
|
||||
String id, String raw, String tempType, String tempValue) async {
|
||||
final cpus = await compute(parseCPU, raw);
|
||||
final temp = await compute(parseCPUTemp, [tempType, tempValue]);
|
||||
|
||||
if (cpus.isNotEmpty) {
|
||||
info.status.cpu2Status
|
||||
.update(cpus, await compute(_getCPUTemp, [tempType, tempValue]));
|
||||
getServer(id).status.cpu.update(cpus, temp);
|
||||
}
|
||||
}
|
||||
|
||||
void _getUpTime(ServerPrivateInfo spi, String raw) {
|
||||
_servers.firstWhere((e) => e.info == spi).status.uptime =
|
||||
raw.split('up ')[1].split(', ')[0];
|
||||
void _getUpTime(String id, String raw) {
|
||||
getServer(id).status.uptime = raw.split('up ')[1].split(', ')[0];
|
||||
}
|
||||
|
||||
Future<void> _getTcp(ServerPrivateInfo spi, String raw) async {
|
||||
final info = _servers.firstWhere((e) => e.info == spi);
|
||||
final status = await compute(_parseTcp, raw);
|
||||
Future<void> _getTcp(String id, String raw) async {
|
||||
final status = await compute(parseTcp, raw);
|
||||
if (status != null) {
|
||||
info.status.tcp = status;
|
||||
getServer(id).status.tcp = status;
|
||||
}
|
||||
}
|
||||
|
||||
void _getDisk(ServerPrivateInfo spi, String raw) {
|
||||
final info = _servers.firstWhere((e) => e.info == spi);
|
||||
final list = <DiskInfo>[];
|
||||
final items = raw.split('\n');
|
||||
for (var item in items) {
|
||||
if (items.indexOf(item) == 0 || item.isEmpty) {
|
||||
continue;
|
||||
}
|
||||
final vals = item.split(numReg);
|
||||
list.add(DiskInfo(vals[0], vals[5],
|
||||
int.parse(vals[4].replaceFirst('%', '')), vals[2], vals[1], vals[3]));
|
||||
Future<void> _getDisk(String id, String raw) async {
|
||||
getServer(id).status.disk = await compute(parseDisk, raw);
|
||||
}
|
||||
|
||||
Future<void> _getMem(String id, String raw) async {
|
||||
final s = getServer(id);
|
||||
s.status.mem = await compute(parseMem, raw);
|
||||
s.status.swap = await compute(parseSwap, raw);
|
||||
}
|
||||
|
||||
Future<String?> runSnippet(String id, Snippet snippet) async {
|
||||
final client = getServer(id).client;
|
||||
if (client == null) {
|
||||
return null;
|
||||
}
|
||||
info.status.disk = list;
|
||||
}
|
||||
|
||||
Future<void> _getMem(ServerPrivateInfo spi, String raw) async {
|
||||
final info = _servers.firstWhere((e) => e.info == spi);
|
||||
final mem = await compute(_parseMem, raw);
|
||||
info.status.memory = mem;
|
||||
}
|
||||
|
||||
Future<String?> runSnippet(ServerPrivateInfo spi, Snippet snippet) async {
|
||||
return await _servers
|
||||
.firstWhere((element) => element.info == spi)
|
||||
.client!
|
||||
.run(snippet.script)
|
||||
.string;
|
||||
return await client.run(snippet.script).string;
|
||||
}
|
||||
}
|
||||
|
||||
Memory _parseMem(String raw) {
|
||||
final items = raw.split('\n').map((e) => memItemReg.firstMatch(e)).toList();
|
||||
final total = int.parse(
|
||||
items.firstWhere((e) => e?.group(1) == 'MemTotal:')?.group(2) ?? '1');
|
||||
final free = int.parse(
|
||||
items.firstWhere((e) => e?.group(1) == 'MemFree:')?.group(2) ?? '0');
|
||||
final cached = int.parse(
|
||||
items.firstWhere((e) => e?.group(1) == 'Cached:')?.group(2) ?? '0');
|
||||
final available = int.parse(
|
||||
items.firstWhere((e) => e?.group(1) == 'MemAvailable:')?.group(2) ?? '0');
|
||||
return Memory(
|
||||
total: total,
|
||||
used: total - available,
|
||||
free: free,
|
||||
cache: cached,
|
||||
avail: available);
|
||||
}
|
||||
class _TryLimiter {
|
||||
final Map<String, int> _triedTimes = {};
|
||||
|
||||
TcpStatus? _parseTcp(String raw) {
|
||||
final lines = raw.split('\n');
|
||||
final idx = lines.lastWhere((element) => element.startsWith('Tcp:'),
|
||||
orElse: () => '');
|
||||
if (idx != '') {
|
||||
final vals = idx.split(numReg);
|
||||
return TcpStatus(vals[5].i, vals[6].i, vals[7].i, vals[8].i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
List<CpuStatus> _parseCPU(String raw) {
|
||||
final List<CpuStatus> cpus = [];
|
||||
|
||||
for (var item in raw.split('\n')) {
|
||||
if (item == '') break;
|
||||
final id = item.split(' ').first;
|
||||
final matches = item.replaceFirst(id, '').trim().split(' ');
|
||||
cpus.add(CpuStatus(
|
||||
id,
|
||||
int.parse(matches[0]),
|
||||
int.parse(matches[1]),
|
||||
int.parse(matches[2]),
|
||||
int.parse(matches[3]),
|
||||
int.parse(matches[4]),
|
||||
int.parse(matches[5]),
|
||||
int.parse(matches[6])));
|
||||
}
|
||||
return cpus;
|
||||
}
|
||||
|
||||
String _getCPUTemp(List<String> segments) {
|
||||
const noMatch = "/sys/class/thermal/thermal_zone*/type";
|
||||
final type = segments[0];
|
||||
final value = segments[1];
|
||||
// Not support to get CPU temperature
|
||||
if (value.contains(noMatch) ||
|
||||
type.contains(noMatch) ||
|
||||
value.isEmpty ||
|
||||
type.isEmpty) {
|
||||
return '';
|
||||
}
|
||||
final split = type.split('\n');
|
||||
int idx = 0;
|
||||
for (var item in split) {
|
||||
if (item.contains(cpuTempReg)) {
|
||||
break;
|
||||
bool shouldTry(String id) {
|
||||
final maxCount = locator<SettingStore>().maxRetryCount.fetch()!;
|
||||
if (maxCount <= 0) {
|
||||
return true;
|
||||
}
|
||||
idx++;
|
||||
final times = _triedTimes[id] ?? 0;
|
||||
if (times >= maxCount) {
|
||||
return false;
|
||||
}
|
||||
_triedTimes[id] = times + 1;
|
||||
return true;
|
||||
}
|
||||
final valueSplited = value.split('\n');
|
||||
if (idx >= valueSplited.length) return '';
|
||||
final temp = int.tryParse(valueSplited[idx].trim());
|
||||
if (temp == null) return '';
|
||||
return '${(temp / 1000).toStringAsFixed(1)}°C';
|
||||
}
|
||||
|
||||
List<NetSpeedPart> _parseNetSpeed(String raw) {
|
||||
final split = raw.split('\n');
|
||||
final deviceCount = split.length - 3;
|
||||
if (deviceCount < 1) return [];
|
||||
final time = int.parse(split[split.length - 1]);
|
||||
final results = <NetSpeedPart>[];
|
||||
for (int idx = 2; idx < deviceCount; idx++) {
|
||||
final data = split[idx].trim().split(':');
|
||||
final device = data.first;
|
||||
final bytes = data.last.trim().split(' ');
|
||||
bytes.removeWhere((element) => element == '');
|
||||
final bytesIn = int.parse(bytes.first);
|
||||
final bytesOut = int.parse(bytes[8]);
|
||||
results.add(NetSpeedPart(device, bytesIn, bytesOut, time));
|
||||
void resetTryTimes(String id) {
|
||||
_triedTimes[id] = 0;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_triedTimes.clear();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'package:toolbox/core/provider_base.dart';
|
||||
import 'package:toolbox/data/model/sftp/download_status.dart';
|
||||
import 'package:toolbox/data/model/sftp/download_worker.dart';
|
||||
|
||||
class SftpDownloadProvider extends ProviderBase {
|
||||
import '../model/sftp/download_item.dart';
|
||||
import '../model/sftp/download_status.dart';
|
||||
|
||||
class SftpProvider extends ProviderBase {
|
||||
final List<SftpDownloadStatus> _status = [];
|
||||
List<SftpDownloadStatus> get status => _status;
|
||||
|
||||
|
||||
29
lib/data/provider/virtual_keyboard.dart
Normal file
29
lib/data/provider/virtual_keyboard.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:xterm/core.dart';
|
||||
|
||||
class VirtualKeyboard extends TerminalInputHandler with ChangeNotifier {
|
||||
VirtualKeyboard();
|
||||
|
||||
bool ctrl = false;
|
||||
bool alt = false;
|
||||
|
||||
void reset(TerminalKeyboardEvent e) {
|
||||
if (e.ctrl) {
|
||||
ctrl = false;
|
||||
}
|
||||
if (e.alt) {
|
||||
alt = false;
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
String? call(TerminalKeyboardEvent event) {
|
||||
final e = event.copyWith(
|
||||
ctrl: event.ctrl || ctrl,
|
||||
alt: event.alt || alt,
|
||||
);
|
||||
reset(e);
|
||||
return defaultInputHandler.call(e);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 159;
|
||||
static const String engine =
|
||||
"Flutter 3.3.4 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision eb6d86ee27 (5 weeks ago) • 2022-10-04 22:31:45 -0700\nEngine • revision c08d7d5efc\nTools • Dart 2.18.2 • DevTools 2.15.0\n";
|
||||
static const String buildAt = "2022-11-07 19:55:21.553007";
|
||||
static const int modifications = 0;
|
||||
static const int build = 243;
|
||||
static const String engine = "Flutter 3.7.7 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 2ad6cd72c0 (13 days ago) • 2023-03-08 09:41:59 -0800\nEngine • revision 1837b5be5f\nTools • Dart 2.19.4 • DevTools 2.20.1\n";
|
||||
static const String buildAt = "2023-03-21 15:18:42.802605";
|
||||
static const int modifications = 5;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
import 'package:toolbox/data/store/setting.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
|
||||
Color get primaryColor => Color(locator<SettingStore>().primaryColor.fetch()!);
|
||||
import '../model/app/dynamic_color.dart';
|
||||
|
||||
class DynamicColor {
|
||||
/// 白天模式显示的颜色
|
||||
Color light;
|
||||
Color primaryColor = Color(locator<SettingStore>().primaryColor.fetch()!);
|
||||
|
||||
/// 暗黑模式显示的颜色
|
||||
Color dark;
|
||||
|
||||
DynamicColor(this.light, this.dark);
|
||||
|
||||
resolve(BuildContext context) => isDarkMode(context) ? dark : light;
|
||||
}
|
||||
|
||||
final mainColor = DynamicColor(Colors.black87, Colors.white70);
|
||||
final progressColor = DynamicColor(Colors.grey.shade100, Colors.grey);
|
||||
final contentColor = DynamicColor(Colors.black87, Colors.white70);
|
||||
final bgColor = DynamicColor(Colors.white, Colors.black);
|
||||
final progressColor = DynamicColor(Colors.grey.shade100, Colors.white10);
|
||||
|
||||
28
lib/data/res/error.dart
Normal file
28
lib/data/res/error.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
enum ErrFrom {
|
||||
unknown,
|
||||
apt,
|
||||
docker,
|
||||
sftp,
|
||||
ssh,
|
||||
}
|
||||
|
||||
abstract class Err<T> {
|
||||
final ErrFrom from;
|
||||
final T type;
|
||||
final String? message;
|
||||
|
||||
Err({required this.from, required this.type, this.message});
|
||||
}
|
||||
|
||||
enum DockerErrType {
|
||||
unknown,
|
||||
noClient,
|
||||
notInstalled,
|
||||
invalidVersion,
|
||||
cmdNoPrefix
|
||||
}
|
||||
|
||||
class DockerErr extends Err<DockerErrType> {
|
||||
DockerErr({required DockerErrType type, String? message})
|
||||
: super(from: ErrFrom.docker, type: type, message: message);
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
const TextStyle size18 = TextStyle(fontSize: 18);
|
||||
const TextStyle grey = TextStyle(color: Colors.grey);
|
||||
@@ -1,3 +0,0 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
final appIcon = Image.asset('assets/app_icon.png');
|
||||
@@ -1,26 +0,0 @@
|
||||
final linuxIcons = LinuxIcons([
|
||||
'ubuntu',
|
||||
'arch',
|
||||
'centos',
|
||||
'debian',
|
||||
'fedora',
|
||||
'opensuse',
|
||||
'kali',
|
||||
'wrt',
|
||||
'armbian'
|
||||
]);
|
||||
|
||||
class LinuxIcons {
|
||||
List<String> db;
|
||||
|
||||
LinuxIcons(this.db);
|
||||
|
||||
String? search(String sysVer) {
|
||||
for (var item in db) {
|
||||
if (sysVer.toLowerCase().contains(item)) {
|
||||
return 'assets/linux/$item.png';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
class DropdownBtnItem {
|
||||
final String text;
|
||||
final IconData icon;
|
||||
|
||||
const DropdownBtnItem({
|
||||
required this.text,
|
||||
required this.icon,
|
||||
});
|
||||
|
||||
Widget get build => Row(
|
||||
children: [
|
||||
Icon(icon, color: primaryColor),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
text,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
import '../../view/widget/dropdown_menu.dart';
|
||||
|
||||
class ServerTabMenuItems {
|
||||
static const List<DropdownBtnItem> firstItems = [sftp, snippet, apt, docker];
|
||||
static const List<DropdownBtnItem> firstItems = [sftp, snippet, pkg, docker];
|
||||
static const List<DropdownBtnItem> secondItems = [edit];
|
||||
|
||||
static const sftp =
|
||||
DropdownBtnItem(text: 'SFTP', icon: Icons.insert_drive_file);
|
||||
static const snippet = DropdownBtnItem(text: 'Snippet', icon: Icons.label);
|
||||
static const apt =
|
||||
DropdownBtnItem(text: 'Apt/Yum', icon: Icons.system_security_update);
|
||||
static const snippet = DropdownBtnItem(text: 'Snippet', icon: Icons.code);
|
||||
static const pkg =
|
||||
DropdownBtnItem(text: 'Pkg', icon: Icons.system_security_update);
|
||||
static const docker =
|
||||
DropdownBtnItem(text: 'Docker', icon: Icons.view_agenda);
|
||||
static const edit = DropdownBtnItem(text: 'Edit', icon: Icons.edit);
|
||||
@@ -42,3 +22,22 @@ class DockerMenuItems {
|
||||
static const start = DropdownBtnItem(text: 'Start', icon: Icons.play_arrow);
|
||||
static const stop = DropdownBtnItem(text: 'Stop', icon: Icons.stop);
|
||||
}
|
||||
|
||||
String getDropdownBtnText(S s, String text) {
|
||||
switch (text) {
|
||||
case 'Snippet':
|
||||
return s.snippet;
|
||||
case 'Pkg':
|
||||
return s.pkg;
|
||||
case 'Remove':
|
||||
return s.delete;
|
||||
case 'Start':
|
||||
return s.start;
|
||||
case 'Stop':
|
||||
return s.stop;
|
||||
case 'Edit':
|
||||
return s.edit;
|
||||
default:
|
||||
return text;
|
||||
}
|
||||
}
|
||||
8
lib/data/res/misc.dart
Normal file
8
lib/data/res/misc.dart
Normal file
@@ -0,0 +1,8 @@
|
||||
/// RegExp for number
|
||||
final numReg = RegExp(r'\s{1,}');
|
||||
|
||||
/// Private Key max allowed size is 20kb
|
||||
const privateKeyMaxSize = 20 * 1024;
|
||||
|
||||
/// Max debug log lines
|
||||
const maxDebugLogLines = 100;
|
||||
@@ -1,3 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
const roundRectCardPadding = EdgeInsets.symmetric(horizontal: 17);
|
||||
@@ -8,3 +8,8 @@ Future<Directory> get sftpDownloadDir async {
|
||||
final dir = Directory('${(await docDir).path}/sftp');
|
||||
return dir.create(recursive: true);
|
||||
}
|
||||
|
||||
Future<Directory> get fontDir async {
|
||||
final dir = Directory('${(await docDir).path}/font');
|
||||
return dir.create(recursive: true);
|
||||
}
|
||||
|
||||
32
lib/data/res/server_cmd.dart
Normal file
32
lib/data/res/server_cmd.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'build_data.dart';
|
||||
|
||||
const seperator = 'SrvBox';
|
||||
const serverBoxDir = r'$HOME/.config/server_box';
|
||||
const shellPath = '$serverBoxDir/mobile_app.sh';
|
||||
const installShellCmd =
|
||||
"mkdir -p $serverBoxDir && echo '$shellCmd' > $shellPath && chmod +x $shellPath";
|
||||
|
||||
const shellCmd = """
|
||||
# Script for app `${BuildData.name}`
|
||||
# Delete this file while app is running will cause app crash
|
||||
|
||||
export LANG=en_US.utf-8
|
||||
echo $seperator
|
||||
cat /proc/net/dev && date +%s
|
||||
echo $seperator
|
||||
cat /etc/os-release | grep PRETTY_NAME
|
||||
echo $seperator
|
||||
cat /proc/stat | grep cpu
|
||||
echo $seperator
|
||||
uptime
|
||||
echo $seperator
|
||||
cat /proc/net/snmp
|
||||
echo $seperator
|
||||
df -h
|
||||
echo $seperator
|
||||
cat /proc/meminfo
|
||||
echo $seperator
|
||||
cat /sys/class/thermal/thermal_zone*/type
|
||||
echo $seperator
|
||||
cat /sys/class/thermal/thermal_zone*/temp
|
||||
""";
|
||||
55
lib/data/res/status.dart
Normal file
55
lib/data/res/status.dart
Normal file
@@ -0,0 +1,55 @@
|
||||
import '../model/server/cpu_status.dart';
|
||||
import '../model/server/disk_info.dart';
|
||||
import '../model/server/memory.dart';
|
||||
import '../model/server/net_speed.dart';
|
||||
import '../model/server/server_status.dart';
|
||||
import '../model/server/tcp_status.dart';
|
||||
|
||||
Memory get _initMemory => Memory(
|
||||
total: 1,
|
||||
used: 0,
|
||||
free: 1,
|
||||
cache: 0,
|
||||
avail: 1,
|
||||
);
|
||||
OneTimeCpuStatus get _initOneTimeCpuStatus => OneTimeCpuStatus(
|
||||
'cpu',
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
);
|
||||
CpuStatus get initCpuStatus => CpuStatus(
|
||||
[_initOneTimeCpuStatus],
|
||||
[_initOneTimeCpuStatus],
|
||||
'',
|
||||
);
|
||||
NetSpeedPart get _initNetSpeedPart => NetSpeedPart(
|
||||
'',
|
||||
BigInt.zero,
|
||||
BigInt.zero,
|
||||
BigInt.zero,
|
||||
);
|
||||
NetSpeed get initNetSpeed => NetSpeed(
|
||||
[_initNetSpeedPart],
|
||||
[_initNetSpeedPart],
|
||||
);
|
||||
Swap get _initSwap => Swap(
|
||||
total: 1,
|
||||
used: 0,
|
||||
free: 1,
|
||||
cached: 0,
|
||||
);
|
||||
ServerStatus 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,
|
||||
);
|
||||
148
lib/data/res/terminal.dart
Normal file
148
lib/data/res/terminal.dart
Normal file
@@ -0,0 +1,148 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/data/model/ssh/terminal_color.dart';
|
||||
|
||||
const termDarkTheme = TerminalUITheme(
|
||||
cursor: Color(0XAAAEAFAD),
|
||||
selection: Color(0XAAAEAFAD),
|
||||
foreground: Color(0XFFCCCCCC),
|
||||
background: Colors.black,
|
||||
searchHitBackground: Color(0XFFFFFF2B),
|
||||
searchHitBackgroundCurrent: Color(0XFF31FF26),
|
||||
searchHitForeground: Color(0XFF000000),
|
||||
);
|
||||
|
||||
const termLightTheme = TerminalUITheme(
|
||||
cursor: Color(0XFFAEAFAD),
|
||||
selection: Color.fromARGB(102, 174, 175, 173),
|
||||
foreground: Color(0XFF000000),
|
||||
background: Color(0XFFFFFFFF),
|
||||
searchHitBackground: Color(0XFFFFFF2B),
|
||||
searchHitBackgroundCurrent: Color(0XFF31FF26),
|
||||
searchHitForeground: Color(0XFF000000),
|
||||
);
|
||||
|
||||
class VGATerminalColor extends TerminalColors {
|
||||
VGATerminalColor()
|
||||
: super(
|
||||
TerminalColorsPlatform.vga,
|
||||
const Color.fromARGB(255, 170, 0, 0),
|
||||
const Color.fromARGB(255, 0, 170, 0),
|
||||
const Color.fromARGB(255, 170, 85, 0),
|
||||
const Color.fromARGB(255, 0, 0, 170),
|
||||
const Color.fromARGB(255, 170, 0, 170),
|
||||
const Color.fromARGB(255, 0, 170, 170),
|
||||
const Color.fromARGB(255, 170, 170, 170),
|
||||
const Color.fromARGB(255, 85, 85, 85),
|
||||
const Color.fromARGB(255, 255, 85, 85),
|
||||
const Color.fromARGB(255, 85, 255, 85),
|
||||
const Color.fromARGB(255, 255, 255, 85),
|
||||
const Color.fromARGB(255, 85, 85, 255),
|
||||
const Color.fromARGB(255, 255, 85, 255),
|
||||
const Color.fromARGB(255, 85, 255, 255),
|
||||
);
|
||||
}
|
||||
|
||||
class CMDTerminalColor extends TerminalColors {
|
||||
CMDTerminalColor()
|
||||
: super(
|
||||
TerminalColorsPlatform.cmd,
|
||||
const Color.fromARGB(255, 128, 0, 0),
|
||||
const Color.fromARGB(255, 0, 128, 0),
|
||||
const Color.fromARGB(255, 128, 128, 0),
|
||||
const Color.fromARGB(255, 0, 0, 128),
|
||||
const Color.fromARGB(255, 128, 0, 128),
|
||||
const Color.fromARGB(255, 0, 128, 128),
|
||||
const Color.fromARGB(255, 192, 192, 192),
|
||||
const Color.fromARGB(255, 128, 128, 128),
|
||||
const Color.fromARGB(255, 255, 0, 0),
|
||||
const Color.fromARGB(255, 0, 255, 0),
|
||||
const Color.fromARGB(255, 255, 255, 0),
|
||||
const Color.fromARGB(255, 0, 0, 255),
|
||||
const Color.fromARGB(255, 255, 0, 255),
|
||||
const Color.fromARGB(255, 0, 255, 255),
|
||||
);
|
||||
}
|
||||
|
||||
class MacOSTerminalColor extends TerminalColors {
|
||||
MacOSTerminalColor()
|
||||
: super(
|
||||
TerminalColorsPlatform.macOS,
|
||||
const Color.fromARGB(255, 194, 54, 33),
|
||||
const Color.fromARGB(255, 37, 188, 36),
|
||||
const Color.fromARGB(255, 173, 173, 39),
|
||||
const Color.fromARGB(255, 73, 46, 225),
|
||||
const Color.fromARGB(255, 211, 56, 211),
|
||||
const Color.fromARGB(255, 51, 187, 200),
|
||||
const Color.fromARGB(255, 203, 204, 205),
|
||||
const Color.fromARGB(255, 129, 131, 131),
|
||||
const Color.fromARGB(255, 252, 57, 31),
|
||||
const Color.fromARGB(255, 49, 231, 34),
|
||||
const Color.fromARGB(255, 234, 236, 35),
|
||||
const Color.fromARGB(255, 88, 51, 255),
|
||||
const Color.fromARGB(255, 249, 53, 248),
|
||||
const Color.fromARGB(255, 20, 240, 240),
|
||||
brightWhite: const Color.fromARGB(255, 233, 235, 235));
|
||||
}
|
||||
|
||||
class PuttyTerminalColor extends TerminalColors {
|
||||
PuttyTerminalColor()
|
||||
: super(
|
||||
TerminalColorsPlatform.putty,
|
||||
const Color.fromARGB(255, 187, 0, 0),
|
||||
const Color.fromARGB(255, 0, 187, 0),
|
||||
const Color.fromARGB(255, 187, 187, 0),
|
||||
const Color.fromARGB(255, 0, 0, 187),
|
||||
const Color.fromARGB(255, 187, 0, 187),
|
||||
const Color.fromARGB(255, 0, 187, 187),
|
||||
const Color.fromARGB(255, 187, 187, 187),
|
||||
const Color.fromARGB(255, 85, 85, 85),
|
||||
const Color.fromARGB(255, 255, 85, 85),
|
||||
const Color.fromARGB(255, 85, 255, 85),
|
||||
const Color.fromARGB(255, 255, 255, 85),
|
||||
const Color.fromARGB(255, 85, 85, 255),
|
||||
const Color.fromARGB(255, 255, 85, 255),
|
||||
const Color.fromARGB(255, 85, 255, 255),
|
||||
);
|
||||
}
|
||||
|
||||
class XTermTerminalColor extends TerminalColors {
|
||||
XTermTerminalColor()
|
||||
: super(
|
||||
TerminalColorsPlatform.xterm,
|
||||
const Color.fromARGB(255, 205, 0, 0),
|
||||
const Color.fromARGB(255, 0, 205, 0),
|
||||
const Color.fromARGB(255, 205, 205, 0),
|
||||
const Color.fromARGB(255, 0, 0, 238),
|
||||
const Color.fromARGB(255, 205, 0, 205),
|
||||
const Color.fromARGB(255, 0, 205, 205),
|
||||
const Color.fromARGB(255, 229, 229, 229),
|
||||
const Color.fromARGB(255, 127, 127, 127),
|
||||
const Color.fromARGB(255, 255, 0, 0),
|
||||
const Color.fromARGB(255, 0, 255, 0),
|
||||
const Color.fromARGB(255, 255, 255, 0),
|
||||
const Color.fromARGB(255, 92, 92, 255),
|
||||
const Color.fromARGB(255, 255, 0, 255),
|
||||
const Color.fromARGB(255, 0, 255, 255),
|
||||
);
|
||||
}
|
||||
|
||||
class UbuntuTerminalColor extends TerminalColors {
|
||||
UbuntuTerminalColor()
|
||||
: super(
|
||||
TerminalColorsPlatform.ubuntu,
|
||||
const Color.fromARGB(255, 222, 56, 43),
|
||||
const Color.fromARGB(255, 57, 181, 74),
|
||||
const Color.fromARGB(255, 255, 199, 6),
|
||||
const Color.fromARGB(255, 0, 111, 184),
|
||||
const Color.fromARGB(255, 118, 38, 113),
|
||||
const Color.fromARGB(255, 44, 181, 233),
|
||||
const Color.fromARGB(255, 204, 204, 204),
|
||||
const Color.fromARGB(255, 128, 128, 128),
|
||||
const Color.fromARGB(255, 255, 0, 0),
|
||||
const Color.fromARGB(255, 0, 255, 0),
|
||||
const Color.fromARGB(255, 255, 255, 0),
|
||||
const Color.fromARGB(255, 0, 0, 255),
|
||||
const Color.fromARGB(255, 255, 0, 255),
|
||||
const Color.fromARGB(255, 0, 255, 255),
|
||||
);
|
||||
}
|
||||
25
lib/data/res/ui.dart
Normal file
25
lib/data/res/ui.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Font style
|
||||
|
||||
const textSize18 = TextStyle(fontSize: 18);
|
||||
const textSize11 = TextStyle(fontSize: 11);
|
||||
const textSize13 = TextStyle(fontSize: 13);
|
||||
const textSize13Grey = TextStyle(color: Colors.grey, fontSize: 13);
|
||||
const textSize27 = TextStyle(fontSize: 27);
|
||||
|
||||
const grey = TextStyle(color: Colors.grey);
|
||||
|
||||
/// Icon
|
||||
|
||||
final appIcon = Image.asset('assets/app_icon.png');
|
||||
|
||||
/// Padding
|
||||
|
||||
const roundRectCardPadding = EdgeInsets.symmetric(horizontal: 17, vertical: 13);
|
||||
|
||||
/// SizedBox
|
||||
|
||||
const height13 = SizedBox(height: 13);
|
||||
const width13 = SizedBox(width: 13);
|
||||
const width7 = SizedBox(width: 7);
|
||||
@@ -1,7 +1,14 @@
|
||||
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 = 'https://github.com/LollipopKit/flutter_server_box/issues';
|
||||
const myGithub = 'https://github.com/lollipopkit';
|
||||
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',
|
||||
};
|
||||
|
||||
27
lib/data/res/virtual_key.dart
Normal file
27
lib/data/res/virtual_key.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:xterm/core.dart';
|
||||
|
||||
import '../model/ssh/virtual_key.dart';
|
||||
|
||||
var virtualKeys = [
|
||||
VirtualKey('Esc', key: TerminalKey.escape),
|
||||
VirtualKey('Alt', key: TerminalKey.alt, toggleable: true),
|
||||
VirtualKey('Home', key: TerminalKey.home),
|
||||
VirtualKey('Up', key: TerminalKey.arrowUp, icon: Icons.arrow_upward),
|
||||
VirtualKey('End', key: TerminalKey.end),
|
||||
// VirtualKey(
|
||||
// 'Del',
|
||||
// key: TerminalKey.delete,
|
||||
// ),
|
||||
VirtualKey('Paste', func: VirtualKeyFunc.paste, icon: Icons.paste),
|
||||
VirtualKey('Tab', key: TerminalKey.tab),
|
||||
VirtualKey('Ctrl', key: TerminalKey.control, toggleable: true),
|
||||
VirtualKey('Left', key: TerminalKey.arrowLeft, icon: Icons.arrow_back),
|
||||
VirtualKey('Down', key: TerminalKey.arrowDown, icon: Icons.arrow_downward),
|
||||
VirtualKey('Right', key: TerminalKey.arrowRight, icon: Icons.arrow_forward),
|
||||
VirtualKey(
|
||||
'IME',
|
||||
func: VirtualKeyFunc.toggleIME,
|
||||
icon: Icons.keyboard_hide,
|
||||
),
|
||||
];
|
||||
11
lib/data/store/docker.dart
Normal file
11
lib/data/store/docker.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
import 'package:toolbox/core/persistant_store.dart';
|
||||
|
||||
class DockerStore extends PersistentStore {
|
||||
String? getDockerHost(String id) {
|
||||
return box.get(id);
|
||||
}
|
||||
|
||||
void setDockerHost(String id, String host) {
|
||||
box.put(id, host);
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,15 @@ class ServerStore extends PersistentStore {
|
||||
return ss;
|
||||
}
|
||||
|
||||
void delete(ServerPrivateInfo s) {
|
||||
box.delete(s.id);
|
||||
void delete(String id) {
|
||||
box.delete(id);
|
||||
}
|
||||
|
||||
void update(ServerPrivateInfo old, ServerPrivateInfo newInfo) {
|
||||
if (!have(old)) {
|
||||
throw Exception('Old ServerPrivateInfo not found');
|
||||
}
|
||||
delete(old.id);
|
||||
put(newInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,35 @@ import 'package:toolbox/core/persistant_store.dart';
|
||||
class SettingStore extends PersistentStore {
|
||||
StoreProperty<int> get primaryColor =>
|
||||
property('primaryColor', defaultValue: Colors.deepPurpleAccent.value);
|
||||
|
||||
StoreProperty<int> get serverStatusUpdateInterval =>
|
||||
property('serverStatusUpdateInterval', defaultValue: 2);
|
||||
property('serverStatusUpdateInterval', defaultValue: 3);
|
||||
|
||||
/// Lanch page idx
|
||||
StoreProperty<int> get launchPage => property('launchPage', defaultValue: 0);
|
||||
|
||||
/// Version of store db
|
||||
StoreProperty<int> get storeVersion =>
|
||||
property('storeVersion', defaultValue: 0);
|
||||
|
||||
/// Show logo on server detail page
|
||||
StoreProperty<bool> get showDistLogo =>
|
||||
property('showDistLogo', defaultValue: true);
|
||||
|
||||
/// First time to use SSH term
|
||||
StoreProperty<bool> get firstTimeUseSshTerm =>
|
||||
property('firstTimeUseSshTerm', defaultValue: true);
|
||||
|
||||
StoreProperty<int> get termColorIdx =>
|
||||
property('termColorIdx', defaultValue: 0);
|
||||
|
||||
/// Max retry count when connect to server
|
||||
StoreProperty<int> get maxRetryCount =>
|
||||
property('maxRetryCount', defaultValue: 7);
|
||||
|
||||
/// Night mode: 0 -> auto, 1 -> light, 2 -> dark
|
||||
StoreProperty<int> get themeMode => property('themeMode', defaultValue: 0);
|
||||
|
||||
/// Font file path
|
||||
StoreProperty<String> get fontPath => property('fontPath');
|
||||
}
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
|
||||
// This is a library that looks up messages for specific locales by
|
||||
// delegating to the appropriate library.
|
||||
|
||||
// Ignore issues from commonly used lints in this file.
|
||||
// ignore_for_file:implementation_imports, file_names, unnecessary_new
|
||||
// ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering
|
||||
// ignore_for_file:argument_type_not_assignable, invalid_assignment
|
||||
// ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases
|
||||
// ignore_for_file:comment_references
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:intl/message_lookup_by_library.dart';
|
||||
import 'package:intl/src/intl_helpers.dart';
|
||||
|
||||
import 'messages_en.dart' as messages_en;
|
||||
import 'messages_zh.dart' as messages_zh;
|
||||
|
||||
typedef Future<dynamic> LibraryLoader();
|
||||
Map<String, LibraryLoader> _deferredLibraries = {
|
||||
'en': () => new Future.value(null),
|
||||
'zh': () => new Future.value(null),
|
||||
};
|
||||
|
||||
MessageLookupByLibrary? _findExact(String localeName) {
|
||||
switch (localeName) {
|
||||
case 'en':
|
||||
return messages_en.messages;
|
||||
case 'zh':
|
||||
return messages_zh.messages;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// User programs should call this before using [localeName] for messages.
|
||||
Future<bool> initializeMessages(String localeName) async {
|
||||
var availableLocale = Intl.verifiedLocale(
|
||||
localeName, (locale) => _deferredLibraries[locale] != null,
|
||||
onFailure: (_) => null);
|
||||
if (availableLocale == null) {
|
||||
return new Future.value(false);
|
||||
}
|
||||
var lib = _deferredLibraries[availableLocale];
|
||||
await (lib == null ? new Future.value(false) : lib());
|
||||
initializeInternalMessageLookup(() => new CompositeMessageLookup());
|
||||
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
|
||||
return new Future.value(true);
|
||||
}
|
||||
|
||||
bool _messagesExistFor(String locale) {
|
||||
try {
|
||||
return _findExact(locale) != null;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) {
|
||||
var actualLocale =
|
||||
Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null);
|
||||
if (actualLocale == null) return null;
|
||||
return _findExact(actualLocale);
|
||||
}
|
||||
@@ -1,232 +0,0 @@
|
||||
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
|
||||
// This is a library that provides messages for a en locale. All the
|
||||
// messages from the main program should be duplicated here with the same
|
||||
// function name.
|
||||
|
||||
// Ignore issues from commonly used lints in this file.
|
||||
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
|
||||
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
|
||||
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
|
||||
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
|
||||
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:intl/message_lookup_by_library.dart';
|
||||
|
||||
final messages = new MessageLookup();
|
||||
|
||||
typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
|
||||
|
||||
class MessageLookup extends MessageLookupByLibrary {
|
||||
String get localeName => 'en';
|
||||
|
||||
static String m0(fileName) => "Download [${fileName}] to local?";
|
||||
|
||||
static String m1(runningCount, stoppedCount) =>
|
||||
"${runningCount} running, ${stoppedCount} container stopped.";
|
||||
|
||||
static String m2(count) => "${count} container running.";
|
||||
|
||||
static String m3(percent, size) => "${percent}% of ${size}";
|
||||
|
||||
static String m4(count) => "Found ${count} update";
|
||||
|
||||
static String m5(code) => "request failed, status code: ${code}";
|
||||
|
||||
static String m6(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 m7(myGithub) => "\nMade with ❤️ by ${myGithub}";
|
||||
|
||||
static String m8(url) => "Please report bugs on ${url}";
|
||||
|
||||
static String m9(date) => "Are you sure to restore from ${date} ?";
|
||||
|
||||
static String m10(time) => "Spent time: ${time}";
|
||||
|
||||
static String m11(name) => "Are you sure to delete [${name}]?";
|
||||
|
||||
static String m12(server) => "Are you sure to delete server [${server}]?";
|
||||
|
||||
static String m13(build) => "Found: v1.0.${build}, click to update";
|
||||
|
||||
static String m14(build) => "Current: v1.0.${build}";
|
||||
|
||||
static String m15(build) => "Current: v1.0.${build}, is up to date";
|
||||
|
||||
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
|
||||
"aboutThanks": MessageLookupByLibrary.simpleMessage(
|
||||
"\nAll rights reserved.\n\nThanks to the following people who participated in the test."),
|
||||
"addAServer": MessageLookupByLibrary.simpleMessage("add a server"),
|
||||
"addPrivateKey":
|
||||
MessageLookupByLibrary.simpleMessage("Add private key"),
|
||||
"alreadyLastDir":
|
||||
MessageLookupByLibrary.simpleMessage("Already in last directory."),
|
||||
"appPrimaryColor":
|
||||
MessageLookupByLibrary.simpleMessage("App primary color"),
|
||||
"attention": MessageLookupByLibrary.simpleMessage("Attention"),
|
||||
"backDir": MessageLookupByLibrary.simpleMessage("Back"),
|
||||
"backup": MessageLookupByLibrary.simpleMessage("Backup"),
|
||||
"backupTip": MessageLookupByLibrary.simpleMessage(
|
||||
"The exported data is simply encrypted. \nPlease keep it safe.\nRestoring will not overwrite existing data (except setting)."),
|
||||
"backupVersionNotMatch": MessageLookupByLibrary.simpleMessage(
|
||||
"Backup version is not match."),
|
||||
"cancel": MessageLookupByLibrary.simpleMessage("Cancel"),
|
||||
"choose": MessageLookupByLibrary.simpleMessage("Choose"),
|
||||
"chooseDestination":
|
||||
MessageLookupByLibrary.simpleMessage("Choose destination"),
|
||||
"choosePrivateKey":
|
||||
MessageLookupByLibrary.simpleMessage("Choose private key"),
|
||||
"clear": MessageLookupByLibrary.simpleMessage("Clear"),
|
||||
"clickSee": MessageLookupByLibrary.simpleMessage("Click here"),
|
||||
"close": MessageLookupByLibrary.simpleMessage("Close"),
|
||||
"containerStatus":
|
||||
MessageLookupByLibrary.simpleMessage("Container status"),
|
||||
"convert": MessageLookupByLibrary.simpleMessage("Convert"),
|
||||
"copy": MessageLookupByLibrary.simpleMessage("Copy"),
|
||||
"copyPath": MessageLookupByLibrary.simpleMessage("Copy path"),
|
||||
"createFile": MessageLookupByLibrary.simpleMessage("Create file"),
|
||||
"createFolder": MessageLookupByLibrary.simpleMessage("Create folder"),
|
||||
"currentMode": MessageLookupByLibrary.simpleMessage("Current Mode"),
|
||||
"debug": MessageLookupByLibrary.simpleMessage("Debug"),
|
||||
"decode": MessageLookupByLibrary.simpleMessage("Decode"),
|
||||
"delete": MessageLookupByLibrary.simpleMessage("Delete"),
|
||||
"disconnected": MessageLookupByLibrary.simpleMessage("Disconnected"),
|
||||
"dl2Local": m0,
|
||||
"dockerStatusRunningAndStoppedFmt": m1,
|
||||
"dockerStatusRunningFmt": m2,
|
||||
"download": MessageLookupByLibrary.simpleMessage("Download"),
|
||||
"downloadFinished":
|
||||
MessageLookupByLibrary.simpleMessage("Download finished"),
|
||||
"downloadStatus": m3,
|
||||
"edit": MessageLookupByLibrary.simpleMessage("Edit"),
|
||||
"encode": MessageLookupByLibrary.simpleMessage("Encode"),
|
||||
"error": MessageLookupByLibrary.simpleMessage("Error"),
|
||||
"exampleName": MessageLookupByLibrary.simpleMessage("Example name"),
|
||||
"experimentalFeature":
|
||||
MessageLookupByLibrary.simpleMessage("Experimental feature"),
|
||||
"export": MessageLookupByLibrary.simpleMessage("Export"),
|
||||
"feedback": MessageLookupByLibrary.simpleMessage("Feedback"),
|
||||
"feedbackOnGithub": MessageLookupByLibrary.simpleMessage(
|
||||
"If you have any questions, please feedback on Github."),
|
||||
"fieldMustNotEmpty": MessageLookupByLibrary.simpleMessage(
|
||||
"These fields must not be empty."),
|
||||
"files": MessageLookupByLibrary.simpleMessage("Files"),
|
||||
"foundNUpdate": m4,
|
||||
"go": MessageLookupByLibrary.simpleMessage("Go"),
|
||||
"goSftpDlPage":
|
||||
MessageLookupByLibrary.simpleMessage("Go to SFTP download page?"),
|
||||
"host": MessageLookupByLibrary.simpleMessage("Host"),
|
||||
"httpFailedWithCode": m5,
|
||||
"import": MessageLookupByLibrary.simpleMessage("Import"),
|
||||
"importAndExport":
|
||||
MessageLookupByLibrary.simpleMessage("Import and Export"),
|
||||
"inputDomainHere":
|
||||
MessageLookupByLibrary.simpleMessage("Input Domain here"),
|
||||
"install": MessageLookupByLibrary.simpleMessage("install"),
|
||||
"installDockerWithUrl": MessageLookupByLibrary.simpleMessage(
|
||||
"Please https://docs.docker.com/engine/install docker first."),
|
||||
"invalidJson": MessageLookupByLibrary.simpleMessage("Invalid JSON"),
|
||||
"invalidVersionHelp": m6,
|
||||
"keepForeground":
|
||||
MessageLookupByLibrary.simpleMessage("Keep app foreground!"),
|
||||
"keyAuth": MessageLookupByLibrary.simpleMessage("Key Auth"),
|
||||
"lastTry": MessageLookupByLibrary.simpleMessage("Last try!"),
|
||||
"launchPage": MessageLookupByLibrary.simpleMessage("Launch page"),
|
||||
"license": MessageLookupByLibrary.simpleMessage("License"),
|
||||
"loadingFiles":
|
||||
MessageLookupByLibrary.simpleMessage("Loading files..."),
|
||||
"loss": MessageLookupByLibrary.simpleMessage("loss"),
|
||||
"madeWithLove": m7,
|
||||
"max": MessageLookupByLibrary.simpleMessage("max"),
|
||||
"min": MessageLookupByLibrary.simpleMessage("min"),
|
||||
"ms": MessageLookupByLibrary.simpleMessage("ms"),
|
||||
"name": MessageLookupByLibrary.simpleMessage("Name"),
|
||||
"noClient": MessageLookupByLibrary.simpleMessage("No client"),
|
||||
"noInterface": MessageLookupByLibrary.simpleMessage("No interface"),
|
||||
"noResult": MessageLookupByLibrary.simpleMessage("No result"),
|
||||
"noSavedPrivateKey":
|
||||
MessageLookupByLibrary.simpleMessage("No saved private keys."),
|
||||
"noSavedSnippet":
|
||||
MessageLookupByLibrary.simpleMessage("No saved snippets."),
|
||||
"noServerAvailable":
|
||||
MessageLookupByLibrary.simpleMessage("No server available."),
|
||||
"noUpdateAvailable":
|
||||
MessageLookupByLibrary.simpleMessage("No update available"),
|
||||
"ok": MessageLookupByLibrary.simpleMessage("OK"),
|
||||
"open": MessageLookupByLibrary.simpleMessage("Open"),
|
||||
"ping": MessageLookupByLibrary.simpleMessage("Ping"),
|
||||
"pingAvg": MessageLookupByLibrary.simpleMessage("Avg:"),
|
||||
"pingInputIP": MessageLookupByLibrary.simpleMessage(
|
||||
"Please input a target IP/domain."),
|
||||
"pingNoServer": MessageLookupByLibrary.simpleMessage(
|
||||
"No server to ping.\nPlease add a server in server tab."),
|
||||
"platformNotSupportUpdate": MessageLookupByLibrary.simpleMessage(
|
||||
"Current platform does not support in app update.\nPlease build from source and install it."),
|
||||
"plzEnterHost":
|
||||
MessageLookupByLibrary.simpleMessage("Please enter host."),
|
||||
"plzSelectKey":
|
||||
MessageLookupByLibrary.simpleMessage("Please select a key."),
|
||||
"port": MessageLookupByLibrary.simpleMessage("Port"),
|
||||
"privateKey": MessageLookupByLibrary.simpleMessage("Private Key"),
|
||||
"pwd": MessageLookupByLibrary.simpleMessage("Password"),
|
||||
"rename": MessageLookupByLibrary.simpleMessage("Rename"),
|
||||
"reportBugsOnGithubIssue": m8,
|
||||
"restore": MessageLookupByLibrary.simpleMessage("Restore"),
|
||||
"restoreSuccess": MessageLookupByLibrary.simpleMessage(
|
||||
"Restore success. Restart app to apply."),
|
||||
"restoreSureWithDate": m9,
|
||||
"result": MessageLookupByLibrary.simpleMessage("Result"),
|
||||
"run": MessageLookupByLibrary.simpleMessage("Run"),
|
||||
"save": MessageLookupByLibrary.simpleMessage("Save"),
|
||||
"second": MessageLookupByLibrary.simpleMessage("s"),
|
||||
"server": MessageLookupByLibrary.simpleMessage("Server"),
|
||||
"serverTabConnecting":
|
||||
MessageLookupByLibrary.simpleMessage("Connecting..."),
|
||||
"serverTabEmpty": MessageLookupByLibrary.simpleMessage(
|
||||
"There is no server.\nClick the fab to add one."),
|
||||
"serverTabFailed": MessageLookupByLibrary.simpleMessage("Failed"),
|
||||
"serverTabLoading": MessageLookupByLibrary.simpleMessage("Loading..."),
|
||||
"serverTabPlzSave": MessageLookupByLibrary.simpleMessage(
|
||||
"Please \'save\' this private key again."),
|
||||
"serverTabUnkown":
|
||||
MessageLookupByLibrary.simpleMessage("Unknown state"),
|
||||
"setting": MessageLookupByLibrary.simpleMessage("Setting"),
|
||||
"sftpDlPrepare":
|
||||
MessageLookupByLibrary.simpleMessage("Preparing to connect..."),
|
||||
"sftpNoDownloadTask":
|
||||
MessageLookupByLibrary.simpleMessage("No download task."),
|
||||
"sftpSSHConnected":
|
||||
MessageLookupByLibrary.simpleMessage("SFTP Connected"),
|
||||
"snippet": MessageLookupByLibrary.simpleMessage("Snippet"),
|
||||
"spentTime": m10,
|
||||
"start": MessageLookupByLibrary.simpleMessage("Start"),
|
||||
"stop": MessageLookupByLibrary.simpleMessage("Stop"),
|
||||
"sureDelete": m11,
|
||||
"sureNoPwd": MessageLookupByLibrary.simpleMessage(
|
||||
"Are you sure to use no password?"),
|
||||
"sureToDeleteServer": m12,
|
||||
"ttl": MessageLookupByLibrary.simpleMessage("ttl"),
|
||||
"unknown": MessageLookupByLibrary.simpleMessage("unknown"),
|
||||
"unknownError": MessageLookupByLibrary.simpleMessage("Unknown error"),
|
||||
"unkownConvertMode":
|
||||
MessageLookupByLibrary.simpleMessage("Unknown convert mode"),
|
||||
"update": MessageLookupByLibrary.simpleMessage("Update"),
|
||||
"updateAll": MessageLookupByLibrary.simpleMessage("Update all"),
|
||||
"updateIntervalEqual0": MessageLookupByLibrary.simpleMessage(
|
||||
"You set to 0, will not update automatically.\nYou can pull to refresh manually."),
|
||||
"updateServerStatusInterval": MessageLookupByLibrary.simpleMessage(
|
||||
"Server status update interval"),
|
||||
"upsideDown": MessageLookupByLibrary.simpleMessage("Upside Down"),
|
||||
"urlOrJson": MessageLookupByLibrary.simpleMessage("URL or JSON"),
|
||||
"user": MessageLookupByLibrary.simpleMessage("User"),
|
||||
"versionHaveUpdate": m13,
|
||||
"versionUnknownUpdate": m14,
|
||||
"versionUpdated": m15,
|
||||
"waitConnection": MessageLookupByLibrary.simpleMessage(
|
||||
"Please wait for the connection to be established."),
|
||||
"willTakEeffectImmediately":
|
||||
MessageLookupByLibrary.simpleMessage("Will take effect immediately")
|
||||
};
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
|
||||
// This is a library that provides messages for a zh locale. All the
|
||||
// messages from the main program should be duplicated here with the same
|
||||
// function name.
|
||||
|
||||
// Ignore issues from commonly used lints in this file.
|
||||
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
|
||||
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
|
||||
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
|
||||
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
|
||||
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:intl/message_lookup_by_library.dart';
|
||||
|
||||
final messages = new MessageLookup();
|
||||
|
||||
typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
|
||||
|
||||
class MessageLookup extends MessageLookupByLibrary {
|
||||
String get localeName => 'zh';
|
||||
|
||||
static String m0(fileName) => "下载 [${fileName}] 到本地?";
|
||||
|
||||
static String m1(runningCount, stoppedCount) =>
|
||||
"${runningCount}个正在运行, ${stoppedCount}个已停止";
|
||||
|
||||
static String m2(count) => "${count}个容器正在运行";
|
||||
|
||||
static String m3(percent, size) => "${size} 的 ${percent}%";
|
||||
|
||||
static String m4(count) => "找到 ${count} 个更新";
|
||||
|
||||
static String m5(code) => "请求失败, 状态码: ${code}";
|
||||
|
||||
static String m6(url) =>
|
||||
"请确保正确安装了docker,或者使用的非自编译版本。如果没有以上问题,请在 ${url} 提交问题。";
|
||||
|
||||
static String m7(myGithub) => "\n用❤️制作 by ${myGithub}";
|
||||
|
||||
static String m8(url) => "请到 ${url} 提交问题";
|
||||
|
||||
static String m9(date) => "确定恢复 ${date} 的备份吗?";
|
||||
|
||||
static String m10(time) => "耗时: ${time}";
|
||||
|
||||
static String m11(name) => "确定删除[${name}]?";
|
||||
|
||||
static String m12(server) => "你确定要删除服务器 [${server}] 吗?";
|
||||
|
||||
static String m13(build) => "找到新版本:v1.0.${build}, 点击更新";
|
||||
|
||||
static String m14(build) => "当前:v1.0.${build}";
|
||||
|
||||
static String m15(build) => "当前:v1.0.${build}, 已是最新版本";
|
||||
|
||||
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
|
||||
"aboutThanks":
|
||||
MessageLookupByLibrary.simpleMessage("\n保留所有权利。\n\n感谢以下参与软件测试的各位。"),
|
||||
"addAServer": MessageLookupByLibrary.simpleMessage("添加服务器"),
|
||||
"addPrivateKey": MessageLookupByLibrary.simpleMessage("添加一个私钥"),
|
||||
"alreadyLastDir": MessageLookupByLibrary.simpleMessage("已经是最上层目录了"),
|
||||
"appPrimaryColor": MessageLookupByLibrary.simpleMessage("App主要色"),
|
||||
"attention": MessageLookupByLibrary.simpleMessage("注意"),
|
||||
"backDir": MessageLookupByLibrary.simpleMessage("返回上一级"),
|
||||
"backup": MessageLookupByLibrary.simpleMessage("备份"),
|
||||
"backupTip": MessageLookupByLibrary.simpleMessage(
|
||||
"导出的数据仅进行了简单加密,请妥善保管。\n除了设置项,恢复的数据不会覆盖现有数据。"),
|
||||
"backupVersionNotMatch":
|
||||
MessageLookupByLibrary.simpleMessage("备份版本不匹配,无法恢复"),
|
||||
"cancel": MessageLookupByLibrary.simpleMessage("取消"),
|
||||
"choose": MessageLookupByLibrary.simpleMessage("选择"),
|
||||
"chooseDestination": MessageLookupByLibrary.simpleMessage("选择目标"),
|
||||
"choosePrivateKey": MessageLookupByLibrary.simpleMessage("选择私钥"),
|
||||
"clear": MessageLookupByLibrary.simpleMessage("清除"),
|
||||
"clickSee": MessageLookupByLibrary.simpleMessage("点击查看"),
|
||||
"close": MessageLookupByLibrary.simpleMessage("关闭"),
|
||||
"containerStatus": MessageLookupByLibrary.simpleMessage("容器状态"),
|
||||
"convert": MessageLookupByLibrary.simpleMessage("转换"),
|
||||
"copy": MessageLookupByLibrary.simpleMessage("复制到剪切板"),
|
||||
"copyPath": MessageLookupByLibrary.simpleMessage("复制路径"),
|
||||
"createFile": MessageLookupByLibrary.simpleMessage("创建文件"),
|
||||
"createFolder": MessageLookupByLibrary.simpleMessage("创建文件夹"),
|
||||
"currentMode": MessageLookupByLibrary.simpleMessage("当前模式"),
|
||||
"debug": MessageLookupByLibrary.simpleMessage("调试"),
|
||||
"decode": MessageLookupByLibrary.simpleMessage("解码"),
|
||||
"delete": MessageLookupByLibrary.simpleMessage("删除"),
|
||||
"disconnected": MessageLookupByLibrary.simpleMessage("连接断开"),
|
||||
"dl2Local": m0,
|
||||
"dockerStatusRunningAndStoppedFmt": m1,
|
||||
"dockerStatusRunningFmt": m2,
|
||||
"download": MessageLookupByLibrary.simpleMessage("下载"),
|
||||
"downloadFinished": MessageLookupByLibrary.simpleMessage("下载完成!"),
|
||||
"downloadStatus": m3,
|
||||
"edit": MessageLookupByLibrary.simpleMessage("编辑"),
|
||||
"encode": MessageLookupByLibrary.simpleMessage("编码"),
|
||||
"error": MessageLookupByLibrary.simpleMessage("出错了"),
|
||||
"exampleName": MessageLookupByLibrary.simpleMessage("名称示例"),
|
||||
"experimentalFeature": MessageLookupByLibrary.simpleMessage("实验性功能"),
|
||||
"export": MessageLookupByLibrary.simpleMessage("导出"),
|
||||
"feedback": MessageLookupByLibrary.simpleMessage("反馈"),
|
||||
"feedbackOnGithub":
|
||||
MessageLookupByLibrary.simpleMessage("如果你有任何问题,请在GitHub反馈"),
|
||||
"fieldMustNotEmpty": MessageLookupByLibrary.simpleMessage("这些输入框不能为空。"),
|
||||
"files": MessageLookupByLibrary.simpleMessage("文件"),
|
||||
"foundNUpdate": m4,
|
||||
"go": MessageLookupByLibrary.simpleMessage("开始"),
|
||||
"goSftpDlPage": MessageLookupByLibrary.simpleMessage("前往下载页?"),
|
||||
"host": MessageLookupByLibrary.simpleMessage("主机"),
|
||||
"httpFailedWithCode": m5,
|
||||
"import": MessageLookupByLibrary.simpleMessage("导入"),
|
||||
"importAndExport": MessageLookupByLibrary.simpleMessage("导入或导出"),
|
||||
"inputDomainHere": MessageLookupByLibrary.simpleMessage("在这里输入域名"),
|
||||
"install": MessageLookupByLibrary.simpleMessage("安装"),
|
||||
"installDockerWithUrl": MessageLookupByLibrary.simpleMessage(
|
||||
"请先 https://docs.docker.com/engine/install docker"),
|
||||
"invalidJson": MessageLookupByLibrary.simpleMessage("无效的json,存在格式问题"),
|
||||
"invalidVersionHelp": m6,
|
||||
"keepForeground": MessageLookupByLibrary.simpleMessage("请保持应用处于前台!"),
|
||||
"keyAuth": MessageLookupByLibrary.simpleMessage("公钥认证"),
|
||||
"lastTry": MessageLookupByLibrary.simpleMessage("最后尝试"),
|
||||
"launchPage": MessageLookupByLibrary.simpleMessage("启动页"),
|
||||
"license": MessageLookupByLibrary.simpleMessage("开源证书"),
|
||||
"loadingFiles": MessageLookupByLibrary.simpleMessage("正在加载目录。。。"),
|
||||
"loss": MessageLookupByLibrary.simpleMessage("丢包率"),
|
||||
"madeWithLove": m7,
|
||||
"max": MessageLookupByLibrary.simpleMessage("最大"),
|
||||
"min": MessageLookupByLibrary.simpleMessage("最小"),
|
||||
"ms": MessageLookupByLibrary.simpleMessage("毫秒"),
|
||||
"name": MessageLookupByLibrary.simpleMessage("名称"),
|
||||
"noClient": MessageLookupByLibrary.simpleMessage("没有SSH连接"),
|
||||
"noInterface": MessageLookupByLibrary.simpleMessage("没有可用的接口"),
|
||||
"noResult": MessageLookupByLibrary.simpleMessage("无结果"),
|
||||
"noSavedPrivateKey": MessageLookupByLibrary.simpleMessage("没有已保存的私钥。"),
|
||||
"noSavedSnippet": MessageLookupByLibrary.simpleMessage("没有已保存的代码片段。"),
|
||||
"noServerAvailable": MessageLookupByLibrary.simpleMessage("没有可用的服务器。"),
|
||||
"noUpdateAvailable": MessageLookupByLibrary.simpleMessage("没有可用更新"),
|
||||
"ok": MessageLookupByLibrary.simpleMessage("好"),
|
||||
"open": MessageLookupByLibrary.simpleMessage("打开"),
|
||||
"ping": MessageLookupByLibrary.simpleMessage("Ping"),
|
||||
"pingAvg": MessageLookupByLibrary.simpleMessage("平均:"),
|
||||
"pingInputIP": MessageLookupByLibrary.simpleMessage("请输入目标IP或域名"),
|
||||
"pingNoServer": MessageLookupByLibrary.simpleMessage(
|
||||
"没有服务器可用于Ping\n请在服务器tab添加服务器后再试"),
|
||||
"platformNotSupportUpdate":
|
||||
MessageLookupByLibrary.simpleMessage("当前平台不支持更新,请编译最新源码后手动安装"),
|
||||
"plzEnterHost": MessageLookupByLibrary.simpleMessage("请输入主机"),
|
||||
"plzSelectKey": MessageLookupByLibrary.simpleMessage("请选择私钥"),
|
||||
"port": MessageLookupByLibrary.simpleMessage("端口"),
|
||||
"privateKey": MessageLookupByLibrary.simpleMessage("私钥"),
|
||||
"pwd": MessageLookupByLibrary.simpleMessage("密码"),
|
||||
"rename": MessageLookupByLibrary.simpleMessage("重命名"),
|
||||
"reportBugsOnGithubIssue": m8,
|
||||
"restore": MessageLookupByLibrary.simpleMessage("恢复"),
|
||||
"restoreSuccess":
|
||||
MessageLookupByLibrary.simpleMessage("恢复成功,需要重启App来应用更改"),
|
||||
"restoreSureWithDate": m9,
|
||||
"result": MessageLookupByLibrary.simpleMessage("结果"),
|
||||
"run": MessageLookupByLibrary.simpleMessage("运行"),
|
||||
"save": MessageLookupByLibrary.simpleMessage("保存"),
|
||||
"second": MessageLookupByLibrary.simpleMessage("秒"),
|
||||
"server": MessageLookupByLibrary.simpleMessage("服务器"),
|
||||
"serverTabConnecting": MessageLookupByLibrary.simpleMessage("连接中..."),
|
||||
"serverTabEmpty":
|
||||
MessageLookupByLibrary.simpleMessage("现在没有服务器。\n点击右下方按钮来添加。"),
|
||||
"serverTabFailed": MessageLookupByLibrary.simpleMessage("失败"),
|
||||
"serverTabLoading": MessageLookupByLibrary.simpleMessage("加载中..."),
|
||||
"serverTabPlzSave": MessageLookupByLibrary.simpleMessage("请再次保存该私钥"),
|
||||
"serverTabUnkown": MessageLookupByLibrary.simpleMessage("未知状态"),
|
||||
"setting": MessageLookupByLibrary.simpleMessage("设置"),
|
||||
"sftpDlPrepare": MessageLookupByLibrary.simpleMessage("准备连接至服务器..."),
|
||||
"sftpNoDownloadTask": MessageLookupByLibrary.simpleMessage("没有下载任务"),
|
||||
"sftpSSHConnected":
|
||||
MessageLookupByLibrary.simpleMessage("SFTP 已连接,即将开始下载..."),
|
||||
"snippet": MessageLookupByLibrary.simpleMessage("代码片段"),
|
||||
"spentTime": m10,
|
||||
"start": MessageLookupByLibrary.simpleMessage("开始"),
|
||||
"stop": MessageLookupByLibrary.simpleMessage("停止"),
|
||||
"sureDelete": m11,
|
||||
"sureNoPwd": MessageLookupByLibrary.simpleMessage("确认使用无密码?"),
|
||||
"sureToDeleteServer": m12,
|
||||
"ttl": MessageLookupByLibrary.simpleMessage("缓存时间"),
|
||||
"unknown": MessageLookupByLibrary.simpleMessage("未知"),
|
||||
"unknownError": MessageLookupByLibrary.simpleMessage("未知错误"),
|
||||
"unkownConvertMode": MessageLookupByLibrary.simpleMessage("未知转换模式"),
|
||||
"update": MessageLookupByLibrary.simpleMessage("更新"),
|
||||
"updateAll": MessageLookupByLibrary.simpleMessage("更新全部"),
|
||||
"updateIntervalEqual0": MessageLookupByLibrary.simpleMessage(
|
||||
"你设置为0,服务器状态不会自动刷新。\n你可以手动下拉刷新。"),
|
||||
"updateServerStatusInterval":
|
||||
MessageLookupByLibrary.simpleMessage("服务器状态刷新间隔"),
|
||||
"upsideDown": MessageLookupByLibrary.simpleMessage("上下交换"),
|
||||
"urlOrJson": MessageLookupByLibrary.simpleMessage("链接或JSON"),
|
||||
"user": MessageLookupByLibrary.simpleMessage("用户"),
|
||||
"versionHaveUpdate": m13,
|
||||
"versionUnknownUpdate": m14,
|
||||
"versionUpdated": m15,
|
||||
"waitConnection": MessageLookupByLibrary.simpleMessage("请等待连接建立"),
|
||||
"willTakEeffectImmediately":
|
||||
MessageLookupByLibrary.simpleMessage("更改将会立即生效")
|
||||
};
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
176
lib/l10n/app_en.arb
Normal file
176
lib/l10n/app_en.arb
Normal file
@@ -0,0 +1,176 @@
|
||||
{
|
||||
"about": "About",
|
||||
"aboutThanks": "\nThanks to the following people who participated in the test.",
|
||||
"addAServer": "add a server",
|
||||
"addOne": "Add one",
|
||||
"addPrivateKey": "Add private key",
|
||||
"alreadyLastDir": "Already in last directory.",
|
||||
"appPrimaryColor": "App primary color",
|
||||
"attention": "Attention",
|
||||
"auto": "Auto",
|
||||
"backDir": "Back",
|
||||
"backup": "Backup",
|
||||
"backupTip": "The exported data is simply encrypted. \nPlease keep it safe.\nRestoring will not overwrite existing data (except setting).",
|
||||
"backupVersionNotMatch": "Backup version is not match.",
|
||||
"cancel": "Cancel",
|
||||
"choose": "Choose",
|
||||
"chooseDestination": "Choose destination",
|
||||
"chooseFontFile": "Choose a font file",
|
||||
"choosePrivateKey": "Choose private key",
|
||||
"clear": "Clear",
|
||||
"clickSee": "Click here",
|
||||
"close": "Close",
|
||||
"cmd": "Command",
|
||||
"containerStatus": "Container status",
|
||||
"convert": "Convert",
|
||||
"copy": "Copy",
|
||||
"copyPath": "Copy path",
|
||||
"createFile": "Create file",
|
||||
"createFolder": "Create folder",
|
||||
"currentMode": "Current Mode",
|
||||
"dark": "Dark",
|
||||
"debug": "Debug",
|
||||
"decode": "Decode",
|
||||
"delete": "Delete",
|
||||
"disconnected": "Disconnected",
|
||||
"dl2Local": "Download [{fileName}] to local?",
|
||||
"dockerContainerName": "Container name",
|
||||
"dockerEditHost": "Edit DOCKER_HOST",
|
||||
"dockerEmptyRunningItems": "No running container. \nIt may be that the env DOCKER_HOST is not read correctly. You can found it by running `echo $DOCKER_HOST` in terminal.",
|
||||
"dockerImage": "Image",
|
||||
"dockerImagesFmt": "{count} images",
|
||||
"dockerNotInstalled": "Docker not installed",
|
||||
"dockerStatusRunningAndStoppedFmt": "{runningCount} running, {stoppedCount} container stopped.",
|
||||
"dockerStatusRunningFmt": "{count} container running.",
|
||||
"download": "Download",
|
||||
"downloadFinished": "Download finished",
|
||||
"downloadStatus": "{percent}% of {size}",
|
||||
"edit": "Edit",
|
||||
"encode": "Encode",
|
||||
"error": "Error",
|
||||
"exampleName": "Example name",
|
||||
"experimentalFeature": "Experimental feature",
|
||||
"export": "Export",
|
||||
"extraArgs": "Extra args",
|
||||
"failed": "Failed",
|
||||
"feedback": "Feedback",
|
||||
"feedbackOnGithub": "If you have any questions, please feedback on Github.",
|
||||
"fieldMustNotEmpty": "These fields must not be empty.",
|
||||
"fileNotExist": "{file} not exist",
|
||||
"fileTooLarge": "File '{file}' too large {size}, max {sizeMax}",
|
||||
"files": "Files",
|
||||
"foundNUpdate": "Found {count} update",
|
||||
"getPushTokenFailed": "Can't fetch push token",
|
||||
"gettingToken": "Getting token...",
|
||||
"go": "Go",
|
||||
"goto": "Go to",
|
||||
"host": "Host",
|
||||
"httpFailedWithCode": "request failed, status code: {code}",
|
||||
"imagesList": "Images list",
|
||||
"import": "Import",
|
||||
"importAndExport": "Import and Export",
|
||||
"inputDomainHere": "Input Domain here",
|
||||
"install": "install",
|
||||
"installDockerWithUrl": "Please https://docs.docker.com/engine/install docker first.",
|
||||
"invalidJson": "Invalid JSON",
|
||||
"invalidVersion": "Invalid version",
|
||||
"invalidVersionHelp": "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}.",
|
||||
"isBusy": "Is busy now",
|
||||
"keepForeground": "Keep app foreground!",
|
||||
"keyAuth": "Key Auth",
|
||||
"lastTry": "Last try!",
|
||||
"launchPage": "Launch page",
|
||||
"license": "License",
|
||||
"light": "Light",
|
||||
"loadingFiles": "Loading files...",
|
||||
"loss": "loss",
|
||||
"madeWithLove": "\nMade with ❤️ by {myGithub}",
|
||||
"max": "max",
|
||||
"maxRetryCount": "Number of server reconnection",
|
||||
"maxRetryCountEqual0": "Will retry again and again.",
|
||||
"min": "min",
|
||||
"ms": "ms",
|
||||
"name": "Name",
|
||||
"needRestart": "Need to restart app",
|
||||
"newContainer": "New container",
|
||||
"noClient": "No client",
|
||||
"noInterface": "No interface",
|
||||
"noResult": "No result",
|
||||
"noSavedPrivateKey": "No saved private keys.",
|
||||
"noSavedSnippet": "No saved snippets.",
|
||||
"noServerAvailable": "No server available.",
|
||||
"noUpdateAvailable": "No update available",
|
||||
"notSelected": "Not selected",
|
||||
"nullToken": "Null token",
|
||||
"ok": "OK",
|
||||
"onServerDetailPage": "On server detail page",
|
||||
"onlyIOS": "Only valid on iOS",
|
||||
"open": "Open",
|
||||
"path": "Path",
|
||||
"pickFile": "Pick file",
|
||||
"ping": "Ping",
|
||||
"pingAvg": "Avg:",
|
||||
"pingInputIP": "Please input a target IP/domain.",
|
||||
"pingNoServer": "No server to ping.\nPlease add a server in server tab.",
|
||||
"pkg": "Pkg",
|
||||
"platformNotSupportUpdate": "Current platform does not support in app update.\nPlease build from source and install it.",
|
||||
"plzEnterHost": "Please enter host.",
|
||||
"plzSelectKey": "Please select a key.",
|
||||
"port": "Port",
|
||||
"preview": "Preview",
|
||||
"privateKey": "Private Key",
|
||||
"pushToken": "Push token",
|
||||
"pwd": "Password",
|
||||
"rename": "Rename",
|
||||
"reportBugsOnGithubIssue": "Please report bugs on {url}",
|
||||
"restart": "Restart",
|
||||
"restore": "Restore",
|
||||
"restoreSuccess": "Restore success. Restart app to apply.",
|
||||
"restoreSureWithDate": "Are you sure to restore from {date} ?",
|
||||
"result": "Result",
|
||||
"run": "Run",
|
||||
"save": "Save",
|
||||
"second": "s",
|
||||
"server": "Server",
|
||||
"serverTabConnecting": "Connecting...",
|
||||
"serverTabEmpty": "There is no server.\nClick the fab to add one.",
|
||||
"serverTabFailed": "Failed",
|
||||
"serverTabLoading": "Loading...",
|
||||
"serverTabPlzSave": "Please 'save' this private key again.",
|
||||
"serverTabUnkown": "Unknown state",
|
||||
"setting": "Setting",
|
||||
"sftpDlPrepare": "Preparing to connect...",
|
||||
"sftpNoDownloadTask": "No download task.",
|
||||
"sftpSSHConnected": "SFTP Connected",
|
||||
"showDistLogo": "Show distribution logo",
|
||||
"snippet": "Snippet",
|
||||
"spentTime": "Spent time: {time}",
|
||||
"sshTip": "This function is now in the experimental stage.\n\nPlease report bugs on {url} or join our development.",
|
||||
"start": "Start",
|
||||
"stop": "Stop",
|
||||
"success": "Success",
|
||||
"sureDelete": "Are you sure to delete [{name}]?",
|
||||
"sureNoPwd": "Are you sure to use no password?",
|
||||
"sureToDeleteServer": "Are you sure to delete server [{server}]?",
|
||||
"termTheme": "Terminal theme",
|
||||
"themeMode": "Theme mode",
|
||||
"times": "Times",
|
||||
"ttl": "ttl",
|
||||
"unknown": "unknown",
|
||||
"unknownError": "Unknown error",
|
||||
"unkownConvertMode": "Unknown convert mode",
|
||||
"update": "Update",
|
||||
"updateAll": "Update all",
|
||||
"updateIntervalEqual0": "You set to 0, will not update automatically.\nCan't calculate CPU status.",
|
||||
"updateServerStatusInterval": "Server status update interval",
|
||||
"updateTip": "Update: v1.0.{newest}",
|
||||
"updateTipTooLow": "Current version is too low, please update to v1.0.{newest}",
|
||||
"upsideDown": "Upside Down",
|
||||
"urlOrJson": "URL or JSON",
|
||||
"user": "User",
|
||||
"versionHaveUpdate": "Found: v1.0.{build}, click to update",
|
||||
"versionUnknownUpdate": "Current: v1.0.{build}",
|
||||
"versionUpdated": "Current: v1.0.{build}, is up to date",
|
||||
"waitConnection": "Please wait for the connection to be established.",
|
||||
"willTakEeffectImmediately": "Will take effect immediately"
|
||||
}
|
||||
176
lib/l10n/app_zh.arb
Normal file
176
lib/l10n/app_zh.arb
Normal file
@@ -0,0 +1,176 @@
|
||||
{
|
||||
"about": "关于",
|
||||
"aboutThanks": "\n感谢以下参与软件测试的各位。",
|
||||
"addAServer": "添加服务器",
|
||||
"addOne": "前去新增",
|
||||
"addPrivateKey": "添加一个私钥",
|
||||
"alreadyLastDir": "已经是最上层目录了",
|
||||
"appPrimaryColor": "App主要色",
|
||||
"attention": "注意",
|
||||
"auto": "自动",
|
||||
"backDir": "返回上一级",
|
||||
"backup": "备份",
|
||||
"backupTip": "导出的数据仅进行了简单加密,请妥善保管。\n除了设置项,恢复的数据不会覆盖现有数据。",
|
||||
"backupVersionNotMatch": "备份版本不匹配,无法恢复",
|
||||
"cancel": "取消",
|
||||
"choose": "选择",
|
||||
"chooseDestination": "选择目标",
|
||||
"chooseFontFile": "选择字体文件",
|
||||
"choosePrivateKey": "选择私钥",
|
||||
"clear": "清除",
|
||||
"clickSee": "点击查看",
|
||||
"close": "关闭",
|
||||
"cmd": "命令",
|
||||
"containerStatus": "容器状态",
|
||||
"convert": "转换",
|
||||
"copy": "复制",
|
||||
"copyPath": "复制路径",
|
||||
"createFile": "创建文件",
|
||||
"createFolder": "创建文件夹",
|
||||
"currentMode": "当前模式",
|
||||
"dark": "暗",
|
||||
"debug": "调试",
|
||||
"decode": "解码",
|
||||
"delete": "删除",
|
||||
"disconnected": "连接断开",
|
||||
"dl2Local": "下载 [{fileName}] 到本地?",
|
||||
"dockerContainerName": "容器名",
|
||||
"dockerEditHost": "编辑 DOCKER_HOST",
|
||||
"dockerEmptyRunningItems": "没有正在运行的容器。\n这可能是因为环境变量 DOCKER_HOST 没有被正确读取。你可以通过在终端内运行 `echo $DOCKER_HOST` 来获取。",
|
||||
"dockerImage": "镜像",
|
||||
"dockerImagesFmt": "共 {count} 个镜像",
|
||||
"dockerNotInstalled": "Docker未安装",
|
||||
"dockerStatusRunningAndStoppedFmt": "{runningCount}个正在运行, {stoppedCount}个已停止",
|
||||
"dockerStatusRunningFmt": "{count}个容器正在运行",
|
||||
"download": "下载",
|
||||
"downloadFinished": "下载完成!",
|
||||
"downloadStatus": "{size} 的 {percent}%",
|
||||
"edit": "编辑",
|
||||
"encode": "编码",
|
||||
"error": "出错了",
|
||||
"exampleName": "名称示例",
|
||||
"experimentalFeature": "实验性功能",
|
||||
"export": "导出",
|
||||
"extraArgs": "额外参数",
|
||||
"failed": "失败",
|
||||
"feedback": "反馈",
|
||||
"feedbackOnGithub": "如果你有任何问题,请在GitHub反馈",
|
||||
"fieldMustNotEmpty": "这些输入框不能为空。",
|
||||
"fileNotExist": "{file} 不存在",
|
||||
"fileTooLarge": "文件 '{file}' 过大 '{size}',超过了 {sizeMax}",
|
||||
"files": "文件",
|
||||
"foundNUpdate": "找到 {count} 个更新",
|
||||
"getPushTokenFailed": "未能获取到推送token",
|
||||
"gettingToken": "正在获取Token...",
|
||||
"go": "开始",
|
||||
"goto": "前往",
|
||||
"host": "主机",
|
||||
"httpFailedWithCode": "请求失败, 状态码: {code}",
|
||||
"imagesList": "镜像列表",
|
||||
"import": "导入",
|
||||
"importAndExport": "导入或导出",
|
||||
"inputDomainHere": "在这里输入域名",
|
||||
"install": "安装",
|
||||
"installDockerWithUrl": "请先 https://docs.docker.com/engine/install docker",
|
||||
"invalidJson": "无效的json,存在格式问题",
|
||||
"invalidVersion": "不支持的版本",
|
||||
"invalidVersionHelp": "请确保正确安装了docker,或者使用的非自编译版本。如果没有以上问题,请在 {url} 提交问题。",
|
||||
"isBusy": "当前正忙",
|
||||
"keepForeground": "请保持应用处于前台!",
|
||||
"keyAuth": "公钥认证",
|
||||
"lastTry": "最后尝试",
|
||||
"launchPage": "启动页",
|
||||
"license": "开源证书",
|
||||
"light": "亮",
|
||||
"loadingFiles": "正在加载目录。。。",
|
||||
"loss": "丢包率",
|
||||
"madeWithLove": "\n用❤️制作 by {myGithub}",
|
||||
"max": "最大",
|
||||
"maxRetryCount": "服务器尝试重连次数",
|
||||
"maxRetryCountEqual0": "会无限重试",
|
||||
"min": "最小",
|
||||
"ms": "毫秒",
|
||||
"name": "名称",
|
||||
"needRestart": "需要重启 App",
|
||||
"newContainer": "新建容器",
|
||||
"noClient": "没有SSH连接",
|
||||
"noInterface": "没有可用的接口",
|
||||
"noResult": "无结果",
|
||||
"noSavedPrivateKey": "没有已保存的私钥。",
|
||||
"noSavedSnippet": "没有已保存的代码片段。",
|
||||
"noServerAvailable": "没有可用的服务器。",
|
||||
"noUpdateAvailable": "没有可用更新",
|
||||
"notSelected": "未选择",
|
||||
"nullToken": "无Token",
|
||||
"ok": "好",
|
||||
"onServerDetailPage": "在服务器详情页",
|
||||
"onlyIOS": "仅在iOS上有效",
|
||||
"open": "打开",
|
||||
"path": "路径",
|
||||
"pickFile": "选择文件",
|
||||
"ping": "Ping",
|
||||
"pingAvg": "平均:",
|
||||
"pingInputIP": "请输入目标IP或域名",
|
||||
"pingNoServer": "没有服务器可用于Ping\n请在服务器tab添加服务器后再试",
|
||||
"pkg": "包管理",
|
||||
"platformNotSupportUpdate": "当前平台不支持更新,请编译最新源码后手动安装",
|
||||
"plzEnterHost": "请输入主机",
|
||||
"plzSelectKey": "请选择私钥",
|
||||
"port": "端口",
|
||||
"preview": "预览",
|
||||
"privateKey": "私钥",
|
||||
"pushToken": "消息推送 Token",
|
||||
"pwd": "密码",
|
||||
"rename": "重命名",
|
||||
"reportBugsOnGithubIssue": "请到 {url} 提交问题",
|
||||
"restart": "重启",
|
||||
"restore": "恢复",
|
||||
"restoreSuccess": "恢复成功,需要重启App来应用更改",
|
||||
"restoreSureWithDate": "确定恢复 {date} 的备份吗?",
|
||||
"result": "结果",
|
||||
"run": "运行",
|
||||
"save": "保存",
|
||||
"second": "秒",
|
||||
"server": "服务器",
|
||||
"serverTabConnecting": "连接中...",
|
||||
"serverTabEmpty": "现在没有服务器。\n点击右下方按钮来添加。",
|
||||
"serverTabFailed": "失败",
|
||||
"serverTabLoading": "加载中...",
|
||||
"serverTabPlzSave": "请再次保存该私钥",
|
||||
"serverTabUnkown": "未知状态",
|
||||
"setting": "设置",
|
||||
"sftpDlPrepare": "准备连接至服务器...",
|
||||
"sftpNoDownloadTask": "没有下载任务",
|
||||
"sftpSSHConnected": "SFTP 已连接,即将开始下载...",
|
||||
"showDistLogo": "显示发行版 Logo",
|
||||
"snippet": "代码片段",
|
||||
"spentTime": "耗时: {time}",
|
||||
"sshTip": "该功能目前处于测试阶段。\n\n请在 {url} 反馈问题,或者加入我们开发。",
|
||||
"start": "开始",
|
||||
"stop": "停止",
|
||||
"success": "成功",
|
||||
"sureDelete": "确定删除[{name}]?",
|
||||
"sureNoPwd": "确认使用无密码?",
|
||||
"sureToDeleteServer": "你确定要删除服务器 [{server}] 吗?",
|
||||
"termTheme": "终端主题",
|
||||
"themeMode": "主题模式",
|
||||
"times": "次",
|
||||
"ttl": "缓存时间",
|
||||
"unknown": "未知",
|
||||
"unknownError": "未知错误",
|
||||
"unkownConvertMode": "未知转换模式",
|
||||
"update": "更新",
|
||||
"updateAll": "更新全部",
|
||||
"updateIntervalEqual0": "你设置为0,服务器状态不会自动刷新。\n且不能计算CPU使用情况。",
|
||||
"updateServerStatusInterval": "服务器状态刷新间隔",
|
||||
"updateTip": "新版本: v1.0.{newest}",
|
||||
"updateTipTooLow": "当前版本过低,请升级至 v1.0.{newest}",
|
||||
"upsideDown": "上下交换",
|
||||
"urlOrJson": "链接或JSON",
|
||||
"user": "用户",
|
||||
"versionHaveUpdate": "找到新版本:v1.0.{build}, 点击更新",
|
||||
"versionUnknownUpdate": "当前:v1.0.{build}",
|
||||
"versionUpdated": "当前:v1.0.{build}, 已是最新版本",
|
||||
"waitConnection": "请等待连接建立",
|
||||
"willTakEeffectImmediately": "更改将会立即生效"
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
{
|
||||
"server": "Server",
|
||||
"convert": "Convert",
|
||||
"ping": "Ping",
|
||||
"debug": "Debug",
|
||||
"addAServer": "add a server",
|
||||
"setting": "Setting",
|
||||
"license": "License",
|
||||
"snippet": "Snippet",
|
||||
"privateKey": "Private Key",
|
||||
"madeWithLove": "\nMade with ❤️ by {myGithub}",
|
||||
"aboutThanks": "\nAll rights reserved.\n\nThanks to the following people who participated in the test.",
|
||||
"serverTabEmpty": "There is no server.\nClick the fab to add one.",
|
||||
"serverTabLoading": "Loading...",
|
||||
"serverTabPlzSave": "Please 'save' this private key again.",
|
||||
"serverTabFailed": "Failed",
|
||||
"serverTabUnkown": "Unknown state",
|
||||
"serverTabConnecting": "Connecting...",
|
||||
"decode": "Decode",
|
||||
"encode": "Encode",
|
||||
"currentMode": "Current Mode",
|
||||
"unkownConvertMode": "Unknown convert mode",
|
||||
"copy": "Copy",
|
||||
"upsideDown": "Upside Down",
|
||||
"pingAvg": "Avg:",
|
||||
"unknown": "unknown",
|
||||
"min": "min",
|
||||
"max": "max",
|
||||
"ms": "ms",
|
||||
"ttl": "ttl",
|
||||
"loss": "loss",
|
||||
"noResult": "No result",
|
||||
"pingInputIP": "Please input a target IP/domain.",
|
||||
"clear": "Clear",
|
||||
"start": "Start",
|
||||
"appPrimaryColor": "App primary color",
|
||||
"updateServerStatusInterval": "Server status update interval",
|
||||
"willTakEeffectImmediately": "Will take effect immediately",
|
||||
"launchPage": "Launch page",
|
||||
"versionUpdated": "Current: v1.0.{build}, is up to date",
|
||||
"versionUnknownUpdate": "Current: v1.0.{build}",
|
||||
"versionHaveUpdate": "Found: v1.0.{build}, click to update",
|
||||
"second": "s",
|
||||
"updateIntervalEqual0": "You set to 0, will not update automatically.\nYou can pull to refresh manually.",
|
||||
"edit": "Edit",
|
||||
"noSavedPrivateKey": "No saved private keys.",
|
||||
"name": "Name",
|
||||
"pwd": "Password",
|
||||
"save": "Save",
|
||||
"delete": "Delete",
|
||||
"fieldMustNotEmpty": "These fields must not be empty.",
|
||||
"importAndExport": "Import and Export",
|
||||
"choose": "Choose",
|
||||
"import": "Import",
|
||||
"export": "Export",
|
||||
"ok": "OK",
|
||||
"cancel": "Cancel",
|
||||
"urlOrJson": "URL or JSON",
|
||||
"go": "Go",
|
||||
"httpFailedWithCode": "request failed, status code: {code}",
|
||||
"run": "Run",
|
||||
"noSavedSnippet": "No saved snippets.",
|
||||
"chooseDestination": "Choose destination",
|
||||
"noServerAvailable": "No server available.",
|
||||
"result": "Result",
|
||||
"close": "Close",
|
||||
"attention": "Attention",
|
||||
"sureToDeleteServer": "Are you sure to delete server [{server}]?",
|
||||
"host": "Host",
|
||||
"port": "Port",
|
||||
"user": "User",
|
||||
"keyAuth": "Key Auth",
|
||||
"addPrivateKey": "Add private key",
|
||||
"choosePrivateKey": "Choose private key",
|
||||
"plzEnterHost": "Please enter host.",
|
||||
"sureNoPwd": "Are you sure to use no password?",
|
||||
"plzSelectKey": "Please select a key.",
|
||||
"exampleName": "Example name",
|
||||
"stop": "Stop",
|
||||
"download": "Download",
|
||||
"copyPath": "Copy path",
|
||||
"keepForeground": "Keep app foreground!",
|
||||
"downloadFinished": "Download finished",
|
||||
"downloadStatus": "{percent}% of {size}",
|
||||
"sftpDlPrepare": "Preparing to connect...",
|
||||
"sftpSSHConnected": "SFTP Connected",
|
||||
"spentTime": "Spent time: {time}",
|
||||
"backDir": "Back",
|
||||
"alreadyLastDir": "Already in last directory.",
|
||||
"open": "Open",
|
||||
"sureDelete": "Are you sure to delete [{name}]?",
|
||||
"containerStatus": "Container status",
|
||||
"noClient": "No client",
|
||||
"installDockerWithUrl": "Please https://docs.docker.com/engine/install docker first.",
|
||||
"waitConnection": "Please wait for the connection to be established.",
|
||||
"unknownError": "Unknown error",
|
||||
"dockerStatusRunningFmt": "{count} container running.",
|
||||
"dockerStatusRunningAndStoppedFmt": "{runningCount} running, {stoppedCount} container stopped.",
|
||||
"install": "install",
|
||||
"loadingFiles": "Loading files...",
|
||||
"sftpNoDownloadTask": "No download task.",
|
||||
"goSftpDlPage": "Go to SFTP download page?",
|
||||
"createFolder": "Create folder",
|
||||
"createFile": "Create file",
|
||||
"rename": "Rename",
|
||||
"dl2Local": "Download [{fileName}] to local?",
|
||||
"error": "Error",
|
||||
"disconnected": "Disconnected",
|
||||
"files": "Files",
|
||||
"experimentalFeature": "Experimental feature",
|
||||
"reportBugsOnGithubIssue": "Please report bugs on {url}",
|
||||
"noUpdateAvailable": "No update available",
|
||||
"foundNUpdate": "Found {count} update",
|
||||
"updateAll": "Update all",
|
||||
"platformNotSupportUpdate": "Current platform does not support in app update.\nPlease build from source and install it.",
|
||||
"invalidVersionHelp": "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}.",
|
||||
"noInterface": "No interface",
|
||||
"lastTry": "Last try!",
|
||||
"pingNoServer": "No server to ping.\nPlease add a server in server tab.",
|
||||
"backupTip": "The exported data is simply encrypted. \nPlease keep it safe.\nRestoring will not overwrite existing data (except setting).",
|
||||
"backup": "Backup",
|
||||
"restore": "Restore",
|
||||
"restoreSureWithDate": "Are you sure to restore from {date} ?",
|
||||
"backupVersionNotMatch": "Backup version is not match.",
|
||||
"invalidJson": "Invalid JSON",
|
||||
"restoreSuccess": "Restore success. Restart app to apply.",
|
||||
"clickSee": "Click here",
|
||||
"feedback": "Feedback",
|
||||
"feedbackOnGithub": "If you have any questions, please feedback on Github.",
|
||||
"update": "Update",
|
||||
"inputDomainHere": "Input Domain here"
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
{
|
||||
"server": "服务器",
|
||||
"convert": "转换",
|
||||
"ping": "Ping",
|
||||
"debug": "调试",
|
||||
"addAServer": "添加服务器",
|
||||
"setting": "设置",
|
||||
"license": "开源证书",
|
||||
"snippet": "代码片段",
|
||||
"privateKey": "私钥",
|
||||
"madeWithLove": "\n用❤️制作 by {myGithub}",
|
||||
"aboutThanks": "\n保留所有权利。\n\n感谢以下参与软件测试的各位。",
|
||||
"serverTabEmpty": "现在没有服务器。\n点击右下方按钮来添加。",
|
||||
"serverTabLoading": "加载中...",
|
||||
"serverTabPlzSave": "请再次保存该私钥",
|
||||
"serverTabFailed": "失败",
|
||||
"serverTabUnkown": "未知状态",
|
||||
"serverTabConnecting": "连接中...",
|
||||
"decode": "解码",
|
||||
"encode": "编码",
|
||||
"currentMode": "当前模式",
|
||||
"unkownConvertMode": "未知转换模式",
|
||||
"copy": "复制到剪切板",
|
||||
"upsideDown": "上下交换",
|
||||
"pingAvg": "平均:",
|
||||
"unknown": "未知",
|
||||
"min": "最小",
|
||||
"max": "最大",
|
||||
"ms": "毫秒",
|
||||
"ttl": "缓存时间",
|
||||
"loss": "丢包率",
|
||||
"noResult": "无结果",
|
||||
"pingInputIP": "请输入目标IP或域名",
|
||||
"clear": "清除",
|
||||
"start": "开始",
|
||||
"appPrimaryColor": "App主要色",
|
||||
"updateServerStatusInterval": "服务器状态刷新间隔",
|
||||
"willTakEeffectImmediately": "更改将会立即生效",
|
||||
"launchPage": "启动页",
|
||||
"versionUpdated": "当前:v1.0.{build}, 已是最新版本",
|
||||
"versionUnknownUpdate": "当前:v1.0.{build}",
|
||||
"versionHaveUpdate": "找到新版本:v1.0.{build}, 点击更新",
|
||||
"second": "秒",
|
||||
"updateIntervalEqual0": "你设置为0,服务器状态不会自动刷新。\n你可以手动下拉刷新。",
|
||||
"edit": "编辑",
|
||||
"noSavedPrivateKey": "没有已保存的私钥。",
|
||||
"name": "名称",
|
||||
"pwd": "密码",
|
||||
"save": "保存",
|
||||
"delete": "删除",
|
||||
"fieldMustNotEmpty": "这些输入框不能为空。",
|
||||
"importAndExport": "导入或导出",
|
||||
"choose": "选择",
|
||||
"import": "导入",
|
||||
"export": "导出",
|
||||
"ok": "好",
|
||||
"cancel": "取消",
|
||||
"urlOrJson": "链接或JSON",
|
||||
"go": "开始",
|
||||
"httpFailedWithCode": "请求失败, 状态码: {code}",
|
||||
"run": "运行",
|
||||
"noSavedSnippet": "没有已保存的代码片段。",
|
||||
"chooseDestination": "选择目标",
|
||||
"noServerAvailable": "没有可用的服务器。",
|
||||
"result": "结果",
|
||||
"close": "关闭",
|
||||
"attention": "注意",
|
||||
"sureToDeleteServer": "你确定要删除服务器 [{server}] 吗?",
|
||||
"host": "主机",
|
||||
"port": "端口",
|
||||
"user": "用户",
|
||||
"keyAuth": "公钥认证",
|
||||
"addPrivateKey": "添加一个私钥",
|
||||
"choosePrivateKey": "选择私钥",
|
||||
"plzEnterHost": "请输入主机",
|
||||
"sureNoPwd": "确认使用无密码?",
|
||||
"plzSelectKey": "请选择私钥",
|
||||
"exampleName": "名称示例",
|
||||
"stop": "停止",
|
||||
"download": "下载",
|
||||
"copyPath": "复制路径",
|
||||
"keepForeground": "请保持应用处于前台!",
|
||||
"downloadFinished": "下载完成!",
|
||||
"downloadStatus": "{size} 的 {percent}%",
|
||||
"sftpDlPrepare": "准备连接至服务器...",
|
||||
"sftpSSHConnected": "SFTP 已连接,即将开始下载...",
|
||||
"spentTime": "耗时: {time}",
|
||||
"backDir": "返回上一级",
|
||||
"alreadyLastDir": "已经是最上层目录了",
|
||||
"open": "打开",
|
||||
"sureDelete": "确定删除[{name}]?",
|
||||
"containerStatus": "容器状态",
|
||||
"noClient": "没有SSH连接",
|
||||
"installDockerWithUrl": "请先 https://docs.docker.com/engine/install docker",
|
||||
"waitConnection": "请等待连接建立",
|
||||
"unknownError": "未知错误",
|
||||
"dockerStatusRunningFmt": "{count}个容器正在运行",
|
||||
"dockerStatusRunningAndStoppedFmt": "{runningCount}个正在运行, {stoppedCount}个已停止",
|
||||
"install": "安装",
|
||||
"loadingFiles": "正在加载目录。。。",
|
||||
"sftpNoDownloadTask": "没有下载任务",
|
||||
"goSftpDlPage": "前往下载页?",
|
||||
"createFolder": "创建文件夹",
|
||||
"createFile": "创建文件",
|
||||
"rename": "重命名",
|
||||
"dl2Local": "下载 [{fileName}] 到本地?",
|
||||
"error": "出错了",
|
||||
"disconnected": "连接断开",
|
||||
"files": "文件",
|
||||
"experimentalFeature": "实验性功能",
|
||||
"reportBugsOnGithubIssue": "请到 {url} 提交问题",
|
||||
"noUpdateAvailable": "没有可用更新",
|
||||
"foundNUpdate": "找到 {count} 个更新",
|
||||
"updateAll": "更新全部",
|
||||
"platformNotSupportUpdate": "当前平台不支持更新,请编译最新源码后手动安装",
|
||||
"invalidVersionHelp": "请确保正确安装了docker,或者使用的非自编译版本。如果没有以上问题,请在 {url} 提交问题。",
|
||||
"noInterface": "没有可用的接口",
|
||||
"lastTry": "最后尝试",
|
||||
"pingNoServer": "没有服务器可用于Ping\n请在服务器tab添加服务器后再试",
|
||||
"backupTip": "导出的数据仅进行了简单加密,请妥善保管。\n除了设置项,恢复的数据不会覆盖现有数据。",
|
||||
"backup": "备份",
|
||||
"restore": "恢复",
|
||||
"restoreSureWithDate": "确定恢复 {date} 的备份吗?",
|
||||
"backupVersionNotMatch": "备份版本不匹配,无法恢复",
|
||||
"invalidJson": "无效的json,存在格式问题",
|
||||
"restoreSuccess": "恢复成功,需要重启App来应用更改",
|
||||
"clickSee": "点击查看",
|
||||
"feedback": "反馈",
|
||||
"feedbackOnGithub": "如果你有任何问题,请在GitHub反馈",
|
||||
"update": "更新",
|
||||
"inputDomainHere": "在这里输入域名"
|
||||
}
|
||||
@@ -1,17 +1,20 @@
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:toolbox/data/provider/app.dart';
|
||||
import 'package:toolbox/data/provider/apt.dart';
|
||||
import 'package:toolbox/data/provider/debug.dart';
|
||||
import 'package:toolbox/data/provider/docker.dart';
|
||||
import 'package:toolbox/data/provider/private_key.dart';
|
||||
import 'package:toolbox/data/provider/server.dart';
|
||||
import 'package:toolbox/data/provider/sftp_download.dart';
|
||||
import 'package:toolbox/data/provider/snippet.dart';
|
||||
import 'package:toolbox/data/service/app.dart';
|
||||
import 'package:toolbox/data/store/private_key.dart';
|
||||
import 'package:toolbox/data/store/server.dart';
|
||||
import 'package:toolbox/data/store/setting.dart';
|
||||
import 'package:toolbox/data/store/snippet.dart';
|
||||
|
||||
import 'data/provider/app.dart';
|
||||
import 'data/provider/debug.dart';
|
||||
import 'data/provider/docker.dart';
|
||||
import 'data/provider/pkg.dart';
|
||||
import 'data/provider/private_key.dart';
|
||||
import 'data/provider/server.dart';
|
||||
import 'data/provider/sftp_download.dart';
|
||||
import 'data/provider/snippet.dart';
|
||||
import 'data/provider/virtual_keyboard.dart';
|
||||
import 'data/service/app.dart';
|
||||
import 'data/store/docker.dart';
|
||||
import 'data/store/private_key.dart';
|
||||
import 'data/store/server.dart';
|
||||
import 'data/store/setting.dart';
|
||||
import 'data/store/snippet.dart';
|
||||
|
||||
GetIt locator = GetIt.instance;
|
||||
|
||||
@@ -21,13 +24,14 @@ void setupLocatorForServices() {
|
||||
|
||||
void setupLocatorForProviders() {
|
||||
locator.registerSingleton(AppProvider());
|
||||
locator.registerSingleton(AptProvider());
|
||||
locator.registerSingleton(PkgProvider());
|
||||
locator.registerSingleton(DebugProvider());
|
||||
locator.registerSingleton(DockerProvider());
|
||||
locator.registerSingleton(ServerProvider());
|
||||
locator.registerSingleton(VirtualKeyboard());
|
||||
locator.registerSingleton(SnippetProvider());
|
||||
locator.registerSingleton(PrivateKeyProvider());
|
||||
locator.registerSingleton(SftpDownloadProvider());
|
||||
locator.registerSingleton(SftpProvider());
|
||||
}
|
||||
|
||||
Future<void> setupLocatorForStores() async {
|
||||
@@ -46,6 +50,10 @@ Future<void> setupLocatorForStores() async {
|
||||
final snippet = SnippetStore();
|
||||
await snippet.init(boxName: 'snippet');
|
||||
locator.registerSingleton(snippet);
|
||||
|
||||
final docker = DockerStore();
|
||||
await docker.init(boxName: 'docker');
|
||||
locator.registerSingleton(docker);
|
||||
}
|
||||
|
||||
Future<void> setupLocator() async {
|
||||
|
||||
@@ -4,34 +4,39 @@ import 'package:flutter/material.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/app.dart';
|
||||
import 'package:toolbox/core/analysis.dart';
|
||||
import 'package:toolbox/core/persistant_store.dart';
|
||||
import 'package:toolbox/data/model/server/private_key_info.dart';
|
||||
import 'package:toolbox/data/model/server/server_private_info.dart';
|
||||
import 'package:toolbox/data/model/server/snippet.dart';
|
||||
import 'package:toolbox/data/provider/app.dart';
|
||||
import 'package:toolbox/data/provider/apt.dart';
|
||||
import 'package:toolbox/data/provider/debug.dart';
|
||||
import 'package:toolbox/data/provider/docker.dart';
|
||||
import 'package:toolbox/data/provider/private_key.dart';
|
||||
import 'package:toolbox/data/provider/server.dart';
|
||||
import 'package:toolbox/data/provider/sftp_download.dart';
|
||||
import 'package:toolbox/data/provider/snippet.dart';
|
||||
import 'package:toolbox/data/store/private_key.dart';
|
||||
import 'package:toolbox/data/store/server.dart';
|
||||
import 'package:toolbox/data/store/setting.dart';
|
||||
import 'package:toolbox/data/store/snippet.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
|
||||
import 'app.dart';
|
||||
import 'core/analysis.dart';
|
||||
import 'core/utils/ui.dart';
|
||||
import 'data/model/server/private_key_info.dart';
|
||||
import 'data/model/server/server_private_info.dart';
|
||||
import 'data/model/server/snippet.dart';
|
||||
import 'data/provider/app.dart';
|
||||
import 'data/provider/debug.dart';
|
||||
import 'data/provider/docker.dart';
|
||||
import 'data/provider/pkg.dart';
|
||||
import 'data/provider/private_key.dart';
|
||||
import 'data/provider/server.dart';
|
||||
import 'data/provider/sftp_download.dart';
|
||||
import 'data/provider/snippet.dart';
|
||||
import 'data/provider/virtual_keyboard.dart';
|
||||
import 'data/store/setting.dart';
|
||||
import 'locator.dart';
|
||||
import 'view/widget/rebuild.dart';
|
||||
|
||||
late final DebugProvider _debug;
|
||||
|
||||
Future<void> initApp() async {
|
||||
await initHive();
|
||||
await setupLocator();
|
||||
await upgradeStore();
|
||||
|
||||
_debug = locator<DebugProvider>();
|
||||
locator<SnippetProvider>().loadData();
|
||||
locator<PrivateKeyProvider>().loadData();
|
||||
|
||||
final settings = locator<SettingStore>();
|
||||
await loadFontFile(settings.fontPath.fetch());
|
||||
|
||||
///设置Logger
|
||||
Logger.root.level = Level.ALL; // defaults to Level.INFO
|
||||
Logger.root.onRecord.listen((record) {
|
||||
@@ -47,20 +52,6 @@ Future<void> initHive() async {
|
||||
Hive.registerAdapter(ServerPrivateInfoAdapter());
|
||||
}
|
||||
|
||||
Future<void> upgradeStore() async {
|
||||
final setting = locator<SettingStore>();
|
||||
final version = setting.storeVersion.fetch();
|
||||
if (version == 0) {
|
||||
final snippet = locator<SnippetStore>();
|
||||
final key = locator<PrivateKeyStore>();
|
||||
final spi = locator<ServerStore>();
|
||||
for (final s in <PersistentStore>[snippet, key, spi]) {
|
||||
await s.box.deleteAll(s.box.keys);
|
||||
}
|
||||
setting.storeVersion.put(1);
|
||||
}
|
||||
}
|
||||
|
||||
void runInZone(dynamic Function() body) {
|
||||
final zoneSpec = ZoneSpecification(
|
||||
print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
|
||||
@@ -69,8 +60,7 @@ void runInZone(dynamic Function() body) {
|
||||
// `setState() or markNeedsBuild() called during build`
|
||||
// error.
|
||||
Future.delayed(const Duration(milliseconds: 1), () {
|
||||
final debugProvider = locator<DebugProvider>();
|
||||
debugProvider.addText(line);
|
||||
_debug.addText(line);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -84,9 +74,8 @@ void runInZone(dynamic Function() body) {
|
||||
|
||||
void onError(Object obj, StackTrace stack) {
|
||||
Analysis.recordException(obj);
|
||||
final debugProvider = locator<DebugProvider>();
|
||||
debugProvider.addError(obj);
|
||||
debugProvider.addError(stack);
|
||||
_debug.addMultiline(obj, Colors.red);
|
||||
_debug.addMultiline(stack, Colors.white);
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
@@ -96,16 +85,18 @@ Future<void> main() async {
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (_) => locator<AppProvider>()),
|
||||
ChangeNotifierProvider(create: (_) => locator<AptProvider>()),
|
||||
ChangeNotifierProvider(create: (_) => locator<PkgProvider>()),
|
||||
ChangeNotifierProvider(create: (_) => locator<DebugProvider>()),
|
||||
ChangeNotifierProvider(create: (_) => locator<DockerProvider>()),
|
||||
ChangeNotifierProvider(create: (_) => locator<ServerProvider>()),
|
||||
ChangeNotifierProvider(create: (_) => locator<SnippetProvider>()),
|
||||
ChangeNotifierProvider(create: (_) => locator<VirtualKeyboard>()),
|
||||
ChangeNotifierProvider(create: (_) => locator<PrivateKeyProvider>()),
|
||||
ChangeNotifierProvider(
|
||||
create: (_) => locator<SftpDownloadProvider>()),
|
||||
ChangeNotifierProvider(create: (_) => locator<SftpProvider>()),
|
||||
],
|
||||
child: const MyApp(),
|
||||
child: RebuildWidget(
|
||||
child: MyApp(),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,252 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
import 'package:toolbox/data/model/apt/upgrade_pkg_info.dart';
|
||||
import 'package:toolbox/data/model/server/server_private_info.dart';
|
||||
import 'package:toolbox/data/provider/apt.dart';
|
||||
import 'package:toolbox/data/provider/server.dart';
|
||||
import 'package:toolbox/data/res/url.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
import 'package:toolbox/view/widget/center_loading.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
import 'package:toolbox/view/widget/two_line_text.dart';
|
||||
import 'package:toolbox/view/widget/url_text.dart';
|
||||
|
||||
class AptManagePage extends StatefulWidget {
|
||||
const AptManagePage(this.spi, {Key? key}) : super(key: key);
|
||||
|
||||
final ServerPrivateInfo spi;
|
||||
|
||||
@override
|
||||
_AptManagePageState createState() => _AptManagePageState();
|
||||
}
|
||||
|
||||
class _AptManagePageState extends State<AptManagePage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late MediaQueryData _media;
|
||||
final greyStyle = const TextStyle(color: Colors.grey);
|
||||
final scrollController = ScrollController();
|
||||
final scrollControllerUpdate = ScrollController();
|
||||
final textController = TextEditingController();
|
||||
final _aptProvider = locator<AptProvider>();
|
||||
late S s;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_media = MediaQuery.of(context);
|
||||
s = S.of(context);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
locator<AptProvider>().clear();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final si = locator<ServerProvider>()
|
||||
.servers
|
||||
.firstWhere((e) => e.info == widget.spi);
|
||||
if (si.client == null) {
|
||||
showSnackBar(context, Text(s.waitConnection));
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
|
||||
// ignore: prefer_function_declarations_over_variables
|
||||
Function onSubmitted = () {
|
||||
if (textController.text == '') {
|
||||
showRoundDialog(context, s.attention, Text(s.fieldMustNotEmpty), [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(), child: Text(s.ok)),
|
||||
]);
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
};
|
||||
|
||||
// ignore: prefer_function_declarations_over_variables
|
||||
PwdRequestFunc onPwdRequest = (triedTimes, user) async {
|
||||
if (!mounted) return '';
|
||||
await showRoundDialog(
|
||||
context,
|
||||
triedTimes == 3 ? s.lastTry : (user ?? s.unknown),
|
||||
TextField(
|
||||
controller: textController,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
obscureText: true,
|
||||
onSubmitted: (_) => onSubmitted(),
|
||||
decoration: InputDecoration(
|
||||
labelText: s.pwd,
|
||||
),
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(s.cancel)),
|
||||
TextButton(
|
||||
onPressed: () => onSubmitted(),
|
||||
child: Text(
|
||||
s.ok,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
)),
|
||||
]);
|
||||
return textController.text.trim();
|
||||
};
|
||||
|
||||
_aptProvider.init(
|
||||
si.client!,
|
||||
si.status.sysVer.dist,
|
||||
() =>
|
||||
scrollController.jumpTo(scrollController.position.maxScrollExtent),
|
||||
() => scrollControllerUpdate
|
||||
.jumpTo(scrollControllerUpdate.positions.last.maxScrollExtent),
|
||||
onPwdRequest);
|
||||
_aptProvider.refreshInstalled();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: TwoLineText(up: 'Apt', down: widget.spi.name),
|
||||
),
|
||||
body: Consumer<AptProvider>(builder: (_, apt, __) {
|
||||
if (apt.error != null) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error,
|
||||
color: Colors.redAccent,
|
||||
size: 37,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 37,
|
||||
),
|
||||
SizedBox(
|
||||
height: _media.size.height * 0.4,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(17),
|
||||
child: RoundRectCard(
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(17),
|
||||
child: Text(
|
||||
apt.error!,
|
||||
textAlign: TextAlign.center,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
if (apt.updateLog == null && apt.upgradeable == null) {
|
||||
return centerLoading;
|
||||
}
|
||||
if (apt.updateLog != null && apt.upgradeable == null) {
|
||||
return SizedBox(
|
||||
height: _media.size.height -
|
||||
_media.padding.top -
|
||||
_media.padding.bottom,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints.expand(),
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(18),
|
||||
controller: scrollControllerUpdate,
|
||||
child: Text(apt.updateLog!),
|
||||
),
|
||||
));
|
||||
}
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(13),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(17),
|
||||
child: UrlText(
|
||||
text:
|
||||
'${s.experimentalFeature}\n${s.reportBugsOnGithubIssue(issueUrl)}',
|
||||
replace: 'Github Issue',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
_buildUpdatePanel(apt)
|
||||
].map((e) => RoundRectCard(e)).toList(),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUpdatePanel(AptProvider apt) {
|
||||
if (apt.upgradeable!.isEmpty) {
|
||||
return ListTile(
|
||||
title: Text(
|
||||
s.noUpdateAvailable,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
subtitle: const Text('>_<', textAlign: TextAlign.center),
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ExpansionTile(
|
||||
title: Text(s.foundNUpdate(apt.upgradeable!.length)),
|
||||
subtitle: Text(
|
||||
apt.upgradeable!.map((e) => e.package).join(', '),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: greyStyle,
|
||||
),
|
||||
children: apt.upgradeLog == null
|
||||
? [
|
||||
TextButton(
|
||||
child: Text(s.updateAll),
|
||||
onPressed: () {
|
||||
apt.upgrade();
|
||||
}),
|
||||
SizedBox(
|
||||
height: _media.size.height * 0.73,
|
||||
child: ListView(
|
||||
controller: scrollController,
|
||||
children: apt.upgradeable!
|
||||
.map((e) => _buildUpdateItem(e, apt))
|
||||
.toList()),
|
||||
)
|
||||
]
|
||||
: [
|
||||
SizedBox(
|
||||
height: _media.size.height * 0.7,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints.expand(),
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(18),
|
||||
controller: scrollController,
|
||||
child: Text(apt.upgradeLog!),
|
||||
),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUpdateItem(UpgradePkgInfo info, AptProvider apt) {
|
||||
return ListTile(
|
||||
title: Text(info.package),
|
||||
subtitle: Text(
|
||||
'${info.nowVersion} -> ${info.newVersion}',
|
||||
style: greyStyle,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,35 +4,36 @@ import 'dart:convert';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:toolbox/core/extension/colorx.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
import 'package:toolbox/data/model/app/backup.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
import 'package:toolbox/data/res/font_style.dart';
|
||||
import 'package:toolbox/data/store/private_key.dart';
|
||||
import 'package:toolbox/data/store/server.dart';
|
||||
import 'package:toolbox/data/store/setting.dart';
|
||||
import 'package:toolbox/data/store/snippet.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
|
||||
import '../../core/extension/colorx.dart';
|
||||
import '../../core/utils/ui.dart';
|
||||
import '../../data/model/app/backup.dart';
|
||||
import '../../data/res/ui.dart';
|
||||
import '../../data/store/private_key.dart';
|
||||
import '../../data/store/server.dart';
|
||||
import '../../data/store/setting.dart';
|
||||
import '../../data/store/snippet.dart';
|
||||
import '../../locator.dart';
|
||||
|
||||
const backupFormatVersion = 1;
|
||||
|
||||
class BackupPage extends StatelessWidget {
|
||||
BackupPage({Key? key}) : super(key: key);
|
||||
|
||||
final setting = locator<SettingStore>();
|
||||
final server = locator<ServerStore>();
|
||||
final snippet = locator<SnippetStore>();
|
||||
final privateKey = locator<PrivateKeyStore>();
|
||||
final _setting = locator<SettingStore>();
|
||||
final _server = locator<ServerStore>();
|
||||
final _snippet = locator<SnippetStore>();
|
||||
final _privateKey = locator<PrivateKeyStore>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final media = MediaQuery.of(context);
|
||||
final s = S.of(context);
|
||||
final s = S.of(context)!;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(s.importAndExport, style: size18),
|
||||
title: Text(s.importAndExport, style: textSize18),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
@@ -54,8 +55,12 @@ class BackupPage extends StatelessWidget {
|
||||
const SizedBox(height: 7),
|
||||
const Divider(),
|
||||
const SizedBox(height: 7),
|
||||
_buildCard(s.backup, Icons.file_upload, media,
|
||||
() => _showExportDialog(context, s))
|
||||
_buildCard(
|
||||
s.backup,
|
||||
Icons.file_upload,
|
||||
media,
|
||||
() => _showExportDialog(context, s),
|
||||
)
|
||||
],
|
||||
)),
|
||||
);
|
||||
@@ -63,13 +68,12 @@ class BackupPage extends StatelessWidget {
|
||||
|
||||
Widget _buildCard(String text, IconData icon, MediaQueryData media,
|
||||
FutureOr Function() onTap) {
|
||||
final priColor = primaryColor;
|
||||
final textColor = priColor.isBrightColor ? Colors.black : Colors.white;
|
||||
final textColor = primaryColor.isBrightColor ? Colors.black : Colors.white;
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(37), color: priColor),
|
||||
borderRadius: BorderRadius.circular(37), color: primaryColor),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 7, horizontal: 17),
|
||||
child: Row(
|
||||
@@ -91,60 +95,66 @@ class BackupPage extends StatelessWidget {
|
||||
|
||||
Future<void> _showExportDialog(BuildContext context, S s) async {
|
||||
final exportFieldController = TextEditingController()
|
||||
..text = _diyEncrtpt(json.encode(Backup(
|
||||
backupFormatVersion,
|
||||
DateTime.now().toString().split('.').first,
|
||||
server.fetch(),
|
||||
snippet.fetch(),
|
||||
privateKey.fetch(),
|
||||
setting.primaryColor.fetch() ?? Colors.pinkAccent.value,
|
||||
setting.serverStatusUpdateInterval.fetch() ?? 2,
|
||||
setting.launchPage.fetch() ?? 0,
|
||||
)));
|
||||
await showRoundDialog(
|
||||
context,
|
||||
s.export,
|
||||
TextField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'JSON',
|
||||
..text = _diyEncrtpt(
|
||||
json.encode(
|
||||
Backup(
|
||||
backupFormatVersion,
|
||||
DateTime.now().toString().split('.').first,
|
||||
_server.fetch(),
|
||||
_snippet.fetch(),
|
||||
_privateKey.fetch(),
|
||||
_setting.primaryColor.fetch() ?? Colors.pinkAccent.value,
|
||||
_setting.serverStatusUpdateInterval.fetch() ?? 2,
|
||||
_setting.launchPage.fetch() ?? 0,
|
||||
),
|
||||
maxLines: 7,
|
||||
controller: exportFieldController,
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
child: Text(s.copy),
|
||||
onPressed: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(text: exportFieldController.text));
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
]);
|
||||
);
|
||||
await showRoundDialog(
|
||||
context,
|
||||
s.export,
|
||||
TextField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'JSON',
|
||||
),
|
||||
maxLines: 7,
|
||||
controller: exportFieldController,
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
child: Text(s.copy),
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: exportFieldController.text));
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showImportDialog(BuildContext context, S s) async {
|
||||
final importFieldController = TextEditingController();
|
||||
await showRoundDialog(
|
||||
context,
|
||||
s.import,
|
||||
TextField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'JSON',
|
||||
),
|
||||
maxLines: 3,
|
||||
controller: importFieldController,
|
||||
context,
|
||||
s.import,
|
||||
TextField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'JSON',
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(s.cancel)),
|
||||
TextButton(
|
||||
onPressed: () async =>
|
||||
await _import(importFieldController.text.trim(), context, s),
|
||||
child: const Text('GO'),
|
||||
)
|
||||
]);
|
||||
maxLines: 3,
|
||||
controller: importFieldController,
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async =>
|
||||
await _import(importFieldController.text.trim(), context, s),
|
||||
child: const Text('GO'),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _import(String text, BuildContext context, S s) async {
|
||||
@@ -165,32 +175,36 @@ class BackupPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
await showRoundDialog(
|
||||
context, s.attention, Text(s.restoreSureWithDate(backup.date)), [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
for (final s in backup.snippets) {
|
||||
snippet.put(s);
|
||||
}
|
||||
for (final s in backup.spis) {
|
||||
server.put(s);
|
||||
}
|
||||
for (final s in backup.keys) {
|
||||
privateKey.put(s);
|
||||
}
|
||||
setting.primaryColor.put(backup.primaryColor);
|
||||
setting.serverStatusUpdateInterval
|
||||
.put(backup.serverStatusUpdateInterval);
|
||||
setting.launchPage.put(backup.launchPage);
|
||||
Navigator.of(context).pop();
|
||||
showSnackBar(context, Text(s.restoreSuccess));
|
||||
},
|
||||
child: Text(s.ok),
|
||||
),
|
||||
]);
|
||||
context,
|
||||
s.attention,
|
||||
Text(s.restoreSureWithDate(backup.date)),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
for (final s in backup.snippets) {
|
||||
_snippet.put(s);
|
||||
}
|
||||
for (final s in backup.spis) {
|
||||
_server.put(s);
|
||||
}
|
||||
for (final s in backup.keys) {
|
||||
_privateKey.put(s);
|
||||
}
|
||||
_setting.primaryColor.put(backup.primaryColor);
|
||||
_setting.serverStatusUpdateInterval
|
||||
.put(backup.serverStatusUpdateInterval);
|
||||
_setting.launchPage.put(backup.launchPage);
|
||||
Navigator.of(context).pop();
|
||||
showSnackBar(context, Text(s.restoreSuccess));
|
||||
},
|
||||
child: Text(s.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
} catch (e) {
|
||||
showSnackBar(context, Text(s.invalidJson));
|
||||
return;
|
||||
|
||||
@@ -2,11 +2,12 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:toolbox/view/widget/input_field.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
import '../../core/utils/ui.dart';
|
||||
import '../../data/res/color.dart';
|
||||
import '../widget/input_field.dart';
|
||||
import '../widget/round_rect_card.dart';
|
||||
|
||||
class ConvertPage extends StatefulWidget {
|
||||
const ConvertPage({Key? key}) : super(key: key);
|
||||
@@ -21,7 +22,7 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
late TextEditingController _textEditingControllerResult;
|
||||
late MediaQueryData _media;
|
||||
late ThemeData _theme;
|
||||
late S s;
|
||||
late S _s;
|
||||
|
||||
int _typeOptionIndex = 0;
|
||||
|
||||
@@ -37,7 +38,7 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
super.didChangeDependencies();
|
||||
_media = MediaQuery.of(context);
|
||||
_theme = Theme.of(context);
|
||||
s = S.of(context);
|
||||
_s = S.of(context)!;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -45,14 +46,17 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
super.build(context);
|
||||
return Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 7),
|
||||
controller: ScrollController(),
|
||||
child: Column(children: [
|
||||
padding: const EdgeInsets.symmetric(horizontal: 7),
|
||||
controller: ScrollController(),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 13),
|
||||
_buildInputTop(),
|
||||
_buildTypeOption(),
|
||||
_buildMiddleBtns(),
|
||||
_buildResult(),
|
||||
])),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
try {
|
||||
@@ -62,7 +66,8 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
showSnackBar(context, Text('Error: \n$e'));
|
||||
}
|
||||
},
|
||||
tooltip: s.convert,
|
||||
tooltip: _s.convert,
|
||||
heroTag: 'convert fab',
|
||||
child: const Icon(Icons.send),
|
||||
),
|
||||
);
|
||||
@@ -80,7 +85,7 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
case 3:
|
||||
return Uri.decodeFull(text);
|
||||
default:
|
||||
return s.unkownConvertMode;
|
||||
return _s.unkownConvertMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,9 +96,9 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTypeOption() {
|
||||
final decode = s.decode;
|
||||
final encode = s.encode;
|
||||
Widget _buildMiddleBtns() {
|
||||
final decode = _s.decode;
|
||||
final encode = _s.encode;
|
||||
final List<String> typeOption = [
|
||||
'Base64 $decode',
|
||||
'Base64 $encode',
|
||||
@@ -107,9 +112,7 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
title: Row(
|
||||
children: [
|
||||
TextButton(
|
||||
style: ButtonStyle(
|
||||
foregroundColor: MaterialStateProperty.all(primaryColor)),
|
||||
child: Icon(Icons.change_circle, semanticLabel: s.upsideDown),
|
||||
child: Icon(Icons.change_circle, semanticLabel: _s.upsideDown),
|
||||
onPressed: () {
|
||||
final temp = _textEditingController.text;
|
||||
_textEditingController.text = _textEditingControllerResult.text;
|
||||
@@ -117,14 +120,13 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
style: ButtonStyle(
|
||||
foregroundColor: MaterialStateProperty.all(primaryColor)),
|
||||
child: Icon(Icons.copy, semanticLabel: s.copy),
|
||||
child: Icon(Icons.copy, semanticLabel: _s.copy),
|
||||
onPressed: () => Clipboard.setData(
|
||||
ClipboardData(
|
||||
text: _textEditingControllerResult.text == ''
|
||||
? ' '
|
||||
: _textEditingControllerResult.text),
|
||||
text: _textEditingControllerResult.text == ''
|
||||
? ' '
|
||||
: _textEditingControllerResult.text,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
@@ -135,15 +137,18 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(typeOption[_typeOptionIndex],
|
||||
textScaleFactor: 1.0,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: primaryColor)),
|
||||
Text(
|
||||
s.currentMode,
|
||||
typeOption[_typeOptionIndex],
|
||||
textScaleFactor: 1.0,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
_s.currentMode,
|
||||
textScaleFactor: 1.0,
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(fontSize: 9.0, color: Colors.grey),
|
||||
@@ -152,15 +157,17 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
),
|
||||
),
|
||||
children: typeOption
|
||||
.map((e) => ListTile(
|
||||
title: Text(
|
||||
e,
|
||||
style: TextStyle(
|
||||
color: _theme.textTheme.bodyText2!.color!.withAlpha(177),
|
||||
),
|
||||
.map(
|
||||
(e) => ListTile(
|
||||
title: Text(
|
||||
e,
|
||||
style: TextStyle(
|
||||
color: _theme.textTheme.bodyMedium?.color?.withAlpha(177),
|
||||
),
|
||||
trailing: _buildRadio(typeOption.indexOf(e)),
|
||||
))
|
||||
),
|
||||
trailing: _buildRadio(typeOption.indexOf(e)),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
@@ -179,7 +186,7 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
groupValue: _typeOptionIndex,
|
||||
onChanged: (int? value) {
|
||||
setState(() {
|
||||
_typeOptionIndex = value!;
|
||||
_typeOptionIndex = value ?? 0;
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@@ -13,8 +13,10 @@ class _DebugPageState extends State<DebugPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar:
|
||||
AppBar(title: const Text('App log'), backgroundColor: Colors.black),
|
||||
appBar: AppBar(
|
||||
title: const Text('Logs'),
|
||||
backgroundColor: Colors.black,
|
||||
),
|
||||
body: _buildTerminal(context),
|
||||
backgroundColor: Colors.black,
|
||||
);
|
||||
@@ -31,12 +33,15 @@ class _DebugPageState extends State<DebugPage> {
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Consumer<DebugProvider>(builder: (_, debug, __) {
|
||||
return Column(
|
||||
child: Consumer<DebugProvider>(
|
||||
builder: (_, debug, __) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: debug.widgets);
|
||||
}),
|
||||
children: debug.widgets,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
import 'package:toolbox/data/model/app/menu_item.dart';
|
||||
import 'package:toolbox/data/model/docker/ps.dart';
|
||||
import 'package:toolbox/data/model/server/server_private_info.dart';
|
||||
import 'package:toolbox/data/provider/docker.dart';
|
||||
import 'package:toolbox/data/provider/server.dart';
|
||||
import 'package:toolbox/data/res/url.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
import 'package:toolbox/view/widget/center_loading.dart';
|
||||
import 'package:toolbox/view/widget/two_line_text.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
import 'package:toolbox/view/widget/url_text.dart';
|
||||
|
||||
import '../../core/utils/ui.dart';
|
||||
import '../../data/model/docker/ps.dart';
|
||||
import '../../data/model/server/server_private_info.dart';
|
||||
import '../../data/provider/docker.dart';
|
||||
import '../../data/provider/server.dart';
|
||||
import '../../data/res/error.dart';
|
||||
import '../../data/res/menu.dart';
|
||||
import '../../data/res/ui.dart';
|
||||
import '../../data/res/url.dart';
|
||||
import '../../data/store/docker.dart';
|
||||
import '../../locator.dart';
|
||||
import '../widget/center_loading.dart';
|
||||
import '../widget/dropdown_menu.dart';
|
||||
import '../widget/round_rect_card.dart';
|
||||
import '../widget/two_line_text.dart';
|
||||
import '../widget/url_text.dart';
|
||||
|
||||
class DockerManagePage extends StatefulWidget {
|
||||
final ServerPrivateInfo spi;
|
||||
@@ -24,8 +29,8 @@ class DockerManagePage extends StatefulWidget {
|
||||
|
||||
class _DockerManagePageState extends State<DockerManagePage> {
|
||||
final _docker = locator<DockerProvider>();
|
||||
final greyTextStyle = const TextStyle(color: Colors.grey);
|
||||
late S s;
|
||||
final _textController = TextEditingController();
|
||||
late S _s;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@@ -36,90 +41,386 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
s = S.of(context);
|
||||
_s = S.of(context)!;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final client = locator<ServerProvider>()
|
||||
.servers
|
||||
.firstWhere((element) => element.info == widget.spi)
|
||||
.client;
|
||||
final client = locator<ServerProvider>().getServer(widget.spi.id).client;
|
||||
if (client == null) {
|
||||
showSnackBar(context, Text(s.noClient));
|
||||
showSnackBar(context, Text(_s.noClient));
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
_docker.init(client, widget.spi.user);
|
||||
_docker.init(client, widget.spi.user, onPwdRequest, widget.spi.id);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: TwoLineText(up: 'Docker', down: widget.spi.name),
|
||||
),
|
||||
body: _buildMain(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMain() {
|
||||
return Consumer<DockerProvider>(builder: (_, docker, __) {
|
||||
final running = docker.items;
|
||||
if (docker.error != null && running == null) {
|
||||
return SizedBox.expand(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error,
|
||||
size: 37,
|
||||
),
|
||||
const SizedBox(height: 27),
|
||||
Text(docker.error!),
|
||||
const SizedBox(height: 27),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(17),
|
||||
child: _buildSolution(docker.error!),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
if (running == null) {
|
||||
_docker.refresh();
|
||||
return centerLoading;
|
||||
}
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(7),
|
||||
children: [
|
||||
_buildVersion(
|
||||
docker.edition ?? s.unknown, docker.version ?? s.unknown),
|
||||
_buildPsItems(running, docker)
|
||||
].map((e) => RoundRectCard(e)).toList(),
|
||||
return Consumer<DockerProvider>(builder: (_, ___, __) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: TwoLineText(up: 'Docker', down: widget.spi.name),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () => _docker.refresh(),
|
||||
icon: const Icon(Icons.refresh),
|
||||
)
|
||||
],
|
||||
),
|
||||
body: _buildMain(),
|
||||
floatingActionButton: _buildFAB(),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildSolution(String err) {
|
||||
switch (err) {
|
||||
case 'docker not found':
|
||||
Widget _buildFAB() {
|
||||
return FloatingActionButton(
|
||||
onPressed: () async => await _showAddFAB(),
|
||||
child: const Icon(Icons.add),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showAddFAB() async {
|
||||
final imageCtrl = TextEditingController();
|
||||
final nameCtrl = TextEditingController();
|
||||
final argsCtrl = TextEditingController();
|
||||
await showRoundDialog(
|
||||
context,
|
||||
_s.newContainer,
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
keyboardType: TextInputType.text,
|
||||
decoration: InputDecoration(
|
||||
labelText: _s.dockerImage, hintText: 'ubuntu:22.10'),
|
||||
controller: imageCtrl,
|
||||
autocorrect: false,
|
||||
),
|
||||
TextField(
|
||||
keyboardType: TextInputType.text,
|
||||
controller: nameCtrl,
|
||||
decoration: InputDecoration(
|
||||
labelText: _s.dockerContainerName, hintText: 'ubuntu22'),
|
||||
autocorrect: false,
|
||||
),
|
||||
TextField(
|
||||
keyboardType: TextInputType.text,
|
||||
controller: argsCtrl,
|
||||
decoration: InputDecoration(
|
||||
labelText: _s.extraArgs,
|
||||
hintText: '-p 2222:22 -v ~/.xxx/:/xxx'),
|
||||
autocorrect: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
await _showAddCmdPreview(
|
||||
_buildAddCmd(
|
||||
imageCtrl.text.trim(),
|
||||
nameCtrl.text.trim(),
|
||||
argsCtrl.text.trim(),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showAddCmdPreview(String cmd) async {
|
||||
await showRoundDialog(
|
||||
context,
|
||||
_s.preview,
|
||||
Text(cmd),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final result = await _docker.run(cmd);
|
||||
if (result != null) {
|
||||
showSnackBar(context, Text(getErrMsg(result) ?? _s.unknownError));
|
||||
}
|
||||
},
|
||||
child: Text(_s.run),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String _buildAddCmd(String image, String name, String args) {
|
||||
var suffix = '';
|
||||
if (args.isEmpty) {
|
||||
suffix = image;
|
||||
} else {
|
||||
suffix = '$args $image';
|
||||
}
|
||||
if (name.isEmpty) {
|
||||
return 'docker run -itd $suffix';
|
||||
}
|
||||
return 'docker run -itd --name $name $suffix';
|
||||
}
|
||||
|
||||
String? getErrMsg(DockerErr err) {
|
||||
switch (err.type) {
|
||||
default:
|
||||
return err.message;
|
||||
}
|
||||
}
|
||||
|
||||
void onSubmitted() {
|
||||
if (_textController.text == '') {
|
||||
showRoundDialog(context, _s.attention, Text(_s.fieldMustNotEmpty), [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
]);
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
Future<String> onPwdRequest() async {
|
||||
if (!mounted) return '';
|
||||
await showRoundDialog(
|
||||
context,
|
||||
widget.spi.user,
|
||||
TextField(
|
||||
controller: _textController,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
obscureText: true,
|
||||
onSubmitted: (_) => onSubmitted(),
|
||||
decoration: InputDecoration(
|
||||
labelText: _s.pwd,
|
||||
),
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => onSubmitted(),
|
||||
child: Text(
|
||||
_s.ok,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
return _textController.text.trim();
|
||||
}
|
||||
|
||||
Widget _buildMain() {
|
||||
if (_docker.error != null && _docker.items == null) {
|
||||
return SizedBox.expand(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error,
|
||||
size: 37,
|
||||
),
|
||||
const SizedBox(height: 27),
|
||||
_buildErr(_docker.error!),
|
||||
const SizedBox(height: 27),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(17),
|
||||
child: _buildSolution(_docker.error!),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
if (_docker.items == null || _docker.images == null) {
|
||||
_docker.refresh();
|
||||
return centerLoading;
|
||||
}
|
||||
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(7),
|
||||
children: [
|
||||
_buildLoading(),
|
||||
_buildVersion(
|
||||
_docker.edition ?? _s.unknown, _docker.version ?? _s.unknown),
|
||||
_buildPsItems(),
|
||||
_buildImages(),
|
||||
_buildEditHost(),
|
||||
].map((e) => RoundRectCard(e)).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildImages() {
|
||||
if (_docker.images == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return ExpansionTile(
|
||||
title: Text(_s.imagesList),
|
||||
subtitle: Text(
|
||||
_s.dockerImagesFmt(_docker.images!.length),
|
||||
style: grey,
|
||||
),
|
||||
children: _docker.images!
|
||||
.map(
|
||||
(e) => ListTile(
|
||||
title: Text(e.repo),
|
||||
subtitle: Text('${e.tag} - ${e.size}'),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.delete),
|
||||
onPressed: () async {
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.attention,
|
||||
Text(_s.sureDelete(e.repo)),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final result = await _docker.run(
|
||||
'docker rmi ${e.id} -f',
|
||||
);
|
||||
if (result != null) {
|
||||
showSnackBar(
|
||||
context,
|
||||
Text(getErrMsg(result) ?? _s.unknownError),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
_s.ok,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoading() {
|
||||
if (!_docker.isBusy) return const SizedBox();
|
||||
final haveLog = _docker.runLog != null;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(17),
|
||||
child: Column(
|
||||
children: [
|
||||
const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
haveLog ? const SizedBox(height: 17) : const SizedBox(),
|
||||
haveLog ? Text(_docker.runLog!) : const SizedBox()
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEditHost() {
|
||||
if (_docker.items!.isNotEmpty || _docker.images!.isNotEmpty) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(17, 17, 17, 0),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
_s.dockerEmptyRunningItems,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => _showEditHostDialog(),
|
||||
child: Text(_s.dockerEditHost),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showEditHostDialog() async {
|
||||
await showRoundDialog(
|
||||
context,
|
||||
_s.dockerEditHost,
|
||||
TextField(
|
||||
maxLines: 1,
|
||||
autocorrect: false,
|
||||
controller:
|
||||
TextEditingController(text: 'unix:///run/user/1000/docker.sock'),
|
||||
onSubmitted: (value) {
|
||||
locator<DockerStore>().setDockerHost(widget.spi.id, value.trim());
|
||||
_docker.refresh();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildErr(DockerErr err) {
|
||||
var errStr = '';
|
||||
switch (err.type) {
|
||||
case DockerErrType.noClient:
|
||||
errStr = _s.noClient;
|
||||
break;
|
||||
case DockerErrType.notInstalled:
|
||||
errStr = _s.dockerNotInstalled;
|
||||
break;
|
||||
case DockerErrType.invalidVersion:
|
||||
errStr = _s.invalidVersion;
|
||||
break;
|
||||
default:
|
||||
errStr = err.message ?? _s.unknown;
|
||||
}
|
||||
return Text(errStr);
|
||||
}
|
||||
|
||||
Widget _buildSolution(DockerErr err) {
|
||||
switch (err.type) {
|
||||
case DockerErrType.notInstalled:
|
||||
return UrlText(
|
||||
text: s.installDockerWithUrl,
|
||||
replace: s.install,
|
||||
text: _s.installDockerWithUrl,
|
||||
replace: _s.install,
|
||||
);
|
||||
case 'no client':
|
||||
return Text(s.waitConnection);
|
||||
case 'invalid version':
|
||||
case DockerErrType.noClient:
|
||||
return Text(_s.waitConnection);
|
||||
case DockerErrType.invalidVersion:
|
||||
return UrlText(
|
||||
text: s.invalidVersionHelp(issueUrl),
|
||||
text: _s.invalidVersionHelp(issueUrl),
|
||||
replace: 'Github',
|
||||
);
|
||||
default:
|
||||
return Text(s.unknownError);
|
||||
return Text(_s.unknownError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,46 +434,63 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPsItems(List<DockerPsItem> running, DockerProvider docker) {
|
||||
Widget _buildPsItems() {
|
||||
return ExpansionTile(
|
||||
title: Text(s.containerStatus),
|
||||
subtitle: Text(_buildSubtitle(running), style: greyTextStyle),
|
||||
children: running.map((item) {
|
||||
return ListTile(
|
||||
title: Text(item.image),
|
||||
subtitle: Text(item.status),
|
||||
trailing: docker.isBusy
|
||||
? const CircularProgressIndicator()
|
||||
: _buildMoreBtn(item.running, item.containerId),
|
||||
);
|
||||
}).toList(),
|
||||
title: Text(_s.containerStatus),
|
||||
subtitle: Text(_buildSubtitle(_docker.items!), style: grey),
|
||||
children: _docker.items!.map(
|
||||
(item) {
|
||||
return ListTile(
|
||||
title: Text(item.name),
|
||||
subtitle: Text('${item.image} - ${item.status}'),
|
||||
trailing: _buildMoreBtn(item, _docker.isBusy),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMoreBtn(bool running, String containerId) {
|
||||
final item = running ? DockerMenuItems.stop : DockerMenuItems.start;
|
||||
Widget _buildMoreBtn(DockerPsItem dItem, bool busy) {
|
||||
final item = dItem.running ? DockerMenuItems.stop : DockerMenuItems.start;
|
||||
return buildPopuopMenu(
|
||||
items: [
|
||||
PopupMenuItem<DropdownBtnItem>(
|
||||
value: item,
|
||||
child: item.build,
|
||||
child: item.build(_s),
|
||||
),
|
||||
PopupMenuItem<DropdownBtnItem>(
|
||||
value: DockerMenuItems.rm,
|
||||
child: DockerMenuItems.rm.build,
|
||||
child: DockerMenuItems.rm.build(_s),
|
||||
),
|
||||
],
|
||||
onSelected: (value) {
|
||||
if (busy) {
|
||||
showSnackBar(context, Text(_s.isBusy));
|
||||
return;
|
||||
}
|
||||
final item = value as DropdownBtnItem;
|
||||
switch (item) {
|
||||
case DockerMenuItems.rm:
|
||||
_docker.delete(containerId);
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.attention,
|
||||
Text(_s.sureDelete(dItem.name)),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
_docker.delete(dItem.containerId);
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
)
|
||||
],
|
||||
);
|
||||
break;
|
||||
case DockerMenuItems.start:
|
||||
_docker.start(containerId);
|
||||
_docker.start(dItem.containerId);
|
||||
break;
|
||||
case DockerMenuItems.stop:
|
||||
_docker.stop(containerId);
|
||||
_docker.stop(dItem.containerId);
|
||||
break;
|
||||
}
|
||||
},
|
||||
@@ -183,8 +501,8 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
final runningCount = running.where((element) => element.running).length;
|
||||
final stoped = running.length - runningCount;
|
||||
if (stoped == 0) {
|
||||
return s.dockerStatusRunningFmt(runningCount);
|
||||
return _s.dockerStatusRunningFmt(runningCount);
|
||||
}
|
||||
return s.dockerStatusRunningAndStoppedFmt(runningCount, stoped);
|
||||
return _s.dockerStatusRunningAndStoppedFmt(runningCount, stoped);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
import 'package:after_layout/after_layout.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:toolbox/core/analysis.dart';
|
||||
import 'package:toolbox/core/build_mode.dart';
|
||||
import 'package:toolbox/core/route.dart';
|
||||
import 'package:toolbox/core/update.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
import 'package:toolbox/data/model/app/navigation_item.dart';
|
||||
import 'package:toolbox/data/provider/server.dart';
|
||||
import 'package:toolbox/data/res/build_data.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
import 'package:toolbox/data/res/font_style.dart';
|
||||
import 'package:toolbox/data/res/icon/common.dart';
|
||||
import 'package:toolbox/data/res/tab.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/backup.dart';
|
||||
import 'package:toolbox/view/page/convert.dart';
|
||||
import 'package:toolbox/view/page/debug.dart';
|
||||
import 'package:toolbox/view/page/ping.dart';
|
||||
import 'package:toolbox/view/page/private_key/list.dart';
|
||||
import 'package:toolbox/view/page/server/tab.dart';
|
||||
import 'package:toolbox/view/page/setting.dart';
|
||||
import 'package:toolbox/view/page/sftp/downloaded.dart';
|
||||
import 'package:toolbox/view/page/snippet/list.dart';
|
||||
import 'package:toolbox/view/widget/url_text.dart';
|
||||
|
||||
import '../../core/analysis.dart';
|
||||
import '../../core/route.dart';
|
||||
import '../../core/update.dart';
|
||||
import '../../core/utils/ui.dart';
|
||||
import '../../data/model/app/dynamic_color.dart';
|
||||
import '../../data/model/app/navigation_item.dart';
|
||||
import '../../data/provider/server.dart';
|
||||
import '../../data/res/build_data.dart';
|
||||
import '../../data/res/tab.dart';
|
||||
import '../../data/res/ui.dart';
|
||||
import '../../data/res/url.dart';
|
||||
import '../../data/store/setting.dart';
|
||||
import '../../locator.dart';
|
||||
import '../widget/url_text.dart';
|
||||
import 'backup.dart';
|
||||
import 'convert.dart';
|
||||
import 'debug.dart';
|
||||
import 'ping.dart';
|
||||
import 'private_key/list.dart';
|
||||
import 'server/tab.dart';
|
||||
import 'setting.dart';
|
||||
import 'sftp/downloaded.dart';
|
||||
import 'snippet/list.dart';
|
||||
|
||||
final _bottomItemOverlayColor =
|
||||
DynamicColor(Colors.black.withOpacity(0.07), Colors.white12);
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({Key? key, required this.primaryColor}) : super(key: key);
|
||||
final Color primaryColor;
|
||||
const MyHomePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
@@ -40,14 +40,13 @@ class MyHomePage extends StatefulWidget {
|
||||
class _MyHomePageState extends State<MyHomePage>
|
||||
with
|
||||
AutomaticKeepAliveClientMixin,
|
||||
SingleTickerProviderStateMixin,
|
||||
AfterLayoutMixin,
|
||||
WidgetsBindingObserver {
|
||||
late final ServerProvider _serverProvider;
|
||||
late final PageController _pageController;
|
||||
late int _selectIndex;
|
||||
late double _width;
|
||||
late S s;
|
||||
late S _s;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -61,7 +60,7 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
s = S.of(context);
|
||||
_s = S.of(context)!;
|
||||
_width = MediaQuery.of(context).size.width;
|
||||
}
|
||||
|
||||
@@ -69,6 +68,7 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
_serverProvider.closeServer();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -86,27 +86,14 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return WillPopScope(
|
||||
child: _buildMain(context),
|
||||
onWillPop: () {
|
||||
final scaffold = Scaffold.of(context);
|
||||
if (scaffold.isDrawerOpen) {
|
||||
scaffold.closeDrawer();
|
||||
return Future.value(false);
|
||||
}
|
||||
return Future.value(true);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildMain(BuildContext context) {
|
||||
return Scaffold(
|
||||
drawer: _buildDrawer(),
|
||||
appBar: AppBar(
|
||||
title: Text(tabTitleName(context, _selectIndex), style: size18),
|
||||
title: Text(tabTitleName(context, _selectIndex), style: textSize18),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.developer_mode, size: 23),
|
||||
tooltip: s.debug,
|
||||
tooltip: _s.debug,
|
||||
onPressed: () =>
|
||||
AppRoute(const DebugPage(), 'Debug Page').go(context),
|
||||
),
|
||||
@@ -116,7 +103,7 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
physics: const ClampingScrollPhysics(),
|
||||
controller: _pageController,
|
||||
onPageChanged: (i) {
|
||||
FocusScope.of(context).unfocus();
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
_selectIndex = i;
|
||||
setState(() {});
|
||||
},
|
||||
@@ -126,8 +113,7 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItem(int idx, NavigationItem item, bool isSelected) {
|
||||
bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
||||
Widget _buildBottomItem(int idx, NavigationItem item, bool isSelected) {
|
||||
final width = _width / tabItems.length;
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 377),
|
||||
@@ -135,12 +121,13 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
height: 50,
|
||||
width: isSelected ? width : width - 17,
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? isDarkMode
|
||||
? Colors.white12
|
||||
: Colors.black.withOpacity(0.07)
|
||||
: Colors.transparent,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(50))),
|
||||
color: isSelected
|
||||
? _bottomItemOverlayColor.resolve(context)
|
||||
: Colors.transparent,
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(50),
|
||||
),
|
||||
),
|
||||
child: IconButton(
|
||||
icon: Icon(item.icon),
|
||||
tooltip: tabTitleName(context, idx),
|
||||
@@ -159,18 +146,25 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
|
||||
Widget _buildBottom(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Container(
|
||||
height: 56,
|
||||
padding: const EdgeInsets.only(left: 8, top: 4, bottom: 4, right: 8),
|
||||
width: _width,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: tabItems.map((item) {
|
||||
int itemIndex = tabItems.indexOf(item);
|
||||
return _buildItem(itemIndex, item, _selectIndex == itemIndex);
|
||||
}).toList(),
|
||||
child: Container(
|
||||
height: 56,
|
||||
padding: const EdgeInsets.only(left: 8, top: 4, bottom: 4, right: 8),
|
||||
width: _width,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: tabItems.map(
|
||||
(item) {
|
||||
int itemIndex = tabItems.indexOf(item);
|
||||
return _buildBottomItem(
|
||||
itemIndex,
|
||||
item,
|
||||
_selectIndex == itemIndex,
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDrawer() {
|
||||
@@ -179,8 +173,19 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildIcon(),
|
||||
const Text(BuildData.name),
|
||||
Text(_buildVersionStr()),
|
||||
TextButton(
|
||||
onPressed: () => showRoundDialog(
|
||||
context,
|
||||
_versionStr,
|
||||
const Text(BuildData.buildAt),
|
||||
[],
|
||||
),
|
||||
child: Text(
|
||||
'${BuildData.name}\n$_versionStr',
|
||||
textAlign: TextAlign.center,
|
||||
style: textSize13,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.07,
|
||||
),
|
||||
@@ -190,74 +195,77 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.settings),
|
||||
title: Text(s.setting),
|
||||
title: Text(_s.setting),
|
||||
onTap: () =>
|
||||
AppRoute(const SettingPage(), 'Setting').go(context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.vpn_key),
|
||||
title: Text(s.privateKey),
|
||||
title: Text(_s.privateKey),
|
||||
onTap: () => AppRoute(
|
||||
const StoredPrivateKeysPage(), 'private key list')
|
||||
.go(context),
|
||||
const PrivateKeysListPage(),
|
||||
'private key list',
|
||||
).go(context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.download),
|
||||
title: Text(s.download),
|
||||
title: Text(_s.download),
|
||||
onTap: () =>
|
||||
AppRoute(const SFTPDownloadedPage(), 'snippet list')
|
||||
.go(context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.import_export),
|
||||
title: Text(s.backup),
|
||||
title: Text(_s.backup),
|
||||
onTap: () =>
|
||||
AppRoute(BackupPage(), 'backup page').go(context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.info),
|
||||
title: Text(s.feedback),
|
||||
title: Text(_s.feedback),
|
||||
onTap: () => showRoundDialog(
|
||||
context, s.feedback, Text(s.feedbackOnGithub), [
|
||||
TextButton(
|
||||
onPressed: () => Clipboard.setData(
|
||||
const ClipboardData(text: issueUrl)),
|
||||
child: Text(s.copy)),
|
||||
TextButton(
|
||||
context,
|
||||
_s.feedback,
|
||||
Text(_s.feedbackOnGithub),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => openUrl(issueUrl),
|
||||
child: Text(s.feedback)),
|
||||
TextButton(
|
||||
child: Text(_s.feedback),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(s.close))
|
||||
]),
|
||||
child: Text(_s.close),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.snippet_folder),
|
||||
title: Text(s.snippet),
|
||||
title: Text(_s.snippet),
|
||||
onTap: () => AppRoute(const SnippetListPage(), 'snippet list')
|
||||
.go(context),
|
||||
),
|
||||
AboutListTile(
|
||||
icon: const Icon(Icons.text_snippet),
|
||||
applicationName: BuildData.name,
|
||||
applicationVersion: _buildVersionStr(),
|
||||
applicationName: '\n${BuildData.name}',
|
||||
applicationVersion: _versionStr,
|
||||
applicationIcon: _buildIcon(),
|
||||
aboutBoxChildren: [
|
||||
UrlText(
|
||||
text: s.madeWithLove(myGithub), replace: 'LollipopKit'),
|
||||
text: _s.madeWithLove(myGithub),
|
||||
replace: 'lollipopkit'),
|
||||
UrlText(
|
||||
text: s.aboutThanks,
|
||||
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),
|
||||
child: Text(_s.about),
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -272,10 +280,11 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxHeight: 53, maxWidth: 53),
|
||||
child: Container(
|
||||
color: primaryColor,
|
||||
)),
|
||||
constraints: const BoxConstraints(maxHeight: 53, maxWidth: 53),
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxHeight: 83, maxWidth: 83),
|
||||
child: appIcon,
|
||||
@@ -284,7 +293,7 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
);
|
||||
}
|
||||
|
||||
String _buildVersionStr() {
|
||||
String get _versionStr {
|
||||
var mod = '';
|
||||
if (BuildData.modifications != 0) {
|
||||
mod = '(+${BuildData.modifications})';
|
||||
@@ -300,8 +309,8 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
await GetIt.I.allReady();
|
||||
await locator<ServerProvider>().loadLocalData();
|
||||
await doUpdate(context);
|
||||
if (BuildMode.isRelease) {
|
||||
await Analysis.init(false);
|
||||
if (!Analysis.enabled) {
|
||||
await Analysis.init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:after_layout/after_layout.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/extension/uint8list.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
import 'package:toolbox/data/model/server/ping_result.dart';
|
||||
import 'package:toolbox/data/provider/server.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
import 'package:toolbox/view/widget/input_field.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
import '../../core/extension/uint8list.dart';
|
||||
import '../../core/utils/ui.dart';
|
||||
import '../../data/model/server/ping_result.dart';
|
||||
import '../../data/provider/server.dart';
|
||||
import '../../data/res/color.dart';
|
||||
import '../../data/res/ui.dart';
|
||||
import '../../locator.dart';
|
||||
import '../widget/input_field.dart';
|
||||
import '../widget/round_rect_card.dart';
|
||||
|
||||
final doaminReg =
|
||||
RegExp(r'^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$');
|
||||
@@ -23,15 +28,12 @@ class PingPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PingPageState extends State<PingPage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
with AutomaticKeepAliveClientMixin, AfterLayoutMixin {
|
||||
late TextEditingController _textEditingController;
|
||||
late MediaQueryData _media;
|
||||
final List<PingResult> _results = [];
|
||||
final _serverProvider = locator<ServerProvider>();
|
||||
late S s;
|
||||
static const summaryTextStyle = TextStyle(
|
||||
fontSize: 12,
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -43,7 +45,7 @@ class _PingPageState extends State<PingPage>
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_media = MediaQuery.of(context);
|
||||
s = S.of(context);
|
||||
s = S.of(context)!;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -51,27 +53,34 @@ class _PingPageState extends State<PingPage>
|
||||
super.build(context);
|
||||
return Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 7),
|
||||
child: Column(children: [
|
||||
padding: const EdgeInsets.symmetric(horizontal: 7),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 13),
|
||||
buildInput(context, _textEditingController,
|
||||
hint: s.inputDomainHere,
|
||||
maxLines: 1,
|
||||
onSubmitted: (_) => doPing()),
|
||||
buildInput(
|
||||
context,
|
||||
_textEditingController,
|
||||
hint: s.inputDomainHere,
|
||||
maxLines: 1,
|
||||
onSubmitted: (_) => doPing(),
|
||||
),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: _media.size.height * 0.6,
|
||||
child: ListView.builder(
|
||||
controller: ScrollController(),
|
||||
itemCount: _results.length,
|
||||
itemBuilder: (context, index) {
|
||||
final result = _results[index];
|
||||
return _buildResultItem(result);
|
||||
}),
|
||||
controller: ScrollController(),
|
||||
itemCount: _results.length,
|
||||
itemBuilder: (context, index) {
|
||||
final result = _results[index];
|
||||
return _buildResultItem(result);
|
||||
},
|
||||
),
|
||||
),
|
||||
])),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.play_arrow),
|
||||
heroTag: 'ping fab',
|
||||
onPressed: () {
|
||||
try {
|
||||
doPing();
|
||||
@@ -79,6 +88,7 @@ class _PingPageState extends State<PingPage>
|
||||
showSnackBar(context, Text('Error: \n$e'));
|
||||
}
|
||||
},
|
||||
child: const Icon(Icons.play_arrow),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -86,19 +96,30 @@ class _PingPageState extends State<PingPage>
|
||||
Widget _buildResultItem(PingResult result) {
|
||||
final unknown = s.unknown;
|
||||
final ms = s.ms;
|
||||
return RoundRectCard(ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 7, horizontal: 17),
|
||||
title: Text(result.serverName,
|
||||
return RoundRectCard(
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 7, horizontal: 17),
|
||||
title: Text(
|
||||
result.serverName,
|
||||
style: TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.bold, color: primaryColor)),
|
||||
subtitle: Text(
|
||||
_buildPingSummary(result, unknown, ms),
|
||||
style: summaryTextStyle,
|
||||
),
|
||||
trailing: Text(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
_buildPingSummary(result, unknown, ms),
|
||||
style: textSize11,
|
||||
),
|
||||
trailing: Text(
|
||||
'${s.pingAvg}${result.statistic?.avg?.toStringAsFixed(2) ?? s.unknown} $ms',
|
||||
style: TextStyle(fontSize: 14, color: primaryColor)),
|
||||
));
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _buildPingSummary(PingResult result, String unknown, String ms) {
|
||||
@@ -114,6 +135,7 @@ class _PingPageState extends State<PingPage>
|
||||
}
|
||||
|
||||
Future<void> doPing() async {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
_results.clear();
|
||||
final target = _textEditingController.text.trim();
|
||||
if (target.isEmpty) {
|
||||
@@ -139,7 +161,7 @@ class _PingPageState extends State<PingPage>
|
||||
return;
|
||||
}
|
||||
final result = await e.client!.run('ping -c 3 $target').string;
|
||||
_results.add(PingResult.parse(e.info.name, result));
|
||||
_results.add(PingResult.parse(e.spi.name, result));
|
||||
setState(() {});
|
||||
}));
|
||||
} catch (e) {
|
||||
@@ -149,4 +171,12 @@ class _PingPageState extends State<PingPage>
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
Future<FutureOr<void>> afterFirstLayout(BuildContext context) async {
|
||||
if (_serverProvider.servers.isEmpty) {
|
||||
await _serverProvider.loadLocalData();
|
||||
await _serverProvider.refreshData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
235
lib/view/page/pkg.dart
Normal file
235
lib/view/page/pkg.dart
Normal file
@@ -0,0 +1,235 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../data/model/pkg/upgrade_info.dart';
|
||||
import '../../data/model/server/dist.dart';
|
||||
import '../../core/utils/ui.dart';
|
||||
import '../../data/model/server/server_private_info.dart';
|
||||
import '../../data/provider/pkg.dart';
|
||||
import '../../data/provider/server.dart';
|
||||
import '../../data/res/ui.dart';
|
||||
import '../../locator.dart';
|
||||
import '../widget/center_loading.dart';
|
||||
import '../widget/round_rect_card.dart';
|
||||
import '../widget/two_line_text.dart';
|
||||
|
||||
class PkgManagePage extends StatefulWidget {
|
||||
const PkgManagePage(this.spi, {Key? key}) : super(key: key);
|
||||
|
||||
final ServerPrivateInfo spi;
|
||||
|
||||
@override
|
||||
_PkgManagePageState createState() => _PkgManagePageState();
|
||||
}
|
||||
|
||||
class _PkgManagePageState extends State<PkgManagePage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late MediaQueryData _media;
|
||||
final _scrollController = ScrollController();
|
||||
final _scrollControllerUpdate = ScrollController();
|
||||
final _textController = TextEditingController();
|
||||
final _aptProvider = locator<PkgProvider>();
|
||||
late S _s;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_media = MediaQuery.of(context);
|
||||
_s = S.of(context)!;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
locator<PkgProvider>().clear();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final si = locator<ServerProvider>().getServer(widget.spi.id);
|
||||
if (si.client == null) {
|
||||
showSnackBar(context, Text(_s.waitConnection));
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
|
||||
_aptProvider.init(
|
||||
si.client!,
|
||||
si.status.sysVer.dist,
|
||||
() =>
|
||||
_scrollController.jumpTo(_scrollController.position.maxScrollExtent),
|
||||
() => _scrollControllerUpdate
|
||||
.jumpTo(_scrollController.position.maxScrollExtent),
|
||||
onPwdRequest,
|
||||
widget.spi.user,
|
||||
);
|
||||
_aptProvider.refresh();
|
||||
}
|
||||
|
||||
void onSubmitted() {
|
||||
if (_textController.text == '') {
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.attention,
|
||||
Text(_s.fieldMustNotEmpty),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
Future<String> onPwdRequest() async {
|
||||
if (!mounted) return '';
|
||||
await showRoundDialog(
|
||||
context,
|
||||
widget.spi.user,
|
||||
TextField(
|
||||
controller: _textController,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
obscureText: true,
|
||||
onSubmitted: (_) => onSubmitted(),
|
||||
decoration: InputDecoration(
|
||||
labelText: _s.pwd,
|
||||
),
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(_s.cancel)),
|
||||
TextButton(
|
||||
onPressed: () => onSubmitted(),
|
||||
child: Text(
|
||||
_s.ok,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
return _textController.text.trim();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: TwoLineText(up: _s.pkg, down: widget.spi.name),
|
||||
),
|
||||
body: Consumer<PkgProvider>(builder: (_, apt, __) {
|
||||
if (apt.error != null) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error,
|
||||
color: Colors.redAccent,
|
||||
size: 37,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 37,
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: _media.size.height * 0.3,
|
||||
minWidth: _media.size.width),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(17),
|
||||
child: RoundRectCard(
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(17),
|
||||
child: Text(
|
||||
apt.error!,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
if (apt.updateLog == null && apt.upgradeable == null) {
|
||||
return centerLoading;
|
||||
}
|
||||
if (apt.updateLog != null && apt.upgradeable == null) {
|
||||
return SizedBox(
|
||||
height:
|
||||
_media.size.height - _media.padding.top - _media.padding.bottom,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints.expand(),
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(18),
|
||||
controller: _scrollControllerUpdate,
|
||||
child: Text(apt.updateLog!),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(13),
|
||||
children: [
|
||||
_buildUpdatePanel(apt),
|
||||
].map((e) => RoundRectCard(e)).toList(),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUpdatePanel(PkgProvider apt) {
|
||||
if (apt.upgradeable!.isEmpty) {
|
||||
return ListTile(
|
||||
title: Text(
|
||||
_s.noUpdateAvailable,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
subtitle: const Text('>_<', textAlign: TextAlign.center),
|
||||
);
|
||||
}
|
||||
return ExpansionTile(
|
||||
title: Text(_s.foundNUpdate(apt.upgradeable!.length)),
|
||||
subtitle: Text(
|
||||
apt.upgradeable!.map((e) => e.package).join(', '),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: grey,
|
||||
),
|
||||
children: apt.upgradeLog == null
|
||||
? [
|
||||
TextButton(
|
||||
child: Text(_s.updateAll),
|
||||
onPressed: () {
|
||||
apt.upgrade();
|
||||
},
|
||||
),
|
||||
...apt.upgradeable!.map((e) => _buildUpdateItem(e, apt)).toList()
|
||||
]
|
||||
: [
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(18),
|
||||
controller: _scrollController,
|
||||
child: Text(apt.upgradeLog!),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUpdateItem(UpgradePkgInfo info, PkgProvider apt) {
|
||||
return ListTile(
|
||||
title: Text(info.package),
|
||||
subtitle: Text(
|
||||
'${info.nowVersion} -> ${info.newVersion}',
|
||||
style: grey,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user