"use client"

import { usePermissionStore } from "@/components/label/store/auth"
import { usePathname } from "next/navigation"
import { useEffect } from "react"

export function InfoCheck() {
  const pathname = usePathname()

  const user_id = usePermissionStore.getState().user_id

  useEffect(() => {
    if (pathname.startsWith("/login")) {
      return
    }
    if (!user_id) {
      // tauri 打包后， 使用router.push跳转路由不执行，会导致白屏
      window.location.href = "/login"
    }
  }, [pathname, user_id])
  return <></>
}
