修正发布模式下无法成功加载路由页面的问题
This commit is contained in:
parent
d27db128ea
commit
914dc61571
|
@ -152,9 +152,12 @@ export function filterAsyncRouter({ menuList, roles, codes }: { menuList; roles?
|
||||||
// accessRoutes = filterAsyncRouterByCodes(roleCodeRoutes, codes) //by codes
|
// accessRoutes = filterAsyncRouterByCodes(roleCodeRoutes, codes) //by codes
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
const views = import.meta.glob('../views/**/*.vue') as Record<string, () => Promise<Component>>
|
||||||
|
|
||||||
function scanRouter(items: any[]) {
|
function scanRouter(items: any[]) {
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
if (item.component === 'Layout') item.component = () => Layout
|
if (item.component === 'Layout') item.component = async () => Layout
|
||||||
else if (typeof item.component === 'string') {
|
else if (typeof item.component === 'string') {
|
||||||
let url: string = item.component
|
let url: string = item.component
|
||||||
if (url.startsWith('@/')) {
|
if (url.startsWith('@/')) {
|
||||||
|
@ -163,7 +166,7 @@ export function filterAsyncRouter({ menuList, roles, codes }: { menuList; roles?
|
||||||
item.component = async () => {
|
item.component = async () => {
|
||||||
let component
|
let component
|
||||||
try {
|
try {
|
||||||
component = await import(/* @vite-ignore */ url)
|
component = await views[url]()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
component = await import('../views/error-page/404.vue')
|
component = await import('../views/error-page/404.vue')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user