direction.ts 472 Bytes
export type UPageTransitionDirection = 'forward' | 'back';

/**
 * 按路由深浅判断方向:层级变深=进入详情,层级变浅=返回。
 * 同级切换(leads → assessment)按 forward 处理,保持一致的轻微右进。
 */
export function pageDirection(previous: string, next: string): UPageTransitionDirection {
  const depth = (path: string) => path.split('/').filter(Boolean).length;
  return depth(next) < depth(previous) ? 'back' : 'forward';
}