feat: 添加跳闸率解析并实现雷暴日与地闪密度自动转换
在Log组件中解析跳闸率数值并暴露给父组件 在ParameterForm组件中实现雷暴日与地闪密度的双向自动转换
This commit is contained in:
@@ -40,6 +40,7 @@ interface LogEntry {
|
||||
const logs = ref<LogEntry[]>([])
|
||||
const logContainer = ref<HTMLElement | null>(null)
|
||||
const expanded = ref(true)
|
||||
const lastTripRates = ref<number[]>([])
|
||||
|
||||
const addLog = (level: LogEntry['level'], message: string) => {
|
||||
const now = new Date()
|
||||
@@ -47,6 +48,13 @@ const addLog = (level: LogEntry['level'], message: string) => {
|
||||
|
||||
logs.value.push({ level, time, message })
|
||||
|
||||
// 解析跳闸率数值
|
||||
const match = message.match(/不同相跳闸率是\[([\d.\s]+)\]/)
|
||||
if (match) {
|
||||
const values = match[1].trim().split(/\s+/).map(Number)
|
||||
lastTripRates.value = values
|
||||
}
|
||||
|
||||
// 自动滚动到底部
|
||||
nextTick(() => {
|
||||
if (logContainer.value) {
|
||||
@@ -62,7 +70,8 @@ const clearLog = () => {
|
||||
// 暴露方法给父组件
|
||||
defineExpose({
|
||||
addLog,
|
||||
clearLog
|
||||
clearLog,
|
||||
lastTripRates
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user