lv il y a 1 mois
Parent
commit
e043912e3f

+ 3 - 1
android/app/src/main/AndroidManifest.xml

@@ -15,11 +15,13 @@
     </intent>
   </queries>
   <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:supportsRtl="true" android:enableOnBackInvokedCallback="false">
+    <meta-data android:name="expo.modules.updates.CODE_SIGNING_CERTIFICATE" android:value="-----BEGIN CERTIFICATE-----&#xD;&#xA;MIICzTCCAbWgAwIBAgIJVRhEHlaBbd3/MA0GCSqGSIb3DQEBCwUAMBAxDjAMBgNV&#xD;&#xA;BAMTBWNkNzExMB4XDTI2MDQxNjA0NDMxNVoXDTM2MDQxNjA0NDMxNVowEDEOMAwG&#xD;&#xA;A1UEAxMFY2Q3MTEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCsNT1A&#xD;&#xA;EX3N3s/tAl4wQCubPWAM4Twh2EVnItwE1WgXk/znnTVnhF7aO0UEqTJcbRPh42jY&#xD;&#xA;bC7Rbz8D6PO8sCPKW36sxRPpGTJXhkiP3cVGJ9UIO1TSIPTuPwMe6HK9B4dmiZvy&#xD;&#xA;4qngttLFRJfIiHLisf5ckJFXMtcR8P3wFAm6YmlThGmdmwnDT1Z7FyPjMniJCTIG&#xD;&#xA;NWOMIWkLMmfe/uMAhXEOC9GmQKLFJKUgJgy9sh0MRpjqdxgrEsuZ6k1V1Ok589BC&#xD;&#xA;Y3gVRizY1jdEvctxYvy08TSQRQ5FF0+aIr7bmBDmlKipb2DFZFJ8ezbNJpkdZZgH&#xD;&#xA;G0nUvoh7iOcgpk9jAgMBAAGjKjAoMA4GA1UdDwEB/wQEAwIHgDAWBgNVHSUBAf8E&#xD;&#xA;DDAKBggrBgEFBQcDAzANBgkqhkiG9w0BAQsFAAOCAQEAUzogAlwcZyQjoyJifKaG&#xD;&#xA;swKTfc5a8lrR1Oo2j6y/U4p9Ce9w9WrNxwHgjIsD/QrXsvwmcuaoeRw5jeha5tHo&#xD;&#xA;eG3UNS2gT9K1LibVTEUa44fyvhrMjs7IMu3gAWYAWXm/3M3Bu6AGnGw4beT05Gdp&#xD;&#xA;8CFMAYfs2TW8IQLTh2bfUnMqN+bl4YuLiE3bsx+MV/UnYxCI8XuJ2N3xdGjRaj0f&#xD;&#xA;NQ5vmWaVdoRq93BqN6k1i+rCAY7f8+ESufbdehfhrvfjGKAXvy8FuLrFzymgXoaF&#xD;&#xA;H08s7Sen5SsK9w6ID8+Pbz+CGs7UWK3URri0kTfJ9dwgL4ilq1At/pYZ8Zid3Ljx&#xD;&#xA;FQ==&#xD;&#xA;-----END CERTIFICATE-----&#xD;&#xA;"/>
+    <meta-data android:name="expo.modules.updates.CODE_SIGNING_METADATA" android:value="{&quot;keyid&quot;:&quot;main&quot;,&quot;alg&quot;:&quot;rsa-v1_5-sha256&quot;}"/>
     <meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
     <meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="@string/expo_runtime_version"/>
     <meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
     <meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="30000"/>
-    <meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://loan.ewaga.com/airpatch/manifest"/>
+    <meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://updates-loan.ewaga.com/api/manifest"/>
     <activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|smallestScreenSize" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
       <intent-filter>
         <action android:name="android.intent.action.MAIN"/>

+ 8 - 9
app.json

