Skip to content

Commit

Permalink
Update to 0.1.2 (#44)
Browse files Browse the repository at this point in the history
* Update README.md (#30)

Co-authored-by: 夏沫花火zzz <[email protected]>

* Add license scan report and status

Signed off by: fossabot <[email protected]>

* Update README.md

* Try build on arm64 linux

* Update build

* 提取主题到单独类中 #38

* Rewrite packager

* Rewrite packager

* Fix

* Fix again #35

* Fix again #35

* Fix checkout submodules #35

* Add exclude analyze_option

* Update packager

* Update packager

* Remove cupertino_icons

* 放弃治疗(

* 镜像源 & 解压弹窗修改 & GitHub Actions ARM64支持(待测试)  (#35)

* 添加镜像源

* 合并GitHub源

* 修点注释

* 提示语

* 镜像源修改、弹窗修改

* 镜像源修改

* Build | GitHub Actions ARM64支持

* Update build.yml

* Create main.yml

* 重写的时候把Windows忘了(

* Update build.yml

* Update build.yml

* Fix build script

* Fix \n

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Text  aarch64 label

* Update build.yml

* Update build.yml

---------

Co-authored-by: 夏沫花火zzz <[email protected]>
Co-authored-by: 落雪无痕LxHTT <[email protected]>
Co-authored-by: 114514-homo-lab <[email protected]>

* Update actions workflow

* Remove needs in build.yml

* Update build.yml

* Update build.yml

* Unkown bug?

* Update build.yml

* Update build.yml

* Update build.yml

* Update tools

* none

* Update description and README.md

* [ci skip]Update version

* Add mirror for frpc download

* 添加未安装Frpc提示,优化一个判定

---------

Co-authored-by: 楠ちゃん <[email protected]>
Co-authored-by: fossabot <[email protected]>
Co-authored-by: YanMo <[email protected]>
Co-authored-by: 落雪无痕LxHTT <[email protected]>
Co-authored-by: 114514-homo-lab <[email protected]>
  • Loading branch information
6 people authored Jan 15, 2024
1 parent da8cea0 commit 6f7a716
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 56 deletions.
6 changes: 5 additions & 1 deletion lib/controller/dsettingfrpc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class DSettingFrpcController extends GetxController {
var frpc_download_show = <Widget>[].obs;
var _frpc_downloaded_versions = [];
dynamic frpc_download_cancel = false;
var frpc_download_use_mirror = false.obs;

var frpc_version = ''.obs;

Expand All @@ -37,6 +38,9 @@ class DSettingFrpcController extends GetxController {

load() async {
cpu_arch.value = await CPUArch.getCPUArchitecture();
await FrpcSettingPrefs.refresh();
final frpcinfo = await FrpcSettingPrefs.getFrpcInfo();
frpc_download_use_mirror.value = frpcinfo.github_mirror;

frpc_version.value = await FrpcManagerStorage.usingVersion;
_load_tip();
Expand All @@ -45,7 +49,7 @@ class DSettingFrpcController extends GetxController {

void _load_tip() async {
_frpc_downloaded_versions = await FrpcManagerStorage.downloadedVersions;
if (_frpc_downloaded_versions.length == 0) {
if (_frpc_downloaded_versions.isEmpty) {
frpc_download_tip.value = FrpcDownloadTip.tip(context: context);
} else {
frpc_download_tip.value =
Expand Down
4 changes: 2 additions & 2 deletions lib/controller/dsettinglauncher.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:nyalcf/io/settingStorage.dart';
import 'package:nyalcf/io/launcherSettingStorage.dart';
import 'package:nyalcf/prefs/LauncherSettingPrefs.dart';
import 'package:package_info_plus/package_info_plus.dart';

Expand Down Expand Up @@ -55,7 +55,7 @@ class DSettingLauncherController extends GetxController {
void switchDarkTheme(value) async {
LauncherSettingPrefs.setThemeDark(value);
theme_dark.value = value;
SettingStorage.save(await LauncherSettingPrefs.getInfo());
LauncherSettingStorage.save(await LauncherSettingPrefs.getInfo());
loadx();
// ThemeControl.switchDarkTheme(value);
}
Expand Down
19 changes: 15 additions & 4 deletions lib/controller/proxies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:nyalcf/dio/proxies/configuration.dart';
import 'package:nyalcf/dio/proxies/get.dart';
import 'package:nyalcf/io/frpcConfigurationStorage.dart';
import 'package:nyalcf/model/ProxyInfo.dart';
import 'package:nyalcf/prefs/FrpcSettingPrefs.dart';
import 'package:nyalcf/ui/model/FrpcConfigurationEditorDialog.dart';
import 'package:nyalcf/util/frpc/ProcessManager.dart';

Expand Down Expand Up @@ -101,10 +102,20 @@ class ProxiesController extends GetxController {
IconButton(
icon: Icon(Icons.play_circle),
tooltip: '启动',
onPressed: () async => {
FrpcProcessManager()
.nwprcs(frp_token: c.frp_token.value, proxy_id: element.id)
},
onPressed: () async {
final frpcinfo = await FrpcSettingPrefs.getFrpcInfo();
if (frpcinfo.frpc_downloaded_versions.isNotEmpty) {
FrpcProcessManager()
.nwprcs(frp_token: c.frp_token.value, proxy_id: element.id);
} else {
Get.snackbar(
'笨..笨蛋!',
'你还没有安装Frpc!请先到 设置->FRPC 安装Frpc才能启动喵!',
snackPosition: SnackPosition.BOTTOM,
animationDuration: Duration(milliseconds: 300),
);
}
},
),
IconButton(
icon: Icon(Icons.edit),
Expand Down
4 changes: 1 addition & 3 deletions lib/dio/basicConfig.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ class basicConfig {
static final frpc_config_url = 'https://www.locyanfrp.cn/api';
static final github_api_url = 'https://api.github.com';
static final github_main_url = 'https://github.com';
static final github_mirrors_url = [
'https://mirror.ghproxy.com/github.com'
];
static final github_mirrors_url = 'https://proxy-gh.1l1.icu/https://github.com';
// static final frpc_release_repo = 'LoCyan-Team/LoCyanFrpPureApp';
}
11 changes: 8 additions & 3 deletions lib/dio/frpc/download.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@ class FrpcDownloadDio {
required String version,
required ProgressCallback progressCallback,
required CancelToken cancelToken,
String proxy = '',
required bool useMirror,
}) async {
print('Start download: ${platform} | ${version} | ${arch}');
try {
final download_basic_url;
if (useMirror)
download_basic_url = basicConfig.github_mirrors_url;
else
download_basic_url = basicConfig.github_main_url;
if (platform == 'windows') {
print('Windows, download zip');
return await dio.download(
'${proxy + basicConfig.github_main_url}/LoCyan-Team/LoCyanFrpPureApp/releases/download/v${version}/frp_LoCyanFrp-${version}_${platform}_${arch}.zip',
'${download_basic_url}/LoCyan-Team/LoCyanFrpPureApp/releases/download/v${version}/frp_LoCyanFrp-${version}_${platform}_${arch}.zip',
'${await FileIO.cache_path}/frpc.zip',
cancelToken: cancelToken,
onReceiveProgress: progressCallback,
);
} else {
print('Download tar.gz');
return await dio.download(
'${proxy + basicConfig.github_main_url}/LoCyan-Team/LoCyanFrpPureApp/releases/download/v${version}/frp_LoCyanFrp-${version}_${platform}_${arch}.tar.gz',
'${download_basic_url}/LoCyan-Team/LoCyanFrpPureApp/releases/download/v${version}/frp_LoCyanFrp-${version}_${platform}_${arch}.tar.gz',
'${await FileIO.cache_path}/frpc.tar.gz',
cancelToken: cancelToken,
onReceiveProgress: progressCallback,
Expand Down
8 changes: 4 additions & 4 deletions lib/io/frpcManagerStorage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FrpcManagerStorage {
Map<String, dynamic> json = {
'settings': {
'frpc_version': '',
'github_proxy': <String>[],
'github_mirror': true,
},
'lists': {
'frpc_downloaded_versions': <String>[],
Expand Down Expand Up @@ -81,9 +81,9 @@ class FrpcManagerStorage {
}

/// GitHub代理
static Future<String> get proxyUrl async {
final url = (await _info).github_proxy;
return url;
static Future<bool> get useGithubMirror async {
final mirror = (await _info).github_mirror;
return mirror;
}

/// 获取已安装版本列表
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'dart:convert';
import 'dart:io';

import 'package:nyalcf/model/Setting.dart';
import 'package:nyalcf/model/LauncherSetting.dart';
import 'package:nyalcf/util/FileIO.dart';

class SettingStorage {
class LauncherSettingStorage {
static final _path = FileIO.support_path;

static void init() {
Expand Down Expand Up @@ -32,18 +32,18 @@ class SettingStorage {
}

/// 保存数据
static Future<void> save(Setting data) async {
static Future<void> save(LauncherSetting data) async {
final String write_data = jsonEncode(data);
await File('${await _path}/settings.json')
.writeAsString(write_data, encoding: utf8);
}

/// 读取数据
static Future<Setting?> read() async {
static Future<LauncherSetting?> read() async {
try {
final String result =
File('${await _path}/settings.json').readAsStringSync(encoding: utf8);
return Setting.fromJson(jsonDecode(result));
return LauncherSetting.fromJson(jsonDecode(result));
} catch (e) {
return null;
}
Expand Down
12 changes: 6 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:nyalcf/controller/user.dart';
import 'package:nyalcf/io/frpcManagerStorage.dart';
import 'package:nyalcf/io/settingStorage.dart';
import 'package:nyalcf/model/Setting.dart';
import 'package:nyalcf/io/launcherSettingStorage.dart';
import 'package:nyalcf/model/LauncherSetting.dart';
import 'package:nyalcf/prefs/LauncherSettingPrefs.dart';
import 'package:nyalcf/ui/auth/login.dart';
import 'package:nyalcf/ui/auth/register.dart';
Expand All @@ -17,13 +17,13 @@ import 'package:nyalcf/ui/panel/proxies.dart';
import 'package:nyalcf/ui/setting/injector.dart';
import 'package:nyalcf/util/ThemeControl.dart';

Setting? _settings = null;
LauncherSetting? _settings = null;

void main() async {
/// 初始化配置文件
SettingStorage.init();
LauncherSettingStorage.init();
FrpcManagerStorage.init();
_settings = await SettingStorage.read();
_settings = await LauncherSettingStorage.read();

runApp(const App());

Expand All @@ -47,7 +47,7 @@ class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
LauncherSettingPrefs.setInfo(_settings ??
Setting(
LauncherSetting(
theme_auto: true,
theme_dark: false,
theme_light_seed_enable: false,
Expand Down
5 changes: 3 additions & 2 deletions lib/model/FrpcConfig.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ class FrpcConfig {
return settings['frpc_version'];
}

String get github_proxy {
return settings['github_proxy'];
bool get github_mirror {
print('Mir: ${settings['github_mirror']}');
return settings['github_mirror'];
}

List<String> get frpc_downloaded_versions {
Expand Down
6 changes: 3 additions & 3 deletions lib/model/Setting.dart → lib/model/LauncherSetting.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Setting {
Setting({
class LauncherSetting {
LauncherSetting({
required this.theme_auto,
required this.theme_dark,
required this.theme_light_seed_enable,
Expand All @@ -26,7 +26,7 @@ class Setting {
},
};

Setting.fromJson(Map<String, dynamic> json)
LauncherSetting.fromJson(Map<String, dynamic> json)
: theme_auto = json['theme']['auto'],
theme_dark = json['theme']['dark']['enable'],
theme_light_seed = json['theme']['light']['seed']['value'],
Expand Down
22 changes: 19 additions & 3 deletions lib/prefs/FrpcSettingPrefs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FrpcSettingPrefs {
prefs.setString('frpc@setting@frpc_version', frpcinfo.frpc_version);
prefs.setStringList('frpc@list@frpc_downloaded_versions',
frpcinfo.frpc_downloaded_versions);
prefs.setString('frpc@setting@github_proxy', frpcinfo.github_proxy);
prefs.setString('frpc@setting@github_mirror', frpcinfo.github_mirror.toString());
prefs.setStringList('frpc@list@github_proxies', frpcinfo.github_proxies);
}

Expand All @@ -20,18 +20,23 @@ class FrpcSettingPrefs {
prefs.setStringList('frpc@list@frpc_downloaded_versions', newlist);
}

static Future<void> setDownloadUseMirror(bool value) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('frpc@setting@github_mirror', value.toString());
}

static Future<FrpcConfig> getFrpcInfo() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
final s_frpc_version = prefs.getString('frpc@setting@frpc_version') ?? '';
final l_frpc_downloaded_versions =
prefs.getStringList('frpc@list@frpc_downloaded_versions') ?? [];
final s_github_proxy = prefs.getString('frpc@setting@github_proxy') ?? '';
final s_github_mirror = prefs.getString('frpc@setting@github_mirror') ?? 'false';
final l_github_proxies =
prefs.getStringList('frpc@list@github_proxies') ?? [];

final Map<String, dynamic> settings = Map();
settings['frpc_version'] = s_frpc_version;
settings['github_proxy'] = s_github_proxy;
settings['github_mirror'] = s_github_mirror.toBoolean();

final Map<String, List<String>> lists = Map();
lists['frpc_downloaded_versions'] = l_frpc_downloaded_versions;
Expand All @@ -45,3 +50,14 @@ class FrpcSettingPrefs {
if (res != null) setFrpcInfo(res);
}
}

extension on String {
bool toBoolean() {
print(this);
return (this.toLowerCase() == 'true' || this.toLowerCase() == '1')
? true
: (this.toLowerCase() == 'false' || this.toLowerCase() == '0'
? false
: throw UnsupportedError);
}
}
12 changes: 6 additions & 6 deletions lib/prefs/LauncherSettingPrefs.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:nyalcf/io/settingStorage.dart';
import 'package:nyalcf/model/Setting.dart';
import 'package:nyalcf/io/launcherSettingStorage.dart';
import 'package:nyalcf/model/LauncherSetting.dart';
import 'package:shared_preferences/shared_preferences.dart';

class LauncherSettingPrefs {
static Future<void> setInfo(Setting data) async {
static Future<void> setInfo(LauncherSetting data) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('setting@theme@auto', data.theme_auto.toString());
prefs.setString('setting@theme@dark@enable', data.theme_dark.toString());
Expand All @@ -12,7 +12,7 @@ class LauncherSettingPrefs {
prefs.setString('setting@theme@light@seed@value', data.theme_light_seed);
}

static Future<Setting> getInfo() async {
static Future<LauncherSetting> getInfo() async {
SharedPreferences prefs = await SharedPreferences.getInstance();

final theme_auto = prefs.getString('setting@theme@auto') ?? 'true';
Expand All @@ -21,7 +21,7 @@ class LauncherSettingPrefs {
prefs.getString('setting@theme@light@seed@enable') ?? 'false';
final theme_light_seed =
prefs.getString('setting@theme@light@seed@value') ?? '';
return Setting(
return LauncherSetting(
theme_auto: theme_auto.toBoolean(),
theme_dark: theme_dark.toBoolean(),
theme_light_seed: theme_light_seed,
Expand All @@ -30,7 +30,7 @@ class LauncherSettingPrefs {
}

static Future<void> refresh() async {
final res = await SettingStorage.read();
final res = await LauncherSettingStorage.read();
if (res != null) setInfo(res);
}

Expand Down
20 changes: 13 additions & 7 deletions lib/ui/model/FrpcDownloadDialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:nyalcf/controller/dsettingfrpc.dart';
import 'package:nyalcf/dio/frpc/download.dart';
import 'package:nyalcf/prefs/FrpcSettingPrefs.dart';

class FrpcDownloadDialogX {
FrpcDownloadDialogX({required this.context});
Expand Down Expand Up @@ -31,15 +32,17 @@ class FrpcDownloadDialogX {
onPressed: () async {
/// 刷新UI,下载frpc
ds_c.refreshDownloadShow();

/// 开始下载
Get.dialog(_downloading(), barrierDismissible: false);
final res = await FrpcDownloadDio().download(
arch: ds_c.arch[ds_c.frpc_download_arch.value]['arch'],
platform: ds_c.platform,
version: '0.51.3',
progressCallback: ds_c.downloadFrpcCallback,
cancelToken: ds_c.downloadCancelToken,
);
arch: ds_c.arch[ds_c.frpc_download_arch.value]['arch'],
platform: ds_c.platform,
version: '0.51.3',
progressCallback: ds_c.downloadFrpcCallback,
cancelToken: ds_c.downloadCancelToken,
useMirror:
(await FrpcSettingPrefs.getFrpcInfo()).github_mirror);
ds_c.frpc_download_cancel = res;
ds_c.refreshDownloadShow();
},
Expand Down Expand Up @@ -83,7 +86,10 @@ class FrpcDownloadDialogX {
title: const Column(
children: [
Text('正在解压...'),
Text('这可能需要几分钟时间,稍安勿躁喵~'),
Text(
'这可能需要几分钟时间,稍安勿躁喵~',
style: TextStyle(fontSize: 15.0),
),
],
),
children: <Widget>[
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/panel/proxies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:nyalcf/controller/proxies.dart';
import 'package:nyalcf/controller/user.dart';
import 'package:nyalcf/prefs/FrpcSettingPrefs.dart';
import 'package:nyalcf/ui/model/AccountDialog.dart';
import 'package:nyalcf/ui/model/AppbarActions.dart';
import 'package:nyalcf/ui/model/Drawer.dart';
Expand All @@ -17,6 +18,7 @@ class PanelProxies extends StatelessWidget {
Widget build(BuildContext context) {
final p_c = Get.put(ProxiesController(context: context));

FrpcSettingPrefs.refresh();
p_c.load(c.user, c.token);

return Scaffold(
Expand Down
Loading

0 comments on commit 6f7a716

Please sign in to comment.