/**
 * 统一处理session过期的逻辑
 * 避免在多个拦截器中重复代码
 */
export async function handleSessionExpired(statusCode: number): Promise<void> {
  try {
    const { useAuthStore } = await import('../stores/auth')
    const { default: router } = await import('../../app/router')
    const authStore = useAuthStore()
    
    if (authStore.isLoggedIn && router.currentRoute.value.path !== '/login') {
      await authStore.logout()
      router.push('/login')
    }
  } catch (error) {
    // 静默失败
  }
}