@@ -8,7 +8,7 @@
     "scheme": "loanassistant",
     "userInterfaceStyle": "light",
     "runtimeVersion": {
-      "policy": "appVersion" 
+      "policy": "appVersion"
     },
     "ios": {
       "icon": "./assets/expo.icon",
@@ -64,14 +64,13 @@
     },
     "updates": {
       "enabled": true,
-      "checkAutomatically": "ON_LOAD",
-      "url": "https://loan.ewaga.com/airpatch/api/manifest", // 你的服务器地址
+      "url": "https://updates-loan.ewaga.com/api/manifest",
       "fallbackToCacheTimeout": 30000,
-      // "codeSigningCertificate": "./code-signing/certificate.pem",
-      // "codeSigningMetadata": {
-      //   "keyid": "main",
-      //   "alg": "rsa-v1_5-sha256"
-      // }
-    },
+      "codeSigningCertificate": "./code-signing/certificate.pem",
+      "codeSigningMetadata": {
+        "keyid": "main",
+        "alg": "rsa-v1_5-sha256"
+      }
+    }
   }
 }

+ 62 - 0
build-and-publish-app-release.sh

@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# Check if the correct number of arguments are provided
+if [ "$#" -ne 3 ]; then
+  echo "Usage: $0 <runtimeVersion> <xavia-ota-url> <upload-key>"
+  exit 1
+fi
+
+# Get the current commit hash and message
+commitHash=$(git rev-parse HEAD)
+commitMessage=$(git log -1 --pretty=%B)
+
+# Assign arguments to variables
+runtimeVersion=$1
+serverHost=$2
+uploadKey=$3
+
+# Generate a timestamp for the output folder
+timestamp=$(date -u +%Y%m%d%H%M%S)
+outputFolder="../ota-builds/$timestamp"
+
+# Ask the user to confirm the hash, commit message, runtime version, and output folder
+echo "Output Folder: $outputFolder"
+echo "Runtime Version: $runtimeVersion"
+echo "Commit Hash: $commitHash"
+echo "Commit Message: $commitMessage"
+
+read -p "Do you want to proceed with these values? (y/n): " confirm
+
+if [ "$confirm" != "y" ]; then
+  echo "Operation cancelled by the user."
+  exit 1
+fi
+
+rm -rf $outputFolder
+mkdir -p $outputFolder
+
+# Run expo export with the specified output folder
+npx expo export --output-dir $outputFolder
+
+# Extract expo config property from app.json and save to expoconfig.json
+jq '.expo' app.json > $outputFolder/expoconfig.json
+
+
+# Zip the output folder
+cd $outputFolder  
+zip -q -r ${timestamp}.zip .
+
+
+# Upload the zip file to the server
+curl -X POST $serverHost/api/upload -F "file=@${timestamp}.zip" -F "runtimeVersion=$runtimeVersion" -F "commitHash=$commitHash" -F "commitMessage=$commitMessage" -F "uploadKey=$uploadKey"
+
+echo ""
+
+echo "Uploaded to $serverHost/api/upload"
+cd ..
+
+# Remove the output folder and zip file
+rm -rf $outputFolder
+
+echo "Removed $outputFolder"
+echo "Done"

+ 4 - 4
ios/LoanAssistant.xcodeproj/project.pbxproj

@@ -368,11 +368,11 @@
 				);
 				OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
 				PRODUCT_BUNDLE_IDENTIFIER = com.cdloan.assistant;
-				PRODUCT_NAME = LoanAssistant;
+				PRODUCT_NAME = "LoanAssistant";
 				SWIFT_OBJC_BRIDGING_HEADER = "LoanAssistant/LoanAssistant-Bridging-Header.h";
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
 				SWIFT_VERSION = 5.0;
-				TARGETED_DEVICE_FAMILY = 1;
+				TARGETED_DEVICE_FAMILY = "1";
 				VERSIONING_SYSTEM = "apple-generic";
 			};
 			name = Debug;
@@ -399,10 +399,10 @@
 				);
 				OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
 				PRODUCT_BUNDLE_IDENTIFIER = com.cdloan.assistant;
-				PRODUCT_NAME = LoanAssistant;
+				PRODUCT_NAME = "LoanAssistant";
 				SWIFT_OBJC_BRIDGING_HEADER = "LoanAssistant/LoanAssistant-Bridging-Header.h";
 				SWIFT_VERSION = 5.0;
