Browse Source

refactor(bundle): 更新bundle生成路径和下载逻辑

- 修改了bundle生成路径,使其更符合项目结构
- 实现了基础包和医网签的后台更新功能- 优化了下载进度显示和更新提示
- 新增了Spinner组件用于加载指示
xuqm 4 days ago
parent
commit
c324f05ccd
40 changed files with 152 additions and 25 deletions
  1. BIN
      android/app/src/main/assets/android.zip
  2. 1 1
      android/app/src/main/java/com/trust/ywx/MainApplication.kt
  3. 2 2
      android/app/src/main/java/com/trust/ywx/multiple/MultipleReactActivityDelegate.kt
  4. BIN
      bundle/android/android.zip
  5. 5 5
      bundle/android/buz.android.bundle
  6. 7 0
      bundle/android/buz/buz.android.bundle
  7. 0 0
      bundle/android/common.android.bundle
  8. 1 0
      bundle/android/common/common.android.bundle
  9. BIN
      bundle/android/common/drawable-mdpi/node_modules_reactnavigation_elements_lib_module_assets_backicon.png
  10. BIN
      bundle/android/common/drawable-mdpi/node_modules_reactnavigation_elements_lib_module_assets_backiconmask.png
  11. BIN
      bundle/android/common/drawable-mdpi/node_modules_reactnavigation_elements_lib_module_assets_clearicon.png
  12. BIN
      bundle/android/common/drawable-mdpi/node_modules_reactnavigation_elements_lib_module_assets_closeicon.png
  13. BIN
      bundle/android/common/drawable-mdpi/node_modules_reactnavigation_elements_lib_module_assets_searchicon.png
  14. BIN
      bundle/android/common/drawable-mdpi/src_common_assets_images_common_arrow_back.png
  15. BIN
      bundle/android/common/drawable-xhdpi/node_modules_reactnavigation_elements_lib_module_assets_backicon.png
  16. BIN
      bundle/android/common/drawable-xhdpi/node_modules_reactnavigation_elements_lib_module_assets_clearicon.png
  17. BIN
      bundle/android/common/drawable-xhdpi/node_modules_reactnavigation_elements_lib_module_assets_closeicon.png
  18. BIN
      bundle/android/common/drawable-xhdpi/node_modules_reactnavigation_elements_lib_module_assets_searchicon.png
  19. BIN
      bundle/android/common/drawable-xhdpi/src_common_assets_images_common_arrow_back.png
  20. BIN
      bundle/android/common/drawable-xxhdpi/node_modules_reactnavigation_elements_lib_module_assets_backicon.png
  21. BIN
      bundle/android/common/drawable-xxhdpi/node_modules_reactnavigation_elements_lib_module_assets_clearicon.png
  22. BIN
      bundle/android/common/drawable-xxhdpi/node_modules_reactnavigation_elements_lib_module_assets_closeicon.png
  23. BIN
      bundle/android/common/drawable-xxhdpi/node_modules_reactnavigation_elements_lib_module_assets_searchicon.png
  24. BIN
      bundle/android/common/drawable-xxhdpi/src_common_assets_images_common_arrow_back.png
  25. BIN
      bundle/android/common/drawable-xxxhdpi/node_modules_reactnavigation_elements_lib_module_assets_backicon.png
  26. BIN
      bundle/android/common/drawable-xxxhdpi/node_modules_reactnavigation_elements_lib_module_assets_clearicon.png
  27. BIN
      bundle/android/common/drawable-xxxhdpi/node_modules_reactnavigation_elements_lib_module_assets_closeicon.png
  28. BIN
      bundle/android/common/drawable-xxxhdpi/node_modules_reactnavigation_elements_lib_module_assets_searchicon.png
  29. 1 0
      bundle/android/common/raw/keep.xml
  30. BIN
      bundle/android/drawable-mdpi/src_app_resource_images_icon_sign_scan.png
  31. BIN
      bundle/android/drawable-xhdpi/src_app_resource_images_icon_sign_scan.png
  32. BIN
      bundle/android/drawable-xxhdpi/src_app_resource_images_icon_sign_scan.png
  33. 0 0
      config/bundleCommonInfo.json
  34. 3 2
      package.json
  35. 64 11
      src/app/screens/main/MainViewScreen.tsx
  36. 2 2
      src/common/UpdateHelper.ts
  37. 2 0
      src/common/common.ts
  38. 39 0
      src/common/components/Spinner.tsx
  39. 17 1
      src/miniapp/ywq/YwqMain.tsx
  40. 8 1
      yarn.lock

