From 308480095bf9d75961ef791860d4f94adc4e9f6e Mon Sep 17 00:00:00 2001 From: xkeyC <3334969096@qq.com> Date: Wed, 4 Sep 2024 19:02:31 +0800 Subject: [PATCH] feat: Proxy Source --- lib/api/analytics.dart | 28 ++++---- lib/common/conf/url_conf.dart | 8 +-- lib/generated/intl/messages_en.dart | 4 +- lib/generated/intl/messages_zh_CN.dart | 2 +- lib/generated/intl/messages_zh_TW.dart | 2 +- lib/generated/l10n.dart | 4 +- lib/l10n/intl_en.arb | 2 +- lib/l10n/intl_zh_CN.arb | 2 +- lib/l10n/intl_zh_TW.arb | 2 +- lib/ui/home/home_ui.dart | 69 ++++++++++++++++++ lib/ui/home/home_ui_model.dart | 7 +- lib/ui/index_ui.dart | 99 +++++++++++++------------- 12 files changed, 152 insertions(+), 77 deletions(-) diff --git a/lib/api/analytics.dart b/lib/api/analytics.dart index f6be2d1..0444d29 100644 --- a/lib/api/analytics.dart +++ b/lib/api/analytics.dart @@ -1,25 +1,25 @@ import 'dart:convert'; -import 'package:flutter/foundation.dart'; import 'package:starcitizen_doctor/common/conf/url_conf.dart'; import 'package:starcitizen_doctor/common/io/rs_http.dart'; import 'package:starcitizen_doctor/common/utils/log.dart'; class AnalyticsApi { static touch(String key) async { - if (kDebugMode || kProfileMode) { - dPrint("AnalyticsApi.touch === $key skip"); - return; - } - dPrint("AnalyticsApi.touch === $key start"); - try { - final r = await RSHttp.postData( - "${URLConf.analyticsApiHome}/analytics/$key", - data: null); - dPrint("AnalyticsApi.touch === $key over statusCode == ${r.statusCode}"); - } catch (e) { - dPrint("AnalyticsApi.touch === $key Error:$e"); - } + return; + // if (kDebugMode || kProfileMode) { + // dPrint("AnalyticsApi.touch === $key skip"); + // return; + // } + // dPrint("AnalyticsApi.touch === $key start"); + // try { + // final r = await RSHttp.postData( + // "${URLConf.analyticsApiHome}/analytics/$key", + // data: null); + // dPrint("AnalyticsApi.touch === $key over statusCode == ${r.statusCode}"); + // } catch (e) { + // dPrint("AnalyticsApi.touch === $key Error:$e"); + // } } static Future> getAnalyticsData() async { diff --git a/lib/common/conf/url_conf.dart b/lib/common/conf/url_conf.dart index ba3ae27..f90030a 100644 --- a/lib/common/conf/url_conf.dart +++ b/lib/common/conf/url_conf.dart @@ -4,9 +4,10 @@ import 'package:starcitizen_doctor/common/utils/log.dart'; class URLConf { /// HOME API - static String gitApiHome = "https://git.scbox.xkeyc.cn"; - static String rssApiHome = "https://rss.scbox.xkeyc.cn"; - static const String analyticsApiHome = "https://scbox.org"; + static String gitApiHome = "https://web-proxy.scbox.xkeyc.cn/git"; + static String rssApiHome = "https://web-proxy.scbox.xkeyc.cn/rss"; + static const String analyticsApiHome = + "https://web-proxy.scbox.xkeyc.cn/analytics/analytics"; static bool isUrlCheckPass = false; @@ -69,5 +70,4 @@ class URLConf { } } } - } diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 267c03a..0d39524 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -673,8 +673,8 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Launching game for you ..."), "home_login_title_welcome_back": MessageLookupByLibrary.simpleMessage("Welcome back!"), - "home_not_installed_or_failed": MessageLookupByLibrary.simpleMessage( - "Unpacking or installation failed"), + "home_not_installed_or_failed": + MessageLookupByLibrary.simpleMessage("Your computer"), "home_title_app_name": MessageLookupByLibrary.simpleMessage("SCToolBox"), "home_title_logging_in": diff --git a/lib/generated/intl/messages_zh_CN.dart b/lib/generated/intl/messages_zh_CN.dart index a7da628..a22d669 100644 --- a/lib/generated/intl/messages_zh_CN.dart +++ b/lib/generated/intl/messages_zh_CN.dart @@ -607,7 +607,7 @@ class MessageLookup extends MessageLookupByLibrary { "home_login_title_welcome_back": MessageLookupByLibrary.simpleMessage("欢迎回来!"), "home_not_installed_or_failed": - MessageLookupByLibrary.simpleMessage("未安装 或 安装失败"), + MessageLookupByLibrary.simpleMessage("您的电脑"), "home_title_app_name": MessageLookupByLibrary.simpleMessage("SC汉化盒子"), "home_title_logging_in": MessageLookupByLibrary.simpleMessage("登录中..."), "lobby_invitation_to_participate": diff --git a/lib/generated/intl/messages_zh_TW.dart b/lib/generated/intl/messages_zh_TW.dart index b9d10c4..1a702d5 100644 --- a/lib/generated/intl/messages_zh_TW.dart +++ b/lib/generated/intl/messages_zh_TW.dart @@ -608,7 +608,7 @@ class MessageLookup extends MessageLookupByLibrary { "home_login_title_welcome_back": MessageLookupByLibrary.simpleMessage("歡迎回來!"), "home_not_installed_or_failed": - MessageLookupByLibrary.simpleMessage("未安裝 或 安裝失敗"), + MessageLookupByLibrary.simpleMessage("您的電腦"), "home_title_app_name": MessageLookupByLibrary.simpleMessage("SC工具箱"), "home_title_logging_in": MessageLookupByLibrary.simpleMessage("正在登入..."), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 9fe6d91..3f69b52 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -1230,10 +1230,10 @@ class S { ); } - /// `Unpacking or installation failed` + /// `Your computer` String get home_not_installed_or_failed { return Intl.message( - 'Unpacking or installation failed', + 'Your computer', name: 'home_not_installed_or_failed', desc: '', args: [], diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 52914a5..29222c9 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -237,7 +237,7 @@ "@doctor_action_view_details": {}, "home_install_location": "Installation location:", "@home_install_location": {}, - "home_not_installed_or_failed": "Unpacking or installation failed", + "home_not_installed_or_failed": "Your computer", "@home_not_installed_or_failed": {}, "home_action_star_citizen_website_localization": "SC Official Localization", "@home_action_star_citizen_website_localization": {}, diff --git a/lib/l10n/intl_zh_CN.arb b/lib/l10n/intl_zh_CN.arb index 69d13bc..93374f8 100644 --- a/lib/l10n/intl_zh_CN.arb +++ b/lib/l10n/intl_zh_CN.arb @@ -236,7 +236,7 @@ "@doctor_action_view_details": {}, "home_install_location": "安装位置:", "@home_install_location": {}, - "home_not_installed_or_failed": "未安装 或 安装失败", + "home_not_installed_or_failed": "您的电脑", "@home_not_installed_or_failed": {}, "home_action_star_citizen_website_localization": "星际公民官网汉化", "@home_action_star_citizen_website_localization": {}, diff --git a/lib/l10n/intl_zh_TW.arb b/lib/l10n/intl_zh_TW.arb index 99bc7a9..5ed6190 100644 --- a/lib/l10n/intl_zh_TW.arb +++ b/lib/l10n/intl_zh_TW.arb @@ -236,7 +236,7 @@ "@doctor_action_view_details": {}, "home_install_location": "安裝位置:", "@home_install_location": {}, - "home_not_installed_or_failed": "未安裝 或 安裝失敗", + "home_not_installed_or_failed": "您的電腦", "@home_not_installed_or_failed": {}, "home_action_star_citizen_website_localization": "星際公民官網", "@home_action_star_citizen_website_localization": {}, diff --git a/lib/ui/home/home_ui.dart b/lib/ui/home/home_ui.dart index f312ecd..8e49ca6 100644 --- a/lib/ui/home/home_ui.dart +++ b/lib/ui/home/home_ui.dart @@ -115,6 +115,75 @@ class HomeUI extends HookConsumerWidget { ), ], ), + const SizedBox(height: 24), + Padding( + padding: const EdgeInsets.only(left: 24, right: 24), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text(S.current.home_install_location), + const SizedBox(width: 6), + Expanded( + child: ComboBox( + value: homeState.scInstalledPath, + isExpanded: true, + items: [ + ComboBoxItem( + value: "not_install", + child: Text(S.current.home_not_installed_or_failed), + ), + for (final path in homeState.scInstallPaths) + ComboBoxItem( + value: path, + child: Row( + children: [Text(path)], + ), + ) + ], + onChanged: model.onChangeInstallPath, + ), + ), + const SizedBox(width: 12), + Button( + onPressed: homeState.webLocalizationVersionsData == null + ? null + : () => model.launchRSI(context), + style: homeState.isCurGameRunning + ? null + : ButtonStyle( + backgroundColor: + WidgetStateProperty.resolveWith(_getRunButtonColor), + ), + child: Padding( + padding: const EdgeInsets.all(6), + child: Icon( + homeState.isCurGameRunning + ? FluentIcons.stop_solid + : FluentIcons.play_solid, + color: homeState.isCurGameRunning + ? Colors.red.withOpacity(.8) + : Colors.white, + ), + )), + const SizedBox(width: 12), + Button( + onPressed: () {}, + child: const Padding( + padding: EdgeInsets.all(6), + child: Icon(FluentIcons.folder_open), + ), + ), + const SizedBox(width: 12), + Button( + onPressed: model.reScanPath, + child: const Padding( + padding: EdgeInsets.all(6), + child: Icon(FluentIcons.refresh), + ), + ), + ], + ), + ), const SizedBox(height: 8), Text(homeState.lastScreenInfo, maxLines: 1), makeIndexActionLists(context, model, homeState, ref), diff --git a/lib/ui/home/home_ui_model.dart b/lib/ui/home/home_ui_model.dart index bebc142..23b0b82 100644 --- a/lib/ui/home/home_ui_model.dart +++ b/lib/ui/home/home_ui_model.dart @@ -76,7 +76,12 @@ class HomeUIModel extends _$HomeUIModel { for (var node in h.body!.nodes) { if (node is html_dom.Element) { if (node.localName == "img") { - return node.attributes["src"]?.trim() ?? ""; + var image = node.attributes["src"]?.trim() ?? ""; + var updatedImage = image.replaceAllMapped( + RegExp(r'http(s)?://i(\d+)\.hdslb\.com/bfs/'), + (match) => 'https://web-proxy.scbox.xkeyc.cn/bfs${match[2]}/bfs/' + ); + return updatedImage; } } } diff --git a/lib/ui/index_ui.dart b/lib/ui/index_ui.dart index 087b6c9..190e01a 100644 --- a/lib/ui/index_ui.dart +++ b/lib/ui/index_ui.dart @@ -22,61 +22,62 @@ class IndexUI extends HookConsumerWidget { final globalState = ref.watch(appGlobalModelProvider); final curIndex = useState(0); - return Container( - decoration: BoxDecoration( - image: DecorationImage( - image: - ExtendedAssetImageProvider(globalState.backgroundImageAssetsPath), + return Stack( + children: [ + ExtendedImage.asset( + width: double.infinity, + height: double.infinity, + globalState.backgroundImageAssetsPath, fit: BoxFit.cover, ), - ), - child: Center( - child: ClipRRect( - borderRadius: BorderRadius.circular(12), - child: BlurOvalWidget( - child: Container( - constraints: - const BoxConstraints(maxWidth: 1440, maxHeight: 1000), - child: NavigationView( - appBar: NavigationAppBar( - automaticallyImplyLeading: false, - title: () { - return Align( - alignment: AlignmentDirectional.centerStart, - child: Row( - children: [ - Image.asset( - "assets/app_logo_mini.png", - width: 20, - height: 20, - fit: BoxFit.cover, - ), - const SizedBox(width: 12), - Text(S.current.app_index_version_info( - ConstConf.appVersion, - ConstConf.isMSE ? "" : " Dev")), - ], - ), - ); - }(), + Center( + child: ClipRRect( + borderRadius: BorderRadius.circular(12), + child: BlurOvalWidget( + child: Container( + constraints: + const BoxConstraints(maxWidth: 1440, maxHeight: 920), + child: NavigationView( + appBar: NavigationAppBar( + automaticallyImplyLeading: false, + title: () { + return Align( + alignment: AlignmentDirectional.centerStart, + child: Row( + children: [ + Image.asset( + "assets/app_logo_mini.png", + width: 20, + height: 20, + fit: BoxFit.cover, + ), + const SizedBox(width: 12), + Text(S.current.app_index_version_info( + ConstConf.appVersion, + ConstConf.isMSE ? "" : " Dev")), + ], + ), + ); + }(), + ), + pane: NavigationPane( + key: Key("NavigationPane_${S.current.app_language_code}"), + selected: curIndex.value, + items: getNavigationPaneItems(curIndex), + size: NavigationPaneSize( + openWidth: S.current.app_language_code.startsWith("zh") + ? 64 + : 74), + ), + paneBodyBuilder: (item, child) { + return item!.body; + }, ), - pane: NavigationPane( - key: Key("NavigationPane_${S.current.app_language_code}"), - selected: curIndex.value, - items: getNavigationPaneItems(curIndex), - size: NavigationPaneSize( - openWidth: S.current.app_language_code.startsWith("zh") - ? 64 - : 74), - ), - paneBodyBuilder: (item, child) { - return item!.body; - }, ), ), ), - ), - ), + ) + ], ); }