diff --git a/package.json b/package.json index 5a0a388..cde4652 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nazhua", - "version": "0.6.0", + "version": "0.6.2", "type": "module", "scripts": { "dev": "vite", diff --git a/public/config.js b/public/config.js index 30370da..a3a8dac 100644 --- a/public/config.js +++ b/public/config.js @@ -27,6 +27,7 @@ window.$$nazhuaConfig = { // hideListItemStatusDonut: false, // 隐藏列表项的饼图 // hideListItemStat: false, // 隐藏列表项的统计信息 // hideListItemBill: false, // 隐藏列表项的账单信息 + hideListItemLink: true, // 隐藏列表项的购买链接 // hideFilter: false, // 隐藏筛选 // hideTag: false, // 隐藏标签 // hideDotBG: true, // 隐藏框框里面的点点背景 diff --git a/src/utils/host.js b/src/utils/host.js index 1a7f478..3e4cae0 100644 --- a/src/utils/host.js +++ b/src/utils/host.js @@ -46,68 +46,146 @@ export function getCPUInfo(text = '') { [cpuInfo.model] = modelMatch; } if (text.includes('Ryzen')) { - // 5900X 5950X 7900X 7950X 9900X 9950X - const modelNumReg = /Ryzen.*(\d{4}X)/; + // 匹配各种Ryzen型号: + // - 标准型号: 5900X, 5950X, 7900X, 7950X, 9900X, 9950X + // - 普通型号: 3600, 5600, 7600 + // - G系列APU: 5700G, 3400G + // - XT系列: 3600XT, 5600XT + // - 移动版: 4800U, 5800H, 6800HS + const modelNumReg = /Ryzen\s*(?:\d|(?:TR))\s*(?:\d{4}(?:[A-Z]{1,2})?)/; const modelNumMatch = text.match(modelNumReg); if (modelNumMatch) { - [, cpuInfo.modelNum] = modelNumMatch; + cpuInfo.modelNum = modelNumMatch[0].replace(/Ryzen\s*(?:\d|(?:TR))\s*/, ''); + } else { + // 备用正则表达式,尝试匹配其他可能的格式 + const altModelNumReg = /Ryzen.*?(\d{3,4}(?:[A-Z]{0,2}))/; + const altModelNumMatch = text.match(altModelNumReg); + if (altModelNumMatch) { + [, cpuInfo.modelNum] = altModelNumMatch; + } } } if (text.includes('EPYC')) { - // 7B13 7B13 9654... - const modelNumReg = /EPYC (\w{4})/; + // 匹配各种EPYC型号: + // - 第一代: 7001系列 (7351, 7551, 7601) + // - 第二代: 7002系列 (7252, 7542, 7742) + // - 第三代: 7003系列 (7313, 7543, 7763) + // - 第四代: 9004系列 (9124, 9354, 9654) + // - 特殊系列: 7Fxx, 7Hxx, 7Bxx (7F72, 7H12, 7B13) + const modelNumReg = /EPYC\s+(\d[A-Z0-9]{2,4})/i; const modelNumMatch = text.match(modelNumReg); if (modelNumMatch) { [, cpuInfo.modelNum] = modelNumMatch; + } else { + // 备用匹配,处理可能的其他格式 + const altModelNumReg = /EPYC.*?(\d{4,5}[A-Z]?)/i; + const altModelNumMatch = text.match(altModelNumReg); + if (altModelNumMatch) { + [, cpuInfo.modelNum] = altModelNumMatch; + } } } // 匹配特定的CPU型号编号 if (text.includes('Xeon')) { + // 匹配所有Xeon处理器系列 + // - E系列: E3, E5, E7等 + // - 金属系列: Platinum, Gold, Silver, Bronze + // - 数字系列: W-1290, D-1653N等 + // - 扩展名系列: L, X, M, D等(如X7560, L5640) if (text.includes(' E')) { - // Xeon型号 - const modelNumReg = /(E\d-\w+)/; + const modelNumReg = /(E\d-\d{4}(?:\s?v\d)?)/; const modelNumMatch = text.match(modelNumReg); if (modelNumMatch) { [, cpuInfo.modelNum] = modelNumMatch; } - } - if (text.includes('Gold')) { - // Xeon型号 - const modelNumReg = /(Gold\s\w+)/; + } else if (text.includes('Platinum')) { + const modelNumReg = /(?:Platinum\s+)(\d{4}(?:\w)?)/; const modelNumMatch = text.match(modelNumReg); if (modelNumMatch) { [, cpuInfo.modelNum] = modelNumMatch; } + } else if (text.includes('Gold')) { + const modelNumReg = /(?:Gold\s+)(\d{4}(?:\w)?)/; + const modelNumMatch = text.match(modelNumReg); + if (modelNumMatch) { + [, cpuInfo.modelNum] = modelNumMatch; + } + } else if (text.includes('Silver')) { + const modelNumReg = /(?:Silver\s+)(\d{4}(?:\w)?)/; + const modelNumMatch = text.match(modelNumReg); + if (modelNumMatch) { + [, cpuInfo.modelNum] = modelNumMatch; + } + } else if (text.includes('Bronze')) { + const modelNumReg = /(?:Bronze\s+)(\d{4}(?:\w)?)/; + const modelNumMatch = text.match(modelNumReg); + if (modelNumMatch) { + [, cpuInfo.modelNum] = modelNumMatch; + } + } else { + // 通用Xeon型号匹配 + const genericXeonReg = /Xeon(?:\(R\))?\s+(?:\w+-)?((?:W|D)?-?\d{4,5}(?:\w)?)/; + const genericMatch = text.match(genericXeonReg); + if (genericMatch) { + [, cpuInfo.modelNum] = genericMatch; + } } } - if (text.includes('Core(TM)')) { - const modelNumReg = /Core\(TM\) (\w+-\w+)/; + + if (text.includes('Core')) { + if (text.includes('Core(TM)')) { + // 匹配如 Core(TM) i7-10700K 等格式 + const modelNumReg = /Core\(TM\)\s+(\w\d+-\w+)/; + const modelNumMatch = text.match(modelNumReg); + if (modelNumMatch) { + [, cpuInfo.modelNum] = modelNumMatch; + } + } else { + // 匹配如 Core i9-12900K, Core i5-13600K 等格式 + const coreReg = /Core\s+(i[3579]-\d{4,5}(?:\w+)?)/i; + const coreMatch = text.match(coreReg); + if (coreMatch) { + [, cpuInfo.modelNum] = coreMatch; + } + } + } + + if (text.includes('Celeron')) { + const modelNumReg = /Celeron(?:\(R\))?\s+(\w+\d+(?:\w+)?)/; const modelNumMatch = text.match(modelNumReg); if (modelNumMatch) { [, cpuInfo.modelNum] = modelNumMatch; } } - 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+)/; + + if (text.includes('Pentium')) { + const modelNumReg = /Pentium(?:\(R\))?\s+(\w+\d+(?:\w+)?)/; const modelNumMatch = text.match(modelNumReg); if (modelNumMatch) { [, cpuInfo.modelNum] = modelNumMatch; } } + if (text.includes('Intel(R) N')) { - const modelNumReg = /Intel\(R\) (N\d+)/; + const modelNumReg = /Intel\(R\)\s+(N\d+(?:\w+)?)/; const modelNumMatch = text.match(modelNumReg); if (modelNumMatch) { [, cpuInfo.modelNum] = modelNumMatch; } } + + // 匹配Apple M系列芯片 + if (text.includes('Apple') && text.match(/M\d/)) { + // 匹配各种Apple Silicon M系列芯片: + // - 基本型号: M1, M2, M3等 + // - 变种型号: M1 Pro, M2 Max, M3 Ultra等 + const appleChipReg = /Apple\s+(?:Silicon\s+)?M(\d+(?:\s+(?:Pro|Max|Ultra|Extreme))?)/i; + const appleChipMatch = text.match(appleChipReg); + if (appleChipMatch) { + [, cpuInfo.modelNum] = appleChipMatch; + } + } + if (coresMatch) { [cpuInfo.core, cpuInfo.cores] = coresMatch; } diff --git a/src/views/components/server-detail/server-info-box.vue b/src/views/components/server-detail/server-info-box.vue index c0d037c..64fcb1b 100644 --- a/src/views/components/server-detail/server-info-box.vue +++ b/src/views/components/server-detail/server-info-box.vue @@ -78,8 +78,27 @@ class="server-info-item" :class="`temperature--${ttItem.type}`" > - - {{ ttItem.label }} + + + + + + {{ ttItem.value }} @@ -331,96 +350,157 @@ const temperatureData = computed(() => { const acpitz = []; const coretemp_package_id = []; const coretemp_core = []; + const nvme = []; + const k10temp = []; + const amdgpu = []; const other = []; + + // 温度数据分类处理 props.info.State.Temperatures.forEach((item) => { - if (item.Name.indexOf('acpitz') === 0) { - acpitz.push(item.Temperature); + const name = item.Name.toLowerCase(); + const temp = item.Temperature; + + if (name.startsWith('acpitz')) { + acpitz.push(temp); return; } - if (item.Name.indexOf('coretemp_package_id_') === 0) { - const coreIndex = parseInt(item.Name.replace('coretemp_package_id_', ''), 10); + if (name.startsWith('coretemp_package_id_')) { + const coreIndex = parseInt(name.replace('coretemp_package_id_', ''), 10); coretemp_package_id.push({ index: coreIndex, - value: `${item.Temperature}℃`, + value: temp, }); return; } - if (item.Name.indexOf('coretemp_core_') === 0) { - const coreIndex = parseInt(item.Name.replace('coretemp_core_', ''), 10); + if (name.startsWith('coretemp_core_')) { + const coreIndex = parseInt(name.replace('coretemp_core_', ''), 10); coretemp_core.push({ index: coreIndex, - value: item.Temperature, + value: temp, + }); + return; + } + if (name.includes('nvme')) { + nvme.push({ + name: item.Name, + value: temp, + }); + return; + } + if (name.includes('k10temp')) { + k10temp.push({ + name: item.Name, + value: temp, + }); + return; + } + if (name.includes('amdgpu')) { + amdgpu.push({ + name: item.Name, + value: temp, + }); + return; + } + if (name.includes('motherboard') || name.includes('mainboard') || name.includes('board')) { + other.push({ + label: '主板', + value: temp, + type: 'motherboard', }); return; } - // console.log(item); other.push({ label: item.Name, - value: `${item.Temperature}℃`, + value: temp, + type: 'other', }); }); + // 主板温度处理 if (acpitz.length) { + const acpitzMean = (acpitz.reduce((a, b) => a + b, 0) / acpitz.length).toFixed(1); data.push({ label: i18n.t('acpitz'), - value: `${acpitz[0]}℃`, + value: `${acpitzMean}℃`, + title: acpitz.map((i, index) => `传感器${index + 1}: ${parseFloat(i).toFixed(1)}℃`).join('\n'), type: 'acpitz', }); - if (acpitz.length) { - const acpitzMean = (acpitz.reduce((a, b) => a + b, 0) / acpitz.length).toFixed(1) * 1; + } + + // CPU温度处理 + if (coretemp_package_id.length || coretemp_core.length) { + const temps = []; + const details = []; + + // 处理 CPU 温度 + if (coretemp_package_id.length) { + const cpuTemps = coretemp_package_id.map((i) => `${parseFloat(i.value).toFixed(1)}℃`); + temps.push(cpuTemps.join(', ')); + details.push(...coretemp_package_id.map((i) => `CPU.${i.index + 1}: ${parseFloat(i.value).toFixed(1)}℃`)); + } + + // 处理核心温度 + if (coretemp_core.length) { + const coreMean = (coretemp_core.reduce((a, b) => a + b.value, 0) / coretemp_core.length).toFixed(1); + temps.push(`${parseFloat(coreMean).toFixed(1)}℃`); + details.push(...coretemp_core.map((i) => `核心${i.index + 1}: ${parseFloat(i.value).toFixed(1)}℃`)); + } + + data.push({ + label: 'CPU', + value: temps.join(' / '), + title: details.join('\n'), + type: 'cpu', + }); + } + + // AMD CPU温度处理 + if (k10temp.length) { + const tctl = k10temp.find((i) => i.name.includes('tctl')); + if (tctl) { data.push({ - label: i18n.t('acpitzMean'), - value: `${acpitzMean}℃`, - title: acpitz.map((i, index) => `传感器${index + 1}: ${i}℃`).join('\n'), - type: 'acpitz-mean', + label: 'AMD CPU', + value: `${parseFloat(tctl.value).toFixed(1)}℃`, + title: k10temp.map((i) => `${i.name}: ${parseFloat(i.value).toFixed(1)}℃`).join('\n'), + type: 'cpu', }); } } - if (coretemp_package_id.length) { - data.push({ - label: i18n.t('coretempPackage'), - value: coretemp_package_id.map((i) => i.value).join(', '), - title: coretemp_package_id.length > 1 - ? coretemp_package_id.map((i) => `CPU.${i.index + 1}: ${i.value}`).join('\n') - : '', - type: 'coretemp-package', - }); - } - if (coretemp_core.length) { - const coretempCoreMean = (coretemp_core.reduce((a, b) => a + b.value, 0) / coretemp_core.length).toFixed(1) * 1; - data.push({ - label: i18n.t('coretempCoreMean'), - value: `${coretempCoreMean}℃`, - title: coretemp_core.map((i) => `核心${i.index + 1}: ${i.value}℃`).join('\n'), - type: 'coretemp-core', - }); - // 最高温度的核心 - let max; - let maxCore; - coretemp_core.forEach((i) => { - if (max === undefined || i.value > max) { - max = i.value; - maxCore = i.index; - } - }); - // 当最高温度的核心温度比平均温度高 20% 时,显示 - if (max / coretempCoreMean > 1.2) { + + // AMD GPU温度处理 + if (amdgpu.length) { + const edge = amdgpu.find((i) => i.name.includes('edge')); + if (edge) { data.push({ - label: `${i18n.t('coretempMaxCore')}.${maxCore + 1}`, - value: `${max}℃`, - type: 'coretemp-max-core', + label: 'AMD GPU', + value: `${parseFloat(edge.value).toFixed(1)}℃`, + title: amdgpu.map((i) => `${i.name}: ${parseFloat(i.value).toFixed(1)}℃`).join('\n'), + type: 'gpu', }); } } - if (other.length) { - other.forEach((i) => { + + // NVME温度处理 + if (nvme.length) { + const composite = nvme.find((i) => i.name.includes('composite')); + if (composite) { data.push({ - label: i.label, - value: i.value, - type: 'other', + label: 'NVME', + value: `${parseFloat(composite.value).toFixed(1)}℃`, + title: nvme.map((i) => `${i.name}: ${parseFloat(i.value).toFixed(1)}℃`).join('\n'), + type: 'nvme', }); - }); + } } + + // 其他温度处理 + other.forEach((i) => { + data.push({ + label: i.label, + value: `${parseFloat(i.value).toFixed(1)}℃`, + type: i.type || 'other', + }); + }); } return { list: data, @@ -571,6 +651,17 @@ const processCount = computed(() => props.info?.State?.ProcessCount); .server-info-item { display: flex; gap: 0.2em; + align-items: center; + + .server-info-item-icon { + width: 24px; + height: 16px; + display: flex; + align-items: center; + justify-content: center; + font-size: 16px; + color: #ccc; + } } .server-info-item-value { diff --git a/src/views/components/server-detail/server-monitor.vue b/src/views/components/server-detail/server-monitor.vue index a90b7a0..b4b47b2 100644 --- a/src/views/components/server-detail/server-monitor.vue +++ b/src/views/components/server-detail/server-monitor.vue @@ -82,6 +82,9 @@ '--cate-color': cateItem.color, }" @click="toggleShowCate(cateItem.id)" + @touchstart="handleTouchStart(cateItem.id)" + @touchend="handleTouchEnd(cateItem.id)" + @touchmove="handleTouchMove(cateItem.id)" > now.value - (minute.value * 60 * 1000)); @@ -322,9 +325,32 @@ function toggleMinute(value) { } function toggleShowCate(id) { + if (window.innerWidth < 768) { + return; + } showCates.value[id] = !showCates.value[id]; } +function handleTouchStart(id) { + longPressTimer.value = setTimeout(() => { + showCates.value[id] = !showCates.value[id]; + }, 500); +} + +function handleTouchEnd() { + if (longPressTimer.value) { + clearTimeout(longPressTimer.value); + longPressTimer.value = null; + } +} + +function handleTouchMove() { + if (longPressTimer.value) { + clearTimeout(longPressTimer.value); + longPressTimer.value = null; + } +} + async function loadMonitor() { await request({ url: ( @@ -553,6 +579,10 @@ onUnmounted(() => { border-radius: 4px; cursor: pointer; + @media screen and (max-width: 768px) { + cursor: default; + } + .cate-legend { width: 0.5em; height: 0.5em; diff --git a/src/views/components/server-detail/server-name.vue b/src/views/components/server-detail/server-name.vue index 750b7d1..764b66b 100644 --- a/src/views/components/server-detail/server-name.vue +++ b/src/views/components/server-detail/server-name.vue @@ -211,10 +211,17 @@ const platformLogoIconClassName = computed(() => hostUtils.getPlatformLogoIconCl font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-weight: 600; } + &--amd { font-weight: bold; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; } + + &--apple { + font-weight: 600; + font-family: PingFang SC, Arial, "Helvetica Neue", Helvetica, sans-serif; + border-radius: 3px; + } } .cpu-model { diff --git a/src/views/components/server-list/card/server-list-item-bill.vue b/src/views/components/server-list/card/server-list-item-bill.vue index 0746eac..4801580 100644 --- a/src/views/components/server-list/card/server-list-item-bill.vue +++ b/src/views/components/server-list/card/server-list-item-bill.vue @@ -112,7 +112,12 @@ const buyBtnText = computed(() => { } return config.nazhua.buyBtnText || '购买'; }); -const showBuyBtn = computed(() => !!props.info?.PublicNote?.customData?.orderLink); +const showBuyBtn = computed(() => { + if (config.nazhua.hideListItemLink === true) { + return false; + } + return !!props.info?.PublicNote?.customData?.orderLink; +}); function toBuy() { const decodeUrl = decodeURIComponent(props.info?.PublicNote?.customData?.orderLink); diff --git a/src/views/home.vue b/src/views/home.vue index 1a7d86c..0c8dd39 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -234,7 +234,7 @@ const filterServerList = computed(() => { if (validate.isSet(planDataMod?.bandwidth)) { fields.bandwidth = true; } - if (validate.isSet(customData?.orderLink)) { + if (validate.isSet(customData?.orderLink) && config.nazhua.hideListItemLink !== true) { fields.orderLink = true; } }