diff --git a/electron/electron.js b/electron/electron.js index 55793805d..5864d46b4 100644 --- a/electron/electron.js +++ b/electron/electron.js @@ -439,7 +439,7 @@ function createChildWindow(args) { electronMenu.webContentsMenu(browser.webContents) // 加载地址 - const hash = args.hash || args.path; + const hash = `${args.hash || args.path}`; if (/^https?:/i.test(hash)) { browser.loadURL(hash).then(_ => { }).catch(_ => { }) } else if (isPreload) { diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 0955eaa94..11777be01 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -341,7 +341,7 @@ const $preload = async () => { } await store.dispatch("preload"); - const hash = (window.location[routeMode === 'history' ? 'pathname' : 'hash']).replace(/^[#\/\s]/, ''); + const hash = (window.location[routeMode === 'history' ? 'pathname' : 'hash']).replace(/^[#\/\s]+/, ''); if (hash !== 'preload') { await $init() return @@ -355,6 +355,9 @@ const $preload = async () => { } route = route.replace(/^https?:\/\/[^\/]+/, ''); } + if (routeMode === 'hash') { + route = `#/${route.replace(/^[#\/\s]+/, '')}`; + } window.history.replaceState(null, '', route) await $init() }