提交 d74b1fc6 作者: 方治民

feat(util): 优化 API_URL_PREFIX 根据不同环境适配

上级 e65252df
...@@ -62,9 +62,9 @@ ...@@ -62,9 +62,9 @@
"@stomp/stompjs": "^6.1.2", "@stomp/stompjs": "^6.1.2",
"@vue/runtime-core": "^3.2.47", "@vue/runtime-core": "^3.2.47",
"@vue/shared": "^3.2.47", "@vue/shared": "^3.2.47",
"@vueuse/core": "^9.12.0", "@vueuse/core": "^9.13.0",
"@vueuse/shared": "^9.12.0", "@vueuse/shared": "^9.13.0",
"@zxcvbn-ts/core": "^2.2.0", "@zxcvbn-ts/core": "^2.2.1",
"ant-design-vue": "^3.2.15", "ant-design-vue": "^3.2.15",
"axios": "^0.26.1", "axios": "^0.26.1",
"codemirror": "^6.0.1", "codemirror": "^6.0.1",
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
"js-file-download": "^0.4.12", "js-file-download": "^0.4.12",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"mockjs": "^1.1.0", "mockjs": "^1.1.0",
"nanoid": "^4.0.0", "nanoid": "^4.0.1",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"path-to-regexp": "^6.2.1", "path-to-regexp": "^6.2.1",
"pinia": "^2.0.30", "pinia": "^2.0.30",
...@@ -98,9 +98,9 @@ ...@@ -98,9 +98,9 @@
"xlsx": "^0.18.5" "xlsx": "^0.18.5"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^17.4.2", "@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.2", "@commitlint/config-conventional": "^17.4.4",
"@iconify/json": "^2.2.15", "@iconify/json": "^2.2.24",
"@purge-icons/generated": "^0.8.1", "@purge-icons/generated": "^0.8.1",
"@types/codemirror": "^5.60.7", "@types/codemirror": "^5.60.7",
"@types/crypto-js": "^4.1.1", "@types/crypto-js": "^4.1.1",
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
"@types/lodash": "^4.14.191", "@types/lodash": "^4.14.191",
"@types/lodash-es": "^4.17.6", "@types/lodash-es": "^4.17.6",
"@types/mockjs": "^1.0.7", "@types/mockjs": "^1.0.7",
"@types/node": "^18.11.18", "@types/node": "^18.14.0",
"@types/nprogress": "^0.2.0", "@types/nprogress": "^0.2.0",
"@types/qrcode": "^1.5.0", "@types/qrcode": "^1.5.0",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",
...@@ -118,23 +118,23 @@ ...@@ -118,23 +118,23 @@
"@types/sockjs-client": "^1.5.1", "@types/sockjs-client": "^1.5.1",
"@types/sortablejs": "^1.15.0", "@types/sortablejs": "^1.15.0",
"@types/stompjs": "^2.3.5", "@types/stompjs": "^2.3.5",
"@typescript-eslint/eslint-plugin": "^5.50.0", "@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.50.0", "@typescript-eslint/parser": "^5.52.0",
"@vitejs/plugin-legacy": "^2.3.1", "@vitejs/plugin-legacy": "^2.3.1",
"@vitejs/plugin-vue": "^3.2.0", "@vitejs/plugin-vue": "^3.2.0",
"@vitejs/plugin-vue-jsx": "^1.3.10", "@vitejs/plugin-vue-jsx": "^1.3.10",
"@vue/compiler-dom": "^3.2.47", "@vue/compiler-dom": "^3.2.47",
"@vue/compiler-sfc": "3.2.31", "@vue/compiler-sfc": "3.2.31",
"@vue/test-utils": "^2.2.10", "@vue/test-utils": "^2.3.0",
"autoprefixer": "^10.4.13", "autoprefixer": "^10.4.13",
"commitizen": "^4.3.0", "commitizen": "^4.3.0",
"conventional-changelog-cli": "^2.2.2", "conventional-changelog-cli": "^2.2.2",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"cz-conventional-changelog": "^3.3.0", "cz-conventional-changelog": "^3.3.0",
"cz-git": "^1.4.1", "cz-git": "^1.5.0",
"czg": "^1.4.1", "czg": "^1.5.0",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"eslint": "^8.33.0", "eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0", "eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.9.0", "eslint-plugin-vue": "^9.9.0",
...@@ -147,29 +147,29 @@ ...@@ -147,29 +147,29 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"picocolors": "^1.0.0", "picocolors": "^1.0.0",
"pont-engine": "^1.5.5", "pont-engine": "^1.5.7",
"postcss": "^8.4.21", "postcss": "^8.4.21",
"postcss-html": "^1.5.0", "postcss-html": "^1.5.0",
"postcss-less": "^6.0.0", "postcss-less": "^6.0.0",
"prettier": "^2.8.3", "prettier": "^2.8.4",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rollup": "^2.79.1", "rollup": "^2.79.1",
"rollup-plugin-visualizer": "^5.9.0", "rollup-plugin-visualizer": "^5.9.0",
"sort-package-json": "^1.57.0", "sort-package-json": "^1.57.0",
"stylelint": "^14.16.1", "stylelint": "^14.16.1",
"stylelint-config-prettier": "^9.0.4", "stylelint-config-prettier": "^9.0.5",
"stylelint-config-recommended": "^9.0.0", "stylelint-config-recommended": "^9.0.0",
"stylelint-config-recommended-vue": "^1.4.0", "stylelint-config-recommended-vue": "^1.4.0",
"stylelint-config-standard": "^29.0.0", "stylelint-config-standard": "^29.0.0",
"stylelint-order": "^5.0.0", "stylelint-order": "^5.0.0",
"terser": "^5.16.2", "terser": "^5.16.4",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^4.9.5", "typescript": "^4.9.5",
"unplugin-auto-import": "^0.12.2", "unplugin-auto-import": "^0.12.2",
"vite": "^3.2.5", "vite": "^3.2.5",
"vite-plugin-compression": "^0.5.1", "vite-plugin-compression": "^0.5.1",
"vite-plugin-html": "^3.2.0", "vite-plugin-html": "^3.2.0",
"vite-plugin-mkcert": "^1.12.0", "vite-plugin-mkcert": "^1.13.1",
"vite-plugin-mock": "^2.9.6", "vite-plugin-mock": "^2.9.6",
"vite-plugin-purge-icons": "^0.9.2", "vite-plugin-purge-icons": "^0.9.2",
"vite-plugin-pwa": "^0.13.3", "vite-plugin-pwa": "^0.13.3",
...@@ -179,7 +179,7 @@ ...@@ -179,7 +179,7 @@
"vite-plugin-vue-setup-extend": "^0.4.0", "vite-plugin-vue-setup-extend": "^0.4.0",
"vite-plugin-windicss": "^1.8.10", "vite-plugin-windicss": "^1.8.10",
"vue-eslint-parser": "^9.1.0", "vue-eslint-parser": "^9.1.0",
"vue-tsc": "^1.0.24" "vue-tsc": "^1.1.4"
}, },
"engines": { "engines": {
"node": ">=14" "node": ">=14"
......
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
const globSetting = useGlobSetting()
let HOST = 'localhost' let HOST = 'localhost'
let API_URL = `${HOST}` let API_URL = `${HOST}`
const globSetting = useGlobSetting() let API_URL_PREFIX = globSetting.urlPrefix
const API_URL_PREFIX = globSetting.urlPrefix
// ============================================================================= // =============================================================================
// ✨ 生产环境 // ✨ 生产环境
// HOST = 'https://beta.app.yiring.com' // HOST = 'https://beta.app.yiring.com'
// API_URL = `${HOST}` // API_URL = `${HOST}`
// API_URL_PREFIX = globSetting.urlPrefix
// 📖 开发环境 // 📖 开发环境
HOST = globSetting.apiUrl HOST = globSetting.apiUrl
API_URL = `${HOST}` API_URL = `${HOST}`
API_URL_PREFIX = globSetting.urlPrefix
// 🔦 检查生产环境,使用对应 env 中的配置,保留原有方式方便开发中调试 // 🔦 检查生产环境,使用对应 env 中的配置,保留原有方式方便开发中调试
API_URL = import.meta.env.MODE !== 'development' ? globSetting.apiUrl : API_URL if (import.meta.env.MODE !== 'development') {
API_URL = globSetting.apiUrl
API_URL_PREFIX = globSetting.urlPrefix
}
// 📢 如果使用代理访问网站,则默认使用代理 API 地址 // 📢 如果使用代理访问网站,则默认使用代理 API 地址
// API_URL = isProxy(window.location.host) ? `http://proxy.yiring.com` : API_URL // API_URL = isProxy(window.location.host) ? `http://proxy.yiring.com` : API_URL
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论