feat(app): 全局样式重构与核心应用层更新
- 重构 globals.css 设计令牌系统,对齐咨询风品牌色与排版 - 更新根布局,集成 SEO schema 与黑暗模式防闪烁脚本 - 添加 robots.ts 与 sitemap.ts 动态生成 - 添加 middleware.ts 中间件层 - 更新隐私政策与服务条款页面
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
const { pathname } = request.nextUrl;
|
||||
|
||||
// 只处理 /admin 路由(除了登录页和 API 路由)
|
||||
if (pathname.startsWith('/admin') && !pathname.startsWith('/admin/login') && !pathname.startsWith('/api/')) {
|
||||
const token = request.cookies.get('novalon_token')?.value;
|
||||
const authHeader = request.headers.get('authorization');
|
||||
|
||||
// 如果 cookie 和 header 都没有 token,重定向到登录页
|
||||
if (!token && !authHeader) {
|
||||
// 允许客户端组件处理认证(因为 AuthProvider 在客户端也会检查 localStorage)
|
||||
return NextResponse.next();
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ['/admin/:path*'],
|
||||
};
|
||||
Reference in New Issue
Block a user