From cf4f74dcfce619c7c898a05827a27fb595af08e8 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Wed, 18 Oct 2023 19:14:06 +0800 Subject: [PATCH] opt.: snippet result --- README.md | 49 ++++++++++++++++++------------ README_zh.md | 48 +++++++++++++++++------------ lib/core/route.dart | 10 ++++++ lib/data/model/server/snippet.dart | 9 ------ lib/data/provider/snippet.dart | 11 ------- lib/data/res/build_data.dart | 4 +-- lib/data/store/first.dart | 3 -- lib/view/page/snippet/list.dart | 15 ++------- lib/view/page/snippet/result.dart | 47 ++++++++++++++++++++++++++++ 9 files changed, 119 insertions(+), 77 deletions(-) create mode 100644 lib/view/page/snippet/result.dart diff --git a/README.md b/README.md index a4f6b649..2c86887d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,15 @@ Especially thanks to dartss

+- [🔖 Feature](#-feature) +- [🏙️ ScreenShots](#️-screenshots) +- [⬇️ Download](#️-download) +- [🆘 Help](#-help) +- [🧱 Contribution](#-contribution) + - [🌍 l10n](#-l10n) +- [📝 License](#-license) + + ## 🔖 Feature - [x] Functions - [x] `SSH` Terminal, `SFTP`, `Docker & Pkg & Process`, Status chart, Code editor... @@ -27,25 +36,6 @@ Especially thanks to
dartss - [x] Platform support: `iOS / Android / macOS / Windows / Linux` -## ⬇️ Download -Platform | Support | Sign ---- | --- | --- -[iOS](https://apps.apple.com/app/id1586449703) / [Android](https://res.lolli.tech/serverbox/latest.apk) / [macOS](https://apps.apple.com/app/id1586449703) | Full | My own certificate -[Linux](https://res.lolli.tech/serverbox/latest.AppImage) / [Windows](https://res.lolli.tech/serverbox/latest.win.zip) | Not tested | Flutter default certificate - -- Due to Chinese government policy and the [BEIAN](https://github.com/lollipopkit/flutter_server_box/discussions/180) issue. iOS app is now free. Please download it from other regions of AppStore. -- Security: - - To prevent injection attacks and etc., please don't download from untrusted sources. - - Since `Linux / Windows` is signed with flutter default certificate, it is recommended to **build it yourself**. - - -## 🆘 Help -- In order to push server status to your portable device without opening ServerBox app (Such as **message push** and **home widget**), you need to install [ServerBoxMonitor](https://github.com/lollipopkit/server_box_monitor) on your servers, and config it correctly. See [wiki](https://github.com/lollipopkit/server_box_monitor/wiki) for more details. -- **Common issues** can be found in [app wiki](https://github.com/lollipopkit/flutter_server_box/wiki). -- If you have **any question or feature request**, please open a [discussion](https://github.com/lollipopkit/flutter_server_box/discussions/new/choose). -- If ServerBox app has **any bug**, please open an [issue](https://github.com/lollipopkit/flutter_server_box/issues/new). - - ## 🏙️ ScreenShots @@ -75,10 +65,29 @@ Platform | Support | Sign
+## ⬇️ Download +Platform | Support | Sign +--- | --- | --- +[iOS](https://apps.apple.com/app/id1586449703) / [Android](https://res.lolli.tech/serverbox/latest.apk) / [macOS](https://apps.apple.com/app/id1586449703) | Full | My own certificate +[Linux](https://res.lolli.tech/serverbox/latest.AppImage) / [Windows](https://res.lolli.tech/serverbox/latest.win.zip) | Not tested | Flutter default certificate + +- Due to Chinese government policy and the [BEIAN](https://github.com/lollipopkit/flutter_server_box/discussions/180) issue. iOS app is now free. Please download it from other regions of AppStore. +- Security: + - To prevent injection attacks and etc., please don't download from untrusted sources. + - Since `Linux / Windows` is signed with flutter default certificate, it is recommended to **build it yourself**. + + +## 🆘 Help +- In order to push server status to your portable device without opening ServerBox app (Such as **message push** and **home widget**), you need to install [ServerBoxMonitor](https://github.com/lollipopkit/server_box_monitor) on your servers, and config it correctly. See [wiki](https://github.com/lollipopkit/server_box_monitor/wiki) for more details. +- **Common issues** can be found in [app wiki](https://github.com/lollipopkit/flutter_server_box/wiki). +- If you have **any question or feature request**, please open a [discussion](https://github.com/lollipopkit/flutter_server_box/discussions/new/choose). +- If ServerBox app has **any bug**, please open an [issue](https://github.com/lollipopkit/flutter_server_box/issues/new). + + ## 🧱 Contribution **Any positive contribution is welcome**. -### l10n guide +### 🌍 l10n 1. Fork this repo and clone forked repo 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. diff --git a/README_zh.md b/README_zh.md index 1bf09b83..48fd5357 100644 --- a/README_zh.md +++ b/README_zh.md @@ -18,6 +18,14 @@ 特别感谢
dartssh2 & xterm.dart

+- [🔖 特点](#-特点) +- [🏙️ 截屏](#️-截屏) +- [⬇️ 下载](#️-下载) +- [🆘 帮助](#-帮助) +- [🧱 贡献](#-贡献) + - [🌍 l10n](#-l10n) +- [📝 协议](#-协议) + ## 🔖 特点 - [x] 功能 @@ -27,25 +35,6 @@ - [x] 全平台支持(除 `Web`) -## ⬇️ 下载 -平台 | 支持 | 签名 -:-: | :-: | :-: -[iOS](https://apps.apple.com/app/id1586449703) / [Android](https://res.lolli.tech/serverbox/latest.apk) / [macOS](https://apps.apple.com/app/id1586449703) | 完整 | 个人可信签名 -[Linux](https://res.lolli.tech/serverbox/latest.AppImage) / [Windows](https://res.lolli.tech/serverbox/latest.win.zip) | 未测试 | Flutter 默认签名 - -- 由于中国政策原因,且**目前**无法完成[备案](https://github.com/lollipopkit/flutter_server_box/discussions/180)。iOS 端现已转为免费,请移步 AppStore 其他区下载。 -- 关于安全: - - 为了防止注入攻击等因素,请勿从不可信来源下载。 - - 由于 `Linux / Windows` 使用了默认签名,因此建议**自行构建**。 - - -## 🆘 帮助 -- 为了可以在不使用 ServerBox app 时获取服务器状态(例如:桌面小部件、推送服务),你需要在你的服务器上安装 [ServerBoxMonitor](https://github.com/lollipopkit/server_box_monitor),并且正确配置,详情可见 [wiki](https://github.com/lollipopkit/server_box_monitor/wiki/%E4%B8%BB%E9%A1%B5)。 -- **常见问题**可以在 [app wiki](https://github.com/lollipopkit/flutter_server_box/wiki/主页) 查看。 -- 如果你有**任何问题或者功能请求**,请在 [讨论](https://github.com/lollipopkit/flutter_server_box/discussions/new/choose) 中交流。 -- 如果 ServerBox app 有**任何 bug**,请在 [问题](https://github.com/lollipopkit/flutter_server_box/issues/new) 中反馈。 - - ## 🏙️ 截屏 @@ -75,10 +64,29 @@
+## ⬇️ 下载 +平台 | 支持 | 签名 +:-: | :-: | :-: +[iOS](https://apps.apple.com/app/id1586449703) / [Android](https://res.lolli.tech/serverbox/latest.apk) / [macOS](https://apps.apple.com/app/id1586449703) | 完整 | 个人可信签名 +[Linux](https://res.lolli.tech/serverbox/latest.AppImage) / [Windows](https://res.lolli.tech/serverbox/latest.win.zip) | 未测试 | Flutter 默认签名 + +- 由于中国政策原因,且**目前**无法完成[备案](https://github.com/lollipopkit/flutter_server_box/discussions/180)。iOS 端现已转为免费,请移步 AppStore 其他区下载。 +- 关于安全: + - 为了防止注入攻击等因素,请勿从不可信来源下载。 + - 由于 `Linux / Windows` 使用了默认签名,因此建议**自行构建**。 + + +## 🆘 帮助 +- 为了可以在不使用 ServerBox app 时获取服务器状态(例如:桌面小部件、推送服务),你需要在你的服务器上安装 [ServerBoxMonitor](https://github.com/lollipopkit/server_box_monitor),并且正确配置,详情可见 [wiki](https://github.com/lollipopkit/server_box_monitor/wiki/%E4%B8%BB%E9%A1%B5)。 +- **常见问题**可以在 [app wiki](https://github.com/lollipopkit/flutter_server_box/wiki/主页) 查看。 +- 如果你有**任何问题或者功能请求**,请在 [讨论](https://github.com/lollipopkit/flutter_server_box/discussions/new/choose) 中交流。 +- 如果 ServerBox app 有**任何 bug**,请在 [问题](https://github.com/lollipopkit/flutter_server_box/issues/new) 中反馈。 + + ## 🧱 贡献 **任何正面的贡献都欢迎**。 -### l10n +### 🌍 l10n 1. Fork 本项目,并 Clone 你 Fork 的项目至你的电脑 2. 在 `lib/l10n/` 文件夹内创建 `.arb` 本地化文件 - 文件名应该类似 `intl_XX.arb`, `XX` 是语言标识码。 例如 `intl_en.arb` 是给英语的, `intl_zh.arb` 是给中文的 diff --git a/lib/core/route.dart b/lib/core/route.dart index 6602a8e2..cc73f760 100644 --- a/lib/core/route.dart +++ b/lib/core/route.dart @@ -11,6 +11,7 @@ import 'package:toolbox/view/page/private_key/list.dart'; import 'package:toolbox/view/page/server/detail.dart'; import 'package:toolbox/view/page/setting/android.dart'; import 'package:toolbox/view/page/setting/ios.dart'; +import 'package:toolbox/view/page/snippet/result.dart'; import 'package:toolbox/view/page/ssh_term.dart'; import 'package:toolbox/view/page/setting/virt_key.dart'; import 'package:toolbox/view/page/storage/local.dart'; @@ -207,4 +208,13 @@ class AppRoute { static AppRoute androidSettings({Key? key}) { return AppRoute(AndroidSettingsPage(key: key), 'android_setting'); } + + static AppRoute snippetResult({Key? key, required Map results}) { + return AppRoute( + SnippetResultPage( + key: key, + results: results, + ), + 'snippet_result'); + } } diff --git a/lib/data/model/server/snippet.dart b/lib/data/model/server/snippet.dart index 68115c3a..a3d2e67f 100644 --- a/lib/data/model/server/snippet.dart +++ b/lib/data/model/server/snippet.dart @@ -45,12 +45,3 @@ class Snippet implements TagPickable { @override String get tagName => name; } - -/// Snippet for installing ServerBoxMonitor -const installSBM = Snippet( - name: 'Install ServerBoxMonitor', - script: - 'curl -fsSL https://raw.githubusercontent.com/lollipopkit/server_box_monitor/main/install.sh | sh -s -- install', - tags: ['ServerBoxMonitor'], - note: 'One click script to install ServerBoxMonitor', -); diff --git a/lib/data/provider/snippet.dart b/lib/data/provider/snippet.dart index bd777121..e69118c4 100644 --- a/lib/data/provider/snippet.dart +++ b/lib/data/provider/snippet.dart @@ -26,20 +26,9 @@ class SnippetProvider extends ChangeNotifier { Stores.setting.snippetOrder.put(order); } } - _addInternal(); _updateTags(); } - void _addInternal() { - if (!Stores.first.iSSBM.fetch() || - _snippets.any((e) => e.name == installSBM.name)) { - return; - } - _snippets.add(installSBM); - Stores.snippet.put(installSBM); - Stores.first.iSSBM.put(false); - } - void _updateTags() { _tags.clear(); final tags = {}; diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 8ce97131..25649784 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 599; + static const int build = 601; static const String engine = "3.13.7"; - static const String buildAt = "2023-10-15 21:24:51"; + static const String buildAt = "2023-10-17 20:28:10"; static const int modifications = 4; static const int script = 21; } diff --git a/lib/data/store/first.dart b/lib/data/store/first.dart index 7a120c68..46c7541c 100644 --- a/lib/data/store/first.dart +++ b/lib/data/store/first.dart @@ -4,9 +4,6 @@ import 'package:toolbox/core/persistant_store.dart'; class FirstStore extends PersistentStore { FirstStore() : super('first'); - /// Add Snippet `Install ServerBoxMonitor` - late final iSSBM = StoreProperty(box, 'installMonitorSnippet', true); - /// Show tip of suspend late final showSuspendTip = StoreProperty(box, 'showSuspendTip', true); } diff --git a/lib/view/page/snippet/list.dart b/lib/view/page/snippet/list.dart index 89396629..7e414374 100644 --- a/lib/view/page/snippet/list.dart +++ b/lib/view/page/snippet/list.dart @@ -6,7 +6,6 @@ import 'package:toolbox/core/extension/order.dart'; import 'package:toolbox/data/res/provider.dart'; import 'package:toolbox/data/res/store.dart'; -import '../../../core/utils/misc.dart'; import '../../../data/model/server/server.dart'; import '../../../data/model/server/snippet.dart'; import '../../../data/res/ui.dart'; @@ -135,23 +134,15 @@ class _SnippetListPageState extends State { return; } final ids = servers.map((e) => e.spi.id).toList(); + final names = servers.map((e) => e.spi.name).toList(); final results = await Pros.server.runSnippetsMulti(ids, [snippet]); if (results.isNotEmpty) { // SERVER_NAME: RESULT final result = Map.fromIterables( - ids, + names, results, - ).entries.map((e) => '${e.key}:\n${e.value}').join('\n'); - context.showRoundDialog( - title: Text(l10n.result), - child: Text(result), - actions: [ - TextButton( - onPressed: () => copy2Clipboard(result), - child: Text(l10n.copy), - ) - ], ); + AppRoute.snippetResult(results: result).go(context); } } } diff --git a/lib/view/page/snippet/result.dart b/lib/view/page/snippet/result.dart new file mode 100644 index 00000000..ca2f6592 --- /dev/null +++ b/lib/view/page/snippet/result.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; +import 'package:toolbox/core/extension/context/locale.dart'; +import 'package:toolbox/view/widget/cardx.dart'; +import 'package:toolbox/view/widget/custom_appbar.dart'; +import 'package:toolbox/view/widget/expand_tile.dart'; + +class SnippetResultPage extends StatelessWidget { + final Map results; + + const SnippetResultPage({super.key, required this.results}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: CustomAppBar( + title: Text(l10n.result), + ), + body: _buildBody(), + ); + } + + Widget _buildBody() { + return Align( + alignment: Alignment.centerLeft, + child: ListView.builder( + padding: const EdgeInsets.symmetric(horizontal: 17), + itemCount: results.length, + itemBuilder: (_, index) { + final key = results.keys.elementAt(index); + final value = results[key]; + return CardX( + ExpandTile( + initiallyExpanded: results.length == 1, + title: Text(key), + children: [ + Text( + value ?? '', + textAlign: TextAlign.start, + ), + ], + ), + ); + }, + ), + ); + } +}