CzRger 2 hafta önce
ebeveyn
işleme
b9bc1c3cdd
7 değiştirilmiş dosya ile 49 ekleme ve 24 silme
  1. 10 0
      .env.development
  2. 10 0
      .env.production
  3. 1 1
      index.html
  4. 1 0
      package.json
  5. 3 3
      public/config.js
  6. 2 2
      src/App.vue
  7. 22 18
      vite.config.ts

+ 10 - 0
.env.development

@@ -0,0 +1,10 @@
+# 本地环境
+NODE_ENV = development
+# 标题
+VITE_TITLE = 海关安检旅客查验一体化通道系统
+# 基础路径
+VITE_BASE = hg-lvke-web
+# 基础代理
+VITE_BASE_API_PROXY = /hg-lvke-api
+# 是否需要菜单  Y/N
+VITE_MENU = Y

+ 10 - 0
.env.production

@@ -0,0 +1,10 @@
+# 生产环境
+NODE_ENV = production
+# 标题
+VITE_TITLE = 海关安检旅客查验一体化通道系统
+# 基础路径
+VITE_BASE = hg-lvke-web
+# 基础代理
+VITE_BASE_API_PROXY = /hg-lvke-api
+# 是否需要菜单  Y/N
+VITE_MENU = N

+ 1 - 1
index.html

@@ -5,7 +5,7 @@
     <link rel="icon" href="/favicon.ico">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <script type="module" src="/config.js"></script>
-    <title>海关安检旅客查验一体化通道系统</title>
+    <title><{VITE_TITLE}></title>
   </head>
   <body>
     <div id="app"></div>

+ 1 - 0
package.json

@@ -8,6 +8,7 @@
     "build": "run-p type-check \"build-only {@}\" --",
     "preview": "vite preview",
     "build-only": "vite build",
+    "build-only:test": "vite build --mode development",
     "type-check": "vue-tsc --build --force",
     "lint": "eslint . --fix",
     "format": "prettier --write src/"

+ 3 - 3
public/config.js

@@ -3,8 +3,8 @@ window.$config = {
   SERVICE_ID: 'LKCY-YTH-WEB', //应用服务Id,同CACPAppCode
   SERVICE_NAME: 'lkcy-yth-web', //应用服务名
   SERVICE_PAGESIZE: 20,
-  SERVICE_API: '/api/service-api-name',//当前应用api地址,上线需要修改
+  SERVICE_API: '/api/service-api-name', //当前应用api地址,上线需要修改
   SERVICE_TIMEOUT: 10000, //请求超时时间
-  NEED_USER_AUTHORITY: true,//是否需要权限控制
-  FRAME_API: '/api/frame-api-service',//统一入口接口地址
+  NEED_USER_AUTHORITY: true, //是否需要权限控制
+  FRAME_API: import.meta.env.VITE_BASE_API_PROXY //统一入口接口地址
 }

+ 2 - 2
src/App.vue

@@ -1,7 +1,7 @@
 <template>
   <el-container class="container">
     <!-- 开发测试使用 -->
-    <el-aside width="190px" class="aside" v-if="DEV">
+    <el-aside width="190px" class="aside" v-if="VITE_MENU">
       <el-menu class="menu">
         <template v-for="rou in appRouter" :key="rou.name">
           <template v-if="rou.children?.length > 0">
@@ -54,7 +54,7 @@
 import { RouterView } from 'vue-router'
 import appRouter from '@/router/app-router'
 
-const { DEV } = import.meta.env
+const { VITE_MENU } = import.meta.env
 </script>
 
 <style scoped lang="less">

+ 22 - 18
vite.config.ts

@@ -1,28 +1,32 @@
 import { fileURLToPath, URL } from 'node:url'
 
-import { defineConfig } from 'vite'
+import { defineConfig, loadEnv } from 'vite'
 import vue from '@vitejs/plugin-vue'
 import vueJsx from '@vitejs/plugin-vue-jsx'
 import vueDevTools from 'vite-plugin-vue-devtools'
 
 // https://vitejs.dev/config/
-export default defineConfig({
-  plugins: [vue(), vueJsx(), vueDevTools()],
-  resolve: {
-    alias: {
-      '@': fileURLToPath(new URL('./src', import.meta.url)),
-      '@element-plus/icons-vue': '@cacp/svg-icons'
+export default defineConfig(({ mode }) => {
+  const env = loadEnv(mode, process.cwd())
+  const { VITE_BASE } = env
+  return {
+    plugins: [vue(), vueJsx(), vueDevTools()],
+    resolve: {
+      alias: {
+        '@': fileURLToPath(new URL('./src', import.meta.url)),
+        '@element-plus/icons-vue': '@cacp/svg-icons'
+      }
+    },
+    server: {
+      port: 8080,
+      // 是否自动在浏览器打开
+      open: true
+    },
+    base: '/' + VITE_BASE + '/',
+    build: {
+      target: 'esnext',
+      sourcemap: false,
+      outDir: VITE_BASE
     }
-  },
-  server: {
-    port: 8080,
-    // 是否自动在浏览器打开
-    open: true
-  },
-  base: '/hg-lvke-web/',
-  build: {
-    target: 'esnext',
-    sourcemap: false,
-    outDir: 'hg-lvke-web'
   }
 })