fix: 优化前端生命周期清理与本地文件忽略

- 修复流程提交组件 props 默认值返回 undefined 的问题
- 清理调试日志和空生命周期钩子
- 修复 TagsView 滚动监听移除参数不一致
- 补充消息推送 SSE watcher 清理
- 补充缓存监控页 ECharts 实例和 resize 监听清理
- 忽略 IDE 模块文件并纳入 pnpm lockfile
This commit is contained in:
疯狂的狮子Li
2026-06-08 17:52:31 +08:00
parent 62694b1554
commit d74c18e58e
6 changed files with 4633 additions and 65 deletions

2
.gitignore vendored
View File

@@ -14,6 +14,7 @@ selenium-debug.log
# Editor directories and files
.idea
.vscode
*.iml
*.suo
*.ntvs*
*.njsproj
@@ -22,7 +23,6 @@ selenium-debug.log
package-lock.json
yarn.lock
pnpm-lock.yaml
# 编译生成的文件
auto-imports.d.ts

4552
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -221,7 +221,7 @@ const porUserRef = ref<InstanceType<typeof UserSelect>>();
const props = defineProps({
taskVariables: {
type: Object as () => Record<string, any>,
default: () => {}
default: () => ({})
}
});
//遮罩层
@@ -326,7 +326,6 @@ const openDialog = async (id?: string) => {
selectCopyUserList.value = task.value.copyList;
selectCopyUserIds.value = task.value.copyList.map(e => e.userId).join(',');
varNodeList.value = task.value.varList;
console.log('varNodeList', varNodeList.value);
buttonDisabled.value = false;
try {
const data = {
@@ -340,7 +339,6 @@ const openDialog = async (id?: string) => {
}
};
onMounted(() => {});
const emits = defineEmits(['submitCallback', 'cancelCallback']);
/** 办理流程 */

View File

@@ -26,7 +26,7 @@ onMounted(() => {
});
onBeforeUnmount(() => {
getScrollWrapper()?.removeEventListener('scroll', emitScroll);
getScrollWrapper()?.removeEventListener('scroll', emitScroll, true);
});
const smoothScrollTo = (target: number) => {

View File

@@ -8,6 +8,7 @@ import { isMessageRead } from '@/utils/message-read';
import { parsePushMessage, resolveNoticeGroup, resolveNoticeTitle, shouldAppendNotice } from '@/utils/push-message';
let closePushConnection: (() => void) | undefined;
let stopPushWatchers: Array<() => void> = [];
const formatNoticeTime = (timestamp?: number | string) => {
const time = timestamp ? new Date(timestamp) : new Date();
@@ -77,22 +78,23 @@ const initSsePush = (url: string) => {
retries: 5,
delay: 5000,
onFailed() {
console.log('Failed to connect after 5 retries');
console.warn('SSE connection failed after 5 retries');
}
}
});
closePushConnection = close;
watch(error, () => {
console.log('SSE connection error:', error.value);
const stopErrorWatch = watch(error, () => {
console.warn('SSE connection error:', error.value);
error.value = null;
});
watch(data, () => {
const stopDataWatch = watch(data, () => {
if (!data.value) return;
appendNotice(data.value);
data.value = null;
});
stopPushWatchers.push(stopErrorWatch, stopDataWatch);
};
const initWsPush = (url: string) => {
@@ -101,7 +103,7 @@ const initWsPush = (url: string) => {
retries: 3,
delay: 1000,
onFailed() {
console.log('websocket重连失败');
console.warn('websocket重连失败');
}
},
heartbeat: {
@@ -109,12 +111,6 @@ const initWsPush = (url: string) => {
interval: 10000,
pongTimeout: 2000
},
onConnected() {
console.log('websocket已经连接');
},
onDisconnected() {
console.log('websocket已经断开');
},
onMessage: (_, e) => {
if (String(e.data) === 'pong') {
return;
@@ -154,4 +150,6 @@ export const initMessageBox = async () => {
export const closePush = () => {
closePushConnection?.();
closePushConnection = undefined;
stopPushWatchers.forEach(stop => stop());
stopPushWatchers = [];
};

View File

@@ -151,63 +151,83 @@ import modal from '@/plugins/modal';
const cache = ref<Partial<CacheVO>>({});
const commandstats = ref();
const usedmemory = ref();
let commandstatsInstance: echarts.ECharts | undefined;
let usedmemoryInstance: echarts.ECharts | undefined;
const handleResize = () => {
commandstatsInstance?.resize();
usedmemoryInstance?.resize();
};
const disposeCharts = () => {
commandstatsInstance?.dispose();
usedmemoryInstance?.dispose();
commandstatsInstance = undefined;
usedmemoryInstance = undefined;
};
const getList = async () => {
modal.loading('正在加载缓存监控数据,请稍候!');
const res = await getCache();
modal.closeLoading();
cache.value = res.data;
const commandstatsIntance = echarts.init(commandstats.value, 'macarons');
commandstatsIntance.setOption({
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} ({d}%)'
},
series: [
{
name: '命令',
type: 'pie',
roseType: 'radius',
radius: [15, 95],
center: ['50%', '38%'],
data: res.data.commandStats,
animationEasing: 'cubicInOut',
animationDuration: 1000
}
]
});
const usedmemoryInstance = echarts.init(usedmemory.value, 'macarons');
usedmemoryInstance.setOption({
tooltip: {
formatter: '{b} <br/>{a} : ' + cache.value.info.used_memory_human
},
series: [
{
name: '峰值',
type: 'gauge',
min: 0,
max: 1000,
detail: {
formatter: cache.value.info.used_memory_human
},
data: [
{
value: parseFloat(cache.value.info.used_memory_human),
name: '内存消耗'
}
]
}
]
});
window.addEventListener('resize', () => {
commandstatsIntance.resize();
usedmemoryInstance.resize();
});
try {
const res = await getCache();
cache.value = res.data;
disposeCharts();
commandstatsInstance = echarts.init(commandstats.value, 'macarons');
commandstatsInstance.setOption({
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} ({d}%)'
},
series: [
{
name: '命令',
type: 'pie',
roseType: 'radius',
radius: [15, 95],
center: ['50%', '38%'],
data: res.data.commandStats,
animationEasing: 'cubicInOut',
animationDuration: 1000
}
]
});
usedmemoryInstance = echarts.init(usedmemory.value, 'macarons');
usedmemoryInstance.setOption({
tooltip: {
formatter: '{b} <br/>{a} : ' + cache.value.info.used_memory_human
},
series: [
{
name: '峰值',
type: 'gauge',
min: 0,
max: 1000,
detail: {
formatter: cache.value.info.used_memory_human
},
data: [
{
value: parseFloat(cache.value.info.used_memory_human),
name: '内存消耗'
}
]
}
]
});
} finally {
modal.closeLoading();
}
};
onMounted(() => {
window.addEventListener('resize', handleResize);
getList();
});
onBeforeUnmount(() => {
window.removeEventListener('resize', handleResize);
disposeCharts();
});
</script>
<style lang="scss" scoped>