fix(断路器): 日志上限改成200条,格式化代码

This commit is contained in:
fhysy 2024-08-20 11:10:35 +08:00
parent 6257501187
commit 3af303b605
2 changed files with 134 additions and 140 deletions

View File

@ -1,15 +1,11 @@
<template>
<div>
<el-header style="display: flex; font-size: 16px">
<div class='header-left'>
<img :src="logo" alt="">
<div class="header-left">
<img :src="logo" alt="" />
</div>
<div class='haeder-menu' :style="{width:menuWidth + 'px'}">
<el-menu
default-active="/system"
mode="horizontal"
router="true"
>
<div class="haeder-menu" :style="{ width: menuWidth + 'px' }">
<el-menu default-active="/system" mode="horizontal" router="true">
<el-menu-item index="/system">系统模板</el-menu-item>
<!-- <el-menu-item index="/test">测试</el-menu-item>-->
</el-menu>
@ -18,12 +14,10 @@
<div class="block" style="margin-right: 25px">
<el-icon size="24" color="#80b3e6"><BellFilled /></el-icon>
</div>
<div class="user-name" style="margin-right: 10px">
admin
</div>
<div class="user-name" style="margin-right: 10px">admin</div>
<el-dropdown trigger="click">
<div class="el-dropdown-link avatar-box" style="cursor: pointer">
<img :src="avatar" alt="">
<img :src="avatar" alt="" />
</div>
<template #dropdown>
<el-dropdown-menu>
@ -38,12 +32,12 @@
</template>
<script setup>
import { ref, watch } from "vue"
import { ref, watch } from 'vue';
import logo from '@renderer/assets/image/logo.png'
import avatar from '@renderer/assets/image/avatar.png'
import logo from '@renderer/assets/image/logo.png';
import avatar from '@renderer/assets/image/avatar.png';
const screenWidth = ref(document.documentElement.clientWidth || document.body.clientWidth)
const screenWidth = ref(document.documentElement.clientWidth || document.body.clientWidth);
const timer = ref(false);
const domWidth = ref(document.body.clientWidth);
@ -51,26 +45,21 @@ const menuWidth = ref(document.body.clientWidth - 363);
watch(
(screenWidth.value = () => {
console.log("页面变化",document.body.clientWidth)
// 使
if (!timer.value) {
if (domWidth.value != document.body.clientWidth) {
console.log("更新页面")
domWidth.value = document.body.clientWidth
menuWidth.value = document.body.clientWidth - 363
domWidth.value = document.body.clientWidth;
menuWidth.value = document.body.clientWidth - 363;
}
timer.value = true;
setTimeout(function () {
timer.value = false
}, 200)
timer.value = false;
}, 500);
}
})
);
</script>
<style scoped lang="scss">
.el-header {
width: 100%;
@ -116,7 +105,7 @@ watch(
background: #267dd4;
position: relative;
&:after {
content: "";
content: '';
position: absolute;
top: 22px;
left: 20px;
@ -141,7 +130,7 @@ watch(
font-family: Source Han Sans CN;
font-weight: 400;
font-size: 12px;
color: #FFFFFF;
color: #ffffff;
}
.avatar-box {
img {

View File

@ -1004,12 +1004,18 @@ const clearLog = () => {
const getSocketMeassage = message => {
let msg = JSON.parse(message.data);
if (msg.msgType !== undefined) {
if (logList.value.length > 200) {
logList.value.shift();
}
logList.value.push({
time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
msg: msg.data,
type: msg.msgType
});
} else {
if (logList.value.length > 200) {
logList.value.shift();
}
logList.value.push({
time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
msg,
@ -1064,7 +1070,6 @@ const switchSocketStatus = computed(() => {
const searchLogList = computed(() => {
if (!logSearch.value) {
return logList.value.filter(item => {
console.log(item, logType.value.indexOf(item.type));
return logType.value.indexOf(item.type) !== -1;
});
} else {