This commit is contained in:
2026-03-22 13:55:23 +08:00
parent c3f196ded4
commit 69099986e0
616 changed files with 38942 additions and 3 deletions

View File

@@ -0,0 +1,273 @@
<script setup lang="ts">
import { VisArea, VisAxis, VisLine, VisXYContainer } from '@unovis/vue'
import type { ChartConfig } from '@/components/ui/chart'
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from '@/components/ui/card'
import {
ChartContainer,
ChartCrosshair,
ChartLegendContent,
ChartTooltip,
ChartTooltipContent,
componentToString,
} from '@/components/ui/chart'
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select'
const chartData = [
{ date: new Date('2024-04-01'), desktop: 222, mobile: 150 },
{ date: new Date('2024-04-02'), desktop: 97, mobile: 180 },
{ date: new Date('2024-04-03'), desktop: 167, mobile: 120 },
{ date: new Date('2024-04-04'), desktop: 242, mobile: 260 },
{ date: new Date('2024-04-05'), desktop: 373, mobile: 290 },
{ date: new Date('2024-04-06'), desktop: 301, mobile: 340 },
{ date: new Date('2024-04-07'), desktop: 245, mobile: 180 },
{ date: new Date('2024-04-08'), desktop: 409, mobile: 320 },
{ date: new Date('2024-04-09'), desktop: 59, mobile: 110 },
{ date: new Date('2024-04-10'), desktop: 261, mobile: 190 },
{ date: new Date('2024-04-11'), desktop: 327, mobile: 350 },
{ date: new Date('2024-04-12'), desktop: 292, mobile: 210 },
{ date: new Date('2024-04-13'), desktop: 342, mobile: 380 },
{ date: new Date('2024-04-14'), desktop: 137, mobile: 220 },
{ date: new Date('2024-04-15'), desktop: 120, mobile: 170 },
{ date: new Date('2024-04-16'), desktop: 138, mobile: 190 },
{ date: new Date('2024-04-17'), desktop: 446, mobile: 360 },
{ date: new Date('2024-04-18'), desktop: 364, mobile: 410 },
{ date: new Date('2024-04-19'), desktop: 243, mobile: 180 },
{ date: new Date('2024-04-20'), desktop: 89, mobile: 150 },
{ date: new Date('2024-04-21'), desktop: 137, mobile: 200 },
{ date: new Date('2024-04-22'), desktop: 224, mobile: 170 },
{ date: new Date('2024-04-23'), desktop: 138, mobile: 230 },
{ date: new Date('2024-04-24'), desktop: 387, mobile: 290 },
{ date: new Date('2024-04-25'), desktop: 215, mobile: 250 },
{ date: new Date('2024-04-26'), desktop: 75, mobile: 130 },
{ date: new Date('2024-04-27'), desktop: 383, mobile: 420 },
{ date: new Date('2024-04-28'), desktop: 122, mobile: 180 },
{ date: new Date('2024-04-29'), desktop: 315, mobile: 240 },
{ date: new Date('2024-04-30'), desktop: 454, mobile: 380 },
{ date: new Date('2024-05-01'), desktop: 165, mobile: 220 },
{ date: new Date('2024-05-02'), desktop: 293, mobile: 310 },
{ date: new Date('2024-05-03'), desktop: 247, mobile: 190 },
{ date: new Date('2024-05-04'), desktop: 385, mobile: 420 },
{ date: new Date('2024-05-05'), desktop: 481, mobile: 390 },
{ date: new Date('2024-05-06'), desktop: 498, mobile: 520 },
{ date: new Date('2024-05-07'), desktop: 388, mobile: 300 },
{ date: new Date('2024-05-08'), desktop: 149, mobile: 210 },
{ date: new Date('2024-05-09'), desktop: 227, mobile: 180 },
{ date: new Date('2024-05-10'), desktop: 293, mobile: 330 },
{ date: new Date('2024-05-11'), desktop: 335, mobile: 270 },
{ date: new Date('2024-05-12'), desktop: 197, mobile: 240 },
{ date: new Date('2024-05-13'), desktop: 197, mobile: 160 },
{ date: new Date('2024-05-14'), desktop: 448, mobile: 490 },
{ date: new Date('2024-05-15'), desktop: 473, mobile: 380 },
{ date: new Date('2024-05-16'), desktop: 338, mobile: 400 },
{ date: new Date('2024-05-17'), desktop: 499, mobile: 420 },
{ date: new Date('2024-05-18'), desktop: 315, mobile: 350 },
{ date: new Date('2024-05-19'), desktop: 235, mobile: 180 },
{ date: new Date('2024-05-20'), desktop: 177, mobile: 230 },
{ date: new Date('2024-05-21'), desktop: 82, mobile: 140 },
{ date: new Date('2024-05-22'), desktop: 81, mobile: 120 },
{ date: new Date('2024-05-23'), desktop: 252, mobile: 290 },
{ date: new Date('2024-05-24'), desktop: 294, mobile: 220 },
{ date: new Date('2024-05-25'), desktop: 201, mobile: 250 },
{ date: new Date('2024-05-26'), desktop: 213, mobile: 170 },
{ date: new Date('2024-05-27'), desktop: 420, mobile: 460 },
{ date: new Date('2024-05-28'), desktop: 233, mobile: 190 },
{ date: new Date('2024-05-29'), desktop: 78, mobile: 130 },
{ date: new Date('2024-05-30'), desktop: 340, mobile: 280 },
{ date: new Date('2024-05-31'), desktop: 178, mobile: 230 },
{ date: new Date('2024-06-01'), desktop: 178, mobile: 200 },
{ date: new Date('2024-06-02'), desktop: 470, mobile: 410 },
{ date: new Date('2024-06-03'), desktop: 103, mobile: 160 },
{ date: new Date('2024-06-04'), desktop: 439, mobile: 380 },
{ date: new Date('2024-06-05'), desktop: 88, mobile: 140 },
{ date: new Date('2024-06-06'), desktop: 294, mobile: 250 },
{ date: new Date('2024-06-07'), desktop: 323, mobile: 370 },
{ date: new Date('2024-06-08'), desktop: 385, mobile: 320 },
{ date: new Date('2024-06-09'), desktop: 438, mobile: 480 },
{ date: new Date('2024-06-10'), desktop: 155, mobile: 200 },
{ date: new Date('2024-06-11'), desktop: 92, mobile: 150 },
{ date: new Date('2024-06-12'), desktop: 492, mobile: 420 },
{ date: new Date('2024-06-13'), desktop: 81, mobile: 130 },
{ date: new Date('2024-06-14'), desktop: 426, mobile: 380 },
{ date: new Date('2024-06-15'), desktop: 307, mobile: 350 },
{ date: new Date('2024-06-16'), desktop: 371, mobile: 310 },
{ date: new Date('2024-06-17'), desktop: 475, mobile: 520 },
{ date: new Date('2024-06-18'), desktop: 107, mobile: 170 },
{ date: new Date('2024-06-19'), desktop: 341, mobile: 290 },
{ date: new Date('2024-06-20'), desktop: 408, mobile: 450 },
{ date: new Date('2024-06-21'), desktop: 169, mobile: 210 },
{ date: new Date('2024-06-22'), desktop: 317, mobile: 270 },
{ date: new Date('2024-06-23'), desktop: 480, mobile: 530 },
{ date: new Date('2024-06-24'), desktop: 132, mobile: 180 },
{ date: new Date('2024-06-25'), desktop: 141, mobile: 190 },
{ date: new Date('2024-06-26'), desktop: 434, mobile: 380 },
{ date: new Date('2024-06-27'), desktop: 448, mobile: 490 },
{ date: new Date('2024-06-28'), desktop: 149, mobile: 200 },
{ date: new Date('2024-06-29'), desktop: 103, mobile: 160 },
{ date: new Date('2024-06-30'), desktop: 446, mobile: 400 },
]
type Data = typeof chartData[number]
const chartConfig = {
// visitors: {
// label: 'Visitors',
// },
mobile: {
label: 'Mobile',
color: 'var(--chart-2)',
},
desktop: {
label: 'Desktop',
color: 'var(--chart-1)',
},
} satisfies ChartConfig
const svgDefs = `
<linearGradient id="fillDesktop" x1="0" y1="0" x2="0" y2="1">
<stop
offset="5%"
stop-color="var(--color-desktop)"
stop-opacity="0.8"
/>
<stop
offset="95%"
stop-color="var(--color-desktop)"
stop-opacity="0.1"
/>
</linearGradient>
<linearGradient id="fillMobile" x1="0" y1="0" x2="0" y2="1">
<stop
offset="5%"
stop-color="var(--color-mobile)"
stop-opacity="0.8"
/>
<stop
offset="95%"
stop-color="var(--color-mobile)"
stop-opacity="0.1"
/>
</linearGradient>
`
const timeRange = ref('90d')
const filterRange = computed(() => {
return chartData.filter((item) => {
const date = new Date(item.date)
const referenceDate = new Date('2024-06-30')
let daysToSubtract = 90
if (timeRange.value === '30d') {
daysToSubtract = 30
}
else if (timeRange.value === '7d') {
daysToSubtract = 7
}
const startDate = new Date(referenceDate)
startDate.setDate(startDate.getDate() - daysToSubtract)
return date >= startDate
})
})
</script>
<template>
<Card class="pt-0">
<CardHeader class="flex items-center gap-2 space-y-0 border-b py-5 sm:flex-row">
<div class="grid flex-1 gap-1">
<CardTitle>Area Chart - Interactive</CardTitle>
<CardDescription>
Showing total visitors for the last 3 months
</CardDescription>
</div>
<Select v-model="timeRange">
<SelectTrigger
class="hidden w-[160px] rounded-lg sm:ml-auto sm:flex"
aria-label="Select a value"
>
<SelectValue placeholder="Last 3 months" />
</SelectTrigger>
<SelectContent class="rounded-xl">
<SelectItem value="90d" class="rounded-lg">
Last 3 months
</SelectItem>
<SelectItem value="30d" class="rounded-lg">
Last 30 days
</SelectItem>
<SelectItem value="7d" class="rounded-lg">
Last 7 days
</SelectItem>
</SelectContent>
</Select>
</CardHeader>
<CardContent class="px-2 pt-4 sm:px-6 sm:pt-6 pb-4">
<ChartContainer :config="chartConfig" class="aspect-auto h-[250px] w-full" :cursor="false">
<VisXYContainer
:data="filterRange"
:svg-defs="svgDefs"
:margin="{ left: -40 }"
:y-domain="[0, 1200]"
>
<VisArea
:x="(d: Data) => d.date"
:y="[(d: Data) => d.mobile, (d: Data) => d.desktop]"
:color="(_d: Data, i: number) => ['url(#fillMobile)', 'url(#fillDesktop)'][i]"
:opacity="0.6"
/>
<VisLine
:x="(d: Data) => d.date"
:y="[(d: Data) => d.mobile, (d: Data) => d.mobile + d.desktop]"
:color="(_d: Data, i: number) => [chartConfig.mobile.color, chartConfig.desktop.color][i]"
:line-width="1"
/>
<VisAxis
type="x"
:x="(d: Data) => d.date"
:tick-line="false"
:domain-line="false"
:grid-line="false"
:num-ticks="6"
:tick-format="(d: number, _index: number) => {
const date = new Date(d)
return date.toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
})
}"
/>
<VisAxis
type="y"
:num-ticks="3"
:tick-line="false"
:domain-line="false"
/>
<ChartTooltip />
<ChartCrosshair
:template="componentToString(chartConfig, ChartTooltipContent, {
labelFormatter: (d) => {
return new Date(d).toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
})
},
})"
:color="(_d: Data, i: number) => [chartConfig.mobile.color, chartConfig.desktop.color][i % 2]"
/>
</VisXYContainer>
<ChartLegendContent />
</ChartContainer>
</CardContent>
</Card>
</template>

