liming 3 nedēļas atpakaļ
vecāks
revīzija
f33df87307

+ 18 - 9
capacitor.config.ts

@@ -1,19 +1,17 @@
 import { CapacitorConfig } from '@capacitor/cli';
-// import { updateVersion } from './scripts/sync-version';
+import { updateVersion } from './scripts/sync-version';
 
-// updateVersion()
+updateVersion()
+
+
+
+// 获取本地服务
+console.log("import.meta.env=", process.env.DAPP_BUILD)
 
 const config: CapacitorConfig = {
   appId: 'com.example.app',
   appName: 'AngelToken',
   webDir: 'dist',
-
-  // 开发服务器配置(热更新用)
-  server: {
-    url: 'http://192.168.0.59:5173',
-    cleartext: true,          // 允许HTTP明文通信(仅开发环境)
-    allowNavigation: ['*']    // 允许任意URL导航
-  },
   // 插件配置
   plugins: {
     CapacitorAssets: {
@@ -45,5 +43,16 @@ const config: CapacitorConfig = {
     }
   }
 };
+// 开发服务器配置(热更新用)
+if (process.env.DAPP_BUILD != "1") {
+  config.server = {
+    url: 'http://192.168.0.59:5173',
+    cleartext: true,          // 允许HTTP明文通信(仅开发环境)
+    allowNavigation: ['*']    // 允许任意URL导航
+  }
+}
+
+
+
 
 export default config;

+ 7 - 6
package.json

@@ -1,18 +1,18 @@
 {
   "name": "wallet_app",
-  "version": "2.0.0",
+  "version": "1.0.0",
   "private": true,
   "type": "module",
   "scripts": {
-    "dev": "vite --host",
-    "s": "npx cap sync",
+    "dev": "vite --host", 
+    "s": "cross-env DAPP_BUILD=1 npx cap sync",
     "a": "npx cap run android --live-reload --host=192.168.0.59 --port=5173",
     "app": "npx cap run android --live-reload --host=192.168.0.70 --port=5173",
     "ios": "npx cap run ios --live-reload --host=192.168.0.59 --port=5173",
     "android": "npx cap add android && npx cap sync",
     "android:clean": "(cd android && ./gradlew clean)",
-    "build": "vite build && npx cap copy",
-    "build:apk": "vite build && npx cap copy && (cd android && ./gradlew assembleRelease)",
+    "build": "vite build",
+    "build:apk": "npm run s && cross-env DAPP_BUILD=1 npx cap copy  && (cd android && ./gradlew assembleRelease)",
     "build:apk:windows": "vite build && npx cap copy && cd android && .\\gradlew.bat build",
     "icon": "npx capacitor-assets generate --android",
     "preview": "vite preview"
@@ -20,7 +20,7 @@
   "dependencies": {
     "@aparajita/capacitor-biometric-auth": "^9.0.0",
     "@capacitor/android": "^7.2.0",
-    "@capacitor/app": "^7.0.1", 
+    "@capacitor/app": "^7.0.1",
     "@capacitor/cli": "^7.2.0",
     "@capacitor/core": "^7.2.0",
     "@capacitor/device": "^7.0.1",
@@ -56,6 +56,7 @@
     "@vitejs/plugin-vue-jsx": "^5.0.1",
     "code-inspector-plugin": "^0.20.12",
     "cordova-plugin-console": "^1.1.0",
+    "cross-env": "^7.0.3",
     "fast-glob": "^3.3.3",
     "unplugin-auto-import": "^19.3.0",
     "vite": "^6.2.4",

+ 31 - 18
scripts/sync-version.js

@@ -1,34 +1,47 @@
 import fs from "fs";
 import path from "path";
 
+ 
+
 export const updateVersion = () => {
   // 读取 package.json 版本
   const packageJson = JSON.parse(fs.readFileSync("./package.json", "utf8"));
   const version = packageJson.version;
- 
+
   const rootDir = process.cwd();
 
   // 更新 Android 版本
-  const androidBuildGradlePath = path.join(
-    rootDir,
-    "android/app/build.gradle"
-  );
-  let androidBuildGradle = fs.readFileSync(androidBuildGradlePath, "utf8");
-  androidBuildGradle = androidBuildGradle.replace(
-    /versionName\s+".*?"/,
-    `versionName "${version}"`
-  );
-  fs.writeFileSync(androidBuildGradlePath, androidBuildGradle);
+  const androidBuildGradlePath = path.join(rootDir, "android/app/build.gradle");
+  if (fs.existsSync(androidBuildGradlePath)) {
+    let androidBuildGradle = fs.readFileSync(androidBuildGradlePath, "utf8");
+    androidBuildGradle = androidBuildGradle.replace(
+      /versionName\s+".*?"/,
+      `versionName "${version}"`
+    );
+    fs.writeFileSync(androidBuildGradlePath, androidBuildGradle);
+  } else {
+    console.log("没有找到 Android build.gradle 文件。");
+  }
 
   // 更新 iOS 版本
   const iosPlistPath = path.join(rootDir, "ios/App/App/Info.plist");
-  let iosPlist = fs.readFileSync(iosPlistPath, "utf8");
-  iosPlist = iosPlist.replace(
-    /<key>CFBundleShortVersionString<\/key>\s*<string>.*?<\/string>/,
-    `<key>CFBundleShortVersionString</key>\n\t<string>${version}</string>`
-  );
-  fs.writeFileSync(iosPlistPath, iosPlist);
+  if (fs.existsSync(iosPlistPath)) {
+    let iosPlist = fs.readFileSync(iosPlistPath, "utf8");
+    iosPlist = iosPlist.replace(
+      /<key>CFBundleShortVersionString<\/key>\s*<string>.*?<\/string>/,
+      `<key>CFBundleShortVersionString</key>\n\t<string>${version}</string>`
+    );
+    fs.writeFileSync(iosPlistPath, iosPlist);
+  } else {
+    console.log("没有找到iOS plist文件");
+  }
 
   console.log(`✅ 版本号已同步至: ${version}`);
-  return version
+  return version;
 };
+
+export const url = () => {
+  return import.meta.env;
+};
+
+

+ 1 - 1
src/App.vue

@@ -44,7 +44,7 @@ onBeforeMount(async () => {
   };
  
 
-  appStart()
+  // appStart()
 });
 </script>
 

+ 2 - 2
src/router/index.js

@@ -1,5 +1,5 @@
  
-import { createRouter, createWebHistory } from 'vue-router'
+import { createRouter, createWebHistory} from 'vue-router'
 import { systemRoutes } from './system'
 import { whitelistRoutes } from './whitelist'
 import { createRouterGuards } from './router.guards.js'
@@ -8,7 +8,7 @@ import { createRouterGuards } from './router.guards.js'
 
 
 const router = createRouter({
-  history: createWebHistory(import.meta.env.BASE_URL),
+  history: createWebHistory(),
   routes: [ 
     ...systemRoutes,
     ...whitelistRoutes

+ 13 - 1
src/router/router.guards.js

@@ -1,14 +1,26 @@
 import { useSystemStore } from "@/stores/modules/systemStore";
 import { useWalletStore } from "@/stores/modules/walletStore";
 
+import { whitelistRoutes } from "@/router/whitelist";
+
+
+
+const paths = whitelistRoutes.map(item =>{
+  return item.path
+});
+
 export function createRouterGuards(router) {
   const systemStore = useSystemStore();
   const walletStore = useWalletStore();
   // 路由拦截
   router.beforeEach(async (to, from, next) => {
+    if (paths.includes(to.path)) {
+      return next();
+    }
+    
     // 没有钱包,则跳转到login 页
     if (!walletStore.account || !systemStore.token) {
-      next("/login");
+      return next("/login");
     }
     next();
   });

+ 12 - 4
src/views/login/backupMnemonic/index.vue

@@ -1,6 +1,12 @@
 <template>
   <div class="container">
-    <div class="tag-container">
+    <van-skeleton
+      v-if="walletData.words.length == 0"
+      style="width: 100%"
+      title
+      :row="8"
+    />
+    <div class="tag-container" v-else>
       <van-tag
         v-for="item in walletData.words"
         :key="item"
@@ -43,12 +49,14 @@ useCopy();
 const router = useRouter();
 const walletStore = useWalletStore();
 
-const walletData = ref({});
+const walletData = ref({
+  words: [],
+});
 
 const next = async () => {
   // 登录
-  await walletStore.loginWithPrivateKey()
-  walletStore.$persist(); 
+  await walletStore.loginWithPrivateKey();
+  walletStore.$persist();
   router.push({
     path: "/wallet",
   });

+ 4 - 2
vite.config.js

@@ -12,7 +12,7 @@ import { resolve } from "path";
 // https://vite.dev/config/
 export default defineConfig(({ mode }) => {
   const env = loadEnv(mode, process.cwd());
- 
+
   return {
     base: "./",
     plugins: [
@@ -51,6 +51,9 @@ export default defineConfig(({ mode }) => {
     build: {
       minify: true, // 生产环境不生成sourcemap
       target: "es2015",
+      outDir: "dist",
+      assetsDir: "static", // 与 index.html 中的路径匹配
+      emptyOutDir: true,
       // 警报门槛,限制大文件大小
       chunkSizeWarningLimit: 5000,
       rollupOptions: {
@@ -85,7 +88,6 @@ export default defineConfig(({ mode }) => {
           changeOrigin: true,
           secure: true,
         },
-       
       },
     },
   };