Merge branch 'main' of https://github.com/hamster1963/nezha-dash-v1 into hamster1963-main

This commit is contained in:
wood chen 2025-03-17 17:19:36 +08:00
commit bfc7a01828
8 changed files with 95 additions and 63 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -10,63 +10,63 @@
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"@fontsource/inter": "^5.1.1", "@fontsource/inter": "5.1.1",
"@heroicons/react": "^2.2.0", "@heroicons/react": "2.2.0",
"@number-flow/react": "^0.5.5", "@number-flow/react": "0.5.5",
"@radix-ui/react-accordion": "^1.2.3", "@radix-ui/react-accordion": "1.2.3",
"@radix-ui/react-checkbox": "^1.1.4", "@radix-ui/react-checkbox": "1.1.4",
"@radix-ui/react-dialog": "^1.1.6", "@radix-ui/react-dialog": "1.1.6",
"@radix-ui/react-dropdown-menu": "^2.1.6", "@radix-ui/react-dropdown-menu": "2.1.6",
"@radix-ui/react-label": "^2.1.2", "@radix-ui/react-label": "2.1.2",
"@radix-ui/react-popover": "^1.1.6", "@radix-ui/react-popover": "1.1.6",
"@radix-ui/react-progress": "^1.1.2", "@radix-ui/react-progress": "1.1.2",
"@radix-ui/react-select": "^2.1.6", "@radix-ui/react-select": "2.1.6",
"@radix-ui/react-separator": "^1.1.2", "@radix-ui/react-separator": "1.1.2",
"@radix-ui/react-slot": "^1.1.2", "@radix-ui/react-slot": "1.1.2",
"@radix-ui/react-switch": "^1.1.3", "@radix-ui/react-switch": "1.1.3",
"@radix-ui/react-tooltip": "^1.1.8", "@radix-ui/react-tooltip": "1.1.8",
"@tanstack/react-query": "^5.66.7", "@tanstack/react-query": "5.66.7",
"@tanstack/react-query-devtools": "^5.66.7", "@tanstack/react-query-devtools": "5.66.7",
"@tanstack/react-table": "^8.21.2", "@tanstack/react-table": "8.21.2",
"@trivago/prettier-plugin-sort-imports": "^5.2.2", "@trivago/prettier-plugin-sort-imports": "5.2.2",
"@types/d3-geo": "^3.1.0", "@types/d3-geo": "3.1.0",
"@types/luxon": "^3.4.2", "@types/luxon": "3.4.2",
"class-variance-authority": "^0.7.1", "class-variance-authority": "0.7.1",
"clsx": "^2.1.1", "clsx": "2.1.1",
"cmdk": "1.0.0", "cmdk": "1.0.0",
"country-flag-icons": "^1.5.18", "country-flag-icons": "1.5.18",
"d3-geo": "^3.1.1", "d3-geo": "3.1.1",
"dayjs": "^1.11.13", "dayjs": "1.11.13",
"framer-motion": "^12.4.5", "framer-motion": "12.4.5",
"i18n-iso-countries": "^7.14.0", "i18n-iso-countries": "7.14.0",
"i18next": "^24.2.2", "i18next": "24.2.2",
"lucide-react": "^0.460.0", "lucide-react": "0.460.0",
"luxon": "^3.5.0", "luxon": "3.5.0",
"prettier-plugin-tailwindcss": "^0.6.11", "prettier-plugin-tailwindcss": "0.6.11",
"react": "^18.2.0", "react": "19.0.0",
"react-dom": "^18.2.0", "react-dom": "19.0.0",
"react-i18next": "^15.4.1", "react-i18next": "15.4.1",
"react-router-dom": "^7.2.0", "react-router-dom": "7.2.0",
"recharts": "^2.15.1", "recharts": "2.15.1",
"sonner": "^1.7.4", "sonner": "1.7.4",
"tailwind-merge": "^2.6.0", "tailwind-merge": "2.6.0",
"tailwindcss-animate": "^1.0.7" "tailwindcss-animate": "1.0.7"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.20.0", "@eslint/js": "9.20.0",
"@types/node": "^22.13.4", "@types/node": "22.13.4",
"@types/react": "^19.0.10", "@types/react": "19.0.10",
"@types/react-dom": "^19.0.4", "@types/react-dom": "19.0.4",
"@vitejs/plugin-react-swc": "^3.8.0", "@vitejs/plugin-react-swc": "3.8.0",
"autoprefixer": "^10.4.20", "autoprefixer": "10.4.20",
"eslint": "^9.20.1", "eslint": "9.20.1",
"eslint-plugin-react-hooks": "^5.1.0", "eslint-plugin-react-hooks": "5.1.0",
"eslint-plugin-react-refresh": "^0.4.19", "eslint-plugin-react-refresh": "0.4.19",
"globals": "^15.15.0", "globals": "15.15.0",
"postcss": "^8.5.3", "postcss": "8.5.3",
"tailwindcss": "^3.4.17", "tailwindcss": "3.4.17",
"typescript": "~5.6.3", "typescript": "~5.6.3",
"typescript-eslint": "^8.24.1", "typescript-eslint": "8.24.1",
"vite": "^6.1.1" "vite": "6.1.1"
} }
} }

View File