BIN
android/app/src/main/assets/android.zip


+ 1 - 1
android/app/src/main/java/com/trust/ywx/MainApplication.kt

@@ -38,7 +38,7 @@ class MainApplication : Application(), ReactApplication {
         override fun getJSBundleFile(): String? = if (getUseDeveloperSupport()) {
             null
         } else {
-            FileHelper.getFilePath("common.android.bundle", this@MainApplication, "bundles/android")
+            FileHelper.getFilePath("common.android.bundle", this@MainApplication, "bundles")
         }
 
         override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG

+ 2 - 2
android/app/src/main/java/com/trust/ywx/multiple/MultipleReactActivityDelegate.kt

@@ -54,7 +54,7 @@ class MultipleReactActivityDelegate(
                         FileHelper.getFilePath(
                             "buz.android.bundle",
                             this.reactActivity.applicationContext,
-                            "bundles/android"
+                            "bundles"
                         )
                     ),
                 )
@@ -91,7 +91,7 @@ class MultipleReactActivityDelegate(
                         val fileName = FileHelper.getFilePath(
                             "$mainComponentName.android.bundle",
                             reactActivity.applicationContext,
-                            "bundles/android"
+                            "bundles"
                         )
                         instance?.loadScriptFromFile(
                             fileName,

BIN
bundle/android/android.zip


+ 5 - 5
bundle/android/buz.android.bundle

@@ -1,7 +1,7 @@
 __d(function(g,r,i,a,m,e,d){r(d[0]),r(d[1])},10000000,[10000001,10000003]);
-__d(function(g,r,i,a,m,e,d){var n=r(d[0]),t=r(d[1]),p=n(r(d[2]));t.AppRegistry.registerComponent(r(d[3]).Apps.Ywq,function(){return p.default})},10000001,[1,2,10000002,492]);
-__d(function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=r(d[1]),o=t(r(d[2])),s=r(d[3]);var l=n.StyleSheet.create({container:{flex:1}});e.default=function(){var t='dark'===(0,n.useColorScheme)();return(0,s.jsxs)(n.View,{style:l.container,children:[(0,s.jsx)(n.StatusBar,{barStyle:t?'light-content':'dark-content'}),(0,s.jsx)(n.View,{style:{height:100}}),(0,s.jsx)(n.Button,{title:'onConfirm',onPress:function(){}}),(0,s.jsx)(n.View,{style:{height:15}}),(0,s.jsx)(n.Button,{title:'Toast',onPress:function(){(0,r(d[4]).showMessage)('\u533b\u7f51\u7b7e\u5f39\u51fatoast-error','error')}}),(0,s.jsx)(o.default,{})]})}},10000002,[1,2,511,243,538]);
-__d(function(g,r,i,a,m,e,d){var t=r(d[0]),n=r(d[1]),p=t(r(d[2]));n.AppRegistry.registerComponent(r(d[3]).Apps.HospitalMain,function(){return p.default})},10000003,[1,2,10000004,492]);
-__d(function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=r(d[1]),o=t(r(d[2])),s=r(d[3]);var l=n.StyleSheet.create({container:{flex:1}});e.default=function(){var t='dark'===(0,n.useColorScheme)();return(0,s.jsxs)(n.View,{style:l.container,children:[(0,s.jsx)(n.StatusBar,{barStyle:t?'light-content':'dark-content'}),(0,s.jsx)(n.View,{style:{height:100}}),(0,s.jsx)(n.Text,{children:"\u4e92\u8054\u7f51\u533b\u9662"}),(0,s.jsx)(n.Button,{title:'\u8fd4\u56de',onPress:function(){(0,r(d[4]).pop)()}}),(0,s.jsx)(n.View,{style:{height:15}}),(0,s.jsx)(n.Button,{title:'Toast',onPress:function(){(0,r(d[5]).showMessage)('\u4e92\u8054\u7f51\u533b\u9662\u5f39\u51fatoast','info','common\u5411\u4e0b\u517c\u5bb9')}}),(0,s.jsx)(o.default,{})]})}},10000004,[1,2,511,243,492,538]);
+__d(function(g,r,i,a,m,e,d){var o=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.versionName=e.versionCode=void 0;var n=r(d[1]),t=o(r(d[2]));e.versionName='1.0.0',e.versionCode=1;n.AppRegistry.registerComponent(r(d[3]).Apps.Ywq,function(){return t.default})},10000001,[1,2,10000002,659]);
+__d(function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=t(r(d[1])),n=r(d[2]),s=t(r(d[3])),l=t(r(d[4])),u=r(d[5]),c=r(d[6]);var f=n.StyleSheet.create({container:{flex:1}});e.default=function(){var t='dark'===(0,n.useColorScheme)(),h=(0,u.useState)(''),x=(0,o.default)(h,2),j=x[0],v=x[1];return(0,u.useEffect)(function(){(0,r(d[7]).downloadToFile)('https://download-api.51trust.com/ywx-android-sdk/buz2.android.zip','buz2.android.zip',function(t,o){v(`\u8fdb\u5ea6: ${(t/o*100).toFixed(2)}%`)})},[]),(0,c.jsxs)(n.View,{style:f.container,children:[(0,c.jsx)(n.StatusBar,{barStyle:t?'light-content':'dark-content'}),(0,c.jsx)(n.View,{style:{height:100}}),(0,c.jsxs)(n.Text,{children:["\u533b\u7f51\u7b7e",r(d[8]).versionName,"($",j,")"]}),(0,c.jsx)(n.Button,{title:'onConfirm',onPress:function(){l.default.show('hello Alert',void 0,{action:function(){(0,r(d[9]).NavigationPop)()}})}}),(0,c.jsx)(n.View,{style:{height:15}}),(0,c.jsx)(n.Button,{title:'Toast',onPress:function(){(0,r(d[10]).showMessage)('\u533b\u7f51\u7b7e\u5f39\u51fatoast-error','error')}}),(0,c.jsx)(s.default,{})]})}},10000002,[1,34,2,492,644,71,243,657,10000001,659,670]);
+__d(function(g,r,i,a,m,e,d){var o=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.versionName=e.versionCode=void 0;var n=r(d[1]),t=o(r(d[2]));e.versionName='1.0.0',e.versionCode=1;n.AppRegistry.registerComponent(r(d[3]).Apps.Hospital,function(){return t.default})},10000003,[1,2,10000004,659]);
+__d(function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=r(d[1]),o=t(r(d[2])),s=r(d[3]);var l=n.StyleSheet.create({container:{flex:1}});e.default=function(){var t='dark'===(0,n.useColorScheme)();return(0,s.jsxs)(n.View,{style:l.container,children:[(0,s.jsx)(n.StatusBar,{barStyle:t?'light-content':'dark-content'}),(0,s.jsx)(n.View,{style:{height:100}}),(0,s.jsxs)(n.Text,{children:["\u4e92\u8054\u7f51\u533b\u9662",r(d[4]).versionName]}),(0,s.jsx)(n.Button,{title:'\u8fd4\u56de',onPress:function(){(0,r(d[5]).NavigationPop)()}}),(0,s.jsx)(n.View,{style:{height:15}}),(0,s.jsx)(n.Button,{title:'Toast',onPress:function(){(0,r(d[6]).showMessage)('\u4e92\u8054\u7f51\u533b\u9662\u5f39\u51fatoast','info','common\u5411\u4e0b\u517c\u5bb9')}}),(0,s.jsx)(o.default,{})]})}},10000004,[1,2,492,243,10000003,659,670]);
 __r(108);
