优化导入组件

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 UsageByModel from "./usage-by-model-chart";
import UserByMap from "./user-by-map"; import UserByMap from "./user-by-map";
import { getSession } from "@/lib/auth"; import { getSession } from "@/lib/auth";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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