feat: Proxy Source

This commit is contained in:
2024-09-04 19:02:31 +08:00
parent 74fe0457f0
commit 308480095b
12 changed files with 152 additions and 77 deletions

View File

@ -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<String>(
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),

View File

@ -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;
}
}
}

View File

@ -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;
},
),
),
),
),
),
)
],
);
}