From 39cd51f22a83003628b1f1e969dbe2b4ac3ed312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=B2=AB=E8=8A=B1=E7=81=ABzzz=F0=9F=8C=99?= Date: Sat, 7 Sep 2024 10:08:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B7=B1=E5=BA=A6=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E5=90=AF=E5=8A=A8=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RELEASE_CHANGELOG.md | 14 +++------- .../storages/stores/user_info_storage.dart | 15 ++++++++--- nyalcf_core/pubspec.yaml | 2 +- nyalcf_gui/lib/main.dart | 27 ++++++++++++++++--- .../lib/utils/deep_link_executor.dart | 4 ++- nyalcf_gui/nyalcf_core_extend/pubspec.yaml | 2 +- nyalcf_gui/nyalcf_inject_extend/pubspec.yaml | 2 +- nyalcf_gui/nyalcf_ui/lib/views/home.dart | 5 ++++ nyalcf_gui/nyalcf_ui/pubspec.yaml | 2 +- nyalcf_gui/pubspec.yaml | 2 +- 10 files changed, 52 insertions(+), 23 deletions(-) diff --git a/RELEASE_CHANGELOG.md b/RELEASE_CHANGELOG.md index 212649f..db25c58 100644 --- a/RELEASE_CHANGELOG.md +++ b/RELEASE_CHANGELOG.md @@ -6,24 +6,16 @@ ### GUI -- 修改了 Frpc 下载的处理逻辑 -- 打开终端默认自动滚动到底部 +- 针对 `深度链接` 调用启动进行了优化,现在若隧道执行启动成功会自动进入 `仅 Frp Token 模式` ### CLI -/- -### 其他 - -#### NyaLCF Core - -- 修改了网络请求的返回数据类型 -- 升级 Frpc 到 `LoCyanFrp-0.51.3-4 #2024082401` ([See here](https://github.com/LoCyan-Team/LoCyanFrpPureApp/releases/tag/v0.51.3-4)) - ## 版本信息 -- nyalcf_gui: 0.2.1 +- nyalcf_gui: 0.2.2 - nyalcf_cli: 0.0.2 -- nyalcf_core,nyalcf_inject: 1.0.7 +- nyalcf_core,nyalcf_inject: 1.0.8 diff --git a/nyalcf_core/lib/storages/stores/user_info_storage.dart b/nyalcf_core/lib/storages/stores/user_info_storage.dart index 982e48e..786475d 100644 --- a/nyalcf_core/lib/storages/stores/user_info_storage.dart +++ b/nyalcf_core/lib/storages/stores/user_info_storage.dart @@ -26,12 +26,21 @@ class UserInfoStorage { } /// 退出登录 - static sigo(user, token) async { - final res = await LogoutAuth.requestLogout(user, token); - if (res.status) { + static Future sigo(user, token, {deleteSessionFileOnly = false}) async { + deleteFile() async { await File('$_path/session.json').delete(); return true; } + if (!deleteSessionFileOnly) { + final res = await LogoutAuth.requestLogout(user, token); + if (res.status) { + await deleteFile(); + return true; + } + } else { + await deleteFile(); + return true; + } return false; } } diff --git a/nyalcf_core/pubspec.yaml b/nyalcf_core/pubspec.yaml index 3fbcf40..16783bf 100644 --- a/nyalcf_core/pubspec.yaml +++ b/nyalcf_core/pubspec.yaml @@ -1,6 +1,6 @@ name: nyalcf_core description: 'Nya LoCyanFrp! core module.' -version: 1.0.7 +version: 1.0.8 homepage: https://nyalcf.1l1.icu publish_to: none # repository: https://github.com/my_org/my_repo diff --git a/nyalcf_gui/lib/main.dart b/nyalcf_gui/lib/main.dart index 357fc26..2931133 100644 --- a/nyalcf_gui/lib/main.dart +++ b/nyalcf_gui/lib/main.dart @@ -4,6 +4,7 @@ import 'package:app_links/app_links.dart'; import 'package:bitsdojo_window/bitsdojo_window.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:nyalcf_core_extend/storages/prefs/token_mode_prefs.dart'; import 'package:tray_manager/tray_manager.dart'; import 'package:window_manager/window_manager.dart'; @@ -31,6 +32,7 @@ import 'package:nyalcf_ui/views/tokenmode/panel.dart'; import 'package:nyalcf_ui/views/license.dart'; final _appLinks = AppLinks(); +bool _appInit = false; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -61,9 +63,26 @@ void main() async { /// 注册并监听深度链接 if (Platform.isWindows) DeepLinkRegister.registerWindows('locyanfrp'); - _appLinks.uriLinkStream.listen((uri) { + _appLinks.uriLinkStream.listen((uri) async { Logger.debug('Received uri scheme: $uri'); - DeepLinkExecutor(uri: uri.toString()).execute(); + final res = await DeepLinkExecutor(uri: uri.toString()).execute(); + + Logger.debug(res); + if (res[0]) { + Logger.debug('Started as token-only mode as deeplink executed success'); + await TokenModePrefs.setToken(res[1]); + await Future.doWhile(() async { + if (_appInit) { + Get.toNamed('/token_mode/panel'); + return false; // 结束循环 + } + Logger.debug('Waiting for app init...'); + await Future.delayed(const Duration(milliseconds: 1000)); // 延迟检查 + return true; // 继续循环 + }); + } else { + Logger.debug('Skip for enter token-only mode'); + } }); /// 启动定时任务 @@ -87,7 +106,7 @@ class _AppState extends State with WindowListener, TrayListener { Widget build(BuildContext context) { ThemeData themeData = ThemeControl().getTheme(); - return GetMaterialApp( + final app = GetMaterialApp( logWriterCallback: Logger.getxLogWriter, title: 'Nya LoCyanFrp!', routes: { @@ -105,6 +124,8 @@ class _AppState extends State with WindowListener, TrayListener { }, theme: themeData, ); + _appInit = true; + return app; } /// 组件初始化时操作 diff --git a/nyalcf_gui/nyalcf_core_extend/lib/utils/deep_link_executor.dart b/nyalcf_gui/nyalcf_core_extend/lib/utils/deep_link_executor.dart index 0d60512..2aae366 100644 --- a/nyalcf_gui/nyalcf_core_extend/lib/utils/deep_link_executor.dart +++ b/nyalcf_gui/nyalcf_core_extend/lib/utils/deep_link_executor.dart @@ -9,7 +9,7 @@ class DeepLinkExecutor { final String uri; - void execute() async { + Future> execute() async { final content = uri.replaceFirst('locyanfrp://', ''); final data = content.split('/'); final frpToken = data[0], proxyId = int.parse(data[1]); @@ -20,9 +20,11 @@ class DeepLinkExecutor { proxyId: proxyId, frpcPath: frpcPath, ); + return [true, frpToken]; } else { Logger.error( 'Could not implement proxy fast startup, no frpc has installed!'); } + return [false]; } } diff --git a/nyalcf_gui/nyalcf_core_extend/pubspec.yaml b/nyalcf_gui/nyalcf_core_extend/pubspec.yaml index 698b06c..c3247c2 100644 --- a/nyalcf_gui/nyalcf_core_extend/pubspec.yaml +++ b/nyalcf_gui/nyalcf_core_extend/pubspec.yaml @@ -1,6 +1,6 @@ name: nyalcf_core_extend description: "Nya LoCyanFrp! core extend module." -version: 1.0.7 +version: 1.0.8 homepage: https://nyalcf.1l1.icu publish_to: none diff --git a/nyalcf_gui/nyalcf_inject_extend/pubspec.yaml b/nyalcf_gui/nyalcf_inject_extend/pubspec.yaml index d649787..5f6a56c 100644 --- a/nyalcf_gui/nyalcf_inject_extend/pubspec.yaml +++ b/nyalcf_gui/nyalcf_inject_extend/pubspec.yaml @@ -1,6 +1,6 @@ name: nyalcf_inject_extend description: "Nya LoCyanFrp! communication injector extend module." -version: 1.0.7 +version: 1.0.8 homepage: https://nyalcf.1l1.icu publish_to: none diff --git a/nyalcf_gui/nyalcf_ui/lib/views/home.dart b/nyalcf_gui/nyalcf_ui/lib/views/home.dart index b3d62ac..a2dafc5 100644 --- a/nyalcf_gui/nyalcf_ui/lib/views/home.dart +++ b/nyalcf_gui/nyalcf_ui/lib/views/home.dart @@ -124,6 +124,11 @@ class HC extends GetxController { // 跳转到面板首页 Get.toNamed('/panel/home'); } else { + UserInfoStorage.sigo( + userinfo.user, + userinfo.token, + deleteSessionFileOnly: true, + ); // 显示令牌校验失败的SnackBar Get.snackbar( '令牌校验失败', diff --git a/nyalcf_gui/nyalcf_ui/pubspec.yaml b/nyalcf_gui/nyalcf_ui/pubspec.yaml index 6039d77..30568f4 100644 --- a/nyalcf_gui/nyalcf_ui/pubspec.yaml +++ b/nyalcf_gui/nyalcf_ui/pubspec.yaml @@ -1,6 +1,6 @@ name: nyalcf_ui description: "Nya LoCyanFrp! user interface module." -version: 1.0.7 +version: 1.0.8 homepage: https://nyalcf.1l1.icu publish_to: none diff --git a/nyalcf_gui/pubspec.yaml b/nyalcf_gui/pubspec.yaml index da7cab8..ffd183c 100644 --- a/nyalcf_gui/pubspec.yaml +++ b/nyalcf_gui/pubspec.yaml @@ -1,6 +1,6 @@ name: nyalcf description: "[GUI]The next generation of LoCyanFrp launcher." -version: 0.2.2 +version: 0.2.2+1 homepage: https://nyalcf.1l1.icu publish_to: 'none'