From 4119b2ee4b502baff5e2d6c7a184bbf6b4185430 Mon Sep 17 00:00:00 2001 From: zeronumber Date: Sat, 6 Apr 2024 20:46:44 +0800 Subject: [PATCH 1/2] fix: Optimized macos platform support --- lib/data/services/extension_service.dart | 55 +++++--- lib/main.dart | 9 +- lib/views/pages/main_page.dart | 64 +++++----- .../pages/search/extension_searcher_page.dart | 67 +++++----- macos/Flutter/Flutter-Debug.xcconfig | 1 + macos/Flutter/Flutter-Release.xcconfig | 1 + macos/Podfile | 43 +++++++ macos/Podfile.lock | 120 ++++++++++++++++++ macos/Runner.xcodeproj/project.pbxproj | 100 ++++++++++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../contents.xcworkspacedata | 3 + 11 files changed, 376 insertions(+), 89 deletions(-) create mode 100644 macos/Podfile create mode 100644 macos/Podfile.lock diff --git a/lib/data/services/extension_service.dart b/lib/data/services/extension_service.dart index 277fd7de..e45e01b6 100644 --- a/lib/data/services/extension_service.dart +++ b/lib/data/services/extension_service.dart @@ -443,19 +443,29 @@ class ExtensionService { } Future> latest(int page) async { - return runExtension(() async { - final jsResult = await runtime.handlePromise( - await runtime.evaluateAsync('stringify(()=>extension.latest($page))'), - ); - List result = - jsonDecode(jsResult.stringResult).map((e) { - return ExtensionListItem.fromJson(e); - }).toList(); - for (var element in result) { - element.headers ??= await _defaultHeaders; - } - return result; - }); + return runExtension( + () async { + final jsPromise = await runtime.evaluateAsync( + 'extension.latest($page)', + ); + final jsResult = await runtime.handlePromise( + jsPromise, + timeout: const Duration(seconds: 15), + ); + + final data = jsonDecode(jsResult.stringResult); + if (data is! List) throw 'result is not list'; + + final result = data + .map((e) => ExtensionListItem.fromJson(e)) + .toList(); + for (var element in result) { + element.headers ??= await _defaultHeaders; + } + + return result; + }, + ); } Future> search( @@ -464,17 +474,24 @@ class ExtensionService { Map>? filter, }) async { return runExtension(() async { + final jsPromise = await runtime.evaluateAsync( + 'extension.search("$kw",$page,${filter == null ? null : jsonEncode(filter)})', + ); final jsResult = await runtime.handlePromise( - await runtime.evaluateAsync( - 'stringify(()=>extension.search("$kw",$page,${filter == null ? null : jsonEncode(filter)}))'), + jsPromise, + timeout: const Duration(seconds: 15), ); - List result = - jsonDecode(jsResult.stringResult).map((e) { - return ExtensionListItem.fromJson(e); - }).toList(); + + final data = jsonDecode(jsResult.stringResult); + if (data is! List) throw 'result is not list'; + + final result = data + .map((e) => ExtensionListItem.fromJson(e)) + .toList(); for (var element in result) { element.headers ??= await _defaultHeaders; } + return result; }); } diff --git a/lib/main.dart b/lib/main.dart index abe63936..f0ec733c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -58,11 +58,12 @@ void main(List args) async { await windowManager.ensureInitialized(); final sizeArr = MiruStorage.getSetting(SettingKey.windowSize).split(","); final size = Size(double.parse(sizeArr[0]), double.parse(sizeArr[1])); - WindowOptions windowOptions = WindowOptions( + final windowOptions = WindowOptions( size: size, center: true, skipTaskbar: false, - titleBarStyle: TitleBarStyle.hidden, + titleBarStyle: + Platform.isMacOS ? TitleBarStyle.normal : TitleBarStyle.hidden, ); windowManager.waitUntilReadyToShow(windowOptions, () async { final position = MiruStorage.getSetting(SettingKey.windowPosition); @@ -72,9 +73,7 @@ void main(List args) async { double.parse(offsetArr[0]), double.parse(offsetArr[1]), ); - await windowManager.setPosition( - offset, - ); + await windowManager.setPosition(offset); } await windowManager.show(); await windowManager.focus(); diff --git a/lib/views/pages/main_page.dart b/lib/views/pages/main_page.dart index d5698cdf..bdf73cff 100644 --- a/lib/views/pages/main_page.dart +++ b/lib/views/pages/main_page.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:fluent_ui/fluent_ui.dart' as fluent; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -67,37 +69,39 @@ class _DesktopMainPageState extends State with WindowListener { @override Widget build(BuildContext context) { return fluent.NavigationView( - appBar: fluent.NavigationAppBar( - leading: () { - return fluent.IconButton( - icon: const Icon(fluent.FluentIcons.back, size: 12.0), - onPressed: () { - if (router.canPop()) { - context.pop(); - setState(() {}); - } - }, - ); - }(), - title: _title(), - actions: Obx( - () => Row( - children: [ - const Spacer(), - ...c.actions, - SizedBox( - width: 138, - height: 50, - child: WindowCaption( - backgroundColor: Colors.transparent, - brightness: fluent.FluentTheme.of(context).brightness, + appBar: Platform.isMacOS + ? null + : fluent.NavigationAppBar( + leading: () { + return fluent.IconButton( + icon: const Icon(fluent.FluentIcons.back, size: 12.0), + onPressed: () { + if (router.canPop()) { + context.pop(); + setState(() {}); + } + }, + ); + }(), + title: _title(), + actions: Obx( + () => Row( + children: [ + const Spacer(), + ...c.actions, + SizedBox( + width: 138, + height: 50, + child: WindowCaption( + backgroundColor: Colors.transparent, + brightness: fluent.FluentTheme.of(context).brightness, + ), + ) + ], ), - ) - ], - ), - ), - automaticallyImplyLeading: false, - ), + ), + automaticallyImplyLeading: false, + ), paneBodyBuilder: (item, body) { return widget.child; }, diff --git a/lib/views/pages/search/extension_searcher_page.dart b/lib/views/pages/search/extension_searcher_page.dart index f23df0ba..c21a1977 100644 --- a/lib/views/pages/search/extension_searcher_page.dart +++ b/lib/views/pages/search/extension_searcher_page.dart @@ -254,18 +254,21 @@ class _ExtensionSearcherPageState extends fluent.State { } Widget _buildDesktop(BuildContext context) { - final suffix = Row(mainAxisSize: MainAxisSize.min, children: [ - Padding( - padding: const EdgeInsetsDirectional.only(start: 2.0), - child: fluent.IconButton( - icon: const Icon(fluent.FluentIcons.chrome_close, size: 9.0), - onPressed: () { - _textEditingController.clear(); - _onSearch(""); - }, + final suffix = Row( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: const EdgeInsetsDirectional.only(start: 2.0), + child: fluent.IconButton( + icon: const Icon(fluent.FluentIcons.chrome_close, size: 9.0), + onPressed: () { + _textEditingController.clear(); + _onSearch(""); + }, + ), ), - ), - ]); + ], + ); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -321,27 +324,27 @@ class _ExtensionSearcherPageState extends fluent.State { onRefresh: _onRefresh, onLoad: _onLoad, child: LayoutBuilder( - builder: ((context, constraints) => GridView.builder( - padding: const EdgeInsets.all(16), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: constraints.maxWidth ~/ 160, - childAspectRatio: 0.6, - crossAxisSpacing: 16, - mainAxisSpacing: 16, - ), - itemCount: _data.length, - itemBuilder: (context, index) { - final item = _data[index]; - return ExtensionItemCard( - title: item.title, - url: item.url, - package: widget.package, - cover: item.cover, - update: item.update, - headers: item.headers, - ); - }, - )), + builder: (context, constraints) => GridView.builder( + padding: const EdgeInsets.all(16), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: constraints.maxWidth ~/ 160, + childAspectRatio: 0.6, + crossAxisSpacing: 16, + mainAxisSpacing: 16, + ), + itemCount: _data.length, + itemBuilder: (context, index) { + final item = _data[index]; + return ExtensionItemCard( + title: item.title, + url: item.url, + package: widget.package, + cover: item.cover, + update: item.update, + headers: item.headers, + ); + }, + ), ), ), ) diff --git a/macos/Flutter/Flutter-Debug.xcconfig b/macos/Flutter/Flutter-Debug.xcconfig index c2efd0b6..4b81f9b2 100644 --- a/macos/Flutter/Flutter-Debug.xcconfig +++ b/macos/Flutter/Flutter-Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/Flutter-Release.xcconfig b/macos/Flutter/Flutter-Release.xcconfig index c2efd0b6..5caa9d15 100644 --- a/macos/Flutter/Flutter-Release.xcconfig +++ b/macos/Flutter/Flutter-Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Podfile b/macos/Podfile new file mode 100644 index 00000000..c795730d --- /dev/null +++ b/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.14' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/macos/Podfile.lock b/macos/Podfile.lock new file mode 100644 index 00000000..ce7ae07c --- /dev/null +++ b/macos/Podfile.lock @@ -0,0 +1,120 @@ +PODS: + - desktop_multi_window (0.0.1): + - FlutterMacOS + - device_info_plus (0.0.1): + - FlutterMacOS + - flutter_inappwebview_macos (0.0.1): + - FlutterMacOS + - OrderedSet (~> 5.0) + - flutter_js (0.0.1): + - FlutterMacOS + - FlutterMacOS (1.0.0) + - isar_flutter_libs (1.0.0): + - FlutterMacOS + - media_kit_libs_macos_video (1.0.4): + - FlutterMacOS + - media_kit_native_event_loop (1.0.0): + - FlutterMacOS + - media_kit_video (0.0.1): + - FlutterMacOS + - OrderedSet (5.0.0) + - package_info_plus (0.0.1): + - FlutterMacOS + - path_provider_foundation (0.0.1): + - Flutter + - FlutterMacOS + - screen_brightness_macos (0.1.0): + - FlutterMacOS + - screen_retriever (0.0.1): + - FlutterMacOS + - share_plus (0.0.1): + - FlutterMacOS + - url_launcher_macos (0.0.1): + - FlutterMacOS + - wakelock_plus (0.0.1): + - FlutterMacOS + - window_manager (0.2.0): + - FlutterMacOS + +DEPENDENCIES: + - desktop_multi_window (from `Flutter/ephemeral/.symlinks/plugins/desktop_multi_window/macos`) + - device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`) + - flutter_inappwebview_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_inappwebview_macos/macos`) + - flutter_js (from `Flutter/ephemeral/.symlinks/plugins/flutter_js/macos`) + - FlutterMacOS (from `Flutter/ephemeral`) + - isar_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/isar_flutter_libs/macos`) + - media_kit_libs_macos_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos`) + - media_kit_native_event_loop (from `Flutter/ephemeral/.symlinks/plugins/media_kit_native_event_loop/macos`) + - media_kit_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos`) + - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) + - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) + - screen_brightness_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_brightness_macos/macos`) + - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`) + - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) + - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) + - wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`) + - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) + +SPEC REPOS: + trunk: + - OrderedSet + +EXTERNAL SOURCES: + desktop_multi_window: + :path: Flutter/ephemeral/.symlinks/plugins/desktop_multi_window/macos + device_info_plus: + :path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos + flutter_inappwebview_macos: + :path: Flutter/ephemeral/.symlinks/plugins/flutter_inappwebview_macos/macos + flutter_js: + :path: Flutter/ephemeral/.symlinks/plugins/flutter_js/macos + FlutterMacOS: + :path: Flutter/ephemeral + isar_flutter_libs: + :path: Flutter/ephemeral/.symlinks/plugins/isar_flutter_libs/macos + media_kit_libs_macos_video: + :path: Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos + media_kit_native_event_loop: + :path: Flutter/ephemeral/.symlinks/plugins/media_kit_native_event_loop/macos + media_kit_video: + :path: Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos + package_info_plus: + :path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos + path_provider_foundation: + :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin + screen_brightness_macos: + :path: Flutter/ephemeral/.symlinks/plugins/screen_brightness_macos/macos + screen_retriever: + :path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos + share_plus: + :path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos + url_launcher_macos: + :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos + wakelock_plus: + :path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos + window_manager: + :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos + +SPEC CHECKSUMS: + desktop_multi_window: 566489c048b501134f9d7fb6a2354c60a9126486 + device_info_plus: 5401765fde0b8d062a2f8eb65510fb17e77cf07f + flutter_inappwebview_macos: 9600c9df9fdb346aaa8933812009f8d94304203d + flutter_js: c664361655af1d8fc24e278c7d086e9cbe0d68bc + FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 + isar_flutter_libs: 43385c99864c168fadba7c9adeddc5d38838ca6a + media_kit_libs_macos_video: b3e2bbec2eef97c285f2b1baa7963c67c753fb82 + media_kit_native_event_loop: 81fd5b45192b72f8b5b69eaf5b540f45777eb8d5 + media_kit_video: c75b07f14d59706c775778e4dd47dd027de8d1e5 + OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c + package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce + path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c + screen_brightness_macos: 2d6d3af2165592d9a55ffcd95b7550970e41ebda + screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 + share_plus: 76dd39142738f7a68dd57b05093b5e8193f220f7 + url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 + wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269 + window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 + +PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 + +COCOAPODS: 1.15.2 diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 05c81b92..467a957e 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -21,12 +21,14 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 260EF47D739C9436C4AACD3D /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ECF7D5F73711E53ADD30877D /* Pods_Runner.framework */; }; 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + 52383ECA1D848ED03085DCFD /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4044F9F7C2AC9A02B0C72C96 /* Pods_RunnerTests.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -60,11 +62,12 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 32475264717CEDCE213EA740 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* Miru.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Miru.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10ED2044A3C60003C045 /* Miru.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Miru.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; @@ -76,8 +79,15 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 33F65BB3D50AFAEB7D05FF74 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + 37A996C8293E88AF45B4D7ED /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 4044F9F7C2AC9A02B0C72C96 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 963B5831F93900C4DE7A2B52 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; + A0FFBD25AA2ED0BF41DA920B /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; + E29CE0CB945FC687BD792577 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; + ECF7D5F73711E53ADD30877D /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -85,6 +95,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 52383ECA1D848ED03085DCFD /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -92,6 +103,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 260EF47D739C9436C4AACD3D /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -125,6 +137,7 @@ 331C80D6294CF71000263BE5 /* RunnerTests */, 33CC10EE2044A3C60003C045 /* Products */, D73912EC22F37F3D000D13A0 /* Frameworks */, + 6598A84037BC0EB7AEF92349 /* Pods */, ); sourceTree = ""; }; @@ -172,9 +185,25 @@ path = Runner; sourceTree = ""; }; + 6598A84037BC0EB7AEF92349 /* Pods */ = { + isa = PBXGroup; + children = ( + 37A996C8293E88AF45B4D7ED /* Pods-Runner.debug.xcconfig */, + 33F65BB3D50AFAEB7D05FF74 /* Pods-Runner.release.xcconfig */, + 963B5831F93900C4DE7A2B52 /* Pods-Runner.profile.xcconfig */, + A0FFBD25AA2ED0BF41DA920B /* Pods-RunnerTests.debug.xcconfig */, + 32475264717CEDCE213EA740 /* Pods-RunnerTests.release.xcconfig */, + E29CE0CB945FC687BD792577 /* Pods-RunnerTests.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; D73912EC22F37F3D000D13A0 /* Frameworks */ = { isa = PBXGroup; children = ( + ECF7D5F73711E53ADD30877D /* Pods_Runner.framework */, + 4044F9F7C2AC9A02B0C72C96 /* Pods_RunnerTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -186,6 +215,7 @@ isa = PBXNativeTarget; buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( + 014686974BE7CD6AF4CD5201 /* [CP] Check Pods Manifest.lock */, 331C80D1294CF70F00263BE5 /* Sources */, 331C80D2294CF70F00263BE5 /* Frameworks */, 331C80D3294CF70F00263BE5 /* Resources */, @@ -204,11 +234,13 @@ isa = PBXNativeTarget; buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + B4B0202130AC9E6E0F9BE8DE /* [CP] Check Pods Manifest.lock */, 33CC10E92044A3C60003C045 /* Sources */, 33CC10EA2044A3C60003C045 /* Frameworks */, 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, + 9825839A1BDF313E0C8BBC43 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -227,7 +259,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 331C80D4294CF70F00263BE5 = { @@ -290,6 +322,28 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 014686974BE7CD6AF4CD5201 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; 3399D490228B24CF009A79C7 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -328,6 +382,45 @@ shellPath = /bin/sh; shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; + 9825839A1BDF313E0C8BBC43 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + B4B0202130AC9E6E0F9BE8DE /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -379,6 +472,7 @@ /* Begin XCBuildConfiguration section */ 331C80DB294CF71000263BE5 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = A0FFBD25AA2ED0BF41DA920B /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; @@ -393,6 +487,7 @@ }; 331C80DC294CF71000263BE5 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 32475264717CEDCE213EA740 /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; @@ -407,6 +502,7 @@ }; 331C80DD294CF71000263BE5 /* Profile */ = { isa = XCBuildConfiguration; + baseConfigurationReference = E29CE0CB945FC687BD792577 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 67e78f35..d691377c 100644 --- a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ + + From 5e5036781fe8169f96269d807a5aeb37f08cfef3 Mon Sep 17 00:00:00 2001 From: zeronumber Date: Sat, 6 Apr 2024 21:08:00 +0800 Subject: [PATCH 2/2] pref: Optimized code --- lib/data/services/extension_service.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/data/services/extension_service.dart b/lib/data/services/extension_service.dart index e45e01b6..c56c688b 100644 --- a/lib/data/services/extension_service.dart +++ b/lib/data/services/extension_service.dart @@ -446,7 +446,9 @@ class ExtensionService { return runExtension( () async { final jsPromise = await runtime.evaluateAsync( - 'extension.latest($page)', + Platform.isMacOS + ? 'extension.latest($page)' + : 'stringify(()=>extension.latest($page))', ); final jsResult = await runtime.handlePromise( jsPromise, @@ -475,7 +477,9 @@ class ExtensionService { }) async { return runExtension(() async { final jsPromise = await runtime.evaluateAsync( - 'extension.search("$kw",$page,${filter == null ? null : jsonEncode(filter)})', + Platform.isMacOS + ? 'extension.search("$kw",$page,${filter == null ? null : jsonEncode(filter)})' + : 'stringify(()=>extension.search("$kw",$page,${filter == null ? null : jsonEncode(filter)}))', ); final jsResult = await runtime.handlePromise( jsPromise,