From 720b71bd9aa389447a2b0aaf7662cba354a42114 Mon Sep 17 00:00:00 2001 From: wzy-warehouse <18135009705@163.com> Date: Tue, 7 Apr 2026 21:01:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=BA=E7=A1=80=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/config.json | 2 +- tsconfig.app.json | 16 ++++++------ tsconfig.json | 10 +++++--- tsconfig.node.json | 35 +++++++++++--------------- vite.config.ts | 56 ++++++++++++++++++++++-------------------- 5 files changed, 60 insertions(+), 59 deletions(-) diff --git a/src/config/config.json b/src/config/config.json index 7e8eb41..fe3bf47 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -1,5 +1,5 @@ { - "backendBaseUrl": "http://localhost:8080", + "backendBaseUrl": "__BACKEND_BASE_URL__", "apiBaseUrl": "/api", "noEncryptUrls": ["/crypto/sm2/public-key"], "tdMapToken": [ diff --git a/tsconfig.app.json b/tsconfig.app.json index 5c750c5..572f6da 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -1,14 +1,12 @@ { "extends": "@vue/tsconfig/tsconfig.dom.json", + "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], + "exclude": ["src/**/__tests__/*"], "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", - "types": ["vite/client"], - /* Linting */ - "noUnusedLocals": true, - "noUnusedParameters": true, - "erasableSyntaxOnly": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] -} + "paths": { + "@/*": ["./src/*"] + } + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 1ffef60..8f5fb56 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,11 @@ { "files": [], "references": [ - { "path": "./tsconfig.app.json" }, - { "path": "./tsconfig.node.json" } + { + "path": "./tsconfig.node.json" + }, + { + "path": "./tsconfig.app.json" + } ] -} +} \ No newline at end of file diff --git a/tsconfig.node.json b/tsconfig.node.json index d3c52ea..9826ef0 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -1,24 +1,19 @@ { + "extends": "@tsconfig/node22/tsconfig.json", + "include": [ + "vite.config.*", + "vitest.config.*", + "cypress.config.*", + "nightwatch.conf.*", + "playwright.config.*", + "eslint.config.*" + ], "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - "target": "es2023", - "lib": ["ES2023"], - "module": "esnext", - "types": ["node"], - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "moduleDetection": "force", "noEmit": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - /* Linting */ - "noUnusedLocals": true, - "noUnusedParameters": true, - "erasableSyntaxOnly": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["vite.config.ts"] -} + "module": "ESNext", + "moduleResolution": "Bundler", + "types": ["node"] + } +} \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 1be42b7..e27b8a4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,39 +1,43 @@ import { fileURLToPath, URL } from 'node:url' -import { defineConfig } from 'vite' +import { defineConfig, loadEnv } from 'vite' import vue from '@vitejs/plugin-vue' import vueDevTools from 'vite-plugin-vue-devtools' -import config from './src/config/config.json' import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' import cesium from 'vite-plugin-cesium' // https://vite.dev/config/ -export default defineConfig({ - plugins: [ - vue(), - vueDevTools(), - cesium(), - AutoImport({ - resolvers: [ElementPlusResolver()], - }), - Components({ - resolvers: [ElementPlusResolver()], - }), - ], - resolve: { - alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)), - }, - }, - server: { - proxy: { - '/api': { - target: config.backendBaseUrl, - changeOrigin: true, - rewrite: (p) => p.replace(/^\/api/, ''), +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd(), '') + const backendBaseUrl = env.VITE_BACKEND_BASE_URL + + return { + plugins: [ + vue(), + vueDevTools(), + cesium(), + AutoImport({ + resolvers: [ElementPlusResolver()], + }), + Components({ + resolvers: [ElementPlusResolver()], + }), + ], + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, - }, + server: { + proxy: { + '/api': { + target: backendBaseUrl, + changeOrigin: true, + rewrite: (p) => p.replace(/^\/api/, ''), + }, + }, + }, + } })