import Aegis from '../aegis'; export interface UseAegisPageViewOptions { /** * 需要忽略的路径列表,支持字符串精确匹配和正则表达式。 * 匹配到的路径不会触发 PV 上报。 * * @example * // 忽略 modal 和所有 /sheet/ 开头的路径 * useAegisPageView(aegis, pathname, { * ignore: [/modal, /^\/sheet/], * }); */ ignore?: Array; } /** * 通用页面流转监控 Hook(兜底方案) * * 不依赖任何特定路由库,只要能获取到当前路径字符串即可使用。 * 自动处理首屏 PV 上报(首次挂载时 pathname 有值即触发)和相同路径去重。 * * **适用场景:** * - Expo Router:通过 `usePathname()` 获取 pathname * - react-router-native v6:通过 `useLocation().pathname` 获取 * - react-router-native v4:通过 `withRouter` HOC 注入 `location.pathname` * - 任意路由框架:只要能拿到 pathname 字符串 * - 当专用 API(如 createReactNavigationIntegration、createNativeRouterListener) * 不适用于当前路由框架时,本 Hook 作为通用兜底 * * @param aegis Aegis 实例 * @param pathname 当前路由路径(来源不限,任何方式获取均可) * @param options 可选配置 * @param options.ignore 忽略上报的路径列表,支持字符串精确匹配和正则表达式 * * @example * // Expo Router * function NavigationListener() { * const pathname = usePathname(); * useAegisPageView(aegis, pathname); * return null; * } * * @example * // react-router-native v6 * function AegisRouteTracker() { * const { pathname } = useLocation(); * useAegisPageView(aegis, pathname); * return null; * } * * @example * // react-router-native v4(withRouter 注入) * function AegisRouteTracker({ location }) { * useAegisPageView(aegis, location.pathname); * return null; * } * export default withRouter(AegisRouteTracker); * * @example * // 忽略 modal / sheet 类浮层页面 * useAegisPageView(aegis, pathname, { * ignore: [/modal, /^\/sheet/], * }); */ export declare const useAegisPageView: (aegis: Aegis, pathname: string, options?: UseAegisPageViewOptions) => void;