diff --git a/.vscode/settings.json b/.vscode/settings.json index b404e3f..4ec5457 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,6 @@ { "editor.tabSize": 2, - "editor.formatOnType": true, - "editor.formatOnSave": true, - "editor.formatOnPaste": true, + "prettier.enable": false, "eslint.format.enable": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true @@ -13,6 +11,10 @@ "typescript", "typescriptreact", "vue", - "json" + "html", + "markdown", + "json", + "jsonc", + "yaml" ] } diff --git a/build/plugins/vue.ts b/build/plugins/vue.ts index b9f4d43..b45cea0 100644 --- a/build/plugins/vue.ts +++ b/build/plugins/vue.ts @@ -2,9 +2,6 @@ import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' -// https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx -import VueDevTools from 'vite-plugin-vue-devtools' // https://github.com/webfansplz/vite-plugin-vue-devtools - -const plugins = [vue(), vueJsx(), VueDevTools()] +const plugins = [vue(), vueJsx()] export default plugins diff --git a/package.json b/package.json index a32c4fe..d2d3c99 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,6 @@ "vite-plugin-compression": "^0.5.1", "vite-plugin-mock": "^2.9.8", "vite-plugin-svg-icons": "^2.0.1", - "vite-plugin-vue-devtools": "^0.2.1", "vue-tsc": "^1.8.1" }, "lint-staged": { diff --git a/public/favicon.svg b/public/favicon.svg index 6b92fc9..50956b5 100644 --- a/public/favicon.svg +++ b/public/favicon.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/logo.svg b/src/assets/icons/logo.svg index 6b92fc9..50956b5 100644 --- a/src/assets/icons/logo.svg +++ b/src/assets/icons/logo.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/config/env.ts b/src/config/env.ts index ec6ff76..ad6f7c1 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -3,7 +3,7 @@ export const proxyConfig: Record = { dev: { url: 'https://mock.mengxuegu.com/mock/61e4df7c17249f68847fc191/api', urlPattern: '/url-pattern', - secondUrl: 'http://localhost:8081', + secondUrl: 'http://localhost:3000', secondUrlPattern: '/second-url-pattern', }, test: { diff --git a/src/service/api/login.ts b/src/service/api/login.ts index 4692500..ad2c95d 100644 --- a/src/service/api/login.ts +++ b/src/service/api/login.ts @@ -1,4 +1,4 @@ -import { mockRequest } from '../http' +import { devRequest, mockRequest } from '../http' interface Ilogin { userName: string @@ -6,7 +6,7 @@ interface Ilogin { } export function fetchLogin(params: Ilogin) { - return mockRequest.post('/login', params) + return devRequest.post('/auth/login', params) } export function fetchUpdateToken(params: any) { return mockRequest.post('/updateToken', params) diff --git a/src/service/http/index.ts b/src/service/http/index.ts index bd8402f..ba6d8b5 100644 --- a/src/service/http/index.ts +++ b/src/service/http/index.ts @@ -1,11 +1,20 @@ import { createRequest } from './request' import { proxyConfig } from '@/config' -const { url, urlPattern } = proxyConfig[import.meta.env.MODE] +const { url, urlPattern, secondUrl, secondUrlPattern } + = proxyConfig[import.meta.env.MODE] const isHttpProxy = import.meta.env.VITE_HTTP_PROXY === 'Y' || false -export const request = createRequest({ baseURL: isHttpProxy ? urlPattern : url }) +export const request = createRequest({ + baseURL: isHttpProxy ? urlPattern : url, +}) + +export const devRequest = createRequest({ + baseURL: isHttpProxy ? secondUrlPattern : secondUrl, +}, { + msgKey: 'message', +}) // export const secondRequest = createRequest({ baseURL: isHttpProxy ? secondUrlPattern : secondUrl }); export const mockRequest = createRequest({ baseURL: '/mock' }) diff --git a/src/service/http/instance.ts b/src/service/http/instance.ts index b65c7f2..3420f4d 100644 --- a/src/service/http/instance.ts +++ b/src/service/http/instance.ts @@ -22,7 +22,7 @@ export default class CreateAxiosInstance { // 基础配置 axiosConfig: AxiosRequestConfig = {} - constructor(axiosConfig: AxiosRequestConfig, backendConfig: Service.BackendResultConfig = DEFAULT_BACKEND_OPTIONS) { + constructor(axiosConfig: AxiosRequestConfig, backendConfig: Partial = DEFAULT_BACKEND_OPTIONS) { // 设置了axios实例上的一些默认配置,新配置会覆盖默认配置 this.backendConfig = { ...DEFAULT_BACKEND_OPTIONS, ...backendConfig } this.instance = axios.create({ ...DEFAULT_AXIOS_OPTIONS, ...axiosConfig }) diff --git a/src/service/http/request.ts b/src/service/http/request.ts index be99229..a8df1a5 100644 --- a/src/service/http/request.ts +++ b/src/service/http/request.ts @@ -34,7 +34,7 @@ async function getRequestResponse(options: { */ export function createRequest( axiosConfig: AxiosRequestConfig, - backendConfig?: Service.BackendResultConfig, + backendConfig?: Partial, ) { const axiosInstance = new CreateAxiosInstance(axiosConfig, backendConfig) /** diff --git a/vite.config.ts b/vite.config.ts index d481dd2..b163243 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -28,9 +28,10 @@ export default defineConfig(({ mode }: ConfigEnv) => { }, server: { host: '0.0.0.0', - port: 3000, + port: 4000, open: false, - proxy: env.VITE_HTTP_PROXY === 'Y' ? createViteProxy(envConfig) : undefined, + proxy: + env.VITE_HTTP_PROXY === 'Y' ? createViteProxy(envConfig) : undefined, }, preview: { port: 5211,