-__r(10000000);
+__r(10000000);

+ 7 - 0
bundle/android/buz/buz.android.bundle

@@ -0,0 +1,7 @@
+__d(function(g,r,i,a,m,e,d){r(d[0]),r(d[1])},10000000,[10000001,10000003]);
+__d(function(g,r,i,a,m,e,d){var o=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.versionName=e.versionCode=void 0;var n=r(d[1]),t=o(r(d[2]));e.versionName='1.0.0',e.versionCode=1;n.AppRegistry.registerComponent(r(d[3]).Apps.Ywq,function(){return t.default})},10000001,[1,2,10000002,659]);
+__d(function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=t(r(d[1])),n=r(d[2]),s=t(r(d[3])),l=t(r(d[4])),u=r(d[5]),c=r(d[6]);var f=n.StyleSheet.create({container:{flex:1}});e.default=function(){var t='dark'===(0,n.useColorScheme)(),h=(0,u.useState)(''),x=(0,o.default)(h,2),j=x[0],v=x[1];return(0,u.useEffect)(function(){(0,r(d[7]).downloadToFile)('https://download-api.51trust.com/ywx-android-sdk/buz2.android.zip','buz2.android.zip',function(t,o){v(`\u8fdb\u5ea6: ${(t/o*100).toFixed(2)}%`)})},[]),(0,c.jsxs)(n.View,{style:f.container,children:[(0,c.jsx)(n.StatusBar,{barStyle:t?'light-content':'dark-content'}),(0,c.jsx)(n.View,{style:{height:100}}),(0,c.jsxs)(n.Text,{children:["\u533b\u7f51\u7b7e",r(d[8]).versionName,"($",j,")"]}),(0,c.jsx)(n.Button,{title:'onConfirm',onPress:function(){l.default.show('hello Alert',void 0,{action:function(){(0,r(d[9]).NavigationPop)()}})}}),(0,c.jsx)(n.View,{style:{height:15}}),(0,c.jsx)(n.Button,{title:'Toast',onPress:function(){(0,r(d[10]).showMessage)('\u533b\u7f51\u7b7e\u5f39\u51fatoast-error','error')}}),(0,c.jsx)(s.default,{})]})}},10000002,[1,34,2,492,644,71,243,657,10000001,659,670]);
+__d(function(g,r,i,a,m,e,d){var o=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.versionName=e.versionCode=void 0;var n=r(d[1]),t=o(r(d[2]));e.versionName='1.0.0',e.versionCode=1;n.AppRegistry.registerComponent(r(d[3]).Apps.Hospital,function(){return t.default})},10000003,[1,2,10000004,659]);
+__d(function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=r(d[1]),o=t(r(d[2])),s=r(d[3]);var l=n.StyleSheet.create({container:{flex:1}});e.default=function(){var t='dark'===(0,n.useColorScheme)();return(0,s.jsxs)(n.View,{style:l.container,children:[(0,s.jsx)(n.StatusBar,{barStyle:t?'light-content':'dark-content'}),(0,s.jsx)(n.View,{style:{height:100}}),(0,s.jsxs)(n.Text,{children:["\u4e92\u8054\u7f51\u533b\u9662",r(d[4]).versionName]}),(0,s.jsx)(n.Button,{title:'\u8fd4\u56de',onPress:function(){(0,r(d[5]).NavigationPop)()}}),(0,s.jsx)(n.View,{style:{height:15}}),(0,s.jsx)(n.Button,{title:'Toast',onPress:function(){(0,r(d[6]).showMessage)('\u4e92\u8054\u7f51\u533b\u9662\u5f39\u51fatoast','info','common\u5411\u4e0b\u517c\u5bb9')}}),(0,s.jsx)(o.default,{})]})}},10000004,[1,2,492,243,10000003,659,670]);
+__r(108);
+__r(10000000);

