feat: 适配 HTML5 模式路由 (#11)

* feat: 适配 HTML5 模式路由
This commit is contained in:
JDS-JH
2022-08-19 22:05:26 +08:00
committed by GitHub
parent 903db88cdf
commit 4369d90d98
6 changed files with 20 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router"
import { createRouter, createWebHashHistory, createWebHistory, RouteRecordRaw } from "vue-router"
const Layout = () => import("@/layout/index.vue")
/** 常驻路由 */
@@ -202,7 +202,10 @@ export const asyncRoutes: Array<RouteRecordRaw> = [
]
const router = createRouter({
history: createWebHashHistory(),
history:
import.meta.env.VITE_ROUTER_HISTORY === "hash"
? createWebHashHistory(import.meta.env.VITE_PUBLIC_PATH)
: createWebHistory(import.meta.env.VITE_PUBLIC_PATH),
routes: constantRoutes
})