/** * 解析 H5 登录/注册后的 redirect(可能含 query),供 router.replace 使用。 */ export function parseH5RedirectLocation(redirect: string | null | undefined): { path: string query?: Record } { const raw = String(redirect || '').trim() if (!raw.startsWith('/h5') || raw.startsWith('/h5/admin')) { return { path: '/h5/price' } } const hashIdx = raw.indexOf('#') const withoutHash = hashIdx >= 0 ? raw.slice(0, hashIdx) : raw const qIdx = withoutHash.indexOf('?') if (qIdx < 0) { return { path: withoutHash || '/h5/price' } } const path = withoutHash.slice(0, qIdx) || '/h5/price' const query: Record = {} new URLSearchParams(withoutHash.slice(qIdx + 1)).forEach((value, key) => { if (key) query[key] = value }) return Object.keys(query).length ? { path, query } : { path } }