耐受实验调整为首页、替换标题

This commit is contained in:
caozehui
2026-04-30 09:31:01 +08:00
parent 8ab1a35f3b
commit 0e0969c50f
4 changed files with 135 additions and 18 deletions

View File

@@ -42,7 +42,7 @@ function createTray() {
tray = new Tray(iconPath); tray = new Tray(iconPath);
} }
tray.setToolTip('NPQS-9100自动检测平台'); tray.setToolTip('变频器暂降耐受实验平台');
console.log('[Tray] Tray created successfully'); console.log('[Tray] Tray created successfully');
// 创建托盘菜单 // 创建托盘菜单

View File

@@ -36,7 +36,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, ref, watch } from 'vue' import { computed, nextTick, ref, watch } from 'vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { Document, Download } from '@element-plus/icons-vue' import { Document, Download } from '@element-plus/icons-vue'
import * as XLSX from 'xlsx' import * as XLSX from 'xlsx'
@@ -127,6 +127,107 @@ const sortedCharacteristicCurveData = computed(() => {
}) })
}) })
const clampValue = (value: number, min: number, max: number) => {
return Math.min(max, Math.max(min, value))
}
const buildExtendedCurvePoint = (points: Array<[number, number]>, targetDuration: number) => {
if (!points.length || !Number.isFinite(targetDuration) || targetDuration <= 0) {
return null as [number, number] | null
}
const lastPoint = points[points.length - 1]
if (!lastPoint || targetDuration === lastPoint[0]) {
return null as [number, number] | null
}
if (points.length === 1) {
return [targetDuration, lastPoint[1]] as [number, number]
}
const recentDistinctPoints: Array<[number, number]> = []
for (let index = points.length - 1; index >= 0 && recentDistinctPoints.length < 3; index -= 1) {
const point = points[index]
if (recentDistinctPoints.some(item => item[0] === point[0])) {
continue
}
recentDistinctPoints.unshift(point)
}
if (recentDistinctPoints.length < 2) {
return [targetDuration, lastPoint[1]] as [number, number]
}
const toLogDuration = (value: number) => Math.log10(value)
const getSlope = (start: [number, number], end: [number, number]) => {
const deltaX = toLogDuration(end[0]) - toLogDuration(start[0])
if (!Number.isFinite(deltaX) || deltaX === 0) {
return null
}
return (end[1] - start[1]) / deltaX
}
let slope = getSlope(
recentDistinctPoints[recentDistinctPoints.length - 2],
recentDistinctPoints[recentDistinctPoints.length - 1]
)
if (recentDistinctPoints.length >= 3) {
const previousSlope = getSlope(recentDistinctPoints[0], recentDistinctPoints[1])
if (previousSlope !== null && slope !== null) {
slope = previousSlope * 0.35 + slope * 0.65
}
}
if (slope === null) {
return [targetDuration, lastPoint[1]] as [number, number]
}
const deltaX = toLogDuration(targetDuration) - toLogDuration(lastPoint[0])
if (!Number.isFinite(deltaX)) {
return null as [number, number] | null
}
const predictedResidualVoltage = lastPoint[1] + slope * deltaX
const nearbyResidualVoltages = recentDistinctPoints.map(item => item[1])
const minResidualVoltage = Math.max(0, Math.min(...nearbyResidualVoltages) - 15)
const maxResidualVoltage = Math.min(100, Math.max(...nearbyResidualVoltages) + 15)
return [
targetDuration,
Number(clampValue(predictedResidualVoltage, minResidualVoltage, maxResidualVoltage).toFixed(2))
] as [number, number]
}
const inferredCharacteristicCurvePoint = computed(() => {
return buildExtendedCurvePoint(sortedCharacteristicCurveData.value, xAxisMax.value)
})
const solidCharacteristicCurveSeriesData = computed(() => {
return sortedCharacteristicCurveData.value.map(item => [item[0], item[1], 'Backend point'])
})
const dashedCharacteristicCurveSeriesData = computed(() => {
const lastPoint = sortedCharacteristicCurveData.value[sortedCharacteristicCurveData.value.length - 1]
const extensionPoint = inferredCharacteristicCurvePoint.value
if (!lastPoint || !extensionPoint) {
return []
}
return [
{
value: [lastPoint[0], lastPoint[1], 'Backend point'],
symbol: 'none'
},
{
value: [extensionPoint[0], extensionPoint[1], 'Inferred point']
}
]
})
const hasChartData = computed(() => { const hasChartData = computed(() => {
return sortedChartPoints.value.length > 0 || sortedCharacteristicCurveData.value.length > 0 return sortedChartPoints.value.length > 0 || sortedCharacteristicCurveData.value.length > 0
}) })
@@ -476,10 +577,10 @@ const exportChartData = () => {
if (sortedChartPoints.value.length) { if (sortedChartPoints.value.length) {
const pointSheet = XLSX.utils.json_to_sheet( const pointSheet = XLSX.utils.json_to_sheet(
sortedChartPoints.value.map((item, index) => ({ sortedChartPoints.value.map((item, index) => ({
序号: index + 1, '序号': index + 1,
持续时间_s: item.duration, '持续时间_s': item.duration,
暂降幅值_pct: item.residualVoltage, '暂降幅值_%': item.residualVoltage,
状态: getStatusText(item.status) '状态': getStatusText(item.status)
})) }))
) )
XLSX.utils.book_append_sheet(workbook, pointSheet, '暂降点') XLSX.utils.book_append_sheet(workbook, pointSheet, '暂降点')
@@ -488,9 +589,9 @@ const exportChartData = () => {
if (sortedCharacteristicCurveData.value.length) { if (sortedCharacteristicCurveData.value.length) {
const curveSheet = XLSX.utils.json_to_sheet( const curveSheet = XLSX.utils.json_to_sheet(
sortedCharacteristicCurveData.value.map((item, index) => ({ sortedCharacteristicCurveData.value.map((item, index) => ({
序号: index + 1, '序号': index + 1,
持续时间_s: item[0], '持续时间_s': item[0],
暂降幅值_pct: item[1] '暂降幅值_%': item[1]
})) }))
) )
XLSX.utils.book_append_sheet(workbook, curveSheet, '特性曲线') XLSX.utils.book_append_sheet(workbook, curveSheet, '特性曲线')
@@ -615,7 +716,23 @@ const chartOptions = computed(() => {
itemStyle: { itemStyle: {
color: '#ff2a2a' color: '#ff2a2a'
}, },
data: characteristicCurveData.value.map(item => [item[0], item[1], '特性曲线']) data: solidCharacteristicCurveSeriesData.value
},
{
name: '特性曲线延伸',
type: 'line',
smooth: true,
showSymbol: true,
symbolSize: 7,
lineStyle: {
color: '#ff2a2a',
width: 3,
type: 'dashed'
},
itemStyle: {
color: '#ff2a2a'
},
data: dashedCharacteristicCurveSeriesData.value
}, },
{ {
name: '暂降点', name: '暂降点',

View File

@@ -6,11 +6,11 @@
:request-api="getTableList" :request-api="getTableList"
> >
<template #tableHeader="scope"> <template #tableHeader="scope">
<el-button v-auth.freqConverter="'add'" type="primary" :icon="CirclePlus" @click="openDialog('add')"> <el-button v-auth.tolerance="'add'" type="primary" :icon="CirclePlus" @click="openDialog('add')">
新增 新增
</el-button> </el-button>
<el-button <el-button
v-auth.freqConverter="'delete'" v-auth.tolerance="'delete'"
type="danger" type="danger"
:icon="Delete" :icon="Delete"
plain plain
@@ -23,7 +23,7 @@
<template #operation="scope"> <template #operation="scope">
<el-button <el-button
v-auth.freqConverter="'edit'" v-auth.tolerance="'edit'"
type="primary" type="primary"
link link
:icon="EditPen" :icon="EditPen"
@@ -33,7 +33,7 @@
编辑 编辑
</el-button> </el-button>
<el-button <el-button
v-auth.freqConverter="'delete'" v-auth.tolerance="'delete'"
type="primary" type="primary"
link link
:icon="Delete" :icon="Delete"
@@ -42,7 +42,7 @@
删除 删除
</el-button> </el-button>
<el-button <el-button
v-auth.freqConverter="'test'" v-auth.tolerance="'test'"
type="primary" type="primary"
link link
:icon="Stopwatch" :icon="Stopwatch"
@@ -51,7 +51,7 @@
检测 检测
</el-button> </el-button>
<el-button <el-button
v-auth.freqConverter="'result'" v-auth.tolerance="'result'"
type="primary" type="primary"
link link
:icon="Coin" :icon="Coin"

View File

@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NPQS-9100自动检测平台 正在启动...</title> <title>变频器暂降耐受实验平台 正在启动...</title>
<style> <style>
* { * {
margin: 0; margin: 0;
@@ -145,7 +145,7 @@
</head> </head>
<body> <body>
<div class="loading-container"> <div class="loading-container">
<div class="logo">NPQS-9100自动检测平台</div> <div class="logo">变频器暂降耐受实验平台</div>
<div class="subtitle">南京灿能电力自动化股份有限公司</div> <div class="subtitle">南京灿能电力自动化股份有限公司</div>
<div class="status-text" id="statusText">正在初始化应用...</div> <div class="status-text" id="statusText">正在初始化应用...</div>