Compare commits
34 Commits
v1.0.9
...
ba65d33a53
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba65d33a53 | ||
|
|
02fb4a8182 | ||
|
|
53f744c350 | ||
|
|
39a815baff | ||
|
|
2250887e04 | ||
|
|
3d12603f0c | ||
|
|
ee9739d08f | ||
|
|
a53a4fdd19 | ||
|
|
b4e9f8a29a | ||
|
|
a223d5e633 | ||
|
|
1d8944c4b7 | ||
|
|
e19ce0a5e4 | ||
|
|
0642ad5c33 | ||
|
|
9def109426 | ||
|
|
280641ee57 | ||
|
|
3f65e9312c | ||
|
|
a5a3494db9 | ||
|
|
a55cf258ba | ||
|
|
b2b8cf5a31 | ||
|
|
ba5c15d5a9 | ||
|
|
484e1eeee3 | ||
|
|
e2a2ae55ec | ||
|
|
558b780235 | ||
|
|
1cd3724805 | ||
|
|
7e3a63169e | ||
|
|
1298dba590 | ||
|
|
2005083d2e | ||
|
|
4e3f8a0df9 | ||
|
|
5698277301 | ||
|
|
02be737264 | ||
|
|
9558f3d235 | ||
|
|
14c3b1a965 | ||
|
|
b89de1414a | ||
|
|
9759caf9b8 |
1
.gitignore
vendored
@@ -44,3 +44,4 @@ app.*.map.json
|
||||
/android/app/debug
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
.fvm/
|
||||
30
.metadata
@@ -1,10 +1,36 @@
|
||||
# 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: 77d935af4db863f6abd0b9c31c7e6df2a13de57b
|
||||
revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
channel: stable
|
||||
|
||||
project_type: app
|
||||
|
||||
# Tracks metadata for the flutter migrate command
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
- platform: linux
|
||||
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
- platform: macos
|
||||
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
- platform: windows
|
||||
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||
|
||||
# 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'
|
||||
|
||||
55
README.md
@@ -2,62 +2,37 @@
|
||||
|
||||
版本更新通知 https://t.me/qinglongapp
|
||||
|
||||
仅供学习交流, 禁止用于任何商业用途
|
||||
基于[qinglong](https://github.com/whyour/qinglong)API实现的三方客户端,采用Flutter编写 (API最低支持2.10.0)
|
||||
|
||||
基于[qinglong](https://github.com/whyour/qinglong)API实现的三方客户端,采用Flutter编写 (API基于v2.10.13)
|
||||
Android端下载地址:[Release](https://github.com/qinglong-app/qinglong_app/releases)
|
||||
|
||||
Android端去[release](https://github.com/qinglong-app/qinglong_app/releases)下载
|
||||
|
||||
iOS端暂无上架打算,用户自行下载main分支源码编译安装
|
||||
iOS端下载地址: [AppStore](https://apps.apple.com/cn/app/id1625871665)
|
||||
|
||||
|
||||
<p float="left">
|
||||
<img src="./art/14.jpg" width="200" />
|
||||
<img src="./art/1.jpg" width="200" />
|
||||
<img src="./art/9.jpg" width="200" />
|
||||
<img src="./art/1.png" width="250" />
|
||||
<img src="./art/2.png" width="250" />
|
||||
<img src="./art/3.png" width="250" />
|
||||
</p>
|
||||
<p float="left">
|
||||
<img src="./art/10.jpg" width="200" />
|
||||
<img src="./art/11.jpg" width="200" />
|
||||
<img src="./art/12.jpg" width="200" />
|
||||
</p>
|
||||
<p float="left">
|
||||
<img src="./art/2.jpg" width="200" />
|
||||
<img src="./art/3.jpg" width="200" />
|
||||
<img src="./art/4.jpg" width="200" />
|
||||
<img src="./art/4.png" width="250" />
|
||||
<img src="./art/5.png" width="250" />
|
||||
</p>
|
||||
|
||||
<p float="left">
|
||||
<img src="./art/5.jpg" width="200" />
|
||||
<img src="./art/6.jpg" width="200" />
|
||||
<img src="./art/7.jpg" width="200" />
|
||||
</p>
|
||||
|
||||
<p float="left">
|
||||
<img src="./art/13.jpg" width="200" />
|
||||
<img src="./art/8.jpg" width="200" />
|
||||
</p>
|
||||
|
||||
## [更新记录](./CHANGELOG.md)
|
||||
|
||||
|
||||
### 不支持的功能
|
||||
>* 应用设置
|
||||
>* 通知设置
|
||||
|
||||
|
||||
版本更新通知 https://t.me/qinglongapp
|
||||
|
||||
用于生成app的图标
|
||||
|
||||
flutter pub run flutter_launcher_icons:main
|
||||
>* flutter pub run flutter_launcher_icons:main
|
||||
|
||||
生成原生的启动页面
|
||||
|
||||
flutter pub run flutter_native_splash:create
|
||||
>* flutter pub run flutter_native_splash:create
|
||||
|
||||
修改app名称
|
||||
|
||||
flutter pub run flutter_app_name
|
||||
>* flutter pub run flutter_app_name
|
||||
|
||||
生成json.jc.dart文件
|
||||
flutter pub run build_runner build --delete-conflicting-outputs
|
||||
|
||||
>* flutter pub run build_runner build --delete-conflicting-outputs
|
||||
|
||||
|
||||
BIN
art/10.jpg
|
Before Width: | Height: | Size: 200 KiB |
BIN
art/11.jpg
|
Before Width: | Height: | Size: 190 KiB |
BIN
art/12.jpg
|
Before Width: | Height: | Size: 301 KiB |
BIN
art/13.jpg
|
Before Width: | Height: | Size: 111 KiB |
BIN
art/14.jpg
|
Before Width: | Height: | Size: 168 KiB |
BIN
assets/images/add_btn_svip.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 19 KiB |
BIN
assets/images/dark.png
Normal file
|
After Width: | Height: | Size: 608 B |
BIN
assets/images/faceid.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/images/figure.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
assets/images/icon_a.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/images/icon_about.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
assets/images/icon_add_file.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
assets/images/icon_app_set.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/images/icon_b.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
assets/images/icon_check.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/images/icon_cron.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/images/icon_cron_checked.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
assets/images/icon_d.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
assets/images/icon_default_user.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
assets/images/icon_disabled.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/images/icon_enable.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/images/icon_env.png
Normal file
|
After Width: | Height: | Size: 960 B |
BIN
assets/images/icon_env_checked.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
assets/images/icon_fail.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/images/icon_file.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/images/icon_file_checked.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
assets/images/icon_history.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
assets/images/icon_idle.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
assets/images/icon_install_fail.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
assets/images/icon_install_success.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/images/icon_login_icon.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/images/icon_other.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/images/icon_other_bg.png
Normal file
|
After Width: | Height: | Size: 400 KiB |
BIN
assets/images/icon_other_checked.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
assets/images/icon_right.png
Normal file
|
After Width: | Height: | Size: 491 B |
BIN
assets/images/icon_running.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
assets/images/icon_s.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
assets/images/icon_safety.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
assets/images/icon_search.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
assets/images/icon_setting.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
assets/images/icon_subsctibe.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/images/icon_success.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/images/icon_task_disable.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
assets/images/icon_task_log.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
assets/images/icon_uncheck.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/images/icon_vip_bg.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
assets/images/icon_vip_bg_check.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
assets/images/js.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/images/json.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 19 KiB |
BIN
assets/images/light.png
Normal file
|
After Width: | Height: | Size: 863 B |
BIN
assets/images/normal.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/images/other.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/images/py.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 16 KiB |
BIN
assets/images/shell.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/images/svip.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
assets/images/svip_logo.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
assets/images/ts.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/images/vip.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
assets/images/vip_logo.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 20 KiB |
@@ -24,12 +24,14 @@ class BaseStateWidget<T extends BaseViewModel> extends ConsumerStatefulWidget {
|
||||
_BaseStateWidgetState<T> createState() => _BaseStateWidgetState<T>();
|
||||
}
|
||||
|
||||
class _BaseStateWidgetState<T extends BaseViewModel> extends ConsumerState<BaseStateWidget<T>> with LazyLoadState<BaseStateWidget<T>> {
|
||||
class _BaseStateWidgetState<T extends BaseViewModel>
|
||||
extends ConsumerState<BaseStateWidget<T>>
|
||||
with LazyLoadState<BaseStateWidget<T>> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var viewModel = ref.watch<T>(widget.model);
|
||||
if (viewModel.failedToast != null) {
|
||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
(viewModel.failedToast ?? "").toast();
|
||||
viewModel.clearToast();
|
||||
});
|
||||
@@ -72,7 +74,7 @@ class _BaseStateWidgetState<T extends BaseViewModel> extends ConsumerState<BaseS
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
if (widget.onReady != null && !widget.lazyLoad) {
|
||||
widget.onReady!(ref.read<T>(widget.model));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:qinglong_app/module/login/user_bean.dart';
|
||||
import 'package:qinglong_app/module/others/dependencies/dependency_bean.dart';
|
||||
import 'package:qinglong_app/module/others/login_log/login_log_bean.dart';
|
||||
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_bean.dart';
|
||||
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||
import 'package:qinglong_app/utils/utils.dart';
|
||||
@@ -353,15 +354,10 @@ class Api {
|
||||
);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> addDependency(String name, int type) async {
|
||||
static Future<HttpResponse<NullResponse>> addDependency(List<Map<String, dynamic>> list) async {
|
||||
return await Http.post<NullResponse>(
|
||||
Url.dependencies,
|
||||
[
|
||||
{
|
||||
"name": name,
|
||||
"type": type,
|
||||
}
|
||||
],
|
||||
list,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -382,4 +378,89 @@ class Api {
|
||||
[id],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// 获取订阅
|
||||
static Future<HttpResponse<List<Subscription>>> getSubscription()async{
|
||||
return await Http.get<List<Subscription>>(
|
||||
Url.subscriptions,
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
// 新增订阅
|
||||
static Future<HttpResponse<Subscription>> postSubscription(Subscription subscription)async{
|
||||
var data = subscription.toJson();
|
||||
data.remove("id");
|
||||
data.remove("status");
|
||||
data.remove("pid");
|
||||
data.remove("log_path");
|
||||
data.remove("is_disabled");
|
||||
data.remove("createdAt");
|
||||
data.remove("updatedAt");
|
||||
data.remove("pullType");
|
||||
data.remove("pullOption");
|
||||
return await Http.post<Subscription>(
|
||||
Url.subscriptions,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
// 修改订阅
|
||||
static Future<HttpResponse<Subscription>> putSubscription(Subscription subscription)async{
|
||||
return await Http.put<Subscription>(
|
||||
Url.subscriptions,
|
||||
subscription.toJson()
|
||||
);
|
||||
}
|
||||
|
||||
// 删除订阅 参数未一个id数组
|
||||
static Future<HttpResponse<NullResponse>> deleteSubscription(List<int> ids)async{
|
||||
return await Http.delete<NullResponse>(
|
||||
Url.subscriptions,
|
||||
ids
|
||||
);
|
||||
}
|
||||
|
||||
// 删除订阅 参数未一个id数组
|
||||
static Future<HttpResponse<NullResponse>> disableSubscription(List<int> ids)async{
|
||||
return await Http.put<NullResponse>(
|
||||
Url.disableSubscriptions,
|
||||
ids
|
||||
);
|
||||
}
|
||||
|
||||
// 删除订阅 参数未一个id数组
|
||||
static Future<HttpResponse<NullResponse>> enableSubscription(List<int> ids)async{
|
||||
return await Http.put<NullResponse>(
|
||||
Url.enableSubscriptions,
|
||||
ids
|
||||
);
|
||||
}
|
||||
|
||||
// 开始执行订阅
|
||||
static Future<HttpResponse<NullResponse>> startSubscription(
|
||||
List<int> subscriptions) async {
|
||||
return await Http.put<NullResponse>(
|
||||
Url.runSubscriptions,
|
||||
subscriptions,
|
||||
);
|
||||
}
|
||||
|
||||
// 暂停订阅执行
|
||||
static Future<HttpResponse<NullResponse>> stopSubscription(
|
||||
List<int> subscriptions) async {
|
||||
return await Http.put<NullResponse>(
|
||||
Url.stopSubscriptions,
|
||||
subscriptions,
|
||||
);
|
||||
}
|
||||
|
||||
// 获取订阅的日志
|
||||
static Future<HttpResponse<String>> subTimeLog(int subId) async {
|
||||
return await Http.get<String>(
|
||||
Url.subtimeLog(subId),
|
||||
null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,8 @@ class Http {
|
||||
if (!pushedLoginPage) {
|
||||
"身份已过期,请重新登录".toast();
|
||||
pushedLoginPage = true;
|
||||
navigatorState.currentState?.pushNamedAndRemoveUntil(Routes.routeLogin, (route) => false);
|
||||
navigatorState.currentState
|
||||
?.pushNamedAndRemoveUntil(Routes.routeLogin, (route) => false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,9 +137,15 @@ class Http {
|
||||
}
|
||||
|
||||
if (e.response != null && e.response!.data != null) {
|
||||
return HttpResponse(success: false, message: e.response?.data["message"] ?? e.message, code: e.response?.data["code"] ?? 0);
|
||||
return HttpResponse(
|
||||
success: false,
|
||||
message: e.response?.data["message"] ?? e.message,
|
||||
code: e.response?.data["code"] ?? 0);
|
||||
} else {
|
||||
return HttpResponse(success: false, message: e.message, code: e.response?.statusCode ?? 0);
|
||||
return HttpResponse(
|
||||
success: false,
|
||||
message: e.message,
|
||||
code: e.response?.statusCode ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +230,8 @@ class HttpResponse<T> {
|
||||
late int code;
|
||||
T? bean;
|
||||
|
||||
HttpResponse({required this.success, this.message, required this.code, this.bean});
|
||||
HttpResponse(
|
||||
{required this.success, this.message, required this.code, this.bean});
|
||||
}
|
||||
|
||||
class DeserializeAction<T> {
|
||||
|
||||
@@ -7,8 +7,7 @@ import '../userinfo_viewmodel.dart';
|
||||
class TokenInterceptor extends Interceptor {
|
||||
@override
|
||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||
options.headers["User-Agent"] =
|
||||
"qinglong_client";
|
||||
options.headers["User-Agent"] = "qinglong_client";
|
||||
|
||||
options.headers["Content-Type"] = "application/json;charset=UTF-8";
|
||||
|
||||
|
||||
@@ -14,70 +14,159 @@ class Url {
|
||||
|
||||
static const updatePassword = "/api/user";
|
||||
|
||||
static get tasks => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons" : "/api/crons";
|
||||
static get tasks => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/crons"
|
||||
: "/api/crons";
|
||||
|
||||
static get runTasks => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/run" : "/api/crons/run";
|
||||
static get runTasks => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/crons/run"
|
||||
: "/api/crons/run";
|
||||
|
||||
static get stopTasks => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/stop" : "/api/crons/stop";
|
||||
static get stopTasks => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/crons/stop"
|
||||
: "/api/crons/stop";
|
||||
|
||||
static get taskDetail => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/" : "/api/crons/";
|
||||
static get taskDetail => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/crons/"
|
||||
: "/api/crons/";
|
||||
|
||||
static get addTask => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons" : "/api/crons";
|
||||
static get addTask => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/crons"
|
||||
: "/api/crons";
|
||||
|
||||
static get pinTask => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/pin" : "/api/crons/pin";
|
||||
static get pinTask => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/crons/pin"
|
||||
: "/api/crons/pin";
|
||||
|
||||
static get unpinTask => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/unpin" : "/api/crons/unpin";
|
||||
static get unpinTask => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/crons/unpin"
|
||||
: "/api/crons/unpin";
|
||||
|
||||
static get enableTask => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/enable" : "/api/crons/enable";
|
||||
static get enableTask => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/crons/enable"
|
||||
: "/api/crons/enable";
|
||||
|
||||
static get disableTask => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/disable" : "/api/crons/disable";
|
||||
static get disableTask => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/crons/disable"
|
||||
: "/api/crons/disable";
|
||||
|
||||
static get files => getIt<UserInfoViewModel>().useSecretLogined ? "/open/configs/files" : "/api/configs/files";
|
||||
static get files => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/configs/files"
|
||||
: "/api/configs/files";
|
||||
|
||||
static get configContent => getIt<UserInfoViewModel>().useSecretLogined ? "/open/configs/" : "/api/configs/";
|
||||
static get configContent => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/configs/"
|
||||
: "/api/configs/";
|
||||
|
||||
static get saveFile => getIt<UserInfoViewModel>().useSecretLogined ? "/open/configs/save" : "/api/configs/save";
|
||||
static get saveFile => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/configs/save"
|
||||
: "/api/configs/save";
|
||||
|
||||
static get envs => getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs" : "/api/envs";
|
||||
static get envs =>
|
||||
getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs" : "/api/envs";
|
||||
|
||||
static get addEnv => getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs" : "/api/envs";
|
||||
static get addEnv =>
|
||||
getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs" : "/api/envs";
|
||||
|
||||
static get delEnv => getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs" : "/api/envs";
|
||||
static get delEnv =>
|
||||
getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs" : "/api/envs";
|
||||
|
||||
static get disableEnvs => getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs/disable" : "/api/envs/disable";
|
||||
static get disableEnvs => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/envs/disable"
|
||||
: "/api/envs/disable";
|
||||
|
||||
static get enableEnvs => getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs/enable" : "/api/envs/enable";
|
||||
static get enableEnvs => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/envs/enable"
|
||||
: "/api/envs/enable";
|
||||
|
||||
static get loginLog => getIt<UserInfoViewModel>().useSecretLogined ? "/open/user/login-log" : "/api/user/login-log";
|
||||
static get loginLog => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/user/login-log"
|
||||
: "/api/user/login-log";
|
||||
|
||||
static get taskLog => getIt<UserInfoViewModel>().useSecretLogined ? "/open/logs" : "/api/logs";
|
||||
static get taskLog =>
|
||||
getIt<UserInfoViewModel>().useSecretLogined ? "/open/logs" : "/api/logs";
|
||||
|
||||
static get taskLogDetail => getIt<UserInfoViewModel>().useSecretLogined ? "/open/logs/" : "/api/logs/";
|
||||
static get taskLogDetail => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/logs/"
|
||||
: "/api/logs/";
|
||||
|
||||
static get scripts => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts/files" : "/api/scripts/files";
|
||||
static get scripts => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/scripts/files"
|
||||
: "/api/scripts/files";
|
||||
|
||||
static get scripts2 => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts" : "/api/scripts";
|
||||
static get scripts2 => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/scripts"
|
||||
: "/api/scripts";
|
||||
|
||||
static get scriptUpdate => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts" : "/api/scripts";
|
||||
static get scriptUpdate => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/scripts"
|
||||
: "/api/scripts";
|
||||
|
||||
static get scriptDetail => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts/" : "/api/scripts/";
|
||||
static get scriptDetail => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/scripts/"
|
||||
: "/api/scripts/";
|
||||
|
||||
static get dependencies => getIt<UserInfoViewModel>().useSecretLogined ? "/open/dependencies" : "/api/dependencies";
|
||||
static get dependencies => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/dependencies"
|
||||
: "/api/dependencies";
|
||||
|
||||
static get addScript => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts" : "/api/scripts";
|
||||
static get addScript => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/scripts"
|
||||
: "/api/scripts";
|
||||
|
||||
static get dependencyReinstall => getIt<UserInfoViewModel>().useSecretLogined ? "/open/dependencies/reinstall" : "/api/dependencies/reinstall";
|
||||
static get dependencyReinstall => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/dependencies/reinstall"
|
||||
: "/api/dependencies/reinstall";
|
||||
|
||||
static intimeLog(String cronId) {
|
||||
return getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/$cronId/log" : "/api/crons/$cronId/log";
|
||||
return getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/crons/$cronId/log"
|
||||
: "/api/crons/$cronId/log";
|
||||
}
|
||||
|
||||
static envMove(String envId) {
|
||||
return getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs/$envId/move" : "/api/envs/$envId/move";
|
||||
return getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/envs/$envId/move"
|
||||
: "/api/envs/$envId/move";
|
||||
}
|
||||
|
||||
// 运行订阅
|
||||
static get runSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/subscriptions/run"
|
||||
: "/api/subscriptions/run";
|
||||
|
||||
// 停止订阅
|
||||
static get stopSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/subscriptions/stop"
|
||||
: "/api/subscriptions/stop";
|
||||
|
||||
// 启用订阅
|
||||
static get enableSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/subscriptions/enable"
|
||||
: "/api/subscriptions/enable";
|
||||
|
||||
// 禁用订阅
|
||||
static get disableSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/subscriptions/disable"
|
||||
: "/api/subscriptions/disable";
|
||||
|
||||
// GET 获取订阅 POST 提交订阅 PUT 修改订阅 DELETE 删除订阅
|
||||
static get subscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/subscriptions"
|
||||
: "/api/subscriptions";
|
||||
|
||||
// 获取订阅日志
|
||||
static subtimeLog(int cronId) {
|
||||
return getIt<UserInfoViewModel>().useSecretLogined
|
||||
? "/open/subscriptions/$cronId/log"
|
||||
: "/api/subscriptions/$cronId/log";
|
||||
}
|
||||
|
||||
static bool inWhiteList(String path) {
|
||||
if (path == login || path == loginByClientId || path == loginTwo || path == loginOld) {
|
||||
if (path == login ||
|
||||
path == loginByClientId ||
|
||||
path == loginTwo ||
|
||||
path == loginOld) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:qinglong_app/module/change_account_page.dart';
|
||||
import 'package:qinglong_app/module/config/config_edit_page.dart';
|
||||
import 'package:qinglong_app/module/env/add_env_page.dart';
|
||||
import 'package:qinglong_app/module/env/env_bean.dart';
|
||||
@@ -7,12 +8,17 @@ import 'package:qinglong_app/module/env/env_detail_page.dart';
|
||||
import 'package:qinglong_app/module/home/home_page.dart';
|
||||
import 'package:qinglong_app/module/login/login_page.dart';
|
||||
import 'package:qinglong_app/module/others/about_page.dart';
|
||||
import 'package:qinglong_app/module/others/backup/backup_page.dart';
|
||||
import 'package:qinglong_app/module/others/dependencies/add_dependency_page.dart';
|
||||
import 'package:qinglong_app/module/others/dependencies/dependency_page.dart';
|
||||
import 'package:qinglong_app/module/others/login_log/login_log_page.dart';
|
||||
import 'package:qinglong_app/module/others/scripts/script_detail_page.dart';
|
||||
import 'package:qinglong_app/module/others/scripts/script_edit_page.dart';
|
||||
import 'package:qinglong_app/module/others/scripts/script_page.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_add_page.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_bean.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_detail_page.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_page.dart';
|
||||
import 'package:qinglong_app/module/others/task_log/task_log_detail_page.dart';
|
||||
import 'package:qinglong_app/module/others/task_log/task_log_page.dart';
|
||||
import 'package:qinglong_app/module/others/theme_page.dart';
|
||||
@@ -21,6 +27,8 @@ import 'package:qinglong_app/module/task/add_task_page.dart';
|
||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||
import 'package:qinglong_app/module/task/task_detail/task_detail_page.dart';
|
||||
|
||||
import '../module/others/scripts/script_add_page.dart';
|
||||
|
||||
class Routes {
|
||||
static const String routeHomePage = "/home/homepage";
|
||||
static const String routeLogin = "/login";
|
||||
@@ -41,6 +49,13 @@ class Routes {
|
||||
static const String routeUpdatePassword = "/updatePassword";
|
||||
static const String routeAbout = "/about";
|
||||
static const String routeTheme = "/theme";
|
||||
static const String routeChangeAccount = "/changeAccount";
|
||||
static const String routerAddScript = "/script/add";
|
||||
static const String routerSubscription = "/subscription";
|
||||
static const String routerSubscriptionDetail = "/subscription/detail";
|
||||
static const String routerSubscriptionAdd = "/subscription/add";
|
||||
|
||||
static const String routerBackup = "/backup";
|
||||
|
||||
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||
switch (settings.name) {
|
||||
@@ -55,97 +70,130 @@ class Routes {
|
||||
} else {
|
||||
return MaterialPageRoute(builder: (context) => const LoginPage());
|
||||
}
|
||||
|
||||
case routeChangeAccount:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => const ChangeAccountPage(),
|
||||
);
|
||||
case routeAddTask:
|
||||
if (settings.arguments != null) {
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => AddTaskPage(
|
||||
taskBean: settings.arguments as TaskBean,
|
||||
));
|
||||
} else {
|
||||
return CupertinoPageRoute(builder: (context) => const AddTaskPage());
|
||||
return MaterialPageRoute(builder: (context) => const AddTaskPage());
|
||||
}
|
||||
case routeAddDependency:
|
||||
return CupertinoPageRoute(
|
||||
builder: (context) => const AddDependencyPage());
|
||||
return MaterialPageRoute(builder: (context) => const AddDependencyPage());
|
||||
case routeAddEnv:
|
||||
if (settings.arguments != null) {
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => AddEnvPage(
|
||||
envBean: settings.arguments as EnvBean,
|
||||
));
|
||||
} else {
|
||||
return CupertinoPageRoute(builder: (context) => const AddEnvPage());
|
||||
return MaterialPageRoute(builder: (context) => const AddEnvPage());
|
||||
}
|
||||
case routeConfigEdit:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => ConfigEditPage(
|
||||
(settings.arguments as Map)["title"],
|
||||
(settings.arguments as Map)["content"],
|
||||
),
|
||||
);
|
||||
case routeLoginLog:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => const LoginLogPage(),
|
||||
);
|
||||
case routeTaskLog:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => const TaskLogPage(),
|
||||
);
|
||||
case routeScript:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => const ScriptPage(),
|
||||
);
|
||||
case routeDependency:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => const DependencyPage(),
|
||||
);
|
||||
case routeTaskLogDetail:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => TaskLogDetailPage(
|
||||
title: (settings.arguments as Map)['title'],
|
||||
path: (settings.arguments as Map)['path'],
|
||||
),
|
||||
);
|
||||
case routeScriptDetail:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => ScriptDetailPage(
|
||||
title: (settings.arguments as Map)["title"],
|
||||
path: (settings.arguments as Map)["path"],
|
||||
),
|
||||
);
|
||||
case routeTaskDetail:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => TaskDetailPage(
|
||||
settings.arguments as TaskBean,
|
||||
),
|
||||
);
|
||||
case routeEnvDetail:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => EnvDetailPage(
|
||||
settings.arguments as EnvBean,
|
||||
),
|
||||
);
|
||||
case routeUpdatePassword:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => const UpdatePasswordPage(),
|
||||
);
|
||||
case routeAbout:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => const AboutPage(),
|
||||
);
|
||||
case routeTheme:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => const ThemePage(),
|
||||
);
|
||||
case routeScriptUpdate:
|
||||
return CupertinoPageRoute(
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => ScriptEditPage(
|
||||
(settings.arguments as Map)["title"],
|
||||
(settings.arguments as Map)["path"],
|
||||
(settings.arguments as Map)["content"],
|
||||
),
|
||||
);
|
||||
case routeScriptAdd:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => ScriptAddPage(
|
||||
(settings.arguments as Map)["title"],
|
||||
(settings.arguments as Map)["path"],
|
||||
),
|
||||
);
|
||||
case routerSubscription:
|
||||
//部分低端手机用Cupertino滑动时掉帧,左侧会出现白色空白
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => const SubscriptionPage(),
|
||||
);
|
||||
case routerSubscriptionDetail:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => SubscriptionDetailPage(
|
||||
settings.arguments as Subscription,
|
||||
),
|
||||
);
|
||||
case routerSubscriptionAdd:
|
||||
if (settings.arguments != null) {
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => SubscriptionAddPage(
|
||||
settings.arguments as Subscription,
|
||||
));
|
||||
} else {
|
||||
return MaterialPageRoute(builder: (context) => const SubscriptionAddPage(null));
|
||||
}
|
||||
case routerBackup:
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => const BackUpPage(),
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -6,3 +6,4 @@ String spTheme = "dart_mode";
|
||||
String spSecretLogined = "secret_logined";
|
||||
String spCustomColor = "customColor";
|
||||
String spLoginHistory = "loginHistory";
|
||||
String spShowLine = "spShowLine";
|
||||
|
||||
@@ -24,7 +24,7 @@ class ThemeViewModel extends ChangeNotifier {
|
||||
ThemeViewModel() {
|
||||
_primaryColor = Color(getIt<UserInfoViewModel>().primaryColor);
|
||||
primaryColor = Color(getIt<UserInfoViewModel>().primaryColor);
|
||||
var brightness = SchedulerBinding.instance!.window.platformBrightness;
|
||||
var brightness = SchedulerBinding.instance.window.platformBrightness;
|
||||
_isInDarkMode = brightness == Brightness.dark;
|
||||
changeThemeReal(_isInDarkMode, false);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class ThemeViewModel extends ChangeNotifier {
|
||||
secondary: _primaryColor,
|
||||
primary: _primaryColor,
|
||||
),
|
||||
scaffoldBackgroundColor: const Color(0xfff5f5f5),
|
||||
scaffoldBackgroundColor: const Color(0xffffffff),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
labelStyle: TextStyle(
|
||||
color: _primaryColor,
|
||||
@@ -223,6 +223,8 @@ abstract class ThemeColors {
|
||||
|
||||
Color tabBarColor();
|
||||
|
||||
Color blackAndWhite();
|
||||
|
||||
Color pinColor();
|
||||
|
||||
Color buttonBgColor();
|
||||
@@ -241,6 +243,11 @@ class LightThemeColors extends ThemeColors {
|
||||
return const Color(0xffF7F7F7);
|
||||
}
|
||||
|
||||
@override
|
||||
Color blackAndWhite() {
|
||||
return Colors.white;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, TextStyle> codeEditorTheme() {
|
||||
return qinglongLightTheme;
|
||||
@@ -288,6 +295,11 @@ class DartThemeColors extends ThemeColors {
|
||||
return qinglongDarkTheme;
|
||||
}
|
||||
|
||||
@override
|
||||
Color blackAndWhite() {
|
||||
return Colors.black;
|
||||
}
|
||||
|
||||
@override
|
||||
Color descColor() {
|
||||
return const Color(0xff999999);
|
||||
|
||||
@@ -6,7 +6,7 @@ mixin LazyLoadState<T extends StatefulWidget> on State<T> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
var route = ModalRoute.of(context);
|
||||
void handler(status) {
|
||||
if (status == AnimationStatus.completed) {
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:flutter/gestures.dart' show kMinFlingVelocity, kLongPressTimeout;
|
||||
import 'package:flutter/gestures.dart'
|
||||
show kMinFlingVelocity, kLongPressTimeout;
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
@@ -42,7 +43,8 @@ typedef _ContextMenuPreviewBuilderChildless = Widget Function(
|
||||
// paintBounds in global coordinates.
|
||||
Rect _getRect(GlobalKey globalKey) {
|
||||
assert(globalKey.currentContext != null);
|
||||
final RenderBox renderBoxContainer = globalKey.currentContext!.findRenderObject()! as RenderBox;
|
||||
final RenderBox renderBoxContainer =
|
||||
globalKey.currentContext!.findRenderObject()! as RenderBox;
|
||||
final Offset containerOffset = renderBoxContainer.localToGlobal(
|
||||
renderBoxContainer.paintBounds.topLeft,
|
||||
);
|
||||
@@ -87,7 +89,7 @@ enum _ContextMenuLocation {
|
||||
/// See also:
|
||||
///
|
||||
/// * [Apple's HIG for Context Menus](https://developer.apple.com/design/human-interface-guidelines/ios/controls/context-menus/)
|
||||
class QlCupertinoContextMenu extends StatefulWidget {
|
||||
class QlCupertinoContextMenu<T> extends StatefulWidget {
|
||||
/// Create a context menu.
|
||||
///
|
||||
/// [actions] is required and cannot be null or empty.
|
||||
@@ -103,7 +105,7 @@ class QlCupertinoContextMenu extends StatefulWidget {
|
||||
assert(child != null),
|
||||
super(key: key);
|
||||
|
||||
final TaskBean bean;
|
||||
final T bean;
|
||||
|
||||
/// The widget that can be "opened" with the [QlCupertinoContextMenu].
|
||||
///
|
||||
@@ -194,7 +196,8 @@ class QlCupertinoContextMenu extends StatefulWidget {
|
||||
State<QlCupertinoContextMenu> createState() => _QlCupertinoContextMenuState();
|
||||
}
|
||||
|
||||
class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with TickerProviderStateMixin {
|
||||
class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu>
|
||||
with TickerProviderStateMixin {
|
||||
final GlobalKey _childGlobalKey = GlobalKey();
|
||||
bool _childHidden = false;
|
||||
|
||||
@@ -227,7 +230,8 @@ class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with Ti
|
||||
final double screenWidth = MediaQuery.of(context).size.width;
|
||||
|
||||
final double center = screenWidth / 2;
|
||||
final bool centerDividesChild = childRect.left < center && childRect.right > center;
|
||||
final bool centerDividesChild =
|
||||
childRect.left < center && childRect.right > center;
|
||||
final double distanceFromCenter = (center - childRect.center.dx).abs();
|
||||
if (centerDividesChild && distanceFromCenter <= childRect.width / 4) {
|
||||
return _ContextMenuLocation.center;
|
||||
@@ -318,7 +322,14 @@ class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with Ti
|
||||
_openController.reverse();
|
||||
} else {
|
||||
if (_openController.isDismissed) {
|
||||
Navigator.of(context).pushNamed(Routes.routeTaskDetail, arguments: widget.bean);
|
||||
if (widget.bean is TaskBean){
|
||||
Navigator.of(context)
|
||||
.pushNamed(Routes.routeTaskDetail, arguments: widget.bean);
|
||||
}else{
|
||||
Navigator.of(context)
|
||||
.pushNamed(Routes.routerSubscriptionDetail, arguments: widget.bean);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -419,7 +430,8 @@ class _DecoyChild extends StatefulWidget {
|
||||
_DecoyChildState createState() => _DecoyChildState();
|
||||
}
|
||||
|
||||
class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin {
|
||||
class _DecoyChildState extends State<_DecoyChild>
|
||||
with TickerProviderStateMixin {
|
||||
// TODO(justinmc): Dark mode support.
|
||||
// See https://github.com/flutter/flutter/issues/43211.
|
||||
static const Color _lightModeMaskColor = Color(0xFF888888);
|
||||
@@ -481,7 +493,9 @@ class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin
|
||||
}
|
||||
|
||||
Widget _buildAnimation(BuildContext context, Widget? child) {
|
||||
final Color color = widget.controller.status == AnimationStatus.reverse ? _masklessColor : _mask.value;
|
||||
final Color color = widget.controller.status == AnimationStatus.reverse
|
||||
? _masklessColor
|
||||
: _mask.value;
|
||||
return Positioned.fromRect(
|
||||
rect: _rect.value!,
|
||||
child: ShaderMask(
|
||||
@@ -538,7 +552,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
|
||||
// The duration of the transition used when a modal popup is shown. Eyeballed
|
||||
// from a physical device running iOS 13.1.2.
|
||||
static const Duration _kModalPopupTransitionDuration = Duration(milliseconds: 335);
|
||||
static const Duration _kModalPopupTransitionDuration =
|
||||
Duration(milliseconds: 335);
|
||||
|
||||
final List<Widget> _actions;
|
||||
final _ContextMenuPreviewBuilderChildless? _builder;
|
||||
@@ -562,7 +577,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
static final RectTween _rectTween = RectTween();
|
||||
static final Animatable<Rect?> _rectAnimatable = _rectTween.chain(_curve);
|
||||
static final RectTween _rectTweenReverse = RectTween();
|
||||
static final Animatable<Rect?> _rectAnimatableReverse = _rectTweenReverse.chain(
|
||||
static final Animatable<Rect?> _rectAnimatableReverse =
|
||||
_rectTweenReverse.chain(
|
||||
_curveReverse,
|
||||
);
|
||||
static final RectTween _sheetRectTween = RectTween();
|
||||
@@ -573,10 +589,12 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
_curveReverse,
|
||||
);
|
||||
static final Tween<double> _sheetScaleTween = Tween<double>();
|
||||
static final Animatable<double> _sheetScaleAnimatable = _sheetScaleTween.chain(
|
||||
static final Animatable<double> _sheetScaleAnimatable =
|
||||
_sheetScaleTween.chain(
|
||||
_curve,
|
||||
);
|
||||
static final Animatable<double> _sheetScaleAnimatableReverse = _sheetScaleTween.chain(
|
||||
static final Animatable<double> _sheetScaleAnimatableReverse =
|
||||
_sheetScaleTween.chain(
|
||||
_curveReverse,
|
||||
);
|
||||
final Tween<double> _opacityTween = Tween<double>(begin: 0.0, end: 1.0);
|
||||
@@ -611,7 +629,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
|
||||
// Get the alignment for the _ContextMenuSheet's Transform.scale based on the
|
||||
// contextMenuLocation.
|
||||
static AlignmentDirectional getSheetAlignment(_ContextMenuLocation contextMenuLocation) {
|
||||
static AlignmentDirectional getSheetAlignment(
|
||||
_ContextMenuLocation contextMenuLocation) {
|
||||
switch (contextMenuLocation) {
|
||||
case _ContextMenuLocation.center:
|
||||
return AlignmentDirectional.topCenter;
|
||||
@@ -623,17 +642,27 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
}
|
||||
|
||||
// The place to start the sheetRect animation from.
|
||||
static Rect _getSheetRectBegin(Orientation? orientation, _ContextMenuLocation contextMenuLocation, Rect childRect, Rect sheetRect) {
|
||||
static Rect _getSheetRectBegin(
|
||||
Orientation? orientation,
|
||||
_ContextMenuLocation contextMenuLocation,
|
||||
Rect childRect,
|
||||
Rect sheetRect) {
|
||||
switch (contextMenuLocation) {
|
||||
case _ContextMenuLocation.center:
|
||||
final Offset target = orientation == Orientation.portrait ? childRect.bottomCenter : childRect.topCenter;
|
||||
final Offset target = orientation == Orientation.portrait
|
||||
? childRect.bottomCenter
|
||||
: childRect.topCenter;
|
||||
final Offset centered = target - Offset(sheetRect.width / 2, 0.0);
|
||||
return centered & sheetRect.size;
|
||||
case _ContextMenuLocation.right:
|
||||
final Offset target = orientation == Orientation.portrait ? childRect.bottomRight : childRect.topRight;
|
||||
final Offset target = orientation == Orientation.portrait
|
||||
? childRect.bottomRight
|
||||
: childRect.topRight;
|
||||
return (target - Offset(sheetRect.width, 0.0)) & sheetRect.size;
|
||||
case _ContextMenuLocation.left:
|
||||
final Offset target = orientation == Orientation.portrait ? childRect.bottomLeft : childRect.topLeft;
|
||||
final Offset target = orientation == Orientation.portrait
|
||||
? childRect.bottomLeft
|
||||
: childRect.topLeft;
|
||||
return target & sheetRect.size;
|
||||
}
|
||||
}
|
||||
@@ -651,7 +680,9 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
// Take measurements on the child and _ContextMenuSheet and update the
|
||||
// animation tweens to match.
|
||||
void _updateTweenRects() {
|
||||
final Rect childRect = _scale == null ? _getRect(_childGlobalKey) : _getScaledRect(_childGlobalKey, _scale!);
|
||||
final Rect childRect = _scale == null
|
||||
? _getRect(_childGlobalKey)
|
||||
: _getScaledRect(_childGlobalKey, _scale!);
|
||||
_rectTween.begin = _previousChildRect;
|
||||
_rectTween.end = childRect;
|
||||
|
||||
@@ -725,7 +756,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
|
||||
Widget buildPage(BuildContext context, Animation<double> animation,
|
||||
Animation<double> secondaryAnimation) {
|
||||
// This is usually used to build the "page", which is then passed to
|
||||
// buildTransitions as child, the idea being that buildTransitions will
|
||||
// animate the entire page into the scene. In the case of _ContextMenuRoute,
|
||||
@@ -735,7 +767,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildTransitions(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
|
||||
Widget buildTransitions(BuildContext context, Animation<double> animation,
|
||||
Animation<double> secondaryAnimation, Widget child) {
|
||||
return OrientationBuilder(
|
||||
builder: (BuildContext context, Orientation orientation) {
|
||||
_lastOrientation = orientation;
|
||||
@@ -744,9 +777,15 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
// they're movable.
|
||||
if (!animation.isCompleted) {
|
||||
final bool reverse = animation.status == AnimationStatus.reverse;
|
||||
final Rect rect = reverse ? _rectAnimatableReverse.evaluate(animation)! : _rectAnimatable.evaluate(animation)!;
|
||||
final Rect sheetRect = reverse ? _sheetRectAnimatableReverse.evaluate(animation)! : _sheetRectAnimatable.evaluate(animation)!;
|
||||
final double sheetScale = reverse ? _sheetScaleAnimatableReverse.evaluate(animation) : _sheetScaleAnimatable.evaluate(animation);
|
||||
final Rect rect = reverse
|
||||
? _rectAnimatableReverse.evaluate(animation)!
|
||||
: _rectAnimatable.evaluate(animation)!;
|
||||
final Rect sheetRect = reverse
|
||||
? _sheetRectAnimatableReverse.evaluate(animation)!
|
||||
: _sheetRectAnimatable.evaluate(animation)!;
|
||||
final double sheetScale = reverse
|
||||
? _sheetScaleAnimatableReverse.evaluate(animation)
|
||||
: _sheetScaleAnimatable.evaluate(animation);
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Positioned.fromRect(
|
||||
@@ -818,7 +857,8 @@ class _ContextMenuRouteStatic extends StatefulWidget {
|
||||
_ContextMenuRouteStaticState createState() => _ContextMenuRouteStaticState();
|
||||
}
|
||||
|
||||
class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with TickerProviderStateMixin {
|
||||
class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic>
|
||||
with TickerProviderStateMixin {
|
||||
// The child is scaled down as it is dragged down until it hits this minimum
|
||||
// value.
|
||||
static const double _kMinScale = 0.8;
|
||||
@@ -838,7 +878,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
late Animation<double> _sheetOpacityAnimation;
|
||||
|
||||
// The scale of the child changes as a function of the distance it is dragged.
|
||||
static double _getScale(Orientation orientation, double maxDragDistance, double dy) {
|
||||
static double _getScale(
|
||||
Orientation orientation, double maxDragDistance, double dy) {
|
||||
final double dyDirectional = dy <= 0.0 ? dy : -dy;
|
||||
return math.max(
|
||||
_kMinScale,
|
||||
@@ -859,11 +900,13 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
// If flung, animate a bit before handling the potential dismiss.
|
||||
if (details.velocity.pixelsPerSecond.dy.abs() >= kMinFlingVelocity) {
|
||||
final bool flingIsAway = details.velocity.pixelsPerSecond.dy > 0;
|
||||
final double finalPosition = flingIsAway ? _moveAnimation.value.dy + 100.0 : 0.0;
|
||||
final double finalPosition =
|
||||
flingIsAway ? _moveAnimation.value.dy + 100.0 : 0.0;
|
||||
|
||||
if (flingIsAway && _sheetController.status != AnimationStatus.forward) {
|
||||
_sheetController.forward();
|
||||
} else if (!flingIsAway && _sheetController.status != AnimationStatus.reverse) {
|
||||
} else if (!flingIsAway &&
|
||||
_sheetController.status != AnimationStatus.reverse) {
|
||||
_sheetController.reverse();
|
||||
}
|
||||
|
||||
@@ -918,21 +961,30 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
widget.onDismiss!(context, _lastScale, _sheetOpacityAnimation.value);
|
||||
}
|
||||
|
||||
Alignment _getChildAlignment(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
||||
Alignment _getChildAlignment(
|
||||
Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
||||
switch (contextMenuLocation) {
|
||||
case _ContextMenuLocation.center:
|
||||
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topRight;
|
||||
return orientation == Orientation.portrait
|
||||
? Alignment.bottomCenter
|
||||
: Alignment.topRight;
|
||||
case _ContextMenuLocation.right:
|
||||
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topLeft;
|
||||
return orientation == Orientation.portrait
|
||||
? Alignment.bottomCenter
|
||||
: Alignment.topLeft;
|
||||
case _ContextMenuLocation.left:
|
||||
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topRight;
|
||||
return orientation == Orientation.portrait
|
||||
? Alignment.bottomCenter
|
||||
: Alignment.topRight;
|
||||
}
|
||||
}
|
||||
|
||||
void _setDragOffset(Offset dragOffset) {
|
||||
// Allow horizontal and negative vertical movement, but damp it.
|
||||
final double endX = _kPadding * dragOffset.dx / _kDamping;
|
||||
final double endY = dragOffset.dy >= 0.0 ? dragOffset.dy : _kPadding * dragOffset.dy / _kDamping;
|
||||
final double endY = dragOffset.dy >= 0.0
|
||||
? dragOffset.dy
|
||||
: _kPadding * dragOffset.dy / _kDamping;
|
||||
setState(() {
|
||||
_dragOffset = dragOffset;
|
||||
_moveAnimation = Tween<Offset>(
|
||||
@@ -949,9 +1001,13 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
);
|
||||
|
||||
// Fade the _ContextMenuSheet out or in, if needed.
|
||||
if (_lastScale <= _kSheetScaleThreshold && _sheetController.status != AnimationStatus.forward && _sheetScaleAnimation.value != 0.0) {
|
||||
if (_lastScale <= _kSheetScaleThreshold &&
|
||||
_sheetController.status != AnimationStatus.forward &&
|
||||
_sheetScaleAnimation.value != 0.0) {
|
||||
_sheetController.forward();
|
||||
} else if (_lastScale > _kSheetScaleThreshold && _sheetController.status != AnimationStatus.reverse && _sheetScaleAnimation.value != 1.0) {
|
||||
} else if (_lastScale > _kSheetScaleThreshold &&
|
||||
_sheetController.status != AnimationStatus.reverse &&
|
||||
_sheetScaleAnimation.value != 1.0) {
|
||||
_sheetController.reverse();
|
||||
}
|
||||
});
|
||||
@@ -960,7 +1016,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
// The order and alignment of the _ContextMenuSheet and the child depend on
|
||||
// both the orientation of the screen as well as the position on the screen of
|
||||
// the original child.
|
||||
List<Widget> _getChildren(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
||||
List<Widget> _getChildren(
|
||||
Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
||||
final Expanded child = Expanded(
|
||||
child: Align(
|
||||
alignment: _getChildAlignment(
|
||||
@@ -995,7 +1052,9 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
case _ContextMenuLocation.center:
|
||||
return <Widget>[child, spacer, sheet];
|
||||
case _ContextMenuLocation.right:
|
||||
return orientation == Orientation.portrait ? <Widget>[child, spacer, sheet] : <Widget>[sheet, spacer, child];
|
||||
return orientation == Orientation.portrait
|
||||
? <Widget>[child, spacer, sheet]
|
||||
: <Widget>[sheet, spacer, child];
|
||||
case _ContextMenuLocation.left:
|
||||
return <Widget>[child, spacer, sheet];
|
||||
}
|
||||
@@ -1004,7 +1063,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
// Build the animation for the _ContextMenuSheet.
|
||||
Widget _buildSheetAnimation(BuildContext context, Widget? child) {
|
||||
return Transform.scale(
|
||||
alignment: _ContextMenuRoute.getSheetAlignment(widget.contextMenuLocation),
|
||||
alignment:
|
||||
_ContextMenuRoute.getSheetAlignment(widget.contextMenuLocation),
|
||||
scale: _sheetScaleAnimation.value,
|
||||
child: FadeTransition(
|
||||
opacity: _sheetOpacityAnimation,
|
||||
|
||||
66
lib/base/ui/search_cell.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../theme.dart';
|
||||
|
||||
class SearchCell extends ConsumerStatefulWidget {
|
||||
final TextEditingController controller;
|
||||
|
||||
const SearchCell({
|
||||
Key? key,
|
||||
required this.controller,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
ConsumerState createState() => _SearchCellState();
|
||||
}
|
||||
|
||||
class _SearchCellState extends ConsumerState<SearchCell> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoSearchTextField(
|
||||
decoration: BoxDecoration(
|
||||
color: ref.watch(themeProvider).themeColor.blackAndWhite(),
|
||||
border: Border.all(width: 1, color: const Color(0xffC0C4CC)),
|
||||
borderRadius: BorderRadius.circular(
|
||||
7,
|
||||
),
|
||||
),
|
||||
onSuffixTap: () {
|
||||
widget.controller.text = "";
|
||||
setState(() {});
|
||||
},
|
||||
controller: widget.controller,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 5,
|
||||
vertical: 5,
|
||||
),
|
||||
suffixInsets: const EdgeInsets.only(
|
||||
right: 15,
|
||||
),
|
||||
prefixIcon: Image.asset(
|
||||
"assets/images/icon_search.png",
|
||||
width: 18,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
prefixInsets: const EdgeInsets.only(
|
||||
left: 10,
|
||||
top: 2,
|
||||
),
|
||||
placeholderStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||
),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
placeholder: "请输入内容",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -29,9 +29,8 @@ class SourceCodeView extends StatefulWidget {
|
||||
this.syntaxHighlighterStyle,
|
||||
}) : super(key: key);
|
||||
|
||||
String? get codeLink => codeLinkPrefix == null
|
||||
? null
|
||||
: '$codeLinkPrefix/$filePath';
|
||||
String? get codeLink =>
|
||||
codeLinkPrefix == null ? null : '$codeLinkPrefix/$filePath';
|
||||
|
||||
@override
|
||||
_SourceCodeViewState createState() {
|
||||
|
||||
@@ -17,7 +17,10 @@ class SyntaxHighlighterStyle {
|
||||
this.constantStyle});
|
||||
|
||||
static SyntaxHighlighterStyle lightThemeStyle() => SyntaxHighlighterStyle(
|
||||
baseStyle: const TextStyle(color: const Color(0xFF000000),height: 1,),
|
||||
baseStyle: const TextStyle(
|
||||
color: const Color(0xFF000000),
|
||||
height: 1,
|
||||
),
|
||||
numberStyle: const TextStyle(color: const Color(0xFF1565C0)),
|
||||
commentStyle: const TextStyle(color: const Color(0xFF9E9E9E)),
|
||||
keywordStyle: const TextStyle(color: const Color(0xFF9C27B0)),
|
||||
|
||||
@@ -26,7 +26,8 @@ class UserInfoViewModel {
|
||||
_useSecertLogined = SpUtil.getBool(spSecretLogined, defValue: false);
|
||||
_host = SpUtil.getString(spHost, defValue: '');
|
||||
|
||||
List<dynamic>? tempList = jsonDecode(SpUtil.getString(spLoginHistory, defValue: '[]'));
|
||||
List<dynamic>? tempList =
|
||||
jsonDecode(SpUtil.getString(spLoginHistory, defValue: '[]'));
|
||||
|
||||
if (tempList != null && tempList.isNotEmpty) {
|
||||
for (Map<String, dynamic> value in tempList) {
|
||||
@@ -40,7 +41,8 @@ class UserInfoViewModel {
|
||||
SpUtil.putString(spUserInfo, token);
|
||||
}
|
||||
|
||||
void updateUserName(String host, String userName, String password, bool secretLogin) {
|
||||
void updateUserName(
|
||||
String host, String userName, String password, bool secretLogin) {
|
||||
updateHost(host);
|
||||
_useSecretLogin(secretLogin);
|
||||
_userName = userName;
|
||||
@@ -93,7 +95,13 @@ class UserInfoViewModel {
|
||||
|
||||
historyAccounts.removeWhere((element) => element.host == _host);
|
||||
|
||||
historyAccounts.insert(0, UserInfoBean(userName: _userName, password: _passWord, useSecretLogined: _useSecertLogined, host: _host));
|
||||
historyAccounts.insert(
|
||||
0,
|
||||
UserInfoBean(
|
||||
userName: _userName,
|
||||
password: _passWord,
|
||||
useSecretLogined: _useSecertLogined,
|
||||
host: _host));
|
||||
|
||||
while (historyAccounts.length > 3) {
|
||||
historyAccounts.removeLast();
|
||||
@@ -117,7 +125,8 @@ class UserInfoBean {
|
||||
bool useSecretLogined = false;
|
||||
String? host;
|
||||
|
||||
UserInfoBean({this.userName, this.password, this.useSecretLogined = false, this.host});
|
||||
UserInfoBean(
|
||||
{this.userName, this.password, this.useSecretLogined = false, this.host});
|
||||
|
||||
UserInfoBean.fromJson(Map<String, dynamic> json) {
|
||||
userName = json['userName'];
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:qinglong_app/module/login/user_bean.dart';
|
||||
import 'package:qinglong_app/module/others/dependencies/dependency_bean.dart';
|
||||
import 'package:qinglong_app/module/others/login_log/login_log_bean.dart';
|
||||
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_bean.dart';
|
||||
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||
|
||||
@@ -65,6 +66,10 @@ class JsonConversion$Json {
|
||||
if(type == (TaskBean).toString()){
|
||||
return TaskBean.jsonConversion(json) as M;
|
||||
}
|
||||
|
||||
if (type == (Subscription).toString()){
|
||||
return Subscription.fromJson(json) as M;
|
||||
}
|
||||
|
||||
throw Exception("not found");
|
||||
}
|
||||
@@ -109,6 +114,10 @@ class JsonConversion$Json {
|
||||
if(<TaskBean>[] is M){
|
||||
return data.map<TaskBean>((e) => TaskBean.jsonConversion(e)).toList() as M;
|
||||
}
|
||||
|
||||
if (<Subscription>[] is M){
|
||||
return data.map<Subscription>((e) => Subscription.jsonConversion(e)).toList() as M;
|
||||
}
|
||||
|
||||
throw Exception("not found");
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:io';
|
||||
import 'package:dio_log/overlay_draggable_button.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
@@ -11,6 +12,7 @@ import 'package:qinglong_app/base/theme.dart';
|
||||
import 'package:qinglong_app/module/login/login_page.dart';
|
||||
import 'package:qinglong_app/utils/sp_utils.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
||||
|
||||
import 'base/routes.dart';
|
||||
import 'base/userinfo_viewmodel.dart';
|
||||
@@ -54,6 +56,29 @@ class QlApp extends ConsumerStatefulWidget {
|
||||
}
|
||||
|
||||
class QlAppState extends ConsumerState<QlApp> {
|
||||
List<DisplayMode> modes = <DisplayMode>[];
|
||||
DisplayMode? active;
|
||||
DisplayMode? preferred;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
fetchAll();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> fetchAll() async {
|
||||
try {
|
||||
modes = await FlutterDisplayMode.supported;
|
||||
modes.forEach(print);
|
||||
await FlutterDisplayMode.setHighRefreshRate();
|
||||
} on PlatformException catch (e) {
|
||||
print(e);
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
@@ -61,37 +86,32 @@ class QlAppState extends ConsumerState<QlApp> {
|
||||
onTap: () {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
},
|
||||
child: MediaQuery(
|
||||
data: MediaQueryData.fromWindow(WidgetsBinding.instance!.window).copyWith(
|
||||
textScaleFactor: 1,
|
||||
),
|
||||
child: MaterialApp(
|
||||
title: "青龙",
|
||||
locale: const Locale('zh', 'CN'),
|
||||
navigatorKey: navigatorState,
|
||||
localizationsDelegates: const [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [
|
||||
Locale('zh', 'CN'),
|
||||
Locale('en', 'US'),
|
||||
],
|
||||
theme: ref.watch<ThemeViewModel>(themeProvider).currentTheme,
|
||||
onGenerateRoute: (setting) {
|
||||
return Routes.generateRoute(setting);
|
||||
child: MaterialApp(
|
||||
title: "青龙",
|
||||
locale: const Locale('zh', 'CN'),
|
||||
navigatorKey: navigatorState,
|
||||
localizationsDelegates: const [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [
|
||||
Locale('zh', 'CN'),
|
||||
Locale('en', 'US'),
|
||||
],
|
||||
theme: ref.watch<ThemeViewModel>(themeProvider).currentTheme,
|
||||
onGenerateRoute: (setting) {
|
||||
return Routes.generateRoute(setting);
|
||||
},
|
||||
home: Builder(
|
||||
builder: (context) {
|
||||
if (!kReleaseMode) {
|
||||
showDebugBtn(context);
|
||||
}
|
||||
return getIt<UserInfoViewModel>().isLogined() ? const HomePage() : const LoginPage();
|
||||
},
|
||||
home: Builder(
|
||||
builder: (context) {
|
||||
if (!kReleaseMode) {
|
||||
showDebugBtn(context);
|
||||
}
|
||||
return getIt<UserInfoViewModel>().isLogined() ? const HomePage() : const LoginPage();
|
||||
},
|
||||
),
|
||||
// home: LoginPage(),
|
||||
),
|
||||
// home: LoginPage(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
326
lib/module/change_account_page.dart
Normal file
@@ -0,0 +1,326 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:qinglong_app/base/http/api.dart';
|
||||
import 'package:qinglong_app/base/http/http.dart';
|
||||
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||
import 'package:qinglong_app/base/routes.dart';
|
||||
import 'package:qinglong_app/base/theme.dart';
|
||||
import 'package:qinglong_app/base/userinfo_viewmodel.dart';
|
||||
import 'package:qinglong_app/utils/extension.dart';
|
||||
import 'package:qinglong_app/utils/login_helper.dart';
|
||||
|
||||
import '../../main.dart';
|
||||
|
||||
class ChangeAccountPage extends ConsumerStatefulWidget {
|
||||
const ChangeAccountPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ChangeAccountPageState createState() => _ChangeAccountPageState();
|
||||
}
|
||||
|
||||
class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
||||
String isLoginingHost = "";
|
||||
String preHost = "";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
preHost = getIt<UserInfoViewModel>().historyAccounts.first.host ?? "";
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: QlAppBar(
|
||||
canBack: true,
|
||||
title: "切换账号",
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 10,
|
||||
),
|
||||
Text(
|
||||
"轻触账号以切换登录",
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 22,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
),
|
||||
child: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
if (index ==
|
||||
getIt<UserInfoViewModel>().historyAccounts.length) {
|
||||
return addAccount();
|
||||
}
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Container(
|
||||
color: ref
|
||||
.watch(themeProvider)
|
||||
.themeColor
|
||||
.settingBordorColor(),
|
||||
child: buildCell(index),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) {
|
||||
return const SizedBox(
|
||||
height: 10,
|
||||
);
|
||||
},
|
||||
itemCount:
|
||||
getIt<UserInfoViewModel>().historyAccounts.length + 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildCell(int index) {
|
||||
Widget child = ListTile(
|
||||
title: Text(
|
||||
getIt<UserInfoViewModel>().historyAccounts[index].host ?? "",
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
),
|
||||
minVerticalPadding: 10,
|
||||
subtitle: Padding(
|
||||
padding: const EdgeInsets.only(top: 10.0),
|
||||
child: Text(
|
||||
getIt<UserInfoViewModel>().historyAccounts[index].userName ?? "",
|
||||
),
|
||||
),
|
||||
trailing: index == 0
|
||||
? Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 5,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(
|
||||
color: ref.watch(themeProvider).primaryColor, width: 1),
|
||||
),
|
||||
child: Text(
|
||||
"已登录",
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).primaryColor, fontSize: 12),
|
||||
),
|
||||
)
|
||||
: (isLoginingHost.isNotEmpty
|
||||
? SizedBox(
|
||||
width: 15,
|
||||
height: 15,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: ref.watch(themeProvider).primaryColor,
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink()),
|
||||
);
|
||||
|
||||
if (getIt<UserInfoViewModel>().historyAccounts[index].host ==
|
||||
getIt<UserInfoViewModel>().host) {
|
||||
return child;
|
||||
}
|
||||
|
||||
return Slidable(
|
||||
key: ValueKey(index),
|
||||
endActionPane: ActionPane(
|
||||
motion: const ScrollMotion(),
|
||||
extentRatio: 0.15,
|
||||
children: [
|
||||
SlidableAction(
|
||||
backgroundColor: Colors.red,
|
||||
flex: 1,
|
||||
onPressed: (_) {
|
||||
getIt<UserInfoViewModel>().removeHistoryAccount(
|
||||
getIt<UserInfoViewModel>().historyAccounts[index].host);
|
||||
setState(() {});
|
||||
},
|
||||
foregroundColor: Colors.white,
|
||||
icon: CupertinoIcons.delete,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
loginNewByBean(getIt<UserInfoViewModel>().historyAccounts[index]);
|
||||
},
|
||||
child: child),
|
||||
);
|
||||
}
|
||||
|
||||
LoginHelper? helper;
|
||||
|
||||
void loginNewByBean(UserInfoBean historyAccount) async {
|
||||
isLoginingHost = historyAccount.host ?? "";
|
||||
setState(() {});
|
||||
helper = LoginHelper(
|
||||
historyAccount.useSecretLogined,
|
||||
historyAccount.host ?? "",
|
||||
historyAccount.userName ?? "",
|
||||
historyAccount.password ?? "",
|
||||
true,
|
||||
);
|
||||
var response = await helper!.login();
|
||||
dealLoginResponse(response);
|
||||
}
|
||||
|
||||
void dealLoginResponse(int response) {
|
||||
if (response == LoginHelper.success) {
|
||||
Navigator.of(context)
|
||||
.pushNamedAndRemoveUntil(Routes.routeHomePage, (_) => false);
|
||||
} else if (response == LoginHelper.failed) {
|
||||
loginFailed();
|
||||
} else {
|
||||
twoFact();
|
||||
}
|
||||
}
|
||||
|
||||
void loginFailed() {
|
||||
isLoginingHost = "";
|
||||
Http.clear();
|
||||
getIt<UserInfoViewModel>().updateHost(preHost);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void twoFact() {
|
||||
String twoFact = "";
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (_) => CupertinoAlertDialog(
|
||||
title: const Text("两步验证"),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: TextField(
|
||||
onChanged: (value) {
|
||||
twoFact = value;
|
||||
},
|
||||
maxLines: 1,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "请输入code",
|
||||
),
|
||||
autofocus: true,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: const Text(
|
||||
"取消",
|
||||
style: TextStyle(
|
||||
color: Color(0xff999999),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(
|
||||
"确定",
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).primaryColor,
|
||||
),
|
||||
),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop(true);
|
||||
if (helper != null) {
|
||||
var response = await helper!.loginTwice(twoFact);
|
||||
dealLoginResponse(response);
|
||||
} else {
|
||||
"状态异常".toast();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
)).then((value) {
|
||||
if (value == null) {
|
||||
isLoginingHost = "";
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget addAccount() {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
Routes.routeLogin,
|
||||
(_) => false,
|
||||
arguments: true,
|
||||
);
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 15,
|
||||
horizontal: 15,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ref.watch(themeProvider).themeColor.settingBordorColor(),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(
|
||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||
),
|
||||
),
|
||||
child: Icon(
|
||||
CupertinoIcons.add,
|
||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
Text(
|
||||
"添加账号",
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
import 'package:code_text_field/code_text_field.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:highlight/languages/powershell.dart';
|
||||
import 'package:qinglong_app/base/http/api.dart';
|
||||
import 'package:qinglong_app/base/http/http.dart';
|
||||
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||
import 'package:qinglong_app/base/sp_const.dart';
|
||||
import 'package:qinglong_app/base/theme.dart';
|
||||
import 'package:qinglong_app/utils/extension.dart';
|
||||
import 'package:qinglong_app/utils/sp_utils.dart';
|
||||
|
||||
class ConfigEditPage extends ConsumerStatefulWidget {
|
||||
final String content;
|
||||
@@ -21,47 +25,122 @@ class ConfigEditPage extends ConsumerStatefulWidget {
|
||||
class _ConfigEditPageState extends ConsumerState<ConfigEditPage> {
|
||||
CodeController? _codeController;
|
||||
late String result;
|
||||
late String preResult;
|
||||
List<String> operateList = [];
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_codeController?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
result = widget.content;
|
||||
|
||||
preResult = widget.content;
|
||||
super.initState();
|
||||
generateOperateList();
|
||||
|
||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
focusNode.requestFocus();
|
||||
checkClipBoard();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> notifyICloud(
|
||||
BuildContext context, String? title, String? content) async {}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_codeController ??= CodeController(
|
||||
text: widget.content,
|
||||
text: result,
|
||||
language: powershell,
|
||||
onChange: (value) {
|
||||
result = value;
|
||||
},
|
||||
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
|
||||
stringMap: {
|
||||
"export": const TextStyle(fontWeight: FontWeight.normal, color: Color(0xff6B2375)),
|
||||
"export": const TextStyle(
|
||||
fontWeight: FontWeight.normal, color: Color(0xff6B2375)),
|
||||
},
|
||||
);
|
||||
return Scaffold(
|
||||
appBar: QlAppBar(
|
||||
canBack: true,
|
||||
backCall: () {
|
||||
Navigator.of(context).pop();
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
|
||||
if (preResult == result) {
|
||||
Navigator.of(context).pop();
|
||||
} else {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (childContext) => CupertinoAlertDialog(
|
||||
title: const Text("温馨提示"),
|
||||
content: const Text("你编辑的内容还没用提交,确定退出吗?"),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: const Text(
|
||||
"取消",
|
||||
style: TextStyle(
|
||||
color: Color(0xff999999),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(childContext).pop();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(
|
||||
"确定",
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).primaryColor,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(childContext).pop();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
title: '编辑${widget.title}',
|
||||
actions: [
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: PopupMenuButton<String>(
|
||||
onSelected: (String result) {
|
||||
updateValueBykey(result);
|
||||
},
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
...operateList
|
||||
.map(
|
||||
(e) => PopupMenuItem<String>(
|
||||
child: Text(e),
|
||||
value: e,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
],
|
||||
child: const Center(
|
||||
child: Icon(
|
||||
CupertinoIcons.arrow_up_right_diamond,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
HttpResponse<NullResponse> response = await Api.saveFile(widget.title, result);
|
||||
HttpResponse<NullResponse> response =
|
||||
await Api.saveFile(widget.title, result);
|
||||
await notifyICloud(context, widget.title, result);
|
||||
if (response.success) {
|
||||
"提交成功".toast();
|
||||
Navigator.of(context).pop(widget.title);
|
||||
@@ -88,14 +167,177 @@ class _ConfigEditPageState extends ConsumerState<ConfigEditPage> {
|
||||
),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
child: CodeField(
|
||||
controller: _codeController!,
|
||||
expands: true,
|
||||
background: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: SpUtil.getBool(spShowLine, defValue: false) ? 0 : 10,
|
||||
),
|
||||
child: CodeField(
|
||||
controller: _codeController!,
|
||||
expands: true,
|
||||
background: Colors.white,
|
||||
wrap: SpUtil.getBool(spShowLine, defValue: false) ? false : true,
|
||||
hideColumn: !SpUtil.getBool(spShowLine, defValue: false),
|
||||
lineNumberStyle: LineNumberStyle(
|
||||
textStyle: TextStyle(
|
||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
FocusNode focusNode = FocusNode();
|
||||
|
||||
void generateOperateList() {
|
||||
operateList.clear();
|
||||
List<String> array = result.split("\n");
|
||||
for (String a in array) {
|
||||
String t = a.replaceAll(" ", "");
|
||||
if (t.trim().startsWith("export")) {
|
||||
int i = t.indexOf("export") + 6;
|
||||
int j = t.indexOf("=");
|
||||
operateList.add(t.substring(i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void updateValueBykey(String key) async {
|
||||
String defaultValue = "";
|
||||
try {
|
||||
var clipBoard = await Clipboard.getData(Clipboard.kTextPlain);
|
||||
|
||||
if (clipBoard != null && clipBoard.text != null) {
|
||||
String tempText = clipBoard.text!;
|
||||
|
||||
if (tempText.trim().contains("export")) {
|
||||
int i = tempText.trim().indexOf("\"");
|
||||
int j = tempText.trim().lastIndexOf("\"");
|
||||
|
||||
if (i == -1 || j == -1) {
|
||||
i = tempText.trim().indexOf("'");
|
||||
j = tempText.trim().lastIndexOf("'");
|
||||
}
|
||||
|
||||
defaultValue = tempText.trim().substring(i, j);
|
||||
} else {
|
||||
defaultValue = tempText;
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
TextEditingController controller = TextEditingController(
|
||||
text: defaultValue.replaceAll("\"", "").replaceAll("'", ""));
|
||||
showCupertinoDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
builder: (context) => CupertinoAlertDialog(
|
||||
title: Text("编辑$key:"),
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
),
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
decoration: const InputDecoration(
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.all(4),
|
||||
hintText: "请输入值",
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: const Text(
|
||||
"取消",
|
||||
style: TextStyle(
|
||||
color: Color(0xff999999),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(
|
||||
"确定",
|
||||
style: TextStyle(
|
||||
color: ref.watch(themeProvider).primaryColor,
|
||||
),
|
||||
),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
updateValueByKey(key, controller.text);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void updateValueByKey(String key, String text) {
|
||||
List<String> array = result.split("\n");
|
||||
for (String a in array) {
|
||||
String t = a.replaceAll(" ", "");
|
||||
if (t.trim().startsWith("export")) {
|
||||
int i = t.indexOf("export") + 6;
|
||||
int j = t.indexOf("=");
|
||||
|
||||
String tempResult = t.substring(i, j);
|
||||
if (tempResult == key) {
|
||||
result = result.replaceAll(a, "\nexport $key = \"$text\" \n\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_codeController = null;
|
||||
setState(() {});
|
||||
"已修改".toast();
|
||||
}
|
||||
|
||||
void checkClipBoard() async {
|
||||
try {
|
||||
String key = "";
|
||||
String value = "";
|
||||
var clipBoard = await Clipboard.getData(Clipboard.kTextPlain);
|
||||
|
||||
if (clipBoard != null && clipBoard.text != null) {
|
||||
String tempText = clipBoard.text!;
|
||||
|
||||
if (tempText.trim().contains("export")) {
|
||||
int kI = tempText.trim().indexOf("export");
|
||||
int kJ = tempText.trim().indexOf("=");
|
||||
|
||||
key = tempText.trim().substring(kI + 6, kJ);
|
||||
|
||||
int i = tempText.trim().indexOf("\"");
|
||||
int j = tempText.trim().lastIndexOf("\"");
|
||||
|
||||
if (i == -1 || j == -1) {
|
||||
i = tempText.trim().indexOf("'");
|
||||
j = tempText.trim().lastIndexOf("'");
|
||||
}
|
||||
value = tempText.trim().substring(i, j);
|
||||
|
||||
if (key.isNotEmpty && result.contains(key) && value.isNotEmpty) {
|
||||
WidgetsBinding.instance.endOfFrame.then((value) {
|
||||
updateValueBykey(key);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||