MCPcopy Create free account
hub / github.com/dajie111/nodeseek-userscript / startAutoSave

Function startAutoSave

notes.js:1488–1513  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1486
1487 // 启动自动保存
1488 function startAutoSave() {
1489 // 清除之前的定时器
1490 if (autoSaveTimer) {
1491 clearInterval(autoSaveTimer);
1492 }
1493
1494 // 每30秒检查并保存
1495 autoSaveTimer = setInterval(() => {
1496 // 检查是否有内容需要保存
1497 const currentTitle = titleInput.value.trim();
1498 const currentContent = editor.innerHTML;
1499
1500 // 如果内容有变化且不为空,则自动保存
1501 if ((currentTitle !== window.lastSaveTitle || currentContent !== window.lastSaveContent) &&
1502 (currentTitle || currentContent.trim())) {
1503
1504 const success = saveCurrent();
1505 if (success) {
1506 window.lastSaveTitle = currentTitle;
1507 window.lastSaveContent = currentContent;
1508 // 显示自动保存提示(不在控制台输出)
1509 showAutoSaveNotification();
1510 }
1511 }
1512 }, 30000); // 30秒
1513 }
1514
1515 // 显示自动保存提示
1516 function showAutoSaveNotification() {

Callers 1

buildDialogFunction · 0.85

Calls 2

saveCurrentFunction · 0.85
showAutoSaveNotificationFunction · 0.85

Tested by

no test coverage detected