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

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

@@ -1,29 +1,13 @@
import {ReactNode} from 'react'
import {merge} from '@/lib/utils'
import {redirect} from 'next/navigation'
import {getProfile} from '@/actions/auth/auth'
import Header from './_client/header'
import Navbar from '@/app/admin/_client/navbar'
export type DashboardLayoutProps = {
export type AdminLayoutProps = {
children: ReactNode
}
export default async function DashboardLayout(props: DashboardLayoutProps) {
// ======================
// profile
// ======================
const user = await getProfile()
if (!user) {
return redirect(`/login?redirect=${encodeURIComponent('/admin')}`)
}
// ======================
// render
// ======================
export default async function AdminLayout(props: AdminLayoutProps) {
return (
<div className={merge(
`h-screen bg-card overflow-hidden min-w-7xl overflow-y-hidden`,