From 8bbbcb5383a2172687e0b9b76b4ac10c3d68a46d Mon Sep 17 00:00:00 2001 From: sladro Date: Sun, 21 Sep 2025 11:07:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dbuild=E5=90=8E?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2=E7=A9=BA=E7=99=BD=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将Vue Router改为Hash模式,解决SPA路由在简单HTTP服务器下的兼容性问题 - 设置Vite base为相对路径,支持任意目录部署 - 确保dist文件夹可直接用于演示和分发 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- config/vite.config.js | 1 + src/router/index.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/vite.config.js b/config/vite.config.js index 8c4ad01..fba1a75 100644 --- a/config/vite.config.js +++ b/config/vite.config.js @@ -8,6 +8,7 @@ export default defineConfig({ plugins: [ vue(), ], + base: './', // 使用相对路径,支持任意目录部署 resolve: { alias: { '@': fileURLToPath(new URL('../src', import.meta.url)) diff --git a/src/router/index.js b/src/router/index.js index 0136cfb..dc21191 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,8 +1,8 @@ -import { createRouter, createWebHistory } from 'vue-router' +import { createRouter, createWebHashHistory } from 'vue-router' import { useAuthStore } from '@/stores/auth' const router = createRouter({ - history: createWebHistory(import.meta.env.BASE_URL), + history: createWebHashHistory(), routes: [ { path: '/login',