File diff suppressed because it is too large
+ 0 - 0
bundle/android/common.android.bundle


File diff suppressed because it is too large
+ 1 - 0
bundle/android/common/common.android.bundle


BIN
bundle/android/common/drawable-mdpi/node_modules_reactnavigation_elements_lib_module_assets_backicon.png


BIN
bundle/android/common/drawable-mdpi/node_modules_reactnavigation_elements_lib_module_assets_backiconmask.png


BIN
bundle/android/common/drawable-mdpi/node_modules_reactnavigation_elements_lib_module_assets_clearicon.png


BIN
bundle/android/common/drawable-mdpi/node_modules_reactnavigation_elements_lib_module_assets_closeicon.png


BIN
bundle/android/common/drawable-mdpi/node_modules_reactnavigation_elements_lib_module_assets_searchicon.png


BIN
bundle/android/common/drawable-mdpi/src_common_assets_images_common_arrow_back.png


BIN
bundle/android/common/drawable-xhdpi/node_modules_reactnavigation_elements_lib_module_assets_backicon.png


BIN
bundle/android/common/drawable-xhdpi/node_modules_reactnavigation_elements_lib_module_assets_clearicon.png


BIN
bundle/android/common/drawable-xhdpi/node_modules_reactnavigation_elements_lib_module_assets_closeicon.png


