优化保存恢复功能

This commit is contained in:
锦恢 2024-10-18 20:40:12 +08:00
parent 08148209e7
commit d901594c16
4 changed files with 16 additions and 5 deletions

Binary file not shown.

View File

@ -12,10 +12,10 @@ export let saveDelay = 1000;
/**
*
* @param {string} file
* @param {*} payload
* @param {any} payload
*/
export async function saveView(file, payload) {
if (payload.waves === undefined || payload.waves.length === 0) {
if (payload === undefined) {
return;
}
if (mode === 'debug') {
@ -47,7 +47,7 @@ function debounceSaveView(delay) {
clearTimeout(timer);
}
timer = setTimeout(() => {
const payload = makeSaveViewPayload(configPool);
const payload = makeSaveViewPayload(configPool);
const savePath = globalLookup.originVcdViewFile;
saveView(savePath, payload);
}, delay);

View File

@ -5,6 +5,6 @@ import { saveViewApi } from "@/api";
export function onUpdate() {
globalLookup.render();
updateCurrentGroups();
// 保存视图
// 保存视图
saveViewApi({ views: true });
}

View File

@ -6,6 +6,7 @@ import { BSON } from "bson";
import { Id2Pivot, orderedTimes, UserPivots } from "@/components/pivot/pivot-view";
import { TreeviewExpandSignals } from "@/components/treeview/modules";
import { controlPanel } from "@/components/right-nav";
import { saveViewApi } from "@/api";
export const recoverConfig = {
/**
@ -228,6 +229,16 @@ export function recoverSession(topModules) {
recoverConfig.treeviewExpands = null;
recoverConfig.waves = null;
recoverConfig.rightNavIndex = null;
// 更新后端缓存
saveViewApi({
waves: true,
views: true,
state: true,
pivots: true,
treeviewExpands: true,
rightNavIndex: true
});
}
/**
@ -353,7 +364,7 @@ export function makeSaveViewPayload(config) {
if (defaultFalseWrapper(config, 'waves')) {
// 有 waves 也一定要有 views
config.views = true;
const waves = [];
for (const wire of globalLookup.currentWires) {
const option = globalLookup.currentSignalRenderOptions.get(wire.link) || {};