diff --git a/app/src/editor/index.ts b/app/src/editor/index.ts index 6324d2287..6232e2278 100644 --- a/app/src/editor/index.ts +++ b/app/src/editor/index.ts @@ -8,6 +8,7 @@ import {setModelsHash} from "../window/setHeader"; import {countBlockWord} from "../layout/status"; import {App} from "../index"; import {fullscreen} from "../protyle/breadcrumb/action"; +import {fetchPost} from "../util/fetch"; export class Editor extends Model { public element: HTMLElement; @@ -33,6 +34,8 @@ export class Editor extends Model { this.headElement = options.tab.headElement; this.element = options.tab.panelElement; this.initProtyle(options); + // 当文档第一次加载到页签时更新 openAt 时间 + fetchPost("/api/storage/updateRecentDocOpenTime", {rootID: options.rootId}); } private initProtyle(options: { diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index eac33105e..45da66d8d 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -488,6 +488,10 @@ export class Wnd { isInitActive = true; } else { item.headElement.setAttribute("data-activetime", (new Date()).getTime().toString()); + // 更新文档浏览时间 + if (currentTab.model instanceof Editor) { + fetchPost("/api/storage/updateRecentDocViewTime", {rootID: currentTab.model.editor.protyle.block.rootID}); + } } } item.panelElement.classList.remove("fn__none"); @@ -556,9 +560,6 @@ export class Wnd { } // focusin 触发前,layout__wnd--active 和 tab 已设置,需在调用里面更新 if (update) { - // 更新文档浏览时间 - fetchPost("/api/storage/updateRecentDocViewTime", {rootID: currentTab.model.editor.protyle.block.rootID}); - updatePanelByEditor({ protyle: currentTab.model.editor.protyle, focus: true, @@ -637,11 +638,6 @@ export class Wnd { tab.callback(tab); } - // 当文档第一次加载到页签时更新 openAt 时间 - if (tab.model instanceof Editor && tab.model.editor?.protyle?.block?.rootID) { - fetchPost("/api/storage/updateRecentDocOpenTime", {rootID: tab.model.editor.protyle.block.rootID}); - } - // 移除 centerLayout 中的 empty if (this.parent.type === "center" && this.children.length === 2 && !this.children[0].headElement) { this.removeTab(this.children[0].id);