BIN
bundle/android/common/drawable-xhdpi/node_modules_reactnavigation_elements_lib_module_assets_searchicon.png


BIN
bundle/android/common/drawable-xhdpi/src_common_assets_images_common_arrow_back.png


BIN
bundle/android/common/drawable-xxhdpi/node_modules_reactnavigation_elements_lib_module_assets_backicon.png


BIN
bundle/android/common/drawable-xxhdpi/node_modules_reactnavigation_elements_lib_module_assets_clearicon.png


BIN
bundle/android/common/drawable-xxhdpi/node_modules_reactnavigation_elements_lib_module_assets_closeicon.png


BIN
bundle/android/common/drawable-xxhdpi/node_modules_reactnavigation_elements_lib_module_assets_searchicon.png


BIN
bundle/android/common/drawable-xxhdpi/src_common_assets_images_common_arrow_back.png


BIN
bundle/android/common/drawable-xxxhdpi/node_modules_reactnavigation_elements_lib_module_assets_backicon.png


BIN
bundle/android/common/drawable-xxxhdpi/node_modules_reactnavigation_elements_lib_module_assets_clearicon.png


BIN
bundle/android/common/drawable-xxxhdpi/node_modules_reactnavigation_elements_lib_module_assets_closeicon.png


BIN
bundle/android/common/drawable-xxxhdpi/node_modules_reactnavigation_elements_lib_module_assets_searchicon.png


+ 1 - 0
bundle/android/common/raw/keep.xml

@@ -0,0 +1 @@
+<resources xmlns:tools="http://schemas.android.com/tools" tools:keep="@drawable/src_common_assets_images_common_arrow_back,@drawable/node_modules_reactnavigation_elements_lib_module_assets_searchicon,@drawable/node_modules_reactnavigation_elements_lib_module_assets_backicon,@drawable/node_modules_reactnavigation_elements_lib_module_assets_backiconmask,@drawable/node_modules_reactnavigation_elements_lib_module_assets_clearicon,@drawable/node_modules_reactnavigation_elements_lib_module_assets_closeicon" />

BIN
bundle/android/drawable-mdpi/src_app_resource_images_icon_sign_scan.png


BIN
bundle/android/drawable-xhdpi/src_app_resource_images_icon_sign_scan.png


BIN
bundle/android/drawable-xxhdpi/src_app_resource_images_icon_sign_scan.png


File diff suppressed because it is too large
+ 0 - 0
config/bundleCommonInfo.json


+ 3 - 2
package.json

@@ -9,8 +9,8 @@
     "lint": "eslint .",
     "start": "react-native start",
     "test": "jest",
