From 816aa417b983e3e85f8b570158c5ee36d2f1fcce Mon Sep 17 00:00:00 2001 From: guoapeng Date: Tue, 29 Apr 2025 21:37:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A1=B9=E7=9B=AE=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.dev | 3 +- .env.pre | 3 +- .env.prod | 3 +- .env.test | 3 +- package.json | 9 +- src/libs/http.ts | 2 +- src/views/debug/index.vue | 306 +++++++++++++++++++++++----------------------- vite.config.ts | 174 +++++++++++++------------- 8 files changed, 256 insertions(+), 247 deletions(-) diff --git a/.env.dev b/.env.dev index 61a3c8c..2e2fb1d 100644 --- a/.env.dev +++ b/.env.dev @@ -3,4 +3,5 @@ FT_NODE_ENV=dev FT_WS_URL=ws://localhost:9527 -FT_PROXY=http://localhost:8080 \ No newline at end of file +FT_PROXY=http://localhost:8080 +FT_API_BASE=/api \ No newline at end of file diff --git a/.env.pre b/.env.pre index 6485b6d..12725ec 100644 --- a/.env.pre +++ b/.env.pre @@ -3,4 +3,5 @@ FT_NODE_ENV=pre FT_WS_URL=ws://192.168.1.140:8080/ws -FT_PROXY=http://192.168.1.140 \ No newline at end of file +FT_PROXY=http://192.168.1.140 +FT_API_BASE=/api \ No newline at end of file diff --git a/.env.prod b/.env.prod index 4c0f215..8fb9dff 100644 --- a/.env.prod +++ b/.env.prod @@ -3,4 +3,5 @@ FT_NODE_ENV=prod FT_WS_URL=ws://192.168.100.168:8080/ws -FT_PROXY=http://192.168.1.168 \ No newline at end of file +FT_PROXY=http://192.168.1.168 +FT_API_BASE=/api \ No newline at end of file diff --git a/.env.test b/.env.test index 87b732c..2bdfd60 100644 --- a/.env.test +++ b/.env.test @@ -3,4 +3,5 @@ FT_NODE_ENV=test FT_WS_URL=ws://192.168.1.121:8080/ws -FT_PROXY=http://192.168.1.121:8080 \ No newline at end of file +FT_PROXY=http://192.168.1.121:8080 +FT_API_BASE=/api \ No newline at end of file diff --git a/package.json b/package.json index 663cb18..8f48915 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,10 @@ "keywords": [], "main": "index.js", "scripts": { - "dev:server": "node server/index.js", - "dev": "vite --mode dev", - "dev:test": "vite --mode test", - "dev:prod": "vite --mode prod", + "dev": "concurrently -n server,client -c green,blue \"node server/index.js\" \"vite --mode dev\"", + "test": "vite --mode test", + "prod": "vite --mode prod", + "pre": "vite --mode pre", "build": "vite build --mode dev", "build:test": "vite build --mode test", "build:prod:patch": "node increment-version.js patch && vite build --mode prod", @@ -57,6 +57,7 @@ "@typescript-eslint/parser": "^8.25.0", "@vitejs/plugin-vue": "^5.2.1", "@vue/eslint-config-prettier": "^10.2.0", + "concurrently": "^9.1.2", "eslint": "^9.21.0", "eslint-config-prettier": "^10.0.2", "eslint-plugin-prettier": "^5.2.3", diff --git a/src/libs/http.ts b/src/libs/http.ts index 33a8e62..c0c0fe7 100644 --- a/src/libs/http.ts +++ b/src/libs/http.ts @@ -4,7 +4,7 @@ import { FtMessage } from 'libs/message' import { getToken } from 'libs/token' const http = axios.create({ - baseURL: `/api`, + baseURL: import.meta.env.FT_API_BASE, timeout: 1000 * 60, }) diff --git a/src/views/debug/index.vue b/src/views/debug/index.vue index bf41941..540affd 100644 --- a/src/views/debug/index.vue +++ b/src/views/debug/index.vue @@ -328,130 +328,141 @@ const door_stop = async () => { - 升降电机 + X轴电机
- + - + + + + 回原点 + + + 开始 + + + 停止 + + - - 上升 - - - 下降 - - - 停止 -
- 加热棒 + Y轴电机
- - + + - - - 开始加热 - - - 停止加热 - + + + + - - 开始恒温 + + 回原点 - - 停止恒温 + + 开始 + + + 停止
- 拍子 -
- - 启动吸附 - - - 停止吸附 - -
- 风扇 -
- - 打开风扇 - - - 关闭风扇 - -
-
- - + Z轴电机
- - + + - - + + - - 抬升 + + 回原点 - - 下降 + + 开始 + + 停止 + + + +
+ 夹爪舵机 +
+ + + + + - - 复位 + + 打开 - + + 闭合 + + 停止
+ + +
+ + 开门 + + + 关门 + + + 停止 + +
+
@@ -601,141 +612,130 @@ const door_stop = async () => { - X轴电机 + 升降电机
- + - + - - - 回原点 - - - 开始 - - - 停止 - - + + 上升 + + + 下降 + + + 停止 +
- Y轴电机 + 加热棒
- - - - - - - + + - - 回原点 + + 开始加热 - - 开始 + + 停止加热 - - 停止 + + + + 开始恒温 + + + 停止恒温
- Z轴电机 + 拍子 +
+ + 启动吸附 + + + 停止吸附 + +
+ 风扇 +
+ + 打开风扇 + + + 关闭风扇 + +
+
+ +
- - + + - - + + - - 回原点 - - - 开始 + + 抬升 - - 停止 + + 下降 - -
- 夹爪舵机 -
- - - - - - - - 打开 - - - 闭合 + + 复位 - + 停止
- - -
- - 开门 - - - 关门 - - - 停止 - -
-
diff --git a/vite.config.ts b/vite.config.ts index 2319096..dc56826 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,105 +2,109 @@ import { resolve } from 'node:path' import vue from '@vitejs/plugin-vue' import AutoImport from 'unplugin-auto-import/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' -import { defineConfig } from 'vite' +import { defineConfig, loadEnv } from 'vite' import viteCompression from 'vite-plugin-compression' import eslintPlugin from 'vite-plugin-eslint' import packageJson from './package.json' const Timestamp = new Date().getTime() -export default defineConfig({ - define: { - __APP_VERSION__: JSON.stringify(packageJson.version), - }, - base: './', - envPrefix: 'FT_', - esbuild: { +export default defineConfig(({ mode }) => { + // eslint-disable-next-line node/prefer-global/process + const env = loadEnv(mode, process.cwd(), 'FT_') + return { + define: { + __APP_VERSION__: JSON.stringify(packageJson.version), + }, + base: './', + envPrefix: 'FT_', + esbuild: { // eslint-disable-next-line node/prefer-global/process - drop: process.env.NODE_ENV === 'production' ? ['console'] : [], - }, - build: { - sourcemap: false, - outDir: `dist-v${packageJson.version}`, - rollupOptions: { - output: { - manualChunks(id) { - if (id.includes('node_modules')) { - return id.toString().split('node_modules/')[1].split('/')[0].toString() - } - }, - chunkFileNames: (chunkInfo) => { - const facadeModuleId = chunkInfo.facadeModuleId - ? chunkInfo.facadeModuleId.split('/') - : [] - const fileName = facadeModuleId.slice(-2)[0] || '[name]' - return `js/${fileName}/[name].[hash].${Timestamp}.js` + drop: process.env.NODE_ENV === 'production' ? ['console'] : [], + }, + build: { + sourcemap: false, + outDir: `dist-v${packageJson.version}`, + rollupOptions: { + output: { + manualChunks(id) { + if (id.includes('node_modules')) { + return id.toString().split('node_modules/')[1].split('/')[0].toString() + } + }, + chunkFileNames: (chunkInfo) => { + const facadeModuleId = chunkInfo.facadeModuleId + ? chunkInfo.facadeModuleId.split('/') + : [] + const fileName = facadeModuleId.slice(-2)[0] || '[name]' + return `js/${fileName}/[name].[hash].${Timestamp}.js` + }, }, }, }, - }, - plugins: [ - vue(), - AutoImport({ - imports: [ - 'vue', - 'vue-router', - { vue: ['withModifiers'] }, - { - from: 'element-plus/es', - imports: ['TabPaneName'], - type: true, + plugins: [ + vue(), + AutoImport({ + imports: [ + 'vue', + 'vue-router', + { vue: ['withModifiers'] }, + { + from: 'element-plus/es', + imports: ['TabPaneName'], + type: true, + }, + ], + dts: true, + eslintrc: { + enabled: true, }, - ], - dts: true, - eslintrc: { - enabled: true, + resolvers: [ElementPlusResolver({ importStyle: 'sass' })], + }), + eslintPlugin({ + cache: false, // 禁用缓存,以确保每次修改后都能及时生效 + }), + viteCompression({ + verbose: true, + disable: false, + threshold: 10240, + algorithm: 'gzip', + ext: '.gz', + }), + ], + resolve: { + alias: { + '@': resolve(__dirname, './src'), + 'apis': resolve(__dirname, 'src/apis'), + 'assets': resolve(__dirname, 'src/assets'), + 'components': resolve(__dirname, 'src/components'), + 'hooks': resolve(__dirname, 'src/hooks'), + 'libs': resolve(__dirname, 'src/libs'), + 'stores': resolve(__dirname, 'src/stores'), + 'views': resolve(__dirname, 'src/views'), + 'router': resolve(__dirname, 'src/router'), }, - resolvers: [ElementPlusResolver({ importStyle: 'sass' })], - }), - eslintPlugin({ - cache: false, // 禁用缓存,以确保每次修改后都能及时生效 - }), - viteCompression({ - verbose: true, - disable: false, - threshold: 10240, - algorithm: 'gzip', - ext: '.gz', - }), - ], - resolve: { - alias: { - '@': resolve(__dirname, './src'), - 'apis': resolve(__dirname, 'src/apis'), - 'assets': resolve(__dirname, 'src/assets'), - 'components': resolve(__dirname, 'src/components'), - 'hooks': resolve(__dirname, 'src/hooks'), - 'libs': resolve(__dirname, 'src/libs'), - 'stores': resolve(__dirname, 'src/stores'), - 'views': resolve(__dirname, 'src/views'), - 'router': resolve(__dirname, 'src/router'), }, - }, - css: { - preprocessorOptions: { - scss: { - additionalData: '@use "@/assets/styles/main.scss" as *;', + css: { + preprocessorOptions: { + scss: { + additionalData: '@use "@/assets/styles/main.scss" as *;', + }, }, }, - }, - // 本地化配置 - server: { - open: true, - hmr: true, - port: 3010, - host: '0.0.0.0', - proxy: { - '/api': { - target: 'http://192.168.1.199:8080', - // secure: false, - changeOrigin: true, // 是否跨域 - rewrite: path => path.replace(/^\/api/, 'api'), + // 本地化配置 + server: { + open: false, + hmr: true, + port: 3010, + host: '0.0.0.0', + proxy: { + [env.FT_API_BASE]: { + target: env.FT_PROXY, + // secure: false, + changeOrigin: true, // 是否跨域 + rewrite: path => path.replace(new RegExp(`^${env.FT_API_BASE}`), 'api'), + }, }, }, - }, + } })