优化导入组件

This commit is contained in:
sijinhui 2024-03-21 11:42:07 +08:00
parent f3faa17f9d
commit 3207168877
8 changed files with 42 additions and 40 deletions

View File

@ -1,4 +1,3 @@
import { Grid, Col } from "@tremor/react";
import UsageByModel from "./usage-by-model-chart";
import UserByMap from "./user-by-map";
import { getSession } from "@/lib/auth";

View File

@ -9,12 +9,22 @@ import React, {
} from "react";
import * as echarts from "echarts";
import { DatePicker } from "@tremor/react";
import { zhCN } from "date-fns/locale";
// import { DatePicker } from "@tremor/react";
import { DatePicker } from "antd";
import { Col, Row } from "antd";
import locale from "antd/es/date-picker/locale/zh_CN";
import "dayjs/locale/zh-cn";
import dayjs from "dayjs";
import { EChartsOption } from "echarts";
import { essos } from "@/lib/charts_theme";
import { subDays, addDays } from "date-fns";
// import customParseFormat from 'dayjs/plugin/customParseFormat';
// dayjs.extend(customParseFormat);
// const dateFormat = 'YYYY-MM-DD';
interface ComponentProps {
currentDate: Date;
setCurrentDate: Dispatch<SetStateAction<Date>>;
@ -64,14 +74,15 @@ function DateSelectComponent({ currentDate, setCurrentDate }: ComponentProps) {
}, [changeCurrentDate, currentDate]);
return (
<div className="max-w-sm mx-auto justify-center mb-1.5">
<DatePicker
className="max-w-sm mx-auto justify-center"
value={currentDate}
locale={zhCN}
defaultValue={new Date()}
onValueChange={(d) => d && changeCurrentDate(d)}
maxDate={maxDate}
value={dayjs(currentDate)}
locale={locale}
// defaultValue={dayjs(new Date())}
onChange={(d, ds) => d && changeCurrentDate(d.toDate())}
maxDate={dayjs(maxDate)}
/>
</div>
);
}
@ -148,14 +159,18 @@ export default function UsageByModelChart() {
return (
<div>
<Row>
<DateSelectComponent
currentDate={currentDate}
setCurrentDate={setCurrentDate}
/>
</Row>
<Row>
<EchartsComponent
currentDate={currentDate}
setCurrentDate={setCurrentDate}
/>
</Row>
</div>
);
}

View File

@ -52,7 +52,7 @@ function MainLayout({ children }: { children: ReactNode }) {
</Header>
<Content
style={{
margin: "24px 16px",
// margin: "24px 16px",
padding: 24,
minHeight: 280,
background: colorBgLayout,

View File

@ -4,19 +4,19 @@ import LoadingDots from "@/app/components/icons/loading-dots";
import { signIn } from "next-auth/react";
import { useSearchParams } from "next/navigation";
import { useState, useEffect } from "react";
import { toast } from "sonner";
// import { toast } from "sonner";
export default function LoginButton() {
const [loading, setLoading] = useState(false);
// Get error message added by next/auth in URL.
const searchParams = useSearchParams();
const error = searchParams?.get("error");
useEffect(() => {
const errorMessage = Array.isArray(error) ? error.pop() : error;
errorMessage && toast.error(errorMessage);
}, [error]);
// const error = searchParams?.get("error");
//
// useEffect(() => {
// const errorMessage = Array.isArray(error) ? error.pop() : error;
// errorMessage && toast.error(errorMessage);
// }, [error]);
return (
<button

View File

@ -10,7 +10,6 @@ console.log("[Next] build with chunk: ", disableChunk);
// const isProd = process.env.NODE_ENV === 'production'
// 为了修复tiktoken的插件问题
import CopyPlugin from "copy-webpack-plugin";
const nextConfig = {
// transpilePackages: ['tiktoken'],
webpack(config) {

View File

@ -23,7 +23,6 @@
"@next/third-parties": "^14.1.0",
"@prisma/client": "^5.9.0",
"@svgr/webpack": "^8.1.0",
"@tremor/react": "^3.13.4",
"@vercel/analytics": "^1.1.2",
"@vercel/speed-insights": "^1.0.9",
"antd": "^5.15.1",
@ -36,7 +35,6 @@
"next": "^14.1.0",
"next-auth": "^4.24.5",
"node-fetch": "^3.3.1",
"prop-types": "^15.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-markdown": "^9.0.1",
@ -47,7 +45,6 @@
"remark-gfm": "^4.0.0",
"remark-math": "^6.0.0",
"sass": "^1.70.0",
"sonner": "^1.4.0",
"spark-md5": "^3.0.2",
"tailwind-merge": "^2.2.1",
"tiktoken": "^1.0.13",
@ -55,8 +52,6 @@
"zustand": "^4.5.0"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10",
"@tauri-apps/cli": "^1.5.8",
"@types/cookie": "^0.6.0",
"@types/node": "^20.11.10",
@ -65,17 +60,15 @@
"@types/react-katex": "^3.0.0",
"@types/spark-md5": "^3.0.4",
"autoprefixer": "^10.4.17",
"copy-webpack-plugin": "^12.0.2",
"cross-env": "^7.0.3",
"date-fns": "^3.6.0",
"eslint": "^8.55.0",
"eslint-config-next": "^14.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"husky": "^9.0.7",
"lint-staged": "^15.2.0",
"mini-css-extract-plugin": "^2.7.7",
"postcss": "^8.4.33",
"postcss-import": "^16.0.0",
"prettier": "^3.2.4",
"prettier-plugin-tailwindcss": "^0.5.11",
"prisma": "^5.9.0",

View File

@ -1,7 +1,5 @@
module.exports = {
plugins: {
"postcss-import": {},
"tailwindcss/nesting": {},
tailwindcss: {},
autoprefixer: {},
},

View File

@ -176,8 +176,6 @@ module.exports = {
},
],
plugins: [
require("@tailwindcss/typography"),
require("@tailwindcss/forms"),
require("tailwindcss-animate"),
],
};