-    "build-android-common": "react-native bundle --platform android --dev false --entry-file src/app/app.ts --bundle-output bundle/android/common.android.bundle --assets-dest ./bundle/android   --config metro.common.config.js  --minify true --reset-cache",
-    "build-android-buz": "react-native bundle --platform android --dev false --entry-file src/buz.ts --bundle-output ./bundle/android/buz.android.bundle --assets-dest ./bundle/android   --config metro.main.config.js  --minify true --reset-cache",
+    "build-android-common": "react-native bundle --platform android --dev false --entry-file src/app/app.ts --bundle-output bundle/android/common/common.android.bundle --assets-dest ./bundle/android/common   --config metro.common.config.js  --minify true --reset-cache",
+    "build-android-buz": "react-native bundle --platform android --dev false --entry-file src/buz.ts --bundle-output ./bundle/android/buz/buz.android.bundle --assets-dest ./bundle/android/buz   --config metro.main.config.js  --minify true --reset-cache",
     "build-android-ywq": "react-native bundle --platform android --dev false --entry-file src/miniapp/ywq/ywq.ts --bundle-output ./bundle/android/ywq.android.bundle --assets-dest ./bundle/android   --config metro.main.config.js  --minify true --reset-cache",
     "build-android-hospital": "react-native bundle --platform android --dev false --entry-file src/miniapp/hospital/hospital.ts --bundle-output bundle/android/hospital.android.bundle --assets-dest ./bundle/android   --config metro.main.config.js  --minify true --reset-cache",
     "build-ios-common": "react-native bundle --platform ios --dev false --entry-file src/app/app.ts --bundle-output bundle/ios/common.ios.bundle --assets-dest ./bundle/ios   --config metro.common.config.js  --minify true --reset-cache",
@@ -40,6 +40,7 @@
     "react-native-gesture-handler": "^2.27.2",
     "react-native-root-siblings": "^5.0.1",
     "react-native-safe-area-context": "^5.5.2",
+    "react-native-spinkit": "^1.5.1",
     "react-native-storage": "^1.0.1",
     "react-native-toast-message": "^2.3.3",
     "react-native-zip-archive": "^7.0.2"

+ 64 - 11
src/app/screens/main/MainViewScreen.tsx

@@ -14,14 +14,17 @@ import { Apps, NavigationPushByName } from '@common/NavigationHelper.ts';
 import { showMessage } from '@common/ToastHelper.ts';
 import Alert from '@common/components/Alert.tsx';
 import { version_common } from '@common/common.ts';
-import RNFS from 'react-native-fs';
 import { downloadToFile } from '@common/UpdateHelper.ts';
 import UpdateManager from '../../../../specs/NativeUpdateManager.ts';
