Skip to content

Commit

Permalink
Merge pull request #207 from Muska-Ami/dev
Browse files Browse the repository at this point in the history
Update to v0.2.3+5 with CLI v0.0.3+2
  • Loading branch information
Muska-Ami authored Oct 3, 2024
2 parents ba7eab1 + fb963eb commit 2a017ad
Show file tree
Hide file tree
Showing 20 changed files with 204 additions and 185 deletions.
13 changes: 6 additions & 7 deletions RELEASE_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@

### GUI

-/-
- 修复系统托盘问题 #189
- 自动移除不存在的自动启动项目 #179

### CLI

-/-
- 修复一个错误的 verbose 输出
- 修复一个错误的启动逻辑
- 优化下载返回

### 其他

#### NyaLCF Core

- 更新 Frpc 版本
[//]: # (### 其他)

## 版本信息

Expand Down
10 changes: 9 additions & 1 deletion nyalcf_cli/lib/commands/download.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';

// Package imports:
import 'package:dio/dio.dart';
import 'package:nyalcf/utils/state.dart';
import 'package:nyalcf_core/network/dio/frpc/download_frpc.dart';
import 'package:nyalcf_core/utils/cpu_arch.dart';
import 'package:nyalcf_core/utils/frpc/arch.dart';
Expand Down Expand Up @@ -33,9 +34,13 @@ class Download implements CommandImplement {
_providePlatform = args[1];
_provide = true;
}
if (verbose) {
Logger.verbose('Provide info: $_provideArch, $_providePlatform');
}
final systemArch = await CPUArch.getCPUArchitecture();
Logger.verbose('CPU arch: $systemArch');
if (verbose) {
Logger.verbose('CPU arch: $systemArch');
}

bool supportedSystem = false;

Expand Down Expand Up @@ -68,9 +73,12 @@ class Download implements CommandImplement {
cancelToken: _cancelToken,
useMirror: false,
);
stdout.write('\r${' ' * 30}');
stdout.write('\rPlease wait, extracting frpc...\n');
await FrpcArchive.extract(
platform: platform, arch: _selectedArch, version: '0.51.3-6');
stdout.write('\r${' ' * 30}');
stdout.write('\rSuccess!\n');
} else {
Logger.error(
'Unsupported system! If you believe this is wrong, please provide arch manually in command.');
Expand Down
6 changes: 5 additions & 1 deletion nyalcf_cli/lib/commands/start.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,21 @@ class Start implements CommandImplement {
Logger.info('Started proxy: $proxyId');
} else {
Logger.error('You have no frpc installed yet!');
exit(0);
}
}