-				TARGETED_DEVICE_FAMILY = 1;
+				TARGETED_DEVICE_FAMILY = "1";
 				VERSIONING_SYSTEM = "apple-generic";
 			};
 			name = Release;

+ 75 - 75
ios/LoanAssistant/Info.plist

@@ -1,78 +1,78 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
-<dict>
-	<key>CADisableMinimumFrameDurationOnPhone</key>
-	<true/>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>$(DEVELOPMENT_LANGUAGE)</string>
-	<key>CFBundleDisplayName</key>
-	<string>借贷助手</string>
-	<key>CFBundleExecutable</key>
-	<string>$(EXECUTABLE_NAME)</string>
-	<key>CFBundleIdentifier</key>
-	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>$(PRODUCT_NAME)</string>
-	<key>CFBundlePackageType</key>
-	<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
-	<key>CFBundleShortVersionString</key>
-	<string>1.0.0</string>
-	<key>CFBundleSignature</key>
-	<string>????</string>
-	<key>CFBundleURLTypes</key>
-	<array>
-		<dict>
-			<key>CFBundleURLSchemes</key>
-			<array>
-				<string>loanassistant</string>
-				<string>com.cdloan.assistant</string>
-			</array>
-		</dict>
-	</array>
-	<key>CFBundleVersion</key>
-	<string>1</string>
-	<key>LSMinimumSystemVersion</key>
-	<string>12.0</string>
-	<key>LSRequiresIPhoneOS</key>
-	<true/>
-	<key>NSAppTransportSecurity</key>
-	<dict>
-		<key>NSAllowsArbitraryLoads</key>
-		<false/>
-		<key>NSAllowsLocalNetworking</key>
-		<true/>
-	</dict>
-	<key>NSCameraUsageDescription</key>
-	<string>需要访问相机权限以扫描二维码</string>
-	<key>NSPhotoLibraryUsageDescription</key>
-	<string>需要访问照片权限以选择图片</string>
-	<key>NSUserActivityTypes</key>
-	<array>
-		<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
-	</array>
-	<key>RCTNewArchEnabled</key>
-	<true/>
-	<key>UILaunchStoryboardName</key>
-	<string>SplashScreen</string>
-	<key>UIRequiredDeviceCapabilities</key>
-	<array>
-		<string>arm64</string>
-	</array>
-	<key>UIRequiresFullScreen</key>
-	<false/>
-	<key>UIStatusBarStyle</key>
-	<string>UIStatusBarStyleDefault</string>
-	<key>UISupportedInterfaceOrientations</key>
-	<array>
-		<string>UIInterfaceOrientationPortrait</string>
-		<string>UIInterfaceOrientationPortraitUpsideDown</string>
-	</array>
-	<key>UIUserInterfaceStyle</key>
-	<string>Light</string>
-	<key>UIViewControllerBasedStatusBarAppearance</key>
-	<false/>
-</dict>
-</plist>
+  <dict>
+    <key>CADisableMinimumFrameDurationOnPhone</key>
+    <true/>
+    <key>CFBundleDevelopmentRegion</key>
+    <string>$(DEVELOPMENT_LANGUAGE)</string>
+    <key>CFBundleDisplayName</key>
+    <string>借贷助手</string>
+    <key>CFBundleExecutable</key>
+    <string>$(EXECUTABLE_NAME)</string>
+    <key>CFBundleIdentifier</key>
+    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+    <key>CFBundleInfoDictionaryVersion</key>
+    <string>6.0</string>
+    <key>CFBundleName</key>
+    <string>$(PRODUCT_NAME)</string>
+    <key>CFBundlePackageType</key>
+    <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
+    <key>CFBundleShortVersionString</key>
+    <string>1.0.0</string>
+    <key>CFBundleSignature</key>
+    <string>????</string>
+    <key>CFBundleURLTypes</key>
+    <array>
+      <dict>
+        <key>CFBundleURLSchemes</key>
+        <array>
+          <string>loanassistant</string>
+          <string>com.cdloan.assistant</string>
+        </array>
+      </dict>
+    </array>
+    <key>CFBundleVersion</key>
+    <string>1</string>
+    <key>LSMinimumSystemVersion</key>
+    <string>12.0</string>
+    <key>LSRequiresIPhoneOS</key>
+    <true/>
+    <key>NSAppTransportSecurity</key>
+    <dict>
+      <key>NSAllowsArbitraryLoads</key>
+      <false/>
+      <key>NSAllowsLocalNetworking</key>
+      <true/>
+    </dict>
+    <key>NSCameraUsageDescription</key>
+    <string>需要访问相机权限以扫描二维码</string>
+    <key>NSPhotoLibraryUsageDescription</key>
+    <string>需要访问照片权限以选择图片</string>
+    <key>NSUserActivityTypes</key>
+    <array>
+      <string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
+    </array>
+    <key>RCTNewArchEnabled</key>
+    <true/>
+    <key>UILaunchStoryboardName</key>
+    <string>SplashScreen</string>
+    <key>UIRequiredDeviceCapabilities</key>
+    <array>
+      <string>arm64</string>
+    </array>
+    <key>UIRequiresFullScreen</key>
+    <false/>
+    <key>UIStatusBarStyle</key>
+    <string>UIStatusBarStyleDefault</string>
+    <key>UISupportedInterfaceOrientations</key>
+    <array>
+      <string>UIInterfaceOrientationPortrait</string>
+      <string>UIInterfaceOrientationPortraitUpsideDown</string>
+    </array>
+    <key>UIUserInterfaceStyle</key>
+    <string>Light</string>
+    <key>UIViewControllerBasedStatusBarAppearance</key>
+    <false/>
+  </dict>
+</plist>