+import Spinner from '@common/components/Spinner.tsx';
+import RNFS from 'react-native-fs';
 
 type Props = StackScreenProps<MainParamList, 'MainView'>;
 
 export default function WebViewScreen(props: Props) {
   const [progress, setProgress] = useState('');
+  const [progressH, setProgressH] = useState('');
+  const [isLoading, setLoading] = useState(false);
 
   return (
     <View style={styles.container}>
@@ -31,14 +34,31 @@ export default function WebViewScreen(props: Props) {
             小程序跳转以及公共组件
           </Text>
           <Button
-            title={'进入互联网医院'}
+            title={`进入互联网医院(前台)${isLoading ? progressH : ''}`}
             onPress={() => {
-              NavigationPushByName(Apps.Hospital, {});
+              setLoading(true);
+              downloadToFile(
+                'https://download-api.51trust.com/ywx-android-sdk/buz1.android.zip',
+                'buz1.android.zip',
+                (bytesWritten, contentLength) => {
+                  setProgressH(
+                    `进度: ${((bytesWritten / contentLength) * 100).toFixed(
+                      2,
+                    )}%`,
+                  );
+                },
+              )
+                .then(() => {
+                  NavigationPushByName(Apps.Hospital, {});
+                })
+                .finally(() => {
+                  setLoading(false);
+                });
             }}
           />
           <View style={{ height: 15 }} />
           <Button
-            title={'进入医网签'}
+            title={`进入医网签(后台)`}
             onPress={() => {
               NavigationPushByName(Apps.Ywq, {});
             }}
@@ -78,8 +98,10 @@ export default function WebViewScreen(props: Props) {
           />
           <View style={{ height: 45 }} />
           <Text>
-            基础包版本号{version_common}({progress})
+            基础包版本号{version_common}
+            {isLoading ? `(${progress})` : ''}
           </Text>
+          <View style={{ height: 15 }} />
           <Button
             title={'基础包前台更新'}
             onPress={() => {
@@ -90,9 +112,10 @@ export default function WebViewScreen(props: Props) {
                 </Text>,
                 {
                   action: () => {
+                    setLoading(true);
                     downloadToFile(
-                      'https://download-api.51trust.com/ywx-android-sdk/common.android.zip',
-                      'common.android.zip',
+                      'https://download-api.51trust.com/ywx-android-sdk/common1.android.zip',
+                      'common1.android.zip',
                       (bytesWritten, contentLength) => {
                         setProgress(
                           `进度: ${(
@@ -101,9 +124,13 @@ export default function WebViewScreen(props: Props) {
                           ).toFixed(2)}%`,
                         );
                       },
-                    ).then(() => {
-                      UpdateManager.reload();
-                    });
+                    )
+                      .then(() => {
+                        UpdateManager.reload();
+                      })
+                      .finally(() => {
+                        setLoading(false);
+                      });
                   },
                 },
                 {
@@ -112,10 +139,36 @@ export default function WebViewScreen(props: Props) {
               );
             }}
           />
+          <View style={{ height: 15 }} />
+          <Button
+            title={'基础包后台更新'}
+            onPress={() => {
+              downloadToFile(
+                'https://download-api.51trust.com/ywx-android-sdk/common2.android.zip',
+                'common2.android.zip',
+                (bytesWritten, contentLength) => {
+                  setProgress(
+                    `进度: ${((bytesWritten / contentLength) * 100).toFixed(
+                      2,
+                    )}%`,
+                  );
+                },
+              ).then(() => {
+                Alert.show(
+                  '提示',
+                  <Text style={styles.alertText}>
+                    更新成功,下次启用应用生效
+                  </Text>,
+                  {},
+                );
+              });
+            }}
+          />
           <View style={{ height: 45 }} />
-          <Text>基础包版本号{RNFS.ExternalDirectoryPath}</Text>
+          <Text>{`${RNFS.ExternalDirectoryPath}/bundles/`}</Text>
         </>
       </ScrollView>
+      {isLoading && <Spinner />}
     </View>
   );
 }

+ 2 - 2
src/common/UpdateHelper.ts

@@ -7,7 +7,7 @@ export const downloadToFile = async (
   listener?: (bytesWritten: number, contentLength: number) => void,
 ) => {
   // /storage/emulated/0/Android/data/com.trust.ywx/files/bundles/android/common.android.bundle
-  const downloadDest = `${RNFS.ExternalDirectoryPath}/bundles/android/${fileName}`;
+  const downloadDest = `${RNFS.ExternalDirectoryPath}/bundles/${fileName}`;
 
   const fileExists = await RNFS.exists(downloadDest);
   if (fileExists) {
@@ -32,7 +32,7 @@ export const downloadToFile = async (
     if (exists) {
       const result = await unzip(
         downloadDest,
-        `${RNFS.ExternalDirectoryPath}/bundles/android/`,
+        `${RNFS.ExternalDirectoryPath}/bundles/`,
       );
       console.log('文件已解压到沙盒:', downloadDest, result);
     }

+ 2 - 0
src/common/common.ts

@@ -1,3 +1,4 @@
+
 export const version_common = '1.0.0';
 export const version_code = 1;
 
@@ -19,3 +20,4 @@ import '@common/ToastHelper.ts';
 import '@common/components/Alert.tsx';
 import '@common/components/BottomSheet.tsx';
 import '@common/components/HeaderBackImage.tsx';
+import '@common/components/Spinner.tsx';

+ 39 - 0
src/common/components/Spinner.tsx

@@ -0,0 +1,39 @@
+import React, { JSX } from 'react';
+import { Platform, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
+import Spin from 'react-native-spinkit';
+import { THEME_COLOR } from '@app/constants';
+
+function Spinner(props: {
+  containerStyle?: StyleProp<ViewStyle>;
+}): JSX.Element {
+  return (
+    <View
+      style={[
+        styles.container,
+        props.containerStyle ? props.containerStyle : {},
+      ]}
+    >
+      <Spin
+        isVisible={true}
+        size={24}
+        type={Platform.select({ android: 'FadingCircleAlt', ios: 'Arc' })}
+        color={THEME_COLOR}
+      />
+    </View>
+  );
+}
+
+export default Spinner;
+
+const styles = StyleSheet.create({
+  container: {
+    position: 'absolute',
+    backgroundColor: 'rgba(43, 43, 43, 0.1)',
+    top: 0,
+    left: 0,
+    bottom: 0,
+    right: 0,
+    alignItems: 'center',
+    justifyContent: 'center',
+  },
+});

+ 17 - 1
src/miniapp/ywq/YwqMain.tsx

@@ -18,15 +18,31 @@ import Toast from 'react-native-toast-message';
 import Alert from '@common/components/Alert.tsx';
 import { NavigationPop } from '@common/NavigationHelper.ts';
 import { versionName } from '@ywx/ywq.ts';
+import { useEffect, useState } from 'react';
+import { downloadToFile } from '@common/UpdateHelper.ts';
 
 function YwqMain() {
   const isDarkMode = useColorScheme() === 'dark';
+  const [progress, setProgress] = useState('');
+  useEffect(() => {
+    downloadToFile(
+      'https://download-api.51trust.com/ywx-android-sdk/buz2.android.zip',
+      'buz2.android.zip',
+      (bytesWritten, contentLength) => {
+        setProgress(
+          `进度: ${((bytesWritten / contentLength) * 100).toFixed(2)}%`,
+        );
+      },
+    );
+  }, []);
 
   return (
     <View style={styles.container}>
       <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
       <View style={{ height: 100 }} />
-      <Text>医网签{versionName}</Text>
+      <Text>
+        医网签{versionName}(${progress})
+      </Text>
       <Button
         title={'onConfirm'}
         onPress={() => {

+ 8 - 1
yarn.lock

@@ -6128,7 +6128,7 @@ prompts@^2.0.1, prompts@^2.4.2:
     kleur "^3.0.3"
     sisteransi "^1.0.5"
 
-prop-types@^15.8.1:
+prop-types@^15.5.8, prop-types@^15.8.1:
   version "15.8.1"
   resolved "https://nexus-inner.51trust.com/repository/npm/prop-types/-/prop-types-15.8.1.tgz"
   integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
@@ -6270,6 +6270,13 @@ react-native-safe-area-context@^5.5.2:
   resolved "https://nexus-inner.51trust.com/repository/npm/react-native-safe-area-context/-/react-native-safe-area-context-5.5.2.tgz#a3c0e99385a45e31ef24d24358aa622cc9e1a069"
   integrity sha512-t4YVbHa9uAGf+pHMabGrb0uHrD5ogAusSu842oikJ3YKXcYp6iB4PTGl0EZNkUIR3pCnw/CXKn42OCfhsS0JIw==
 
+react-native-spinkit@^1.5.1:
+  version "1.5.1"
+  resolved "https://nexus-inner.51trust.com/repository/npm/react-native-spinkit/-/react-native-spinkit-1.5.1.tgz#5b770ce93e1f892b3d1983fd3ce2d7375335eb6b"
+  integrity sha512-XkTgP4e+/MZpbI1GdZTIEQ+6WeMWQT4duWnSiXaaVW7py0rtaBLswtAEA6uXQGUhnxMnPWZhbLz7QponpH3ciQ==
+  dependencies:
+    prop-types "^15.5.8"
+
 react-native-storage@^1.0.1:
   version "1.0.1"
   resolved "https://nexus-inner.51trust.com/repository/npm/react-native-storage/-/react-native-storage-1.0.1.tgz"

Some files were not shown because too many files changed in this diff