int n = 0;
ProcessSignal.sigint.watch().listen((signal) {
n++;
if (verbose) {
Logger.verbose('Caught ${++n} of 2');
Logger.verbose('Caught $n of 2');
}

Logger.info('Press again to close frpc and exit.');

Future.delayed(Duration(seconds: 10), () => n = 0);

if (n == 2) {
for (var process in ProcessManager.processList) {
process.process.kill();
Expand Down
28 changes: 14 additions & 14 deletions nyalcf_cli/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,18 @@ packages:
dependency: transitive
description:
name: meta
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
url: "https://pub.dev"
source: hosted
version: "1.15.0"
version: "1.16.0"
mime:
dependency: transitive
description:
name: mime
sha256: "801fd0b26f14a4a58ccb09d5892c3fbdeff209594300a542492cf13fba9d247a"
sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
url: "https://pub.dev"
source: hosted
version: "1.0.6"
version: "2.0.0"
node_preamble:
dependency: transitive
description:
Expand All @@ -252,7 +252,7 @@ packages:
path: "../nyalcf_core"
relative: true
source: path
version: "1.2.1"
version: "1.2.2"
nyalcf_env:
dependency: "direct main"
description:
Expand All @@ -266,7 +266,7 @@ packages:
path: "../nyalcf_inject"
relative: true
source: path
version: "1.2.1"
version: "1.2.2"
package_config:
dependency: transitive
description:
Expand Down Expand Up @@ -359,10 +359,10 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
version: "1.12.0"
stream_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -431,10 +431,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
url: "https://pub.dev"
source: hosted
version: "14.2.5"
version: "14.3.0"
watcher:
dependency: transitive
description:
Expand All @@ -447,10 +447,10 @@ packages:
dependency: transitive
description:
name: web
sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062
sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
url: "https://pub.dev"
source: hosted
version: "1.0.0"
version: "1.1.0"
web_socket:
dependency: transitive
description:
Expand Down Expand Up @@ -479,10 +479,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: "68d1e89a91ed61ad9c370f9f8b6effed9ae5e0ede22a270bdfa6daf79fc2290a"
sha256: "4d45dc9069dba4619dc0ebd93c7cec5e66d8482cb625a370ac806dcc8165f2ec"
url: "https://pub.dev"
source: hosted
version: "5.5.4"
version: "5.5.5"
win32_registry:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion nyalcf_cli/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: nyalcf
description: "[CLI]The next generation of LoCyanFrp launcher."
version: 0.0.3+1
version: 0.0.3+2
homepage: https://nyalcf.1l1.icu
publish_to: none
# repository: https://github.com/my_org/my_repo
Expand Down
16 changes: 1 addition & 15 deletions nyalcf_gui/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import 'package:nyalcf_core_extend/utils/theme_control.dart';
import 'package:nyalcf_core_extend/utils/universe.dart';
import 'package:nyalcf_env/nyalcf_env.dart';
import 'package:nyalcf_inject/nyalcf_inject.dart';
import 'package:nyalcf_ui/main_tray.dart';
import 'package:nyalcf_ui/main_window.dart';
import 'package:nyalcf_ui/views/auth/login.dart';
import 'package:nyalcf_ui/views/auth/register.dart';
Expand All @@ -33,7 +32,6 @@ import 'package:nyalcf_ui/views/panel/proxies.dart';
import 'package:nyalcf_ui/views/panel/proxies_configuration.dart';
import 'package:nyalcf_ui/views/setting/injector.dart';
import 'package:nyalcf_ui/views/tokenmode/panel.dart';
import 'package:tray_manager/tray_manager.dart';
import 'package:window_manager/window_manager.dart';

final _appLinks = AppLinks();
Expand Down Expand Up @@ -122,7 +120,7 @@ class App extends StatefulWidget {
State<App> createState() => _AppState();
}

class _AppState extends State<App> with WindowListener, TrayListener {
class _AppState extends State<App> with WindowListener {
/// 根组件
@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -155,7 +153,6 @@ class _AppState extends State<App> with WindowListener, TrayListener {
/// 组件初始化时操作
@override
void initState() {
trayManager.addListener(this);
windowManager.addListener(this);
super.initState();
_init();
Expand All @@ -171,21 +168,10 @@ class _AppState extends State<App> with WindowListener, TrayListener {
@override
void dispose() {
windowManager.removeListener(this);
trayManager.removeListener(this);
super.dispose();
}

// 窗口和托盘图标的事件处理
@override
onWindowClose() => MainWindow.onWindowClose();

@override
onTrayIconMouseDown() => MainTray.onTrayIconMouseDown();

@override
onTrayIconRightMouseDown() => MainTray.onTrayIconRightMouseDown();

@override
onTrayMenuItemClick(MenuItem menuItem) =>
MainTray.onTrayMenuItemClick(menuItem);
}
8 changes: 4 additions & 4 deletions nyalcf_gui/linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
#include <gtk/gtk_plugin.h>
#include <screen_retriever/screen_retriever_plugin.h>
#include <tray_manager/tray_manager_plugin.h>
#include <system_tray/system_tray_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
#include <window_manager/window_manager_plugin.h>

Expand All @@ -23,9 +23,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
g_autoptr(FlPluginRegistrar) tray_manager_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "TrayManagerPlugin");
tray_manager_plugin_register_with_registrar(tray_manager_registrar);
g_autoptr(FlPluginRegistrar) system_tray_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "SystemTrayPlugin");
system_tray_plugin_register_with_registrar(system_tray_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
Expand Down
2 changes: 1 addition & 1 deletion nyalcf_gui/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
bitsdojo_window_linux
gtk
screen_retriever
tray_manager
system_tray
url_launcher_linux
window_manager
)
Expand Down
4 changes: 2 additions & 2 deletions nyalcf_gui/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import package_info_plus
import path_provider_foundation
import screen_retriever
import shared_preferences_foundation
import tray_manager
import system_tray
import url_launcher_macos
import window_manager

Expand All @@ -22,7 +22,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin"))
SystemTrayPlugin.register(with: registry.registrar(forPlugin: "SystemTrayPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
// Package imports:
import 'package:get/get.dart';
import 'package:nyalcf_core/models/proxy_info_model.dart';
import 'package:nyalcf_core/models/response/response.dart';
import 'package:nyalcf_core/models/user_info_model.dart';
import 'package:nyalcf_core/network/dio/proxies/proxies.dart';
import 'package:nyalcf_core/storages/configurations/autostart_proxies_storage.dart';
import 'package:nyalcf_core/storages/stores/proxies_storage.dart';
import 'package:nyalcf_core/utils/logger.dart';
import 'package:nyalcf_inject_extend/nyalcf_inject_extend.dart';
import 'package:nyalcf_ui/controllers/proxies_controller.dart';

// Project imports:
import 'package:nyalcf_core_extend/storages/prefs/user_info_prefs.dart';
import 'package:nyalcf_core_extend/tasks/basic.dart';

class ProxiesGetter {
static void startUp() async {
class TaskUpdateProxiesList extends TaskBasic {
@override
void startUp({Function? callback}) async {
if (callback != null) this.callback = callback;
loading.value = true;
Logger.info('Auto updating proxies list...');
final UserInfoModel user = await UserInfoPrefs.getInfo();
Expand All @@ -22,6 +27,7 @@ class ProxiesGetter {
result as ProxiesResponse;
ProxiesStorage.clear();
ProxiesStorage.addAll(result.proxies);
_removeNonExistsAutostart(result.proxies);
try {
final ProxiesController pctr = Get.find();
pctr.load(user.user, user.token, request: true);
Expand All @@ -36,8 +42,16 @@ class ProxiesGetter {
}
loading.value = false;

Future.delayed(const Duration(minutes: 5), () {
startUp();
});
if (this.callback != null) this.callback!();
}

_removeNonExistsAutostart(List<ProxyInfoModel> proxies) async {
final aps = AutostartProxiesStorage();
final nowList = aps.getList();
for (ProxyInfoModel item in nowList) {
Logger.debug("${item.proxyName} not exists again, removing it from autostart.json");
if (!proxies.contains(item)) aps.removeFromList(item.id);
}
aps.save();
}
}
12 changes: 12 additions & 0 deletions nyalcf_gui/nyalcf_core_extend/lib/utils/task_scheduler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:nyalcf_env/nyalcf_env.dart';

// Project imports:
import 'package:nyalcf_core_extend/tasks/auto_sign.dart';
import 'package:nyalcf_core_extend/tasks/update_proxies_list.dart';
import 'package:nyalcf_core_extend/tasks/updater.dart';

class TaskScheduler {
Expand All @@ -12,6 +13,7 @@ class TaskScheduler {
static Future<void> start() async {
if (ENV_GUI_DISABLE_AUTO_UPDATE_CHECK ?? false) _taskUpdater();
_taskAutoSign();
_taskUpdateProxiesList();
}

static _taskUpdater() async {
Expand All @@ -31,4 +33,14 @@ class TaskScheduler {
);
}
}

static _taskUpdateProxiesList() async {
if (_lcs.getAutoSign()) {
TaskUpdateProxiesList().startUp(
callback: () => Future.delayed(const Duration(minutes: 15), () {
TaskUpdateProxiesList().startUp();
}),
);
}
}
}
Loading

0 comments on commit 2a017ad

Please sign in to comment.