Vanessa 2025-10-24 13:08:00 +08:00
parent 6e415879ee
commit 5ec6b314a9
2 changed files with 7 additions and 8 deletions

View file

@ -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: {

View file

@ -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);