+ 28 - 1
ios/LoanAssistant/Supporting/Expo.plist

@@ -4,6 +4,33 @@
   <dict>
     <key>EXUpdatesCheckOnLaunch</key>
     <string>ALWAYS</string>
+    <key>EXUpdatesCodeSigningCertificate</key>
+    <string>-----BEGIN CERTIFICATE-----&#xD;
+MIICzTCCAbWgAwIBAgIJVRhEHlaBbd3/MA0GCSqGSIb3DQEBCwUAMBAxDjAMBgNV&#xD;
+BAMTBWNkNzExMB4XDTI2MDQxNjA0NDMxNVoXDTM2MDQxNjA0NDMxNVowEDEOMAwG&#xD;
+A1UEAxMFY2Q3MTEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCsNT1A&#xD;
+EX3N3s/tAl4wQCubPWAM4Twh2EVnItwE1WgXk/znnTVnhF7aO0UEqTJcbRPh42jY&#xD;
+bC7Rbz8D6PO8sCPKW36sxRPpGTJXhkiP3cVGJ9UIO1TSIPTuPwMe6HK9B4dmiZvy&#xD;
+4qngttLFRJfIiHLisf5ckJFXMtcR8P3wFAm6YmlThGmdmwnDT1Z7FyPjMniJCTIG&#xD;
+NWOMIWkLMmfe/uMAhXEOC9GmQKLFJKUgJgy9sh0MRpjqdxgrEsuZ6k1V1Ok589BC&#xD;
+Y3gVRizY1jdEvctxYvy08TSQRQ5FF0+aIr7bmBDmlKipb2DFZFJ8ezbNJpkdZZgH&#xD;
+G0nUvoh7iOcgpk9jAgMBAAGjKjAoMA4GA1UdDwEB/wQEAwIHgDAWBgNVHSUBAf8E&#xD;
+DDAKBggrBgEFBQcDAzANBgkqhkiG9w0BAQsFAAOCAQEAUzogAlwcZyQjoyJifKaG&#xD;
+swKTfc5a8lrR1Oo2j6y/U4p9Ce9w9WrNxwHgjIsD/QrXsvwmcuaoeRw5jeha5tHo&#xD;
+eG3UNS2gT9K1LibVTEUa44fyvhrMjs7IMu3gAWYAWXm/3M3Bu6AGnGw4beT05Gdp&#xD;
+8CFMAYfs2TW8IQLTh2bfUnMqN+bl4YuLiE3bsx+MV/UnYxCI8XuJ2N3xdGjRaj0f&#xD;
+NQ5vmWaVdoRq93BqN6k1i+rCAY7f8+ESufbdehfhrvfjGKAXvy8FuLrFzymgXoaF&#xD;
+H08s7Sen5SsK9w6ID8+Pbz+CGs7UWK3URri0kTfJ9dwgL4ilq1At/pYZ8Zid3Ljx&#xD;
+FQ==&#xD;
+-----END CERTIFICATE-----&#xD;
+</string>
+    <key>EXUpdatesCodeSigningMetadata</key>
+    <dict>
+      <key>keyid</key>
+      <string>main</string>
+      <key>alg</key>
+      <string>rsa-v1_5-sha256</string>
+    </dict>
     <key>EXUpdatesEnabled</key>
     <true/>
     <key>EXUpdatesLaunchWaitMs</key>
