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 # Editor directories and files
.idea .idea
.vscode .vscode
*.iml
*.suo *.suo
*.ntvs* *.ntvs*
*.njsproj *.njsproj
@ -22,7 +23,6 @@ selenium-debug.log
package-lock.json package-lock.json
yarn.lock yarn.lock
pnpm-lock.yaml
# 编译生成的文件 # 编译生成的文件
auto-imports.d.ts 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({ const props = defineProps({
taskVariables: { taskVariables: {
type: Object as () => Record<string, any>, type: Object as () => Record<string, any>,
default: () => {} default: () => ({})
} }
}); });
// //
@ -326,7 +326,6 @@ const openDialog = async (id?: string) => {
selectCopyUserList.value = task.value.copyList; selectCopyUserList.value = task.value.copyList;
selectCopyUserIds.value = task.value.copyList.map(e => e.userId).join(','); selectCopyUserIds.value = task.value.copyList.map(e => e.userId).join(',');
varNodeList.value = task.value.varList; varNodeList.value = task.value.varList;
console.log('varNodeList', varNodeList.value);
buttonDisabled.value = false; buttonDisabled.value = false;
try { try {
const data = { const data = {
@ -340,7 +339,6 @@ const openDialog = async (id?: string) => {
} }
}; };
onMounted(() => {});
const emits = defineEmits(['submitCallback', 'cancelCallback']); const emits = defineEmits(['submitCallback', 'cancelCallback']);
/** 办理流程 */ /** 办理流程 */

View File

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

View File

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