This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// middleware.ts | |
import { NextResponse } from 'next/server' | |
export function middleware(request) { | |
const { pathname } = request.nextUrl | |
const userInfoCookie = request.cookies.get('user_info')?.value | |
// 解析用户信息(需错误处理) | |
const user = userInfoCookie ? JSON.parse(userInfoCookie) : null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use client"; | |
import { getCookie } from "@/lib/utils"; | |
import { AuthContextType, UserInfo } from "@/types/user"; | |
import { createContext, useContext, useEffect, useState } from "react"; | |
const AuthContext = createContext<AuthContextType>({ | |
userInfo: null, | |
hasRole: () => false, | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en" suppressHydrationWarning> | |
<body | |
className={`${geistSans.variable} ${geistMono.variable} antialiased`} | |
> | |
<ThemeProvider attribute="class" defaultTheme="system"> | |
<Toaster /> | |
<div className="relative flex min-h-screen w-full overflow-hidden"> | |
<SidebarProvider> | |
<div className="sticky left-0 top-0 h-screen"> | |
<AppSidebar /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// store/useIssueStore.ts | |
import create from 'zustand'; | |
interface IssueStore { | |
issueId: number | null; | |
setIssueId: (issueId: number) => void; | |
} | |
const useIssueStore = create<IssueStore>((set) => ({ | |
issueId: null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// types.ts | |
export interface User { | |
id: string; | |
name: string; | |
email: string; | |
} | |
export interface Post { | |
id: string; | |
title: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "admin-dashboard", | |
"version": "0.1.0", | |
"private": true, | |
"scripts": { | |
"dev": "next dev --turbopack", | |
"build": "next build", | |
"start": "next start", | |
"lint": "next lint" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" | |
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert" | |
import { Button } from "@/components/ui/button" | |
import { Mail, Clock, AlertTriangle } from 'lucide-react' | |
export default function MaintenancePage() { | |
return ( | |
<div className="min-h-screen bg-background flex items-center justify-center p-4"> | |
<Card className="w-full max-w-lg"> | |
<CardHeader> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Loader2 } from "lucide-react" | |
import { Card, CardContent } from "@/components/ui/card" | |
export default function Loading() { | |
return ( | |
<div className="absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm"> | |
<Card className="w-[300px]"> | |
<CardContent className="flex flex-col items-center justify-center p-6"> | |
<Loader2 className="h-10 w-10 animate-spin text-primary" /> | |
<p className="mt-4 text-lg font-semibold text-primary">Loading...</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Button } from "@/components/ui/button" | |
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" | |
import { AlertTriangle } from "lucide-react" | |
import Link from "next/link" | |
export default function Custom500() { | |
return ( | |
<div className="min-h-screen flex items-center justify-center bg-gray-100 dark:bg-gray-900"> | |
<Card className="w-full max-w-md"> | |
<CardHeader> |
NewerOlder