Skip to content

Commit

Permalink
re
Browse files Browse the repository at this point in the history
  • Loading branch information
Notsfsssf committed Dec 23, 2024
1 parent cd2a756 commit d47bed1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
22 changes: 16 additions & 6 deletions lib/er/fetcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Fetcher {

Fetcher() {}

start() async {
start(String pictureSource) async {
if (receivePort.isBroadcast) return;
await taskPersistProvider.open();
await taskPersistProvider.getAllAccount();
Expand Down Expand Up @@ -158,7 +158,8 @@ class Fetcher {
}
} catch (e) {}
});
isolate = await Isolate.spawn(entryPoint, receivePort.sendPort,
isolate = await Isolate.spawn(
entryPoint, SendMessage(receivePort.sendPort, pictureSource),
debugName: 'childIsolate');
}

Expand Down Expand Up @@ -242,18 +243,27 @@ class Fetcher {
}
}

class SendMessage {
final SendPort sendPort;
final String pictureSource;

SendMessage(this.sendPort, this.pictureSource);
}

class Seed {}

r.RhttpClient? isolateDio;

entryPoint(SendPort sendPort) async {
LPrinter.d("entryPoint =======");
String inSource = userSetting.pictureSource!;
entryPoint(SendMessage message) async {
String pictureSource = message.pictureSource;
SendPort sendPort = message.sendPort;
LPrinter.d("entryPoint ====== $pictureSource");
String inSource = pictureSource;
await Rhttp.init();
await Hoster.initMap();
Hoster.dnsQueryFetcher();
isolateDio = await r.RhttpClient.create(
settings: userSetting.disableBypassSni
settings: userSetting.disableBypassSni || pictureSource != ImageHost
? null
: r.ClientSettings(
tlsSettings: r.TlsSettings(
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
muteStore.fetchBanUserIds();
muteStore.fetchBanIllusts();
muteStore.fetchBanTags();
fetcher.start();

super.initState();
if (Platform.isIOS) WidgetsBinding.instance.addObserver(this);

Expand Down
8 changes: 5 additions & 3 deletions lib/store/user_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,12 @@ abstract class _UserSetting with Store {
welcomePageNum = prefs.getInt('welcome_page_num') ?? 0;
feedAIBadge = prefs.getBool(FEED_AI_BADGE_KEY) ?? true;
padMode = prefs.getInt(PAD_MODE_KEY) ?? 0;
pictureSource = disableBypassSni
? ImageHost
: (prefs.getString(PICTURE_SOURCE_KEY) ?? ImageHost);
await Hoster.initMap();
themeInitState = 1;
fetcher.start(pictureSource!);
}

@action
Expand All @@ -425,9 +429,7 @@ abstract class _UserSetting with Store {
novelTextStyle = novelTextStyle.copyWith(fontSize: novelFontsize);
saveMode = prefs.getInt(SAVE_MODE_KEY) ??
(isHelplessWay == null ? 0 : (isHelplessWay! ? 2 : 1));
pictureSource = disableBypassSni
? ImageHost
: (prefs.getString(PICTURE_SOURCE_KEY) ?? ImageHost);

splashStore.setHost(pictureSource!);
saveEffect = prefs.getInt(SAVE_EFFECT_KEY) ?? 0;
saveEffectEnable = prefs.getBool(SAVE_EFFECT_ENABLE_KEY) ?? false;
Expand Down

0 comments on commit d47bed1

Please sign in to comment.