feat: 添加非 cnb-board 环境检查,更新相关路由返回值;更新版本号至 0.1.12,新增 common.ts 文件
This commit is contained in:
@@ -65,47 +65,56 @@ export const getLiveMdContent = (opts?: { more?: boolean }) => {
|
||||
`
|
||||
const labels = [
|
||||
{
|
||||
title: 'vscodeWebUrl',
|
||||
key: 'vscodeWebUrl',
|
||||
title: 'VSCode Web 地址',
|
||||
value: vscodeWebUrl,
|
||||
description: 'VSCode Web 的访问地址'
|
||||
},
|
||||
{
|
||||
title: 'kevisualUrl',
|
||||
key: 'kevisualUrl',
|
||||
title: 'Kevisual 地址',
|
||||
value: kevisualUrl,
|
||||
description: 'Kevisual 的访问地址,可以通过该地址访问 Kevisual 服务'
|
||||
},
|
||||
{
|
||||
title: 'cnbTempToken',
|
||||
key: 'cnbTempToken',
|
||||
title: 'CNB Token',
|
||||
value: token,
|
||||
description: 'CNB 临时 Token,保持和环境变量 CNB_TOKEN 一致'
|
||||
},
|
||||
{
|
||||
title: 'openWebUrl',
|
||||
key: 'openWebUrl',
|
||||
title: 'OpenWebUI 地址',
|
||||
value: openWebUrl,
|
||||
description: 'OpenWebUI 的访问地址,可以通过该地址访问 OpenWebUI 服务'
|
||||
},
|
||||
{
|
||||
title: 'openclawUrl',
|
||||
key: 'openclawUrl',
|
||||
title: 'OpenClaw 地址',
|
||||
value: openclawUrl,
|
||||
description: 'OpenClaw 的访问地址,可以通过该地址访问 OpenClaw 服务'
|
||||
},
|
||||
{
|
||||
title: 'openclawUrlSecret',
|
||||
key: 'openclawUrlSecret',
|
||||
title: 'OpenClaw 访问地址(含 Token)',
|
||||
value: openclawUrlSecret,
|
||||
description: 'OpenClaw 的访问地址,包含 token 参数,可以直接访问 OpenClaw 服务'
|
||||
},
|
||||
{
|
||||
title: 'opencodeUrl',
|
||||
key: 'opencodeUrl',
|
||||
title: 'OpenCode 地址',
|
||||
value: opencodeUrl,
|
||||
description: 'OpenCode 的访问地址,可以通过该地址访问 OpenCode 服务'
|
||||
},
|
||||
{
|
||||
title: 'opencodeUrlSecret',
|
||||
key: 'opencodeUrlSecret',
|
||||
title: 'OpenCode 访问地址(含 Token)',
|
||||
value: opencodeUrlSecret,
|
||||
description: 'OpenCode 的访问地址,包含 token 参数,可以直接访问 OpenCode 服务'
|
||||
},
|
||||
{
|
||||
title: 'docs',
|
||||
key: 'docs',
|
||||
title: '配置说明文档',
|
||||
value: TEMPLATE,
|
||||
description: '开发环境模式配置说明文档'
|
||||
}
|
||||
@@ -117,7 +126,7 @@ export const getLiveMdContent = (opts?: { more?: boolean }) => {
|
||||
}
|
||||
|
||||
const createOSInfo = (more = false) => {
|
||||
const labels: Array<{ title: string; value: string; description: string }> = []
|
||||
const labels: Array<{ key: string; title: string; value: string; description: string }> = []
|
||||
const startTimer = useKey('CNB_BUILD_START_TIME') || ''
|
||||
|
||||
// CPU 使用率
|
||||
@@ -162,16 +171,17 @@ const createOSInfo = (more = false) => {
|
||||
return (bytes / Math.pow(1024, i)).toFixed(2) + ' ' + sizes[i]
|
||||
}
|
||||
|
||||
// 启动时间
|
||||
const bootTime = os.uptime()
|
||||
|
||||
// 运行时间格式化
|
||||
const formatUptime = (seconds: number) => {
|
||||
const days = Math.floor(seconds / 86400)
|
||||
const hours = Math.floor((seconds % 86400) / 3600)
|
||||
const minutes = Math.floor((seconds % 3600) / 60)
|
||||
const secs = Math.floor(seconds % 60)
|
||||
return `${days}天 ${hours}小时 ${minutes}分钟 ${secs}秒`
|
||||
let uptimeStr = ''
|
||||
if (days > 0) uptimeStr += `${days}天 `
|
||||
if (hours > 0) uptimeStr += `${hours}小时 `
|
||||
if (minutes > 0) uptimeStr += `${minutes}分钟 `
|
||||
return `${uptimeStr}${secs}秒`
|
||||
}
|
||||
|
||||
// 磁盘使用情况 (使用 du 命令,获取当前目录)
|
||||
@@ -185,45 +195,47 @@ const createOSInfo = (more = false) => {
|
||||
|
||||
labels.push(
|
||||
{
|
||||
title: 'cpuUsage',
|
||||
key: 'cpuUsage',
|
||||
title: 'CPU 使用率',
|
||||
value: `${cpuUsage}%`,
|
||||
description: 'CPU 使用率'
|
||||
},
|
||||
{
|
||||
title: 'cpuCores',
|
||||
key: 'cpuCores',
|
||||
title: 'CPU 核心数',
|
||||
value: `${cpus.length}`,
|
||||
description: 'CPU 核心数'
|
||||
},
|
||||
{
|
||||
title: 'memoryUsed',
|
||||
key: 'memoryUsed',
|
||||
title: '已使用内存',
|
||||
value: formatBytes(memUsed),
|
||||
description: '已使用内存'
|
||||
},
|
||||
{
|
||||
title: 'memoryTotal',
|
||||
key: 'memoryTotal',
|
||||
title: '总内存',
|
||||
value: formatBytes(memTotal),
|
||||
description: '总内存'
|
||||
},
|
||||
{
|
||||
title: 'memoryFree',
|
||||
key: 'memoryFree',
|
||||
title: '空闲内存',
|
||||
value: formatBytes(memFree),
|
||||
description: '空闲内存'
|
||||
},
|
||||
{
|
||||
title: 'memoryUsage',
|
||||
key: 'memoryUsage',
|
||||
title: '内存使用率',
|
||||
value: `${memUsage}%`,
|
||||
description: '内存使用率'
|
||||
},
|
||||
{
|
||||
title: 'diskUsage',
|
||||
key: 'diskUsage',
|
||||
title: '磁盘使用',
|
||||
value: diskUsage,
|
||||
description: '当前目录磁盘使用情况'
|
||||
},
|
||||
{
|
||||
title: 'uptime',
|
||||
value: formatUptime(bootTime),
|
||||
description: '系统运行时间'
|
||||
}
|
||||
)
|
||||
|
||||
// 如果有 CNB_BUILD_START_TIME,添加构建启动时间
|
||||
@@ -237,12 +249,14 @@ const createOSInfo = (more = false) => {
|
||||
|
||||
labels.push(
|
||||
{
|
||||
title: 'buildStartTime',
|
||||
key: 'buildStartTime',
|
||||
title: '构建启动时间',
|
||||
value: buildStartTime,
|
||||
description: '构建启动时间'
|
||||
},
|
||||
{
|
||||
title: 'buildUptime',
|
||||
key: 'buildUptime',
|
||||
title: '构建已运行时间',
|
||||
value: buildUptimeStr,
|
||||
description: '构建已运行时间'
|
||||
}
|
||||
@@ -259,11 +273,13 @@ const createOSInfo = (more = false) => {
|
||||
const timeTo4Str = `[距离晚上4点重启时间: ${formatUptime(Math.floor(timeTo4 / 1000))}]`
|
||||
|
||||
labels.push({
|
||||
title: 'buildMaxRunTime',
|
||||
key: 'buildMaxRunTime',
|
||||
title: '最大运行时间',
|
||||
value: formatUptime(Math.floor(maxRunTime / 1000)),
|
||||
description: '构建最大运行时间(限制时间)'
|
||||
})
|
||||
labels.unshift({
|
||||
key: 'remainingTime',
|
||||
title: '剩余时间',
|
||||
value: formatUptime(Math.floor((maxRunTime - buildUptime) / 1000)) + ' ' + timeTo4Str,
|
||||
description: '构建剩余时间'
|
||||
@@ -276,37 +292,44 @@ const createOSInfo = (more = false) => {
|
||||
const loadavg = os.loadavg()
|
||||
labels.push(
|
||||
{
|
||||
title: 'hostname',
|
||||
key: 'hostname',
|
||||
title: '主机名',
|
||||
value: os.hostname(),
|
||||
description: '主机名'
|
||||
},
|
||||
{
|
||||
title: 'platform',
|
||||
key: 'platform',
|
||||
title: '运行平台',
|
||||
value: os.platform(),
|
||||
description: '运行平台'
|
||||
},
|
||||
{
|
||||
title: 'arch',
|
||||
key: 'arch',
|
||||
title: '系统架构',
|
||||
value: os.arch(),
|
||||
description: '系统架构'
|
||||
},
|
||||
{
|
||||
title: 'osType',
|
||||
key: 'osType',
|
||||
title: '操作系统类型',
|
||||
value: os.type(),
|
||||
description: '操作系统类型'
|
||||
},
|
||||
{
|
||||
title: 'loadavg1m',
|
||||
key: 'loadavg1m',
|
||||
title: '系统负载 (1分钟)',
|
||||
value: loadavg[0].toFixed(2),
|
||||
description: '系统负载 (1分钟)'
|
||||
},
|
||||
{
|
||||
title: 'loadavg5m',
|
||||
key: 'loadavg5m',
|
||||
title: '系统负载 (5分钟)',
|
||||
value: loadavg[1].toFixed(2),
|
||||
description: '系统负载 (5分钟)'
|
||||
},
|
||||
{
|
||||
title: 'loadavg15m',
|
||||
key: 'loadavg15m',
|
||||
title: '系统负载 (15分钟)',
|
||||
value: loadavg[2].toFixed(2),
|
||||
description: '系统负载 (15分钟)'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user