尝试增加管理页面

This commit is contained in:
sijinhui 2023-12-19 19:03:35 +08:00
parent 78ed4f1cbb
commit 8d83e8ad16
7 changed files with 71 additions and 1 deletions

View File

@ -0,0 +1,39 @@
"use client";
import { Grid, Col, Card, Text, AreaChart, Metric } from "@tremor/react";
export default function AdminPage() {
return (
<Grid numItems={1} numItemsSm={2} numItemsLg={3} className="gap-2">
<Col numColSpan={1} numColSpanLg={2}>
<Card>
<Text>Title</Text>
{/*<AreaChart*/}
{/* className="mt-6 h-28"*/}
{/* data={data}*/}
{/* index="Month"*/}
{/* valueFormatter={(number: number) =>*/}
{/* `${Intl.NumberFormat("us").format(number).toString()}`*/}
{/* }*/}
{/* categories={["Total Visitors"]}*/}
{/* colors={["blue"]}*/}
{/* showXAxis={true}*/}
{/* showGridLines={false}*/}
{/* startEndOnly={true}*/}
{/* showYAxis={false}*/}
{/* showLegend={false}*/}
{/*/>*/}
</Card>
</Col>
<Card>
<Text>Title</Text>
<Metric>KPI 2</Metric>
</Card>
<Col>
<Card>
<Text>Title</Text>
<Metric>KPI 3</Metric>
</Card>
</Col>
</Grid>
);
}

View File

@ -0,0 +1,24 @@
import "@/app/app/login.scss";
import { Metadata } from "next";
import { ReactNode } from "react";
export const metadata: Metadata = {
title: "Admin | 管理页面",
};
export default async function AdminLayout({
children,
}: {
children: ReactNode;
}) {
return (
<div className="flex max-w-screen-xl flex-col space-y-12 p-8">
<div className="flex flex-col space-y-6">
<h1 className="font-cal text-3xl font-bold dark:text-white">
Admin Page
</h1>
{children}
</div>
</div>
);
}

View File

@ -1,4 +1,4 @@
import "@/app/styles/login.scss"; import "@/app/app/login.scss";
import { Metadata } from "next"; import { Metadata } from "next";
import { ReactNode } from "react"; import { ReactNode } from "react";
// import { useEffect } from "react"; // import { useEffect } from "react";

View File

@ -29,6 +29,11 @@ export default async function middleware(req: NextRequest) {
new URL(`/app${path}`, req.url), new URL(`/app${path}`, req.url),
); );
} }
if (path == "/admin") {
return NextResponse.rewrite(
new URL(`/app${path}`, req.url),
);
}
if (req.method == 'POST' && (path.startsWith("/api/openai/") || path.startsWith("/api/midjourney"))) { if (req.method == 'POST' && (path.startsWith("/api/openai/") || path.startsWith("/api/midjourney"))) {
// 重写header添加用户名 // 重写header添加用户名

View File

@ -21,6 +21,7 @@
"@next-auth/prisma-adapter": "^1.0.7", "@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^5.7.0", "@prisma/client": "^5.7.0",
"@svgr/webpack": "^8.1.0", "@svgr/webpack": "^8.1.0",
"@tremor/react": "^3.12.1",
"@vercel/analytics": "^1.1.1", "@vercel/analytics": "^1.1.1",
"emoji-picker-react": "^4.5.15", "emoji-picker-react": "^4.5.15",
"fuse.js": "^7.0.0", "fuse.js": "^7.0.0",

View File

@ -5,6 +5,7 @@ module.exports = {
content: [ content: [
// "./app/**/*.{js,ts,jsx,tsx,mdx}", // "./app/**/*.{js,ts,jsx,tsx,mdx}",
"./app/app/**/*.{js,ts,jsx,tsx,mdx}", "./app/app/**/*.{js,ts,jsx,tsx,mdx}",
"./node_modules/@tremor/**/*.{js,ts,jsx,tsx}", // Tremor module
], ],
theme: { theme: {
extend: { extend: {