Skip to content
This repository has been archived by the owner on Jan 25, 2025. It is now read-only.

Commit

Permalink
merge(#19): 首页展示
Browse files Browse the repository at this point in the history
feat(dashboard): 首页展示
  • Loading branch information
bietiaop authored Dec 22, 2024
2 parents dea87ab + d6c57bd commit 5fd48fc
Show file tree
Hide file tree
Showing 21 changed files with 587 additions and 129 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"ahooks": "^3.8.4",
"axios": "^1.7.9",
"clsx": "2.1.1",
"echarts": "^5.5.1",
"event-source-polyfill": "^1.0.31",
"framer-motion": "^11.14.4",
"monaco-editor": "^0.52.2",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions src/components/audio_player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ export default function AudioPlayer(props: AudioPlayerProps) {
const [duration, setDuration] = useState(0)
const [isPlaying, setIsPlaying] = useState(false)
const [volume, setVolume] = useState(100)
const [isCollapsed, setIsCollapsed] = useState(true)
const [isCollapsed, setIsCollapsed] = useLocalStorage(
key.isCollapsedMusicPlayer,
false
)
const audioRef = useRef<HTMLAudioElement>(null)
const cardRef = useRef<HTMLDivElement>(null)
const startY = useRef(0)
Expand Down Expand Up @@ -208,9 +211,8 @@ export default function AudioPlayer(props: AudioPlayerProps) {

<Card
ref={cardRef}
isBlurred
className={clsx(
'border-none bg-background/60 dark:bg-default-100/50 w-full max-w-full transform transition-transform duration-300 overflow-visible',
'border-none bg-background/60 dark:bg-default-300/50 w-full max-w-full transform transition-transform backdrop-blur-md duration-300 overflow-visible',
isSmallScreen ? 'rounded-t-3xl' : 'md:rounded-l-xl'
)}
classNames={{
Expand Down
58 changes: 58 additions & 0 deletions src/components/display_network_item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Card, CardBody } from '@nextui-org/card'
import clsx from 'clsx'

import { title } from '@/components/primitives'

export interface NetworkItemDisplayProps {
count: number
label: string
size?: 'sm' | 'md'
}

const NetworkItemDisplay: React.FC<NetworkItemDisplayProps> = ({
count,
label,
size = 'md'
}) => {
return (
<Card
className={clsx(
'bg-opacity-60 shadow-sm md:rounded-3xl',
size === 'md'
? 'col-span-8 md:col-span-2 bg-danger-50 shadow-danger-100'
: 'col-span-2 md:col-span-1 bg-warning-100 shadow-warning-200'
)}
shadow="sm"
>
<CardBody className="items-center md:gap-1 p-1 md:p-2">
<div
className={clsx(
'font-outfit flex-1',
size === 'md' ? 'text-2xl md:text-3xl' : 'text-xl md:text-2xl',
title({
color: size === 'md' ? 'pink' : 'yellow',
size
})
)}
>
{count}
</div>
<div
className={clsx(
'whitespace-nowrap text-nowrap flex-shrink-0',
size === 'md' ? 'text-sm md:text-base' : 'text-xs md:text-sm',
title({
color: size === 'md' ? 'pink' : 'yellow',
shadow: true,
size: 'xxs'
})
)}
>
{label}
</div>
</CardBody>
</Card>
)
}

export default NetworkItemDisplay
12 changes: 10 additions & 2 deletions src/components/log_com/realtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const RealTimeLogs = () => {
useEffect(() => {
const subscribeLogs = () => {
try {
WebUIManager.getRealTimeLogs((data) => {
console.log('subscribeLogs')
const source = WebUIManager.getRealTimeLogs((data) => {
setDataArr((prev) => {
const newData = [...prev, ...data]
if (newData.length > 1000) {
Expand All @@ -74,12 +75,19 @@ const RealTimeLogs = () => {
return newData
})
})
return () => {
source.close()
}
} catch (error) {
toast.error('获取实时日志失败')
}
}

subscribeLogs()
const close = subscribeLogs()
return () => {
console.log('close')
close?.()
}
}, [])

return (
Expand Down
50 changes: 24 additions & 26 deletions src/components/qq_info_card.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Avatar } from '@nextui-org/avatar'
import { Card, CardBody } from '@nextui-org/card'
import { Image } from '@nextui-org/image'
import clsx from 'clsx'
import { BsTencentQq } from 'react-icons/bs'

import { SelfInfo } from '@/types/user'

Expand All @@ -15,47 +16,44 @@ export interface QQInfoCardProps {
const QQInfoCard: React.FC<QQInfoCardProps> = ({ data, error, loading }) => {
return (
<Card
className="col-span-8 md:col-span-2 shadow-danger-100 relative bg-opacity-30"
className="relative bg-danger-100 bg-opacity-60 overflow-hidden flex-shrink-0 shadow-md shadow-danger-300 dark:shadow-danger-50"
shadow="none"
radius="sm"
radius="lg"
>
<PageLoading loading={loading} />
{error ? (
<CardBody className="items-center gap-1 justify-center">
<div className="font-outfit flex-1 text-pink-500">Error</div>
<div className="font-outfit flex-1 text-content1-foreground">
Error
</div>
<div className="whitespace-nowrap text-nowrap flex-shrink-0">
{error.message}
</div>
</CardBody>
) : (
<CardBody className="flex-row items-stretch gap-2 justify-center">
<div className="flex items-center text-lg font-bold font-noto-serif">
欢迎回来,
<CardBody className="flex-row items-center gap-2 overflow-hidden relative">
<div className="absolute right-0 bottom-0 text-5xl text-danger-400">
<BsTencentQq />
</div>
<div className="flex items-center gap-1 shadow-md py-1 pl-1 pr-4 rounded-full">
<Avatar
<div className="relative flex-shrink-0 z-10">
<Image
src={
data?.avatarUrl ??
`https://q1.qlogo.cn/g?b=qq&nk=${data?.uin}&s=1`
}
size="sm"
className="flex-shrink-0 shadow-md"
className="shadow-md rounded-full w-12 aspect-square"
/>
<div className="flex-col justify-center">
<div className="font-outfit text-pink-500 text-sm">
{data?.nick}
</div>
<div className="font-ubuntu text-gray-500 text-xs">
{data?.uin}
</div>
</div>
<div className="flex-shrink-0 flex items-center ml-2">
<div
className={clsx(
'w-2 h-2 rounded-full',
data?.online ? 'bg-green-500' : 'bg-gray-500'
)}
></div>
<div
className={clsx(
'w-4 h-4 rounded-full absolute right-0.5 bottom-0 border-2 border-danger-100 z-10',
data?.online ? 'bg-green-500' : 'bg-gray-500'
)}
></div>
</div>
<div className="flex-col justify-center">
<div className="font-outfit text-lg truncate">{data?.nick}</div>
<div className="font-ubuntu text-danger-500 text-sm">
{data?.uin}
</div>
</div>
</CardBody>
Expand Down
2 changes: 1 addition & 1 deletion src/components/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const SideBar: React.FC<SideBarProps> = (props) => {
return (
<div
className={clsx(
'overflow-hidden transition-width',
'overflow-hidden transition-width fixed top-0 left-0 h-full z-50 bg-background md:bg-transparent md:static shadow-md md:shadow-none rounded-r-md md:rounded-none',
open ? 'w-64' : 'w-0'
)}
>
Expand Down
69 changes: 69 additions & 0 deletions src/components/system_info.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { Card, CardBody, CardHeader } from '@nextui-org/card'
import { useRequest } from 'ahooks'
import { FaCircleInfo } from 'react-icons/fa6'
import { FaQq } from 'react-icons/fa6'
import { IoLogoChrome, IoLogoOctocat } from 'react-icons/io'
import { RiMacFill } from 'react-icons/ri'

import WebUIManager from '@/controllers/webui_manager'

import packageJson from '../../package.json'

export interface SystemInfoItemProps {
title: string
icon?: React.ReactNode
value?: string
}

const SystemInfoItem: React.FC<SystemInfoItemProps> = ({
title,
value = '--',
icon
}) => {
return (
<div className="flex text-sm gap-1 p-2 items-center shadow-sm shadow-danger-50 dark:shadow-danger-100 rounded text-danger-400">
{icon}
<div className="w-24">{title}</div>
<div className="text-danger-200">{value}</div>
</div>
)
}

const SystemInfo = () => {
const { data, loading, error } = useRequest(WebUIManager.getPackageInfo)
return (
<Card className="bg-opacity-60 shadow-sm shadow-danger-50 dark:shadow-danger-100 overflow-visible flex-1">
<CardHeader className="pb-0 items-center gap-1 text-danger-500 font-extrabold">
<FaCircleInfo className="text-lg" />
<span>系统信息</span>
</CardHeader>
<CardBody className="flex-1">
<div className="flex flex-col justify-between h-full">
<SystemInfoItem
title="NapCat 版本"
icon={<IoLogoOctocat className="text-xl" />}
value={
error
? `错误:${error.message}`
: loading
? '加载中...'
: data?.version
}
/>
<SystemInfoItem
title="WebUI 版本"
icon={<IoLogoChrome className="text-xl" />}
value={packageJson.version}
/>
<SystemInfoItem title="QQ 版本" icon={<FaQq className="text-lg" />} />
<SystemInfoItem
title="系统版本"
icon={<RiMacFill className="text-xl" />}
/>
</div>
</CardBody>
</Card>
)
}

export default SystemInfo
Loading

0 comments on commit 5fd48fc

Please sign in to comment.