@ -74,6 +74,7 @@ export default function ServerDetailOverview({ server_id }: { server_id: string
net_out_transfer, net_out_transfer,
net_in_transfer, net_in_transfer,
last_active_time_string, last_active_time_string,
boot_time_string,
} = formatNezhaInfo(nezhaWsData.now, server) } = formatNezhaInfo(nezhaWsData.now, server)
const customBackgroundImage = (window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined const customBackgroundImage = (window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined
@ -116,7 +117,9 @@ export default function ServerDetailOverview({ server_id }: { server_id: string
<p className="text-xs text-muted-foreground">{t("serverDetail.uptime")}</p> <p className="text-xs text-muted-foreground">{t("serverDetail.uptime")}</p>
<div className="text-xs"> <div className="text-xs">
{" "} {" "}
{online ? (uptime / 86400).toFixed(0) : "N/A"} {t("serverDetail.days")} {uptime / 86400 >= 1
? `${Math.floor(uptime / 86400)} ${t("serverDetail.days")} ${Math.floor((uptime % 86400) / 3600)} ${t("serverDetail.hours")}`
: `${Math.floor(uptime / 3600)} ${t("serverDetail.hours")}`}
</div> </div>
</section> </section>
</CardContent> </CardContent>
@ -285,6 +288,14 @@ export default function ServerDetailOverview({ server_id }: { server_id: string
</section> </section>
<section className="flex flex-wrap gap-2 mt-1"> <section className="flex flex-wrap gap-2 mt-1">
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
<CardContent className="px-1.5 py-1">
<section className="flex flex-col items-start gap-0.5">
<p className="text-xs text-muted-foreground">{t("serverDetail.bootTime")}</p>
<div className="text-xs">{boot_time_string ? boot_time_string : "N/A"}</div>
</section>
</CardContent>
</Card>
<Card className="rounded-[10px] bg-transparent border-none shadow-none"> <Card className="rounded-[10px] bg-transparent border-none shadow-none">
<CardContent className="px-1.5 py-1"> <CardContent className="px-1.5 py-1">
<section className="flex flex-col items-start gap-0.5"> <section className="flex flex-col items-start gap-0.5">

View File

@ -35,6 +35,7 @@ export function formatNezhaInfo(now: number, serverInfo: NezhaServer) {
swap_total: serverInfo.host.swap_total || 0, swap_total: serverInfo.host.swap_total || 0,
disk_total: serverInfo.host.disk_total || 0, disk_total: serverInfo.host.disk_total || 0,
boot_time: serverInfo.host.boot_time || 0, boot_time: serverInfo.host.boot_time || 0,
boot_time_string: serverInfo.host.boot_time ? dayjs(serverInfo.host.boot_time * 1000).format("YYYY-MM-DD HH:mm:ss") : "",
platform_version: serverInfo.host.platform_version || "", platform_version: serverInfo.host.platform_version || "",
cpu_info: serverInfo.host.cpu || [], cpu_info: serverInfo.host.cpu || [],
gpu_info: serverInfo.host.gpu || [], gpu_info: serverInfo.host.gpu || [],

View File

@ -55,6 +55,7 @@
"status": "Status", "status": "Status",
"online": "Online", "online": "Online",
"days": "Days", "days": "Days",
"hours": "Hours",
"offline": "Offline", "offline": "Offline",
"unknown": "Unknown", "unknown": "Unknown",
"uptime": "Uptime", "uptime": "Uptime",
@ -67,7 +68,8 @@
"upload": "Upload", "upload": "Upload",
"download": "Download", "download": "Download",
"lastActive": "Last active time", "lastActive": "Last active time",
"temperature": "Temperature" "temperature": "Temperature",
"bootTime": "Boot time"
}, },
"serverDetailChart": { "serverDetailChart": {
"process": "Process", "process": "Process",

View File

@ -60,6 +60,7 @@
"status": "状态", "status": "状态",
"online": "在线", "online": "在线",
"days": "天", "days": "天",
"hours": "小时",
"offline": "离线", "offline": "离线",
"unknown": "未知", "unknown": "未知",
"uptime": "运行时间", "uptime": "运行时间",
@ -72,7 +73,8 @@
"upload": "上传", "upload": "上传",
"download": "下载", "download": "下载",
"lastActive": "最后上报时间", "lastActive": "最后上报时间",
"temperature": "温度" "temperature": "温度",
"bootTime": "启动时间"
}, },
"serverDetailChart": { "serverDetailChart": {
"process": "进程数", "process": "进程数",

View File

@ -55,6 +55,7 @@
"status": "狀態", "status": "狀態",
"online": "線上", "online": "線上",
"days": "天", "days": "天",
"hours": "小時",
"offline": "離線", "offline": "離線",
"unknown": "未知", "unknown": "未知",
"uptime": "運行時間", "uptime": "運行時間",
@ -67,7 +68,8 @@
"upload": "上傳", "upload": "上傳",
"download": "下載", "download": "下載",
"lastActive": "最後上報時間", "lastActive": "最後上報時間",
"temperature": "溫度" "temperature": "溫度",
"bootTime": "啟動時間"
}, },
"serverDetailChart": { "serverDetailChart": {
"process": "進程數", "process": "進程數",

View File

@ -62,11 +62,25 @@ export default function Servers() {
}, []) }, [])
useEffect(() => { useEffect(() => {
const inlineState = localStorage.getItem("inline") const checkInlineSettings = () => {
if (window.ForceCardInline) { const isMobile = window.innerWidth < 768
setInline("1")
} else if (inlineState !== null) { if (!isMobile) {
setInline(inlineState) const inlineState = localStorage.getItem("inline")
if (window.ForceCardInline) {
setInline("1")
} else if (inlineState !== null) {
setInline(inlineState)
}
}
}
checkInlineSettings()
window.addEventListener("resize", checkInlineSettings)
return () => {
window.removeEventListener("resize", checkInlineSettings)
} }
}, []) }, [])