feat(h5): unify WeChat OAuth under m.runxian.top path routing
Serve user/shop/partner H5 under /user/, /shop/, /partner/ on a single authorized domain; update nginx, SSL script, and router base paths. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
function normalizeBase(base?: string): string {
|
||||
if (!base || base === '/') return '';
|
||||
return base.replace(/\/$/, '');
|
||||
}
|
||||
|
||||
/** React Router basename(来自 Vite `base`) */
|
||||
export function getRouterBasename(baseUrl?: string): string | undefined {
|
||||
const base = normalizeBase(baseUrl ?? import.meta.env?.BASE_URL);
|
||||
return base || undefined;
|
||||
}
|
||||
|
||||
/** 拼接带 Vite base 前缀的应用内路径(用于 window.location 跳转) */
|
||||
export function toAppPath(path: string, baseUrl?: string): string {
|
||||
const base = normalizeBase(baseUrl ?? import.meta.env?.BASE_URL);
|
||||
const normalized = path.startsWith('/') ? path : `/${path}`;
|
||||
return `${base}${normalized}`;
|
||||
}
|
||||
|
||||
export function isOnAppPath(path: string, baseUrl?: string): boolean {
|
||||
if (typeof window === 'undefined') return false;
|
||||
const target = toAppPath(path, baseUrl);
|
||||
return window.location.pathname === target || window.location.pathname.startsWith(`${target}/`);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
export { isWechatBrowser, isMiniProgram, getRuntimePlatform } from './env';
|
||||
export { getRouterBasename, toAppPath, isOnAppPath } from './app-path';
|
||||
export { initWechatJssdk, ensureJssdkReady, isJssdkReady, normalizeJssdkPageUrl, stripOAuthParamsFromLocation } from './jssdk';
|
||||
export {
|
||||
getWechatLocation,
|
||||
|
||||
Reference in New Issue
Block a user