From 8550581d0e36cff6175cb1775935a08cbabca3db Mon Sep 17 00:00:00 2001 From: bob <312777916@qq.com> Date: Mon, 17 Feb 2025 15:53:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=8E=AF=E5=A2=83=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 ++-- .env.production | 10 ++++++++++ package.json | 5 +++-- src/js/utils/request.js | 2 +- vite.config.js | 4 +++- 5 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 .env.production diff --git a/.env.development b/.env.development index e214183..11a3e37 100644 --- a/.env.development +++ b/.env.development @@ -1,7 +1,7 @@ ENV = 'development' -# 客户端版本 -VITE_CLIENT_VERSION = 789654 +# REST API地址 +VITE_BASE_URL = '/api' # 配合vite.config.js中的代理配置解决跨域问题 # ws地址 VITE_WS_URL = 'ws://localhost:80/ws' diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..587d8a1 --- /dev/null +++ b/.env.production @@ -0,0 +1,10 @@ +ENV = 'production' + +# REST API地址 +VITE_BASE_URL = 'https://open-anylink.cn/' + +# ws地址 +VITE_WS_URL = 'wss://open-anylink.cn/ws' + +# title +VITE_TITLE = 'Open-AnyLink' \ No newline at end of file diff --git a/package.json b/package.json index 53049c2..e7a0e43 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,9 @@ "private": true, "type": "module", "scripts": { - "dev": "vite", - "build": "vite build", + "dev": "vite --mode development", + "build": "vite build --mode development", + "build:prod": "vite build --mode production", "preview": "vite preview", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore", "format": "prettier --write src/", diff --git a/src/js/utils/request.js b/src/js/utils/request.js index c8796bd..5a79228 100644 --- a/src/js/utils/request.js +++ b/src/js/utils/request.js @@ -6,7 +6,7 @@ import { v4 as uuidv4 } from 'uuid' import { ElMessage } from 'element-plus' import { CLIENT_TYPE, CLIENT_NAME, CLIENT_VERSION } from '@/const/userConst' -const baseURL = '/api' //配合vite.config.js中的代理配置解决跨域问题 +const baseURL = import.meta.env.VITE_BASE_URL const noTokenReqList = ['/user/login', '/user/register', '/user/validateAccount'] const instance = axios.create({ diff --git a/vite.config.js b/vite.config.js index 720aefb..dc58151 100644 --- a/vite.config.js +++ b/vite.config.js @@ -21,7 +21,9 @@ export default defineConfig({ changeOrigin: true, // 修改源 rewrite: (path) => path.replace(/^\/api/, '') // /api 替换为空字符串 } - } + }, + host: '0.0.0.0', + port: 8080 }, // 屏蔽告警:The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. css: {