فهرست منبع

refactor(android): 重构 Android代码并优化性能

- 修复了使用 navigator.getBattery().then() 的冗余调用
-移除了不必要的电量监听器
- 优化了相机、定位、电池等信息的获取方式
-重命名了部分函数以提高可读性
- 调整了事件处理和状态管理的实现
xuqm 4 روز پیش
والد
کامیت
c8840ac185

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
bundle/android/common.android.bundle


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
bundle/ios/app.ios.bundle


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
bundle/ios/common.ios.bundle


+ 1 - 7
src/app/App.tsx

@@ -1,4 +1,4 @@
-import { StatusBar, StyleSheet, useColorScheme } from 'react-native';
+import { StatusBar, useColorScheme } from 'react-native';
 import Toast from 'react-native-toast-message';
 import { AppProvider } from '@app/contexts/AppProvider.tsx';
 import { RootSiblingParent } from 'react-native-root-siblings';
@@ -32,10 +32,4 @@ function App() {
   );
 }
 
-const styles = StyleSheet.create({
-  tooltip: {
-    backgroundColor: 'rgba(0, 0, 0, 0)',
-  },
-});
-
 export default App;

+ 28 - 2
src/app/screens/main/MainViewScreen.tsx

@@ -1,12 +1,38 @@
 import React from 'react';
-import { StyleSheet, View } from 'react-native';
+import { Button, StyleSheet, View } from 'react-native';
 import { StackScreenProps } from '@react-navigation/stack';
 import { MainParamList } from '@app/routes/MainParamList';
+import { Apps, NavigationPushByName } from '@common/NavigationHelper.ts';
+import { showMessage } from '@common/ToastHelper.ts';
 
 type Props = StackScreenProps<MainParamList, 'MainView'>;
 
 export default function WebViewScreen(props: Props) {
-  return <View style={styles.container}></View>;
+  return (
+    <View style={styles.container}>
+      <View style={{ height: 100 }} />
+      <Button
+        title={'进入互联网医院'}
+        onPress={() => {
+          NavigationPushByName(Apps.Hospital, {});
+        }}
+      />
+      <View style={{ height: 15 }} />
+      <Button
+        title={'进入医网签'}
+        onPress={() => {
+          NavigationPushByName(Apps.Ywq, {});
+        }}
+      />
+      <View style={{ height: 15 }} />
+      <Button
+        title={'Toast'}
+        onPress={() => {
+          showMessage('APP页面弹出toast');
+        }}
+      />
+    </View>
+  );
 }
 
 const styles = StyleSheet.create({

+ 2 - 2
src/common/NavigationHelper.ts

@@ -7,12 +7,12 @@ export enum Apps {
   Ywq = 'ywq',
 }
 
-export const pushByName = (name: string, params: any) => {
+export const NavigationPushByName = (name: string, params: any) => {
   saveItem(`MessageActivity-${name}`, params).finally(() => {
     NavigationManager.navigate(name);
   });
 };
-export const pop = () => {
+export const NavigationPop = () => {
   NavigationManager.pop();
 };
 export const getDataFromName = (name: string) =>

+ 4 - 3
src/common/StorageHelper.ts

@@ -4,16 +4,17 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
 export const storageApp = new Storage({
   size: 1000,
   storageBackend: AsyncStorage,
-  defaultExpires: 1000 * 3600 * 24 * 60,
+  // defaultExpires: 1000 * 3600 * 24 * 60,
   enableCache: true,
 });
 /**
  * 缓存一个键值对
  * @param key
  * @param value
+ * @param expires
  */
-export const saveItem = (key: string, value: any) =>
-  storageApp.save({ key, data: value });
+export const saveItem = (key: string, value: any, expires?: number | null) =>
+  storageApp.save({ key, data: value, expires });
 /**
  * 获取一个键值对
  * @param key

+ 2 - 2
src/miniapp/hospital/HospitalMain.tsx

@@ -13,7 +13,7 @@ import {
   useColorScheme,
   View,
 } from 'react-native';
-import { pop } from '@common/NavigationHelper.ts';
+import { NavigationPop } from '@common/NavigationHelper.ts';
 import { showMessage } from '@common/ToastHelper.ts';
 import Toast from 'react-native-toast-message';
 
@@ -28,7 +28,7 @@ function HospitalMain() {
       <Button
         title={'返回'}
         onPress={() => {
-          pop();
+          NavigationPop();
         }}
       />
       <View style={{ height: 15 }} />

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

@@ -14,6 +14,8 @@ import {
 } from 'react-native';
 import { showMessage } from '@common/ToastHelper.ts';
 import Toast from 'react-native-toast-message';
+import Alert from '@common/components/Alert.tsx';
+import { NavigationPop } from '@common/NavigationHelper.ts';
 
 function YwqMain() {
   const isDarkMode = useColorScheme() === 'dark';
@@ -22,7 +24,16 @@ function YwqMain() {
     <View style={styles.container}>
       <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
       <View style={{ height: 100 }} />
-      <Button title={'onConfirm'} onPress={() => {}} />
+      <Button
+        title={'onConfirm'}
+        onPress={() => {
+          Alert.show('hello Alert', undefined, {
+            action: () => {
+              NavigationPop();
+            },
+          });
+        }}
+      />
       <View style={{ height: 15 }} />
       <Button
         title={'Toast'}
@@ -31,6 +42,7 @@ function YwqMain() {
         }}
       />
       <Toast />
+      <Alert ref={ref => Alert.setRef(ref)} />
     </View>
   );
 }

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است