View File

@@ -0,0 +1,135 @@
<script lang="ts" setup>
import OverviewChart from './overview-chart.vue'
import RecentSales from './recent-sales.vue'
</script>
<template>
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
<UiCard>
<UiCardHeader class="flex flex-row items-center justify-between pb-2 space-y-0">
<UiCardTitle class="text-sm font-medium">
Total Revenue
</UiCardTitle>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
class="size-4 text-muted-foreground"
>
<path d="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6" />
</svg>
</UiCardHeader>
<UiCardContent>
<div class="text-2xl font-bold">
$45,231.89
</div>
<p class="text-xs text-muted-foreground">
+20.1% from last month
</p>
</UiCardContent>
</UiCard>
<UiCard>
<UiCardHeader class="flex flex-row items-center justify-between pb-2 space-y-0">
<UiCardTitle class="text-sm font-medium">
Subscriptions
</UiCardTitle>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
class="size-4 text-muted-foreground"
>
<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" />
<circle cx="9" cy="7" r="4" />
<path d="M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75" />
</svg>
</UiCardHeader>
<UiCardContent>
<div class="text-2xl font-bold">
+2350
</div>
<p class="text-xs text-muted-foreground">
+180.1% from last month
</p>
</UiCardContent>
</UiCard>
<UiCard>
<UiCardHeader class="flex flex-row items-center justify-between pb-2 space-y-0">
<UiCardTitle class="text-sm font-medium">
Sales
</UiCardTitle>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
class="size-4 text-muted-foreground"
>
<rect width="20" height="14" x="2" y="5" rx="2" />
<path d="M2 10h20" />
</svg>
</UiCardHeader>
<UiCardContent>
<div class="text-2xl font-bold">
+12,234
</div>
<p class="text-xs text-muted-foreground">
+19% from last month
</p>
</UiCardContent>
</UiCard>
<UiCard>
<UiCardHeader class="flex flex-row items-center justify-between pb-2 space-y-0">
<UiCardTitle class="text-sm font-medium">
Active Now
</UiCardTitle>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
class="size-4 text-muted-foreground"
>
<path d="M22 12h-4l-3 9L9 3l-3 9H2" />
</svg>
</UiCardHeader>
<UiCardContent>
<div class="text-2xl font-bold">
+573
</div>
<p class="text-xs text-muted-foreground">
+201 since last hour
</p>
</UiCardContent>
</UiCard>
</div>
<div class="grid grid-cols-1 gap-4 lg:grid-cols-7">
<OverviewChart class="col-span-1 lg:col-span-4" />
<UiCard class="col-span-1 lg:col-span-3">
<UiCardHeader>
<UiCardTitle>Recent Sales</UiCardTitle>
<UiCardDescription>
You made 265 sales this month.
</UiCardDescription>
</UiCardHeader>
<UiCardContent>
<RecentSales />
</UiCardContent>
</UiCard>
</div>
</template>

