diff --git a/editor/stores/editorStore.ts b/editor/stores/editorStore.ts index 8f49277..4429808 100644 --- a/editor/stores/editorStore.ts +++ b/editor/stores/editorStore.ts @@ -166,9 +166,14 @@ export const useEditorStore = defineStore('editor', () => { function debouncedSaveVersion() { const current = JSON.stringify(gameData.value) - if (current === lastSavedContent) return - if (saveVersionTimer) clearTimeout(saveVersionTimer) + if (current === lastSavedContent) { + console.log('[版本] 内容相同,跳过') + return + } + if (saveVersionTimer) { console.log('[版本] 重置 3s 计时器'); clearTimeout(saveVersionTimer) } + else console.log('[版本] 启动 3s 计时器') saveVersionTimer = setTimeout(async () => { + console.log('[版本] 保存到 IndexedDB') lastSavedContent = current await saveVersion('手动编辑') }, 3000)