2024-12-08 13:04:23 +08:00
|
|
|
import { buildProgressProps } from '@/components/progress-notify/progress-notify';
|
|
|
|
|
import syssocket from './syssocket';
|
|
|
|
|
import { h, reactive } from 'vue';
|
|
|
|
|
import { ElNotification } from 'element-plus';
|
|
|
|
|
import ProgressNotify from '@/components/progress-notify/progress-notify.vue';
|
|
|
|
|
|
2025-07-27 21:02:48 +08:00
|
|
|
export async function initSysMsgs() {
|
|
|
|
|
await registerDbSqlExecProgress();
|
2024-12-08 13:04:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const sqlExecNotifyMap: Map<string, any> = new Map();
|
|
|
|
|
|
2025-07-27 21:02:48 +08:00
|
|
|
async function registerDbSqlExecProgress() {
|
|
|
|
|
await syssocket.registerMsgHandler('sqlScriptRunProgress', function (message: any) {
|
|
|
|
|
const content = message.params;
|
2024-12-08 13:04:23 +08:00
|
|
|
const id = content.id;
|
|
|
|
|
let progress = sqlExecNotifyMap.get(id);
|
|
|
|
|
if (content.terminated) {
|
|
|
|
|
if (progress != undefined) {
|
|
|
|
|
progress.notification?.close();
|
|
|
|
|
sqlExecNotifyMap.delete(id);
|
|
|
|
|
progress = undefined;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (progress == undefined) {
|
|
|
|
|
progress = {
|
|
|
|
|
props: reactive(buildProgressProps()),
|
|
|
|
|
notification: undefined,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
progress.props.progress.title = content.title;
|
|
|
|
|
progress.props.progress.executedStatements = content.executedStatements;
|
|
|
|
|
if (!sqlExecNotifyMap.has(id)) {
|
|
|
|
|
progress.notification = ElNotification({
|
|
|
|
|
duration: 0,
|
|
|
|
|
title: message.title,
|
|
|
|
|
message: h(ProgressNotify, progress.props),
|
2025-07-27 21:02:48 +08:00
|
|
|
type: 'info',
|
2024-12-08 13:04:23 +08:00
|
|
|
showClose: false,
|
|
|
|
|
});
|
|
|
|
|
sqlExecNotifyMap.set(id, progress);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|