打手端迁移至独立子域名
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
const DEFAULT_WORKER_SITE_URL = 'https://worker.khhao.com'
|
||||
|
||||
export const WORKER_SITE_ORIGIN = resolveWorkerSiteOrigin()
|
||||
|
||||
export function isWorkerSite() {
|
||||
const configuredHostname = new URL(WORKER_SITE_ORIGIN).hostname
|
||||
|
||||
return (
|
||||
window.location.hostname === configuredHostname ||
|
||||
(import.meta.env.DEV && window.location.hostname === 'worker.localhost')
|
||||
)
|
||||
}
|
||||
|
||||
function resolveWorkerSiteOrigin() {
|
||||
const configuredUrl = String(import.meta.env.VITE_WORKER_SITE_URL || '').trim()
|
||||
|
||||
try {
|
||||
return new URL(configuredUrl || DEFAULT_WORKER_SITE_URL).origin
|
||||
} catch {
|
||||
return DEFAULT_WORKER_SITE_URL
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
export function resolveLegacyWorkerPath(hash: string) {
|
||||
const value = hash.startsWith('#') ? hash.slice(1) : hash
|
||||
const queryIndex = value.indexOf('?')
|
||||
const pathname = queryIndex >= 0 ? value.slice(0, queryIndex) : value
|
||||
const search = queryIndex >= 0 ? value.slice(queryIndex) : ''
|
||||
|
||||
if (pathname === '/worker' || pathname === '/worker/' || pathname === '/worker/login') {
|
||||
return `/${search}`
|
||||
}
|
||||
if (pathname === '/worker/hall') return `/hall${search}`
|
||||
if (pathname === '/worker/orders') return `/orders${search}`
|
||||
if (pathname === '/worker/profile') return `/profile${search}`
|
||||
|
||||
return ''
|
||||
}
|
||||
Reference in New Issue
Block a user