Browse Source

replace rootBundle 2 FResourceBundle.assetBundle

Melon 1 year ago
parent
commit
5df3eb2323
2 changed files with 5 additions and 4 deletions
  1. 3 1
      lib/resource.dart
  2. 2 3
      lib/theme_loader.dart

+ 3 - 1
lib/resource.dart

@@ -49,6 +49,8 @@ class FResourceKey {
 
 /// Fis资源集
 abstract class FResourceBundle {
+  static AssetBundle? assetBundle;
+
   late String _resourcePath;
 
   /// 资源路径
@@ -79,7 +81,7 @@ abstract class FResourceBundle {
     if (FTheme.ins.defaultName == _manifestInfoRefer.name) {
       var path =
           "packages/${FisUIConsts.themePackageName}/assets/${resourceInfo.path}";
-      data = await rootBundle.load(path);
+      data = await (FResourceBundle.assetBundle ?? rootBundle).load(path);
     } else {
       data = await _innerLoad(resourceInfo);
     }

+ 2 - 3
lib/theme_loader.dart

@@ -15,8 +15,6 @@ import 'package:path_provider/path_provider.dart';
 
 import 'theme.dart';
 import 'consts.dart';
-import 'resource.dart';
-import 'manifest.dart';
 
 abstract class FThemeLoader {
   /// 主题名称
@@ -61,7 +59,8 @@ abstract class FThemeLoader {
     try {
       String assetPath =
           "packages/${FisUIConsts.themePackageName}/assets/${FisUIConsts.manifestFileName}";
-      String jsonString = await rootBundle.loadString(assetPath, cache: false);
+      String jsonString = await (FResourceBundle.assetBundle ?? rootBundle)
+          .loadString(assetPath, cache: false);
       return jsonString;
     } catch (e) {
       logger.e("读取默认主题清单Json失败", e);