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

View File

@ -74,6 +74,7 @@ export default function ServerDetailOverview({ server_id }: { server_id: string
net_out_transfer,
net_in_transfer,
last_active_time_string,
boot_time_string,
} = formatNezhaInfo(nezhaWsData.now, server)
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>
<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>
</section>
</CardContent>
@ -285,6 +288,14 @@ export default function ServerDetailOverview({ server_id }: { server_id: string
</section>
<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">
<CardContent className="px-1.5 py-1">
<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,
disk_total: serverInfo.host.disk_total || 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 || "",
cpu_info: serverInfo.host.cpu || [],
gpu_info: serverInfo.host.gpu || [],

View File

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

View File

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

View File

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

View File

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