import type { RegionConfig } from './type.js'; export interface UseAutoRedirectOptions { /** * 地区代码到路径前缀的映射 * @example { US: '', CA: 'ca', DE: 'eu-de' } */ regionToPathMap: Record; /** * 地理位置信息(包含国家代码) */ geo?: { country?: { code?: string; }; }; /** * 当前站点的地区代码(用于构建 ref 参数,表示从哪个站点跳转来的) */ currentRegionCode: string; /** * 当前站点的 locale */ locale?: string; /** * 是否检查目标站点页面存在(需要实现 /api/check-page-exists 接口) * @default true */ checkPageExists?: boolean; /** * 页面存在检查的 API 端点 * @default '/api/check-page-exists' */ checkPageApiEndpoint?: string; /** * 自定义 ref 参数前缀(用于自动跳转追踪) * @default 'geo_redirect_auto' * @example 'custom_tracking' */ refPrefix?: string; } export interface UseAutoRedirectReturn { /** * 自动跳转到指定地区的函数 * @param region - 目标地区配置 * @param isCookieRedirect - 是否是通过 cookie 记忆触发的跳转 */ handleAutoRedirect: (region: RegionConfig, isCookieRedirect?: boolean) => Promise; } /** * 自动跳转 Hook * 处理地区跳转的核心逻辑,包括: * - 路径保留和转换 * - 页面存在检查(可选) * - UTM 参数处理 * - sessionStorage 标记 * * @example * ```tsx * const { handleAutoRedirect } = useAutoRedirect({ * regionToPathMap, * geo, * locale, * checkPageExists: true, * }) * * // 当检测到地区不匹配时 * const targetRegion = regions.find(r => r.code === 'DE') * await handleAutoRedirect(targetRegion) * ``` */ export declare function useAutoRedirect(options: UseAutoRedirectOptions): UseAutoRedirectReturn;