完成 load view

This commit is contained in:
锦恢 2024-10-21 23:46:18 +08:00
parent 07ecfb9845
commit 67b008fa31

View File

@ -79,47 +79,52 @@ export async function recoverFromInputFile(inputFile, inputViewFile) {
globalLookup.originVcdFile = inputFile; globalLookup.originVcdFile = inputFile;
// 先尝试从 inputViewFile 中寻找,如果找不到,则从同名的 .view 中寻找 // 先尝试从 inputViewFile 中寻找,如果找不到,则从同名的 .view 中寻找
const recoverJson = await attemptRecover(inputFile, inputViewFile); const recoverJson = await attemptRecover(inputFile, inputViewFile);
recoverFromJson(recoverJson);
}
if (recoverJson) { function recoverFromJson(recoverJson) {
// 加载 waves if (recoverJson === undefined) {
const waves = recoverJson.waves; return;
if (waves instanceof Array && waves.length > 0) { }
for (const wave of waves) {
const name = wave.name; // 加载 waves
const option = wave.option; const waves = recoverJson.waves;
if (name === undefined || option === undefined || recoverConfig.waves.has(name)) { if (waves instanceof Array && waves.length > 0) {
continue; for (const wave of waves) {
} const name = wave.name;
recoverConfig.waves.set(name, option); const option = wave.option;
if (name === undefined || option === undefined || recoverConfig.waves.has(name)) {
continue;
} }
recoverConfig.waves.set(name, option);
} }
}
// 加载 views // 加载 views
const views = recoverJson.views; const views = recoverJson.views;
if (views instanceof Array && views.length > 0) { if (views instanceof Array && views.length > 0) {
recoverConfig.views = recoverJson.views; recoverConfig.views = recoverJson.views;
} }
// 加载 state // 加载 state
recoverConfig.state = recoverJson.state; recoverConfig.state = recoverJson.state;
// 加载 pivots // 加载 pivots
const pivots = recoverJson.pivots; const pivots = recoverJson.pivots;
if (pivots instanceof Array && pivots.length > 0) { if (pivots instanceof Array && pivots.length > 0) {
recoverConfig.pivots = pivots; recoverConfig.pivots = pivots;
} }
// 加载 treeviewExpands // 加载 treeviewExpands
const treeviewExpands = recoverJson.treeviewExpands; const treeviewExpands = recoverJson.treeviewExpands;
if (treeviewExpands instanceof Array && treeviewExpands.length > 0) { if (treeviewExpands instanceof Array && treeviewExpands.length > 0) {
recoverConfig.treeviewExpands = treeviewExpands; recoverConfig.treeviewExpands = treeviewExpands;
} }
// 加载 rightNavIndex // 加载 rightNavIndex
const rightNavIndex = recoverJson.rightNavIndex; const rightNavIndex = recoverJson.rightNavIndex;
if (rightNavIndex !== undefined) { if (rightNavIndex !== undefined) {
recoverConfig.rightNavIndex = rightNavIndex; recoverConfig.rightNavIndex = rightNavIndex;
}
} }
} }