feat(env): 添加环境变量配置并优化代理设置
- 新增 .env 文件,配置不同环境下的基础 URL - 更新 vite.config.ts,添加环境变量加载和代理配置- 添加 request.js 工具类,用于处理 HTTP 请求 - 更新相关组件,集成新的请求方法
This commit is contained in:
10
.env
Normal file
10
.env
Normal file
@@ -0,0 +1,10 @@
|
||||
# .env
|
||||
VITE_APP_BASE_URL=http://192.168.3.7:15001/
|
||||
VITE_APP_ENV=development
|
||||
VITE_APP_CURRENTMODE=dev
|
||||
VITE_APP_BASEOSS=https://diaoyan-files.automark.cc
|
||||
VITE_APP_DELIVERY_BASEURL=https://javaxq.test.automark.cc/
|
||||
VITE_APP_MESSAGE_CENTER=http://gtech-gateway.dcin-test.digitalyili.com/apigtech/message-send-center/
|
||||
VITE_APP_SOCKETURL=wss://yls-api-uat.dctest.digitalyili.com/survey_sync
|
||||
VITE_APP_JSONPURL=https://iam-uat.dctest.digitalyili.com/idp/restful/getIDPToken
|
||||
VITE_APP_YQRURL=https://ocp-uat-ain.digitalyili.com
|
||||
@@ -1,2 +1,10 @@
|
||||
VITE_APP_BASE_URL = '/'
|
||||
VITE_APP_ENV = 'development'
|
||||
# .env.development
|
||||
VITE_APP_BASEURL=http://192.168.3.7:15001/api/
|
||||
VITE_APP_ENV=development
|
||||
VITE_APP_CURRENTMODE=dev
|
||||
VITE_APP_BASEOSS=https://diaoyan-files.automark.cc
|
||||
VITE_APP_DELIVERY_BASEURL=https://javaxq.test.automark.cc/
|
||||
VITE_APP_MESSAGE_CENTER=http://gtech-gateway.dcin-test.digitalyili.com/apigtech/message-send-center/
|
||||
VITE_APP_SOCKETURL=wss://yls-api-uat.dctest.digitalyili.com/survey_sync
|
||||
VITE_APP_JSONPURL=https://iam-uat.dctest.digitalyili.com/idp/restful/getIDPToken
|
||||
VITE_APP_YQRURL=https://ocp-uat-ain.digitalyili.com
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
VITE_APP_BASE_URL = 'https://xx.digitalyili.com'
|
||||
VITE_APP_ENV = 'prod'
|
||||
2
.env.sit
2
.env.sit
@@ -1,2 +0,0 @@
|
||||
VITE_APP_BASE_URL = 'https://sit.xx.digitalyili.com'
|
||||
VITE_APP_ENV = 'sit'
|
||||
2
.env.uat
2
.env.uat
@@ -1,2 +0,0 @@
|
||||
VITE_APP_BASE_URL = 'https://uat.xx.digitalyili.com'
|
||||
VITE_APP_ENV = 'uat'
|
||||
4
auto-imports.d.ts
vendored
4
auto-imports.d.ts
vendored
@@ -5,4 +5,6 @@
|
||||
// Generated by unplugin-auto-import
|
||||
// biome-ignore lint: disable
|
||||
export {}
|
||||
declare global {}
|
||||
declare global {
|
||||
|
||||
}
|
||||
|
||||
125
package-lock.json
generated
125
package-lock.json
generated
@@ -9,12 +9,15 @@
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"axios": "^1.8.2",
|
||||
"dotenv": "^16.4.7",
|
||||
"element-plus": "^2.7.8",
|
||||
"lodash": "^4.17.21",
|
||||
"pinia": "^2.1.7",
|
||||
"sortablejs": "^1.15.6",
|
||||
"uuid": "^11.1.0",
|
||||
"vant": "^4.9.17",
|
||||
"vite-plugin-vue": "^0.0.1",
|
||||
"vue": "^3.4.29",
|
||||
"vue-router": "^4.3.3",
|
||||
"vuex": "^4.1.0"
|
||||
@@ -4782,6 +4785,11 @@
|
||||
"resolved": "https://registry.npmmirror.com/async-validator/-/async-validator-4.2.5.tgz",
|
||||
"integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg=="
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"node_modules/available-typed-arrays": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmmirror.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
|
||||
@@ -4797,6 +4805,16 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.8.2.tgz",
|
||||
"integrity": "sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
"form-data": "^4.0.0",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
@@ -4974,7 +4992,6 @@
|
||||
},
|
||||
"node_modules/call-bind-apply-helpers": {
|
||||
"version": "1.0.2",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
@@ -5100,6 +5117,17 @@
|
||||
"integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/concat-map/-/concat-map-0.0.1.tgz",
|
||||
@@ -5311,6 +5339,14 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/detect-libc": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmmirror.com/detect-libc/-/detect-libc-1.0.3.tgz",
|
||||
@@ -5404,9 +5440,19 @@
|
||||
"url": "https://github.com/fb55/domutils?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.4.7",
|
||||
"resolved": "https://registry.npmmirror.com/dotenv/-/dotenv-16.4.7.tgz",
|
||||
"integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://dotenvx.com"
|
||||
}
|
||||
},
|
||||
"node_modules/dunder-proto": {
|
||||
"version": "1.0.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.1",
|
||||
@@ -5548,7 +5594,6 @@
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -5556,7 +5601,6 @@
|
||||
},
|
||||
"node_modules/es-errors": {
|
||||
"version": "1.3.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -5591,7 +5635,6 @@
|
||||
},
|
||||
"node_modules/es-object-atoms": {
|
||||
"version": "1.1.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
@@ -5602,7 +5645,6 @@
|
||||
},
|
||||
"node_modules/es-set-tostringtag": {
|
||||
"version": "2.1.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
@@ -6614,6 +6656,25 @@
|
||||
"integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.9",
|
||||
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.9.tgz",
|
||||
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"debug": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/for-each": {
|
||||
"version": "0.3.5",
|
||||
"resolved": "https://registry.npmmirror.com/for-each/-/for-each-0.3.5.tgz",
|
||||
@@ -6629,6 +6690,20 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.2.tgz",
|
||||
"integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"es-set-tostringtag": "^2.1.0",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
@@ -6652,7 +6727,6 @@
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.2",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
@@ -6697,7 +6771,6 @@
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.3.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
@@ -6720,7 +6793,6 @@
|
||||
},
|
||||
"node_modules/get-proto": {
|
||||
"version": "1.0.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dunder-proto": "^1.0.1",
|
||||
@@ -6914,7 +6986,6 @@
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.2.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -6978,7 +7049,6 @@
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"version": "1.1.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -6989,7 +7059,6 @@
|
||||
},
|
||||
"node_modules/has-tostringtag": {
|
||||
"version": "1.0.2",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"has-symbols": "^1.0.3"
|
||||
@@ -7003,7 +7072,6 @@
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.2",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
@@ -7826,7 +7894,6 @@
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -7908,6 +7975,25 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "9.0.3",
|
||||
"resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-9.0.3.tgz",
|
||||
@@ -8662,6 +8748,11 @@
|
||||
"react-is": "^16.13.1"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||
},
|
||||
"node_modules/punycode": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmmirror.com/punycode/-/punycode-2.3.1.tgz",
|
||||
@@ -10450,6 +10541,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vite-plugin-vue": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/vite-plugin-vue/-/vite-plugin-vue-0.0.1.tgz",
|
||||
"integrity": "sha512-PhAy+v+t6W3JAeqFxf6w/hGyURZ2qvrJMS/HTeCPLnfllz+O5wNP49TcAb4MROeif93kKIOigtDFJowaLuU+0w==",
|
||||
"deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."
|
||||
},
|
||||
"node_modules/vscode-uri": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/vscode-uri/-/vscode-uri-3.1.0.tgz",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"dev": "vite --mode development",
|
||||
"build": "run-p type-check \"build-only {@}\" --",
|
||||
"preview": "vite preview",
|
||||
"build-only": "vite build",
|
||||
@@ -14,12 +14,15 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"axios": "^1.8.2",
|
||||
"dotenv": "^16.4.7",
|
||||
"element-plus": "^2.7.8",
|
||||
"lodash": "^4.17.21",
|
||||
"pinia": "^2.1.7",
|
||||
"sortablejs": "^1.15.6",
|
||||
"uuid": "^11.1.0",
|
||||
"vant": "^4.9.17",
|
||||
"vite-plugin-vue": "^0.0.1",
|
||||
"vue": "^3.4.29",
|
||||
"vue-router": "^4.3.3",
|
||||
"vuex": "^4.1.0"
|
||||
|
||||
9
src/api/home/index.js
Normal file
9
src/api/home/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import request from '@/utils/request.js';
|
||||
|
||||
export function getQuestionList(params) {
|
||||
return request({
|
||||
url: '/console/template/list_shortcut',
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
}
|
||||
@@ -167,8 +167,8 @@ const getMaxDateLimit = computed(() => {
|
||||
props.format
|
||||
);
|
||||
const tempStr = '0000-12-31 23:59:59';
|
||||
const result =
|
||||
props.maxDate.length !== 0 && thisMax.length > props.maxDate.length
|
||||
const result
|
||||
= props.maxDate.length !== 0 && thisMax.length > props.maxDate.length
|
||||
? thisMax.slice(0, props.maxDate.length) + tempStr.slice(props.maxDate.length)
|
||||
: thisMax;
|
||||
return result.slice(0, props.format.length);
|
||||
@@ -191,8 +191,8 @@ function onChange({ selectedValues, columnIndex }) {
|
||||
renderMinuteColumns,
|
||||
renderSecondColumns
|
||||
];
|
||||
updateColumns[columnIndex] &&
|
||||
updateColumns[columnIndex](changeValue, getMinDateLimit.value, getMaxDateLimit.value, false);
|
||||
updateColumns[columnIndex]
|
||||
&& updateColumns[columnIndex](changeValue, getMinDateLimit.value, getMaxDateLimit.value, false);
|
||||
}
|
||||
|
||||
// 渲染全部列
|
||||
|
||||
12
src/config.js
Normal file
12
src/config.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// src/config.js
|
||||
export default {
|
||||
proxyUrl: import.meta.env.VITE_APP_BASEURL,
|
||||
proxyUrlDelivery: import.meta.env.VITE_APP_DELIVERY_BASEURL,
|
||||
proxyUrlMessageCenter: import.meta.env.VITE_APP_MESSAGE_CENTER,
|
||||
baseOss: import.meta.env.VITE_APP_BASEOSS,
|
||||
loginUrl: import.meta.env.VITE_APP_LOGIN,
|
||||
socketUrl: import.meta.env.VITE_APP_SOCKETURL,
|
||||
jsonpUrl: import.meta.env.VITE_APP_JSONPURL,
|
||||
jqrUrl: import.meta.env.VITE_APP_YQRURL,
|
||||
currentMode: import.meta.env.VITE_APP_CURRENTMODE
|
||||
};
|
||||
94
src/utils/request.js
Normal file
94
src/utils/request.js
Normal file
@@ -0,0 +1,94 @@
|
||||
import axios from 'axios';
|
||||
|
||||
// import router from '@/router/index';
|
||||
// import { A_COMMON_CLEAR_TOKEN } from '@/stores/constance/constance.common.js';
|
||||
|
||||
import * as config from '@/config.js';
|
||||
|
||||
console.log(config.default);
|
||||
// import {proxyUrl} from config.default
|
||||
//
|
||||
|
||||
const NODE_ENV = import.meta.env.VITE_APP_ENV;
|
||||
const baseURL = NODE_ENV === 'production' ? config.default.proxyUrl : '/backend-api';
|
||||
|
||||
// axios.defaults.withCredentials = true;
|
||||
|
||||
// create an axios instance
|
||||
const service = axios.create({
|
||||
baseURL: `${baseURL}`, // url = base url + request url
|
||||
// withCredentials: true, // send cookies when cross-domain requests
|
||||
timeout: 30000 // request timeout
|
||||
});
|
||||
|
||||
// request interceptor
|
||||
service.interceptors.request.use(
|
||||
(config) => {
|
||||
if (!config.headers) {
|
||||
config.headers.Accept = 'application/json';
|
||||
}
|
||||
config.headers.Authorization = `${localStorage.getItem('plantToken')}`;
|
||||
if (!config.headers.remoteIp) {
|
||||
config.baseURL += '/api';
|
||||
}
|
||||
// config.headers.remoteIp = localStorage.getItem('plantIp') || '127.0.0.1';
|
||||
// if (store.state.common.token) {
|
||||
// config.headers['Login-Type'] = 'pc';
|
||||
// config.headers.Authorization = `Bearer ${store.state.common.token}`;
|
||||
// }
|
||||
return config;
|
||||
},
|
||||
(error) => Promise.reject(error)
|
||||
);
|
||||
|
||||
// response interceptor
|
||||
service.interceptors.response.use(
|
||||
(response) => {
|
||||
if (
|
||||
response.status === 200 ||
|
||||
response.status === 201 ||
|
||||
response.status === 202 ||
|
||||
response.status === 204
|
||||
) {
|
||||
if (response.config.method === 'put') {
|
||||
// message.success('保存中...');
|
||||
}
|
||||
return Promise.resolve(response);
|
||||
}
|
||||
// return Promise.reject(/* new Error(response.message || 'Error') */);
|
||||
}
|
||||
// (error) => {
|
||||
// // for debug
|
||||
// if (error.response.status === 401) {
|
||||
// const query = router.currentRoute.value.query;
|
||||
// //关闭已弹出的所有弹框,防止弹框重叠
|
||||
// // Modal.destroyAll();
|
||||
// store.dispatch(A_COMMON_CLEAR_TOKEN);
|
||||
// window.parent.postMessage(
|
||||
// {
|
||||
// code: '301',
|
||||
// params: {}
|
||||
// },
|
||||
// '*'
|
||||
// );
|
||||
// store.commit('common/M_COMMON_SET_TOKEN_UNAUTHORIZED', false);
|
||||
// } else if (error.response.status === 403) {
|
||||
// router.push({
|
||||
// path: '/error/403'
|
||||
// });
|
||||
// } else if (error.response.status === 404) {
|
||||
// router.push({
|
||||
// path: '/error/404'
|
||||
// });
|
||||
// } else if (error.response.status === 500) {
|
||||
// router.push({
|
||||
// path: '/error/500'
|
||||
// });
|
||||
// } else {
|
||||
// // message.error(error.response.data?.message || '服务器错误');
|
||||
// }
|
||||
// return Promise.reject(error.response);
|
||||
// }
|
||||
);
|
||||
|
||||
export default service;
|
||||
@@ -1,5 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { surveys } from './Hooks/useRequestHooks';
|
||||
|
||||
import { getQuestionList } from '@/api/home/index.js';
|
||||
|
||||
const { data: questionList } = await getQuestionList();
|
||||
console.log(questionList);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
102
vite.config.ts
102
vite.config.ts
@@ -1,47 +1,63 @@
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
// vite.config.ts
|
||||
import { defineConfig, loadEnv } from 'vite'; // 从 vite 导入 loadEnv
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import { fileURLToPath, URL } from 'node:url';
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||||
import AutoImport from 'unplugin-auto-import/vite';
|
||||
import Components from 'unplugin-vue-components/vite';
|
||||
import { VantResolver } from 'unplugin-vue-components/resolvers';
|
||||
import postCssPxToRem from 'postcss-pxtorem';
|
||||
export default defineConfig(({ mode }) => {
|
||||
// 接收 mode 参数
|
||||
// 正确加载环境变量
|
||||
const env = loadEnv(mode, process.cwd());
|
||||
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
// import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
||||
import {VantResolver} from 'unplugin-vue-components/resolvers';
|
||||
import postCssPxToRem from 'postcss-pxtorem'
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
server: {
|
||||
host: '0.0.0.0', // 监听所有网络接口
|
||||
port: 3000, // 你也可以指定端口
|
||||
},
|
||||
css: {
|
||||
postcss:{
|
||||
plugins:[
|
||||
postCssPxToRem({
|
||||
rootValue: 37.5,
|
||||
propList: ['*'],
|
||||
})
|
||||
]
|
||||
// 从 env 对象中获取变量
|
||||
const proxyUrl = env.VITE_APP_BASEURL;
|
||||
const proxyUrlDelivery = env.VITE_APP_DELIVERY_BASEURL;
|
||||
return {
|
||||
// 必须 return 配置对象
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 3000,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://192.168.11.119:8090/api/api/',
|
||||
changeOrigin: true,
|
||||
logLevel: 'debug',
|
||||
rewrite: (path) => path.replace(/^\/api/, '/backend-api'), // 添加新前缀
|
||||
bypass: (req) => req.headers.accept?.indexOf('html') !== -1 // 跳过 HTML 请求
|
||||
},
|
||||
'/request-java': {
|
||||
target: `${proxyUrlDelivery}/api`,
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/request-java': '' }
|
||||
}
|
||||
}
|
||||
},
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
api: 'modern-compiler', // or 'modern'
|
||||
css: {
|
||||
postcss: {
|
||||
plugins: [
|
||||
postCssPxToRem({
|
||||
rootValue: 37.5,
|
||||
propList: ['*']
|
||||
})
|
||||
]
|
||||
},
|
||||
preprocessorOptions: {
|
||||
scss: { api: 'modern-compiler' }
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
vue(),
|
||||
vueJsx(),
|
||||
AutoImport({ resolvers: [VantResolver()] }),
|
||||
Components({ resolvers: [VantResolver()] })
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
vue(),
|
||||
vueJsx(),
|
||||
AutoImport({
|
||||
resolvers: [VantResolver()],
|
||||
}),
|
||||
Components({
|
||||
resolvers: [VantResolver()],
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user