mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 07:43:42 +08:00
https://github.com/StarCitizenToolBox/app/issues/1 增加一个工具站镜像的功能
This commit is contained in:
parent
6376c2d607
commit
309f5160b4
@ -17,8 +17,8 @@ import 'package:window_manager/window_manager.dart';
|
|||||||
import '../../base/ui.dart';
|
import '../../base/ui.dart';
|
||||||
|
|
||||||
class AppConf {
|
class AppConf {
|
||||||
static const String appVersion = "2.11.0 Beta";
|
static const String appVersion = "2.10.2 Beta";
|
||||||
static const int appVersionCode = 35;
|
static const int appVersionCode = 37;
|
||||||
static const String appVersionDate = "2024-01-07";
|
static const String appVersionDate = "2024-01-07";
|
||||||
|
|
||||||
static const gameChannels = ["LIVE", "PTU", "EPTU"];
|
static const gameChannels = ["LIVE", "PTU", "EPTU"];
|
||||||
|
@ -9,14 +9,15 @@
|
|||||||
|
|
||||||
class AppVersionData {
|
class AppVersionData {
|
||||||
AppVersionData({
|
AppVersionData({
|
||||||
this.lastVersion,
|
this.lastVersion,
|
||||||
this.lastVersionCode,
|
this.lastVersionCode,
|
||||||
this.minVersionCode,
|
this.minVersionCode,
|
||||||
this.mSELastVersion,
|
this.mSELastVersion,
|
||||||
this.mSELastVersionCode,
|
this.mSELastVersionCode,
|
||||||
this.mSEMinVersionCode,
|
this.mSEMinVersionCode,
|
||||||
this.p4kDownloadUrl,
|
this.p4kDownloadUrl,
|
||||||
this.activityColors,});
|
this.activityColors,
|
||||||
|
});
|
||||||
|
|
||||||
AppVersionData.fromJson(dynamic json) {
|
AppVersionData.fromJson(dynamic json) {
|
||||||
lastVersion = json['lastVersion'];
|
lastVersion = json['lastVersion'];
|
||||||
@ -26,8 +27,12 @@ class AppVersionData {
|
|||||||
mSELastVersionCode = json['MSE_lastVersionCode'];
|
mSELastVersionCode = json['MSE_lastVersionCode'];
|
||||||
mSEMinVersionCode = json['MSE_minVersionCode'];
|
mSEMinVersionCode = json['MSE_minVersionCode'];
|
||||||
p4kDownloadUrl = json['p4kDownloadUrl'];
|
p4kDownloadUrl = json['p4kDownloadUrl'];
|
||||||
activityColors = json['activityColors'] != null ? ActivityColors.fromJson(json['activityColors']) : null;
|
activityColors = json['activityColors'] != null
|
||||||
|
? ActivityColors.fromJson(json['activityColors'])
|
||||||
|
: null;
|
||||||
|
webMirrors = json["web_mirrors"];
|
||||||
}
|
}
|
||||||
|
|
||||||
String? lastVersion;
|
String? lastVersion;
|
||||||
num? lastVersionCode;
|
num? lastVersionCode;
|
||||||
num? minVersionCode;
|
num? minVersionCode;
|
||||||
@ -36,6 +41,7 @@ class AppVersionData {
|
|||||||
num? mSEMinVersionCode;
|
num? mSEMinVersionCode;
|
||||||
String? p4kDownloadUrl;
|
String? p4kDownloadUrl;
|
||||||
ActivityColors? activityColors;
|
ActivityColors? activityColors;
|
||||||
|
Map? webMirrors;
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final map = <String, dynamic>{};
|
final map = <String, dynamic>{};
|
||||||
@ -49,9 +55,9 @@ class AppVersionData {
|
|||||||
if (activityColors != null) {
|
if (activityColors != null) {
|
||||||
map['activityColors'] = activityColors?.toJson();
|
map['activityColors'] = activityColors?.toJson();
|
||||||
}
|
}
|
||||||
|
map["web_mirrors"] = webMirrors;
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// enable : true
|
/// enable : true
|
||||||
@ -63,12 +69,13 @@ class AppVersionData {
|
|||||||
|
|
||||||
class ActivityColors {
|
class ActivityColors {
|
||||||
ActivityColors({
|
ActivityColors({
|
||||||
this.enable,
|
this.enable,
|
||||||
this.startTime,
|
this.startTime,
|
||||||
this.endTime,
|
this.endTime,
|
||||||
this.background,
|
this.background,
|
||||||
this.menu,
|
this.menu,
|
||||||
this.mica,});
|
this.mica,
|
||||||
|
});
|
||||||
|
|
||||||
ActivityColors.fromJson(dynamic json) {
|
ActivityColors.fromJson(dynamic json) {
|
||||||
enable = json['enable'];
|
enable = json['enable'];
|
||||||
@ -78,6 +85,7 @@ class ActivityColors {
|
|||||||
menu = json['menu'];
|
menu = json['menu'];
|
||||||
mica = json['mica'];
|
mica = json['mica'];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool? enable;
|
bool? enable;
|
||||||
int? startTime;
|
int? startTime;
|
||||||
int? endTime;
|
int? endTime;
|
||||||
@ -95,5 +103,4 @@ class ActivityColors {
|
|||||||
map['mica'] = mica;
|
map['mica'] = mica;
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -223,7 +223,7 @@ class HomeUI extends BaseUI<HomeUIModel> {
|
|||||||
),
|
),
|
||||||
name: "UEX 汉化",
|
name: "UEX 汉化",
|
||||||
webTitle: "UEX 汉化",
|
webTitle: "UEX 汉化",
|
||||||
webURL: "https://uexcorp.space",
|
webURL: "https://uexcorp.space/",
|
||||||
info: "采矿、精炼、贸易计算器、价格、船信息",
|
info: "采矿、精炼、贸易计算器、价格、船信息",
|
||||||
useLocalization: true,
|
useLocalization: true,
|
||||||
width: width,
|
width: width,
|
||||||
|
@ -39,6 +39,8 @@ class WebViewModel {
|
|||||||
|
|
||||||
bool enableCapture = false;
|
bool enableCapture = false;
|
||||||
|
|
||||||
|
bool isEnableToolSiteMirrors = false;
|
||||||
|
|
||||||
Map<String, String>? _curReplaceWords;
|
Map<String, String>? _curReplaceWords;
|
||||||
|
|
||||||
Map<String, String>? get curReplaceWords => _curReplaceWords;
|
Map<String, String>? get curReplaceWords => _curReplaceWords;
|
||||||
@ -52,6 +54,9 @@ class WebViewModel {
|
|||||||
|
|
||||||
initWebView({String title = ""}) async {
|
initWebView({String title = ""}) async {
|
||||||
try {
|
try {
|
||||||
|
final userBox = await Hive.openBox("app_conf");
|
||||||
|
isEnableToolSiteMirrors =
|
||||||
|
userBox.get("isEnableToolSiteMirrors", defaultValue: false);
|
||||||
webview = await WebviewWindow.create(
|
webview = await WebviewWindow.create(
|
||||||
configuration: CreateConfiguration(
|
configuration: CreateConfiguration(
|
||||||
windowWidth: loginMode ? 960 : 1920,
|
windowWidth: loginMode ? 960 : 1920,
|
||||||
@ -62,9 +67,8 @@ class WebViewModel {
|
|||||||
// webview.openDevToolsWindow();
|
// webview.openDevToolsWindow();
|
||||||
webview.isNavigating.addListener(() async {
|
webview.isNavigating.addListener(() async {
|
||||||
if (!webview.isNavigating.value && localizationResource.isNotEmpty) {
|
if (!webview.isNavigating.value && localizationResource.isNotEmpty) {
|
||||||
final uri = Uri.parse(url);
|
dPrint("webview Navigating url === $url");
|
||||||
dPrint("webview Navigating uri === $uri");
|
if (url.startsWith("https://robertsspaceindustries.com")) {
|
||||||
if (uri.host.contains("robertsspaceindustries.com")) {
|
|
||||||
// SC 官网
|
// SC 官网
|
||||||
dPrint("load script");
|
dPrint("load script");
|
||||||
await Future.delayed(const Duration(milliseconds: 100));
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
@ -129,7 +133,8 @@ class WebViewModel {
|
|||||||
webview.evaluateJavaScript(
|
webview.evaluateJavaScript(
|
||||||
"getRSILauncherToken(\"$loginChannel\");");
|
"getRSILauncherToken(\"$loginChannel\");");
|
||||||
}
|
}
|
||||||
} else if (uri.host.contains("www.erkul.games")) {
|
} else if (url
|
||||||
|
.startsWith(await _handleMirrorsUrl("https://www.erkul.games"))) {
|
||||||
dPrint("load script");
|
dPrint("load script");
|
||||||
await Future.delayed(const Duration(milliseconds: 100));
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
await webview.evaluateJavaScript(localizationScript);
|
await webview.evaluateJavaScript(localizationScript);
|
||||||
@ -137,7 +142,8 @@ class WebViewModel {
|
|||||||
final replaceWords = _getLocalizationResource("DPS");
|
final replaceWords = _getLocalizationResource("DPS");
|
||||||
await webview.evaluateJavaScript(
|
await webview.evaluateJavaScript(
|
||||||
"WebLocalizationUpdateReplaceWords(${json.encode(replaceWords)},$enableCapture)");
|
"WebLocalizationUpdateReplaceWords(${json.encode(replaceWords)},$enableCapture)");
|
||||||
} else if (uri.host.contains("uexcorp.space")) {
|
} else if (url
|
||||||
|
.startsWith(await _handleMirrorsUrl("https://uexcorp.space"))) {
|
||||||
dPrint("load script");
|
dPrint("load script");
|
||||||
await Future.delayed(const Duration(milliseconds: 100));
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
await webview.evaluateJavaScript(localizationScript);
|
await webview.evaluateJavaScript(localizationScript);
|
||||||
@ -173,8 +179,20 @@ class WebViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> _handleMirrorsUrl(String url) async {
|
||||||
|
var finalUrl = url;
|
||||||
|
if (isEnableToolSiteMirrors) {
|
||||||
|
for (var kv in AppConf.networkVersionData!.webMirrors!.entries) {
|
||||||
|
if (url.startsWith(kv.key)) {
|
||||||
|
finalUrl = url.replaceFirst(kv.key, kv.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return finalUrl;
|
||||||
|
}
|
||||||
|
|
||||||
launch(String url) async {
|
launch(String url) async {
|
||||||
webview.launch(url);
|
webview.launch(await _handleMirrorsUrl(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
initLocalization(AppWebLocalizationVersionsData v) async {
|
initLocalization(AppWebLocalizationVersionsData v) async {
|
||||||
|
@ -51,13 +51,26 @@ class SettingUI extends BaseUI<SettingUIModel> {
|
|||||||
subTitle:
|
subTitle:
|
||||||
"缓存大小 ${(model.locationCacheSize / 1024 / 1024).toStringAsFixed(2)}MB,清理盒子下载的汉化文件缓存,不会影响已安装的汉化",
|
"缓存大小 ${(model.locationCacheSize / 1024 / 1024).toStringAsFixed(2)}MB,清理盒子下载的汉化文件缓存,不会影响已安装的汉化",
|
||||||
onTap: model.cleanLocationCache),
|
onTap: model.cleanLocationCache),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
makeSettingsItem(
|
||||||
|
const Icon(FluentIcons.internet_sharing, size: 20), "工具站访问加速",
|
||||||
|
onTap: () =>
|
||||||
|
model.onChangeToolSiteMirror(!model.isEnableToolSiteMirrors),
|
||||||
|
subTitle:
|
||||||
|
"使用镜像服务器加速访问 DPS UEX 等工具网站,若访问异常请关闭该功能。 为保护账户安全,任何情况下都不会加速RSI官网。",
|
||||||
|
onSwitch: model.onChangeToolSiteMirror,
|
||||||
|
switchStatus: model.isEnableToolSiteMirrors),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget makeSettingsItem(Widget icon, String title,
|
Widget makeSettingsItem(Widget icon, String title,
|
||||||
{String? subTitle, VoidCallback? onTap, VoidCallback? onDel}) {
|
{String? subTitle,
|
||||||
|
VoidCallback? onTap,
|
||||||
|
VoidCallback? onDel,
|
||||||
|
void Function(bool? b)? onSwitch,
|
||||||
|
bool switchStatus = false}) {
|
||||||
return Button(
|
return Button(
|
||||||
onPressed: onTap,
|
onPressed: onTap,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@ -94,8 +107,11 @@ class SettingUI extends BaseUI<SettingUIModel> {
|
|||||||
padding: EdgeInsets.all(6),
|
padding: EdgeInsets.all(6),
|
||||||
child: Icon(FluentIcons.delete),
|
child: Icon(FluentIcons.delete),
|
||||||
)),
|
)),
|
||||||
const SizedBox(width: 12),
|
|
||||||
],
|
],
|
||||||
|
if (onSwitch != null) ...[
|
||||||
|
ToggleSwitch(checked: switchStatus, onChanged: onSwitch),
|
||||||
|
],
|
||||||
|
const SizedBox(width: 12),
|
||||||
const Icon(FluentIcons.chevron_right),
|
const Icon(FluentIcons.chevron_right),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -15,6 +15,7 @@ class SettingUIModel extends BaseUIModel {
|
|||||||
String autoLoginEmail = "-";
|
String autoLoginEmail = "-";
|
||||||
bool isEnableAutoLogin = false;
|
bool isEnableAutoLogin = false;
|
||||||
bool isEnableAutoLoginPwd = false;
|
bool isEnableAutoLoginPwd = false;
|
||||||
|
bool isEnableToolSiteMirrors = false;
|
||||||
String inputGameLaunchECore = "0";
|
String inputGameLaunchECore = "0";
|
||||||
|
|
||||||
String? customLauncherPath;
|
String? customLauncherPath;
|
||||||
@ -34,6 +35,7 @@ class SettingUIModel extends BaseUIModel {
|
|||||||
}
|
}
|
||||||
_loadCustomPath();
|
_loadCustomPath();
|
||||||
_loadLocationCacheSize();
|
_loadLocationCacheSize();
|
||||||
|
_loadToolSiteMirrorState();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onResetAutoLogin() async {
|
Future<void> onResetAutoLogin() async {
|
||||||
@ -174,4 +176,18 @@ class SettingUIModel extends BaseUIModel {
|
|||||||
await Process.run(SystemHelper.powershellPath, [script]);
|
await Process.run(SystemHelper.powershellPath, [script]);
|
||||||
showToast(context!, "创建完毕,请返回桌面查看");
|
showToast(context!, "创建完毕,请返回桌面查看");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_loadToolSiteMirrorState() async {
|
||||||
|
final userBox = await Hive.openBox("app_conf");
|
||||||
|
isEnableToolSiteMirrors =
|
||||||
|
userBox.get("isEnableToolSiteMirrors", defaultValue: false);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void onChangeToolSiteMirror(bool? b) async {
|
||||||
|
final userBox = await Hive.openBox("app_conf");
|
||||||
|
isEnableToolSiteMirrors = b == true;
|
||||||
|
await userBox.put("isEnableToolSiteMirrors", isEnableToolSiteMirrors);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user