refactor(bundle): 更新bundle生成路径和下载逻辑
- 修改了bundle生成路径,使其更符合项目结构 - 实现了基础包和医网签的后台更新功能- 优化了下载进度显示和更新提示 - 新增了Spinner组件用于加载指示
@ -38,7 +38,7 @@ class MainApplication : Application(), ReactApplication {
|
|||||||
override fun getJSBundleFile(): String? = if (getUseDeveloperSupport()) {
|
override fun getJSBundleFile(): String? = if (getUseDeveloperSupport()) {
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
FileHelper.getFilePath("common.android.bundle", this@MainApplication, "bundles/android")
|
FileHelper.getFilePath("common.android.bundle", this@MainApplication, "bundles")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
|
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class MultipleReactActivityDelegate(
|
|||||||
FileHelper.getFilePath(
|
FileHelper.getFilePath(
|
||||||
"buz.android.bundle",
|
"buz.android.bundle",
|
||||||
this.reactActivity.applicationContext,
|
this.reactActivity.applicationContext,
|
||||||
"bundles/android"
|
"bundles"
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -91,7 +91,7 @@ class MultipleReactActivityDelegate(
|
|||||||
val fileName = FileHelper.getFilePath(
|
val fileName = FileHelper.getFilePath(
|
||||||
"$mainComponentName.android.bundle",
|
"$mainComponentName.android.bundle",
|
||||||
reactActivity.applicationContext,
|
reactActivity.applicationContext,
|
||||||
"bundles/android"
|
"bundles"
|
||||||
)
|
)
|
||||||
instance?.loadScriptFromFile(
|
instance?.loadScriptFromFile(
|
||||||
fileName,
|
fileName,
|
||||||
|
|||||||
二进制
bundle/android/android.zip
普通文件
@ -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){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 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 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]);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 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 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.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 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(108);
|
||||||
__r(10000000);
|
__r(10000000);
|
||||||
@ -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);
|
||||||
|
之后 宽度: | 高度: | 大小: 100 B |
|
之后 宽度: | 高度: | 大小: 653 B |
|
之后 宽度: | 高度: | 大小: 220 B |
|
之后 宽度: | 高度: | 大小: 141 B |
|
之后 宽度: | 高度: | 大小: 258 B |
|
之后 宽度: | 高度: | 大小: 459 B |
|
之后 宽度: | 高度: | 大小: 134 B |
|
之后 宽度: | 高度: | 大小: 334 B |
|
之后 宽度: | 高度: | 大小: 201 B |
|
之后 宽度: | 高度: | 大小: 483 B |
|
之后 宽度: | 高度: | 大小: 975 B |
|
之后 宽度: | 高度: | 大小: 167 B |
|
之后 宽度: | 高度: | 大小: 502 B |
|
之后 宽度: | 高度: | 大小: 266 B |
|
之后 宽度: | 高度: | 大小: 728 B |
|
之后 宽度: | 高度: | 大小: 1.4 KiB |
|
之后 宽度: | 高度: | 大小: 207 B |
|
之后 宽度: | 高度: | 大小: 645 B |
|
之后 宽度: | 高度: | 大小: 332 B |
|
之后 宽度: | 高度: | 大小: 928 B |
@ -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" />
|
||||||
|
之前 宽度: | 高度: | 大小: 1.5 KiB |
|
之前 宽度: | 高度: | 大小: 3.5 KiB |
|
之前 宽度: | 高度: | 大小: 6.9 KiB |
@ -9,8 +9,8 @@
|
|||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"start": "react-native start",
|
"start": "react-native start",
|
||||||
"test": "jest",
|
"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-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.android.bundle --assets-dest ./bundle/android --config metro.main.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-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-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",
|
"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-gesture-handler": "^2.27.2",
|
||||||
"react-native-root-siblings": "^5.0.1",
|
"react-native-root-siblings": "^5.0.1",
|
||||||
"react-native-safe-area-context": "^5.5.2",
|
"react-native-safe-area-context": "^5.5.2",
|
||||||
|
"react-native-spinkit": "^1.5.1",
|
||||||
"react-native-storage": "^1.0.1",
|
"react-native-storage": "^1.0.1",
|
||||||
"react-native-toast-message": "^2.3.3",
|
"react-native-toast-message": "^2.3.3",
|
||||||
"react-native-zip-archive": "^7.0.2"
|
"react-native-zip-archive": "^7.0.2"
|
||||||
|
|||||||
@ -14,14 +14,17 @@ import { Apps, NavigationPushByName } from '@common/NavigationHelper.ts';
|
|||||||
import { showMessage } from '@common/ToastHelper.ts';
|
import { showMessage } from '@common/ToastHelper.ts';
|
||||||
import Alert from '@common/components/Alert.tsx';
|
import Alert from '@common/components/Alert.tsx';
|
||||||
import { version_common } from '@common/common.ts';
|
import { version_common } from '@common/common.ts';
|
||||||
import RNFS from 'react-native-fs';
|
|
||||||
import { downloadToFile } from '@common/UpdateHelper.ts';
|
import { downloadToFile } from '@common/UpdateHelper.ts';
|
||||||
import UpdateManager from '../../../../specs/NativeUpdateManager.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'>;
|
type Props = StackScreenProps<MainParamList, 'MainView'>;
|
||||||
|
|
||||||
export default function WebViewScreen(props: Props) {
|
export default function WebViewScreen(props: Props) {
|
||||||
const [progress, setProgress] = useState('');
|
const [progress, setProgress] = useState('');
|
||||||
|
const [progressH, setProgressH] = useState('');
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
@ -31,14 +34,31 @@ export default function WebViewScreen(props: Props) {
|
|||||||
小程序跳转以及公共组件
|
小程序跳转以及公共组件
|
||||||
</Text>
|
</Text>
|
||||||
<Button
|
<Button
|
||||||
title={'进入互联网医院'}
|
title={`进入互联网医院(前台)${isLoading ? progressH : ''}`}
|
||||||
onPress={() => {
|
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 }} />
|
<View style={{ height: 15 }} />
|
||||||
<Button
|
<Button
|
||||||
title={'进入医网签'}
|
title={`进入医网签(后台)`}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
NavigationPushByName(Apps.Ywq, {});
|
NavigationPushByName(Apps.Ywq, {});
|
||||||
}}
|
}}
|
||||||
@ -78,8 +98,10 @@ export default function WebViewScreen(props: Props) {
|
|||||||
/>
|
/>
|
||||||
<View style={{ height: 45 }} />
|
<View style={{ height: 45 }} />
|
||||||
<Text>
|
<Text>
|
||||||
基础包版本号{version_common}({progress})
|
基础包版本号{version_common}
|
||||||
|
{isLoading ? `(${progress})` : ''}
|
||||||
</Text>
|
</Text>
|
||||||
|
<View style={{ height: 15 }} />
|
||||||
<Button
|
<Button
|
||||||
title={'基础包前台更新'}
|
title={'基础包前台更新'}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
@ -90,9 +112,10 @@ export default function WebViewScreen(props: Props) {
|
|||||||
</Text>,
|
</Text>,
|
||||||
{
|
{
|
||||||
action: () => {
|
action: () => {
|
||||||
|
setLoading(true);
|
||||||
downloadToFile(
|
downloadToFile(
|
||||||
'https://download-api.51trust.com/ywx-android-sdk/common.android.zip',
|
'https://download-api.51trust.com/ywx-android-sdk/common1.android.zip',
|
||||||
'common.android.zip',
|
'common1.android.zip',
|
||||||
(bytesWritten, contentLength) => {
|
(bytesWritten, contentLength) => {
|
||||||
setProgress(
|
setProgress(
|
||||||
`进度: ${(
|
`进度: ${(
|
||||||
@ -101,9 +124,13 @@ export default function WebViewScreen(props: Props) {
|
|||||||
).toFixed(2)}%`,
|
).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 }} />
|
<View style={{ height: 45 }} />
|
||||||
<Text>基础包版本号{RNFS.ExternalDirectoryPath}</Text>
|
<Text>{`${RNFS.ExternalDirectoryPath}/bundles/`}</Text>
|
||||||
</>
|
</>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
{isLoading && <Spinner />}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ export const downloadToFile = async (
|
|||||||
listener?: (bytesWritten: number, contentLength: number) => void,
|
listener?: (bytesWritten: number, contentLength: number) => void,
|
||||||
) => {
|
) => {
|
||||||
// /storage/emulated/0/Android/data/com.trust.ywx/files/bundles/android/common.android.bundle
|
// /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);
|
const fileExists = await RNFS.exists(downloadDest);
|
||||||
if (fileExists) {
|
if (fileExists) {
|
||||||
@ -32,7 +32,7 @@ export const downloadToFile = async (
|
|||||||
if (exists) {
|
if (exists) {
|
||||||
const result = await unzip(
|
const result = await unzip(
|
||||||
downloadDest,
|
downloadDest,
|
||||||
`${RNFS.ExternalDirectoryPath}/bundles/android/`,
|
`${RNFS.ExternalDirectoryPath}/bundles/`,
|
||||||
);
|
);
|
||||||
console.log('文件已解压到沙盒:', downloadDest, result);
|
console.log('文件已解压到沙盒:', downloadDest, result);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
export const version_common = '1.0.0';
|
export const version_common = '1.0.0';
|
||||||
export const version_code = 1;
|
export const version_code = 1;
|
||||||
|
|
||||||
@ -19,3 +20,4 @@ import '@common/ToastHelper.ts';
|
|||||||
import '@common/components/Alert.tsx';
|
import '@common/components/Alert.tsx';
|
||||||
import '@common/components/BottomSheet.tsx';
|
import '@common/components/BottomSheet.tsx';
|
||||||
import '@common/components/HeaderBackImage.tsx';
|
import '@common/components/HeaderBackImage.tsx';
|
||||||
|
import '@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',
|
||||||
|
},
|
||||||
|
});
|
||||||
@ -18,15 +18,31 @@ import Toast from 'react-native-toast-message';
|
|||||||
import Alert from '@common/components/Alert.tsx';
|
import Alert from '@common/components/Alert.tsx';
|
||||||
import { NavigationPop } from '@common/NavigationHelper.ts';
|
import { NavigationPop } from '@common/NavigationHelper.ts';
|
||||||
import { versionName } from '@ywx/ywq.ts';
|
import { versionName } from '@ywx/ywq.ts';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { downloadToFile } from '@common/UpdateHelper.ts';
|
||||||
|
|
||||||
function YwqMain() {
|
function YwqMain() {
|
||||||
const isDarkMode = useColorScheme() === 'dark';
|
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 (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
|
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
|
||||||
<View style={{ height: 100 }} />
|
<View style={{ height: 100 }} />
|
||||||
<Text>医网签{versionName}</Text>
|
<Text>
|
||||||
|
医网签{versionName}(${progress})
|
||||||
|
</Text>
|
||||||
<Button
|
<Button
|
||||||
title={'onConfirm'}
|
title={'onConfirm'}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
|||||||
@ -6128,7 +6128,7 @@ prompts@^2.0.1, prompts@^2.4.2:
|
|||||||
kleur "^3.0.3"
|
kleur "^3.0.3"
|
||||||
sisteransi "^1.0.5"
|
sisteransi "^1.0.5"
|
||||||
|
|
||||||
prop-types@^15.8.1:
|
prop-types@^15.5.8, prop-types@^15.8.1:
|
||||||
version "15.8.1"
|
version "15.8.1"
|
||||||
resolved "https://nexus-inner.51trust.com/repository/npm/prop-types/-/prop-types-15.8.1.tgz"
|
resolved "https://nexus-inner.51trust.com/repository/npm/prop-types/-/prop-types-15.8.1.tgz"
|
||||||
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
|
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"
|
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==
|
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:
|
react-native-storage@^1.0.1:
|
||||||
version "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"
|
resolved "https://nexus-inner.51trust.com/repository/npm/react-native-storage/-/react-native-storage-1.0.1.tgz"
|
||||||
|
|||||||