From ac6d84d999a1c0f669a7230109ef5d8059d79eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Sat, 16 Apr 2022 12:41:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B7=AF=E7=94=B1=E6=89=93?= =?UTF-8?q?=E5=8C=85=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZR.Vue3/src/router/index.js | 2 +- ZR.Vue3/vite.config.js | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ZR.Vue3/src/router/index.js b/ZR.Vue3/src/router/index.js index aea32ce..5b20d3b 100644 --- a/ZR.Vue3/src/router/index.js +++ b/ZR.Vue3/src/router/index.js @@ -80,7 +80,7 @@ export const constantRoutes = [ }]; const router = createRouter({ - history: createWebHistory(), + history: createWebHistory(import.meta.env.VITE_APP_ROUTER_PREFIX), routes: constantRoutes, // scrollBehavior(to, from, savedPosition) { // if (savedPosition) { diff --git a/ZR.Vue3/vite.config.js b/ZR.Vue3/vite.config.js index 1801211..414bb23 100644 --- a/ZR.Vue3/vite.config.js +++ b/ZR.Vue3/vite.config.js @@ -3,10 +3,7 @@ import path from 'path' import createVitePlugins from './vite/plugins' // https://vitejs.dev/config/ -export default defineConfig(({ - mode, - command -}) => { +export default defineConfig(({ mode, command }) => { const env = loadEnv(mode, process.cwd()) return { plugins: createVitePlugins(env, command === 'build'), @@ -21,6 +18,7 @@ export default defineConfig(({ // https://cn.vitejs.dev/config/#resolve-extensions extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'], }, + base: env.VITE_APP_ROUTER_PREFIX, // 打包配置 build: { sourcemap: command === 'build' ? false : true, @@ -28,7 +26,6 @@ export default defineConfig(({ outDir: 'dist', //指定输出目录 assetsDir: 'assets', //指定静态资源存储目录 minify: 'terser', //混淆器,terser构建后文件体积更小 - publicDir: import.meta.env.VITE_APP_ROUTER_PREFIX }, // vite 相关配置 server: {