-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Allen Zhang (张涛)
committed
Oct 9, 2024
1 parent
6b868d5
commit 13466b0
Showing
13 changed files
with
429 additions
and
96 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "new-york", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.js", | ||
"css": "src/index.css", | ||
"baseColor": "neutral", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils", | ||
"ui": "@/components/ui", | ||
"lib": "@/lib", | ||
"hooks": "@/hooks" | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,24 @@ | ||
import { useState } from 'react' | ||
import reactLogo from './assets/react.svg' | ||
import viteLogo from '/vite.svg' | ||
import './App.css' | ||
// import { Button } from "@/components/ui/button" | ||
|
||
function App() { | ||
const [count, setCount] = useState(0) | ||
import {Dashboard} from "@/components/Dashboard.tsx"; | ||
|
||
function App() { | ||
return ( | ||
<> | ||
<div> | ||
<a href="https://vitejs.dev" target="_blank"> | ||
<img src={viteLogo} className="logo" alt="Vite logo" /> | ||
</a> | ||
<a href="https://react.dev" target="_blank"> | ||
<img src={reactLogo} className="logo react" alt="React logo" /> | ||
</a> | ||
<div> | ||
<div className="min-h-screen bg-background text-foreground w-[100vw]"> | ||
<header className="border-b"> | ||
<div className="container mx-auto flex items-center justify-between py-4"> | ||
<h1 className="text-2xl font-bold">数据库大盘</h1> | ||
<span></span> | ||
</div> | ||
</header> | ||
<main className="container mx-auto py-8"> | ||
<Dashboard/> | ||
</main> | ||
</div> | ||
<h1>Vite + React</h1> | ||
<div className="card"> | ||
<button onClick={() => setCount((count) => count + 1)}> | ||
count is {count} | ||
</button> | ||
<p> | ||
Edit <code>src/App.tsx</code> and save to test HMR | ||
</p> | ||
</div> | ||
<p className="read-the-docs"> | ||
Click on the Vite and React logos to learn more | ||
</p> | ||
</> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default App | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" | ||
import { PieChart, Pie, Cell, BarChart, Bar, XAxis, YAxis, Tooltip, Legend, ResponsiveContainer } from 'recharts' | ||
import { Database, Table, Users } from "lucide-react" | ||
|
||
const databaseSize = 1024 // GB | ||
const tables = [ | ||
{ name: "用户表", value: 1000000 }, | ||
{ name: "订单表", value: 5000000 }, | ||
{ name: "产品表", value: 100000 }, | ||
{ name: "日志表", value: 10000000 }, | ||
] | ||
const departments = [ | ||
{ name: "市场部", value: 30 }, | ||
{ name: "销售部", value: 25 }, | ||
{ name: "技术部", value: 20 }, | ||
{ name: "人力资源部", value: 15 }, | ||
{ name: "财务部", value: 10 }, | ||
] | ||
|
||
const COLORS = ['#0088FE', '#00C49F', '#FFBB28', '#FF8042', '#8884d8'] | ||
|
||
export function Dashboard() { | ||
return ( | ||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3"> | ||
<Card> | ||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> | ||
<CardTitle className="text-sm font-medium"> | ||
数据库总体积 | ||
</CardTitle> | ||
<Database className="h-4 w-4 text-muted-foreground" /> | ||
</CardHeader> | ||
<CardContent> | ||
<div className="text-2xl font-bold">{databaseSize} GB</div> | ||
</CardContent> | ||
</Card> | ||
<Card> | ||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> | ||
<CardTitle className="text-sm font-medium"> | ||
表数据量 | ||
</CardTitle> | ||
<Table className="h-4 w-4 text-muted-foreground" /> | ||
</CardHeader> | ||
<CardContent className="h-[200px]"> | ||
<ResponsiveContainer width="100%" height="100%"> | ||
<BarChart data={tables}> | ||
<XAxis dataKey="name" fontSize={12} /> | ||
<YAxis fontSize={12} /> | ||
<Tooltip /> | ||
<Legend /> | ||
<Bar dataKey="value" fill="#8884d8" /> | ||
</BarChart> | ||
</ResponsiveContainer> | ||
</CardContent> | ||
</Card> | ||
<Card> | ||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> | ||
<CardTitle className="text-sm font-medium"> | ||
已接入部门 | ||
</CardTitle> | ||
<Users className="h-4 w-4 text-muted-foreground" /> | ||
</CardHeader> | ||
<CardContent className="h-[200px]"> | ||
<ResponsiveContainer width="100%" height="100%"> | ||
<PieChart> | ||
<Pie | ||
data={departments} | ||
cx="50%" | ||
cy="50%" | ||
labelLine={false} | ||
outerRadius={80} | ||
fill="#8884d8" | ||
dataKey="value" | ||
label={({ name, percent }) => `${name} ${(percent * 100).toFixed(0)}%`} | ||
> | ||
{departments.map((_entry, index) => ( | ||
<Cell key={`cell-${index}`} fill={COLORS[index % COLORS.length]} /> | ||
))} | ||
</Pie> | ||
</PieChart> | ||
</ResponsiveContainer> | ||
</CardContent> | ||
</Card> | ||
</div> | ||
) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import * as React from "react" | ||
import { Slot } from "@radix-ui/react-slot" | ||
import { cva, type VariantProps } from "class-variance-authority" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const buttonVariants = cva( | ||
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50", | ||
{ | ||
variants: { | ||
variant: { | ||
default: | ||
"bg-primary text-primary-foreground shadow hover:bg-primary/90", | ||
destructive: | ||
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90", | ||
outline: | ||
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground", | ||
secondary: | ||
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", | ||
ghost: "hover:bg-accent hover:text-accent-foreground", | ||
link: "text-primary underline-offset-4 hover:underline", | ||
}, | ||
size: { | ||
default: "h-9 px-4 py-2", | ||
sm: "h-8 rounded-md px-3 text-xs", | ||
lg: "h-10 rounded-md px-8", | ||
icon: "h-9 w-9", | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: "default", | ||
size: "default", | ||
}, | ||
} | ||
) | ||
|
||
export interface ButtonProps | ||
extends React.ButtonHTMLAttributes<HTMLButtonElement>, | ||
VariantProps<typeof buttonVariants> { | ||
asChild?: boolean | ||
} | ||
|
||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( | ||
({ className, variant, size, asChild = false, ...props }, ref) => { | ||
const Comp = asChild ? Slot : "button" | ||
return ( | ||
<Comp | ||
className={cn(buttonVariants({ variant, size, className }))} | ||
ref={ref} | ||
{...props} | ||
/> | ||
) | ||
} | ||
) | ||
Button.displayName = "Button" | ||
|
||
export { Button, buttonVariants } |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import * as React from 'react'; | ||
|
||
import { cn } from '@/lib/utils'; | ||
|
||
const Card = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn( | ||
'rounded-xl border bg-card text-card-foreground shadow', | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
Card.displayName = 'Card'; | ||
|
||
const CardHeader = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn('flex flex-col space-y-1.5 p-6', className)} | ||
{...props} | ||
/> | ||
)); | ||
CardHeader.displayName = 'CardHeader'; | ||
|
||
const CardTitle = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLHeadingElement> | ||
>(({ className, ...props }, ref) => ( | ||
<h3 | ||
ref={ref} | ||
className={cn('font-semibold leading-none tracking-tight', className)} | ||
{...props} | ||
/> | ||
)); | ||
CardTitle.displayName = 'CardTitle'; | ||
|
||
const CardDescription = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLParagraphElement> | ||
>(({ className, ...props }, ref) => ( | ||
<p | ||
ref={ref} | ||
className={cn('text-sm text-muted-foreground', className)} | ||
{...props} | ||
/> | ||
)); | ||
CardDescription.displayName = 'CardDescription'; | ||
|
||
const CardContent = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div ref={ref} className={cn('p-6 pt-0', className)} {...props} /> | ||
)); | ||
CardContent.displayName = 'CardContent'; | ||
|
||
const CardFooter = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn('flex items-center p-6 pt-0', className)} | ||
{...props} | ||
/> | ||
)); | ||
CardFooter.displayName = 'CardFooter'; | ||
|
||
export { | ||
Card, | ||
CardHeader, | ||
CardFooter, | ||
CardTitle, | ||
CardDescription, | ||
CardContent, | ||
}; |
Oops, something went wrong.