From ee0928cbe9afca97be8a1f539801540d2be044f8 Mon Sep 17 00:00:00 2001 From: hi2hi Date: Mon, 9 Dec 2024 09:43:49 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=A4=9AGPU=E7=9A=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=EF=BC=8C=E6=94=AF=E6=8C=81GPU=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=EF=BC=9B=E5=8C=B9=E9=85=8D=E6=9B=B4=E5=A4=9A=E7=9A=84?= =?UTF-8?q?CPU=E4=BA=A7=E5=93=81=E5=9E=8B=E5=8F=B7=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/config.js | 4 +- src/utils/host.js | 44 ++++++-- .../server-detail/server-info-box.vue | 101 ++++++++++++++---- src/views/composable/server-bill-and-plan.js | 4 +- src/views/detail.vue | 8 +- 5 files changed, 126 insertions(+), 35 deletions(-) diff --git a/public/config.js b/public/config.js index 3357aa4..0d3dbc1 100644 --- a/public/config.js +++ b/public/config.js @@ -1,7 +1,7 @@ window.$$nazhuaConfig = { // title: '哪吒监控', // 网站标题 // freeAmount: '白嫖', // 免费服务的费用名称 - // infinityCycle: '无限', // 无限周期名称 + // infinityCycle: '长期有效', // 无限周期名称 // buyBtnText: '购买', // 购买按钮文案 // listServerStatusType: 'progress', // 服务器状态类型--列表 // detailServerStatusType: 'progress', // 服务器状态类型--详情页 @@ -18,6 +18,8 @@ window.$$nazhuaConfig = { // hideTag: false, // 隐藏标签 // hideDotBG: true, // 隐藏框框里面的点点背景 // monitorRefreshTime: 10, // 监控刷新时间间隔,单位s(秒), 0为不刷新,为保证不频繁请求源站,最低生效值为10s + // filterWeirdGPU: true, // 过滤奇怪的GPU + // filterGPUKeywords: ['Virtual Display'], // 如果GPU名称中包含这些关键字,则过滤掉 // customCodeMap: {}, // 自定义的地图点信息 // nezhaVersion: 'v1', // 哪吒版本 // apiMonitorPath: '/api/v1/monitor/{id}', diff --git a/src/utils/host.js b/src/utils/host.js index f8e880a..08eac38 100644 --- a/src/utils/host.js +++ b/src/utils/host.js @@ -45,11 +45,27 @@ export function getCPUInfo(text = '') { if (modelMatch) { [cpuInfo.model] = modelMatch; } + if (text.includes('Ryzen')) { + // 5900X 5950X 7900X 7950X 9900X 9950X + const modelNumReg = /Ryzen.*(\d{4}X)/; + const modelNumMatch = text.match(modelNumReg); + if (modelNumMatch) { + [, cpuInfo.modelNum] = modelNumMatch; + } + } + if (text.includes('EPYC')) { + // 7B13 7B13 9654... + const modelNumReg = /EPYC (\w{4})/; + const modelNumMatch = text.match(modelNumReg); + if (modelNumMatch) { + [, cpuInfo.modelNum] = modelNumMatch; + } + } // 匹配特定的CPU型号编号 if (text.includes('Xeon')) { - if (text.includes('E-')) { + if (text.includes(' E')) { // Xeon型号 - const modelNumReg = /(E\d-\S+)/; + const modelNumReg = /(E\d-\w+)/; const modelNumMatch = text.match(modelNumReg); if (modelNumMatch) { [, cpuInfo.modelNum] = modelNumMatch; @@ -64,17 +80,29 @@ export function getCPUInfo(text = '') { } } } - if (text.includes('Ryzen')) { - // 5900X 5950X 7900X 7950X 9900X 9950X - const modelNumReg = /Ryzen.*(\d{4}X)/; + if (text.includes('Core(TM)')) { + const modelNumReg = /Core\(TM\) (\w+-\w+)/; const modelNumMatch = text.match(modelNumReg); if (modelNumMatch) { [, cpuInfo.modelNum] = modelNumMatch; } } - if (text.includes('EPYC')) { - // 7B13 7B13 9654... - const modelNumReg = /EPYC (\w{4})/; + if (text.includes('Celeron(R)')) { + const modelNumReg = /Celeron\(R\) (\w+)/; + const modelNumMatch = text.match(modelNumReg); + if (modelNumMatch) { + [, cpuInfo.modelNum] = modelNumMatch; + } + } + if (text.includes('Pentium(R)')) { + const modelNumReg = /Pentium\(R\) (\w+)/; + const modelNumMatch = text.match(modelNumReg); + if (modelNumMatch) { + [, cpuInfo.modelNum] = modelNumMatch; + } + } + if (text.includes('Intel(R) N')) { + const modelNumReg = /Intel\(R\) (N\d+)/; const modelNumMatch = text.match(modelNumReg); if (modelNumMatch) { [, cpuInfo.modelNum] = modelNumMatch; diff --git a/src/views/components/server-detail/server-info-box.vue b/src/views/components/server-detail/server-info-box.vue index 7813b8b..fb9e5bd 100644 --- a/src/views/components/server-detail/server-info-box.vue +++ b/src/views/components/server-detail/server-info-box.vue @@ -5,28 +5,58 @@ CPU
- + + {{ info.Host.CPU[0] }} + + +
- {{ info?.Host?.CPU?.[0] }} - + + CPU.{{ cpuIndex + 1 }} + {{ cpuItem }} + +
GPU
- + + {{ gpuList[0] }} + + +
- {{ info?.Host?.GPU?.[0] }} - + + GPU.{{ gpuIndex + 1 }} + {{ gpuItem }} + +
@@ -50,7 +80,7 @@ 占用
- +
进程数 {{ processCount }} @@ -58,10 +88,10 @@ 负载 - {{ info?.State?.Load1 }},{{ info?.State?.Load5 }},{{ info?.State?.Load15 }} + {{ sysLoadInfo }} - +
@@ -69,7 +99,7 @@ 流量
- +
入网 @@ -84,7 +114,7 @@ {{ transfer?.out?.unit }} - +
@@ -92,7 +122,7 @@ 连接
- +
TCP {{ tcpConnCount }} @@ -101,7 +131,7 @@ UDP {{ udpConnCount }} - +
@@ -132,7 +162,7 @@ 套餐
- +
{{ item.label }} {{ item.value }} - +
{ + const gpus = props.info?.Host?.GPU || []; + if (config.nazhua?.filterGPUKeywords?.length) { + // 过滤奇怪的GPU,可以考虑过滤掉 Virtual Display + const keywors = Array.isArray(config.nazhua.filterGPUKeywords) + ? config.nazhua.filterGPUKeywords + : [config.nazhua.filterGPUKeywords]; + return gpus.filter((i) => { + if (keywors.length) { + return !keywors.some((k) => i.toLowerCase().includes(k.toLowerCase())); + } + return true; + }); + } + return gpus; +}); + +const sysLoadInfo = computed(() => { + if (props.info?.State?.Load1) { + return [ + props.info.State?.Load1, + props.info.State?.Load5, + props.info.State?.Load15, + ].filter((i) => i !== undefined).map((i) => (i).toFixed(2) * 1).join(','); + } + return '-'; +}); + const { billAndPlan, } = handleServerBillAndPlan({ diff --git a/src/views/composable/server-bill-and-plan.js b/src/views/composable/server-bill-and-plan.js index 6f2d3d5..d6ff9b3 100644 --- a/src/views/composable/server-bill-and-plan.js +++ b/src/views/composable/server-bill-and-plan.js @@ -94,8 +94,8 @@ export default (params) => { const endTime = dayjs(endDate).valueOf(); if (endDate.indexOf('0000-00-00') === 0) { obj.remainingTime = { - label: '有效期', - value: config.nazhua.infinityCycle || '无限', + label: '剩余', + value: config.nazhua.infinityCycle || '长期有效', type: 'infinity', }; } else if (autoRenewal === '1') { diff --git a/src/views/detail.vue b/src/views/detail.vue index 6f6c77c..e315159 100644 --- a/src/views/detail.vue +++ b/src/views/detail.vue @@ -12,19 +12,19 @@ :locations="locations" />