Преглед изворни кода

修改公共部分链接方法

yangg пре 6 месеци
родитељ
комит
8279c61935
8 измењених фајлова са 47 додато и 53 уклоњено
  1. 2 0
      .env
  2. 2 0
      .env.development
  3. 2 0
      .env.production
  4. 2 2
      package.json
  5. 1 1
      src/components/c-menu/index.vue
  6. 1 1
      src/router/index.js
  7. 2 2
      src/views/report.vue
  8. 35 47
      vite.config.js

+ 2 - 0
.env

@@ -0,0 +1,2 @@
+VITE_BASE_AI_API=http://192.68.66.187:8082
+ 

+ 2 - 0
.env.development

@@ -0,0 +1,2 @@
+NODE_ENV=development
+VITE_BASE_AI_API=http://192.168.66.187:8082

+ 2 - 0
.env.production

@@ -0,0 +1,2 @@
+NODE_ENV=production
+VITE_BASE_AI_API=https://ylaiapi.raycos.com.cn

+ 2 - 2
package.json

@@ -4,8 +4,8 @@
   "version": "0.0.0",
   "type": "module",
   "scripts": {
-    "dev": "vite",
-    "build": "vite build",
+    "dev": "vite --mode development",
+    "build": "vite build --mode production",
     "preview": "vite preview"
   },
   "dependencies": {

+ 1 - 1
src/components/c-menu/index.vue

@@ -172,7 +172,7 @@ export default defineComponent({
           z-index: 9;
         }
         &:hover {
-          color: @active;
+          /* color: @active; */
           background-color: #2546B1;
         }
       }

+ 1 - 1
src/router/index.js

@@ -2,7 +2,7 @@ import { createRouter, createWebHistory } from 'vue-router'
 import { ROUTE } from './menu.js'
 
 const route = createRouter({
-    history: createWebHistory(process.env.BASE_URL),
+    history: createWebHistory(import.meta.env.BASE_URL),
     scrollBehavior: () => ({ y: 0 }),
     routes: ROUTE
 })

+ 2 - 2
src/views/report.vue

@@ -430,7 +430,7 @@ const uploadFile = async (file) => {
     formData.append("file", file);
 
     const response = await axios.post(
-      "https://ylaiapi.raycos.com.cn/upload/file",
+      `${import.meta.env.VITE_BASE_AI_API}/upload/file`,
       formData,
       {
         headers: {
@@ -577,7 +577,7 @@ const sendMessage = async () => {
 
   try {
     const response = await axios.post(
-      "https://ylaiapi.raycos.com.cn/chatbot/multimodal",
+      `${import.meta.env.VITE_BASE_AI_API}/chatbot/multimodal`,
       {
         message: currentInput,
         chat_config_id: "17",

+ 35 - 47
vite.config.js

@@ -1,4 +1,4 @@
-import { defineConfig } from 'vite'
+import { defineConfig, loadEnv } from 'vite'
 import vue from '@vitejs/plugin-vue'
 import vueJsx from '@vitejs/plugin-vue-jsx'
 import path from 'path'
@@ -10,57 +10,45 @@ function resolve(dir) {
     return path.join(__dirname, dir)
 }
 
-export default defineConfig({
+export default defineConfig(({ command, mode }) => {
+  // 加载env文件
+  const env = loadEnv(mode, process.cwd(), '')
+  
+  return {
     plugins: [
-        vue(),
-        vueJsx()
+      vue(),
+      vueJsx()
     ],
-    define: {
-        'process.env': {
-            BASE_URL: '/',
-            NODE_ENV: process.env.NODE_ENV,
-            API_URL: 'http://your-api-url',
-            // ... 其他环境变量
-        }
-    },
-    css: {
-        preprocessorOptions: {
-            less: {
-                javascriptEnabled: true,
-                additionalData: `@import "${path.resolve(__dirname, 'src/app.less')}";`
-            }
-        }
-    },
     resolve: {
-        alias: {
-            '@': resolve('src'),
-            '@api': resolve('src/api'),
-            '@assets': resolve('src/assets'),
-            '@layouts': resolve('src/layouts'),
-            '@static': resolve('src/static'),
-            '@components': resolve('src/components'),
-            '@router': resolve('src/router'),
-            '@utils': resolve('src/utils'),
-            '@store': resolve('src/store'),
-            '@views': resolve('src/views')
-        },
-        extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.vue']
+      alias: {
+        '@': resolve('src'),
+        '@api': resolve('src/api'),
+        '@assets': resolve('src/assets'),
+        '@layouts': resolve('src/layouts'),
+        '@static': resolve('src/static'),
+        '@components': resolve('src/components'),
+        '@router': resolve('src/router'),
+        '@utils': resolve('src/utils'),
+        '@store': resolve('src/store'),
+        '@views': resolve('src/views')
+      },
+      extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.vue']
     },
     server: {
-        port: 8003,
-        proxy: {
-            '/WebSocketConfig/': {
-                target: 'ws://test.com',
-                changeOrigin: true,
-                ws: true,
-            },
-            '/api/': {
-                target: 'http://test.com',
-                changeOrigin: true,
-                ws: false,
-            }
+      port: 8003,
+      proxy: {
+        '/WebSocketConfig/': {
+          target: 'ws://test.com',
+          changeOrigin: true,
+          ws: true,
+        },
+        '/api/': {
+          target: 'http://test.com',
+          changeOrigin: true,
+          ws: false,
         }
+      }
     },
-    productionSourceMap: false,
-    lintOnSave: false,
+    base: '/',
+  }
 })