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: {