@@ -11,6 +38,6 @@
     <key>EXUpdatesRuntimeVersion</key>
     <string>1.0.0</string>
     <key>EXUpdatesURL</key>
-    <string>https://loan.ewaga.com/airpatch/manifest</string>
+    <string>https://updates-loan.ewaga.com/api/manifest</string>
   </dict>
 </plist>

+ 30 - 17
src/app/_layout.tsx

@@ -12,7 +12,7 @@ import { Provider, Toast } from '@ant-design/react-native';
 import antdDefaultTheme from '@ant-design/react-native/lib/style/themes/default';
 import { useFonts } from 'expo-font';
 import { Stack } from 'expo-router';
-import { useEffect } from 'react';
+import { useEffect, useState } from 'react';
 
 const antdTheme = antdDefaultTheme;
 
@@ -30,40 +30,53 @@ export const DefaultTheme: Theme = {
 };
 
 export default function RootLayout() {
+  const [initing, setIniting] = useState(true);
 
-  const up = updates.useUpdates()
+ 
   // const colorScheme = useColorScheme();
   const [fontsLoaded] = useFonts({
     antoutline: require('@ant-design/icons-react-native/fonts/antoutline.ttf'),
   });
   useEffect(() => {
-    if (up.isUpdateAvailable) {
-      Toast.loading("版本更新中");
-    }
-  })
+const  l = Toast.loading("正在更新 ...");
+    
+    (async ()=> {
+      
+      try {
 
-  // useEffect(() => {
-  //   if (!fontsLoaded) {
-  //     console.warn('Ant Design icons font failed to load');
-  //   }
-  // }, [fontsLoaded]);
+      const res = await updates.checkForUpdateAsync();
+      // alert(JSON.stringify(res))
+      if (res.isAvailable) {
+        const u = await updates.fetchUpdateAsync();
+        await updates.reloadAsync();
+      } else {
+        Toast.remove(l);
+      }
+      } catch(e) {
+Toast.remove(l);
+        alert(e?.message || e+"");
+      }
+      setIniting(false);
+      
+    })();
+
+  }, []);
+
+
+  
 
-  if (!fontsLoaded) {
-    return <Provider theme={antdTheme}>
-      {null}
-      </Provider>; // 或者返回一个加载中的组件
-  }
 
   return (
     <ThemeProvider value={DefaultTheme}>
       <Provider theme={antdTheme}>
+        {(!initing && fontsLoaded) &&
         <AuthProvider>
           <AnimatedSplashOverlay />
           <Stack screenOptions={{ headerShown: false }}>
             <Stack.Screen name="(tabs)" />
             <Stack.Screen name="sign-in" />
           </Stack>
-        </AuthProvider>
+        </AuthProvider>}
       </Provider>
     </ThemeProvider>
   );

+ 1 - 1
src/app/sign-in.tsx

@@ -126,7 +126,7 @@ export default function SignInScreen({
                   <Ionicons name="business" size={30} color="#ffffff" />
                 </View>
                 <Text className="mb-2 text-4xl font-extrabold tracking-tight text-on-surface">
-                  欢迎回来
+                  欢迎 - 回来
                 </Text>
                 <Text className="text-base font-medium leading-7 text-on-surface-variant">
                   登录贷款助手,开启您的