import type { RegionConfig } from './type.js'; export type UseIPRedirectOptions = { /** Cookie 名称,默认为 'user_region' */ cookieName?: string; /** Cookie 过期天数,默认为 90 天 */ cookieExpireDays?: number; /** 地区配置列表 */ regions: RegionConfig[]; /** 当前站点的地区代码(如 'US', 'CN' 等),用于判断是否需要跳转。强烈建议提供此参数以防止无限跳转 */ currentRegionCode?: string; /** 可选的地区检测回调函数,返回检测到的地区代码。如不需要自动检测,可不传此参数 */ onDetectRegion?: () => Promise; /** 是否自动显示弹窗,默认为 true */ autoShow?: boolean; /** 白名单列表,这些 URL/路径不会触发 IP 跳转和横幅显示。支持完整 URL(如 'https://www.anker.com/prime-2025')、路径(如 '/checkout')和通配符(如 '/checkout/*' 或 'https://www.anker.com/campaign/*') */ excludePaths?: string[]; /** 当前页面路径(用于白名单检查) */ currentPath?: string; /** 当前页面完整 URL(用于白名单检查) */ currentUrl?: string; }; export type UseIPRedirectReturn = { /** 是否显示地区选择弹窗 */ isOpen: boolean; /** 设置弹窗显示状态 */ setIsOpen: (open: boolean) => void; /** 用户已保存的地区代码 */ savedRegion: string | null; /** 检测到的用户地区代码 */ detectedRegion: string | null; /** 保存用户选择的地区 */ saveRegion: (regionCode: string, languageCode?: string) => void; /** 清除已保存的地区选择 */ clearRegion: () => void; /** 根据地区代码获取地区配置 */ getRegionByCode: (code: string) => RegionConfig | undefined; }; /** * 地区选择 Hook * 用于管理用户地区选择和 Cookie 存储 */ export declare function useIPRedirect(options: UseIPRedirectOptions): UseIPRedirectReturn;