fix: 🐛 修改 `mock` 数据无效问题修复

This commit is contained in:
hxr 2023-09-22 00:27:39 +08:00
parent bb313cf906
commit 99578a4548
2 changed files with 7 additions and 13 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "vue3-element-admin", "name": "vue3-element-admin",
"private": true, "private": true,
"version": "2.6.1", "version": "2.6.2",
"scripts": { "scripts": {
"preinstall": "npx only-allow pnpm", "preinstall": "npx only-allow pnpm",
"dev": "vite serve --mode development", "dev": "vite serve --mode development",
@ -106,7 +106,7 @@
"unplugin-icons": "^0.16.1", "unplugin-icons": "^0.16.1",
"unplugin-vue-components": "^0.24.1", "unplugin-vue-components": "^0.24.1",
"vite": "^4.4.9", "vite": "^4.4.9",
"vite-plugin-mock": "^3.0.0", "vite-plugin-mock": "^2.9.6",
"vite-plugin-svg-icons": "^2.0.1", "vite-plugin-svg-icons": "^2.0.1",
"vue-tsc": "^1.7.0 " "vue-tsc": "^1.7.0 "
}, },

View File

@ -52,7 +52,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
path.replace( path.replace(
new RegExp("^" + env.VITE_APP_BASE_API), // ^/dev-api new RegExp("^" + env.VITE_APP_BASE_API), // ^/dev-api
env.VITE_APP_TARGET_BASE_API // "" env.VITE_APP_TARGET_BASE_API // ""
), // 以 /dev-api 开头的请求转发至 target示例 http://localhost:3000/dev-api/v1/users (F12可见) 代理转发 https://api.xxx.com/v1/users (真实接口地址) ), // 将 /dev-api 开头的请求转发至 target
}, },
}, },
}, },
@ -62,7 +62,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
hmrTopLevelAwait: false, hmrTopLevelAwait: false,
}), }),
AutoImport({ AutoImport({
imports: ["vue", "@vueuse/core"], // 自动导入 Vue 相关函数ref, reactive, toRef 等 imports: ["vue", "@vueuse/core"],
eslintrc: { eslintrc: {
enabled: false, enabled: false,
filepath: "./.eslintrc-auto-import.json", filepath: "./.eslintrc-auto-import.json",
@ -80,7 +80,6 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
Components({ Components({
resolvers: [ resolvers: [
ElementPlusResolver(), // 自动导入 Element Plus 组件 ElementPlusResolver(), // 自动导入 Element Plus 组件
// 自动导入 Icon 组件
IconsResolver({ IconsResolver({
enabledCollections: ["ep"], // @iconify-json/ep 是 Element Plus 的图标库 enabledCollections: ["ep"], // @iconify-json/ep 是 Element Plus 的图标库
}), }),
@ -91,24 +90,19 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
}), }),
Icons({ Icons({
// 自动安装图标库
autoInstall: true, autoInstall: true,
}), }),
createSvgIconsPlugin({ createSvgIconsPlugin({
// 指定需要缓存的图标文件夹 iconDirs: [path.resolve(pathSrc, "assets/icons")], // 指定需要缓存的图标文件夹
iconDirs: [path.resolve(pathSrc, "assets/icons")], symbolId: "icon-[dir]-[name]", // 指定symbolId格式
// 指定symbolId格式
symbolId: "icon-[dir]-[name]",
}), }),
// https://github.com/anncwb/vite-plugin-mock/issues/9
viteMockServe({ viteMockServe({
ignore: /^\_/, ignore: /^\_/,
mockPath: "mock", mockPath: "mock",
enable: mode === "development", enable: mode === "development",
watchFiles: false,
}), }),
], ],
// 预加载项目必需的组件 /** 预加载项目必需的组件 */
optimizeDeps: { optimizeDeps: {
include: [ include: [
"vue", "vue",