重构鉴权逻辑,新增中间件刷新令牌,授权接口统一后处理无授权跳转

This commit is contained in:
2025-04-26 14:18:08 +08:00
parent 5c88cd7f32
commit 6db037204c
20 changed files with 303 additions and 318 deletions

View File

@@ -17,7 +17,7 @@ export default function Navbar(props: NavbarProps) {
<nav data-expand={navbar} className={merge(
`transition-[flex-basis] duration-200 ease-in-out`,
`flex flex-col overflow-hidden group`,
`flex-none ${navbar ? `expand basis-52` : `noexpand basis-16`}`,
`data-[expand=true]:basis-52 data-[expand=false]:basis-16`,
)}>
{/* logo */}
<Logo mini={!navbar}/>
@@ -25,22 +25,23 @@ export default function Navbar(props: NavbarProps) {
{/* routes */}
<section className={merge(
`transition-[padding] duration-200 ease-in-out`,
`flex-auto overflow-auto ${navbar ? `px-4` : `px-3`}`,
`flex-auto overflow-auto`,
`data-[expand=true]:px-4 data-[expand=false]:px-3`,
)}>
<NavItem href={'/admin'} icon={`🏠`} label={`账户总览`} expand={navbar}/>
<NavItem href={'/admin'} icon={`🏠`} label={`账户总览`}/>
<NavTitle label={`个人信息`}/>
<NavItem href={`/admin/profile`} icon={`📝`} label={`个人中心`} expand={navbar}/>
<NavItem href={`/admin/identify`} icon={`🆔`} label={`实名认证`} expand={navbar}/>
<NavItem href={`/admin/whitelist`} icon={`🔒`} label={`白名单`} expand={navbar}/>
<NavItem href={`/admin/bills`} icon={`💰`} label={`我的账单`} expand={navbar}/>
<NavItem href={`/admin/profile`} icon={`📝`} label={`个人中心`}/>
<NavItem href={`/admin/identify`} icon={`🆔`} label={`实名认证`}/>
<NavItem href={`/admin/whitelist`} icon={`🔒`} label={`白名单`}/>
<NavItem href={`/admin/bills`} icon={`💰`} label={`我的账单`}/>
<NavTitle label={`套餐管理`}/>
<NavItem href={`/admin/purchase`} icon={`🛒`} label={`购买套餐`} expand={navbar}/>
<NavItem href={`/admin/resources`} icon={`📦`} label={`套餐管理`} expand={navbar}/>
<NavItem href={`/admin/purchase`} icon={`🛒`} label={`购买套餐`}/>
<NavItem href={`/admin/resources`} icon={`📦`} label={`套餐管理`}/>
<NavTitle label={`IP 管理`}/>
<NavItem href={`/admin/extract`} icon={`📤`} label={`提取 IP`} expand={navbar}/>
<NavItem href={`/admin`} icon={`👁️`} label={`IP 管理`} expand={navbar}/>
<NavItem href={`/admin`} icon={`📜`} label={`提取记录`} expand={navbar}/>
<NavItem href={`/admin`} icon={`🗂️`} label={`使用记录`} expand={navbar}/>
<NavItem href={`/admin/extract`} icon={`📤`} label={`提取 IP`}/>
<NavItem href={`/admin`} icon={`👁️`} label={`IP 管理`}/>
<NavItem href={`/admin`} icon={`📜`} label={`提取记录`}/>
<NavItem href={`/admin`} icon={`🗂️`} label={`使用记录`}/>
</section>
</nav>
)
@@ -75,10 +76,10 @@ function NavTitle(props: {
`transition-[opacity] duration-150 ease-in-out absolute mx-4`,
`group-data-[expand=true]:delay-[50ms] group-data-[expand=true]:opacity-100 group-data-[expand=false]:opacity-0`,
)}>{props.label}</span>
<div className={merge(
`transition-[opacity] duration-150 ease-in-out absolute w-full border-b`,
<span className={merge(
`transition-[opacity] duration-150 ease-in-out absolute w-full border-b block`,
`group-data-[expand=false]:delay-[50ms] group-data-[expand=false]:opacity-100 group-data-[expand=true]:opacity-0`,
)}></div>
)}></span>
</p>
)
}
@@ -87,7 +88,6 @@ function NavItem(props: {
href: string
icon?: ReactNode
label: string
expand: boolean
}) {
return (
<Link className={merge(

View File

@@ -1,6 +1,6 @@
'use client'
import {Button} from '@/components/ui/button'
import {logout} from '@/actions/auth/auth'
import {logout} from '@/actions/auth'
import {useProfileStore} from '@/components/providers/StoreProvider'
import {useRouter} from 'next/navigation'
import {toast} from 'sonner'