View File

@@ -0,0 +1,42 @@
<script lang="ts" setup>
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
interface User {
avatar: string
name: string
email: string
amount: string
}
const list = ref<User[]>([
{ avatar: '', name: 'Olivia Martin', email: 'olivia.martin@email.com', amount: '$1,999.00' },
{ avatar: '', name: 'Jackson Lee', email: 'jackson.lee@email.com', amount: '$39.00' },
{ avatar: '', name: 'Isabella Nguyen', email: 'isabella.nguyen@email.com', amount: '$299.00' },
{ avatar: '', name: 'William Kim', email: 'will@email.com', amount: '$99.00' },
{ avatar: '', name: 'Sofia Davis', email: 'sofia.davis@email.com', amount: '$39.00' },
])
</script>
<template>
<div class="space-y-8">
<div v-for="item in list" :key="item.name" class="flex items-center gap-4">
<Avatar class-name="h-9 w-9">
<AvatarImage :src="item.avatar" alt="Avatar" />
<AvatarFallback>{{ item.name[0].toUpperCase() }}</AvatarFallback>
</Avatar>
<div class="flex flex-wrap items-center justify-between flex-1">
<div class="space-y-1">
<p class="text-sm font-medium leading-none">
{{ item.name }}
</p>
<p class="text-sm text-muted-foreground">
{{ item.email }}
</p>
</div>
<div class="font-medium">
{{ item.amount }}
</div>
</div>
</div>
</div>
</template>

View File

@@ -0,0 +1,50 @@
<script lang="ts" setup>
import { toast } from 'vue-sonner'
import { BasicPage } from '@/components/global-layout'
import { Button } from '@/components/ui/button'
import OverviewContent from './components/overview-content.vue'
const tabs = ref([
{ name: 'Overview', value: 'overview' },
{ name: 'Analytics', value: 'analytics', disabled: true },
{ name: 'Reports', value: 'reports', disabled: true },
{ name: 'Notifications', value: 'notifications', disabled: true },
])
const activeTab = ref(tabs.value[0].value)
</script>
<template>
<BasicPage
title="workspace"
description="workspace description"
sticky
>
<template #actions>
<Button
@click="() => toast('hello', {
position: 'top-center',
})"
>
{{ $t('download') }}
</Button>
</template>
<UiTabs :default-value="activeTab" class="w-full">
<UiTabsList>
<UiTabsTrigger
v-for="tab in tabs" :key="tab.value"
:value="tab.value"
:disabled="tab.disabled"
>
{{ tab.name }}
</UiTabsTrigger>
</UiTabsList>
<UiTabsContent value="overview" class="space-y-4">
<OverviewContent />
</UiTabsContent>
</UiTabs>
</BasicPage>
</template>