Skip to content

Commit 5ec6b31

Browse files
committed
🎨 #15824
1 parent 6e41587 commit 5ec6b31

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

app/src/editor/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {setModelsHash} from "../window/setHeader";
88
import {countBlockWord} from "../layout/status";
99
import {App} from "../index";
1010
import {fullscreen} from "../protyle/breadcrumb/action";
11+
import {fetchPost} from "../util/fetch";
1112

1213
export class Editor extends Model {
1314
public element: HTMLElement;
@@ -33,6 +34,8 @@ export class Editor extends Model {
3334
this.headElement = options.tab.headElement;
3435
this.element = options.tab.panelElement;
3536
this.initProtyle(options);
37+
// 当文档第一次加载到页签时更新 openAt 时间
38+
fetchPost("/api/storage/updateRecentDocOpenTime", {rootID: options.rootId});
3639
}
3740

3841
private initProtyle(options: {

app/src/layout/Wnd.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,10 @@ export class Wnd {
488488
isInitActive = true;
489489
} else {
490490
item.headElement.setAttribute("data-activetime", (new Date()).getTime().toString());
491+
// 更新文档浏览时间
492+
if (currentTab.model instanceof Editor) {
493+
fetchPost("/api/storage/updateRecentDocViewTime", {rootID: currentTab.model.editor.protyle.block.rootID});
494+
}
491495
}
492496
}
493497
item.panelElement.classList.remove("fn__none");
@@ -556,9 +560,6 @@ export class Wnd {
556560
}
557561
// focusin 触发前,layout__wnd--active 和 tab 已设置,需在调用里面更新
558562
if (update) {
559-
// 更新文档浏览时间
560-
fetchPost("/api/storage/updateRecentDocViewTime", {rootID: currentTab.model.editor.protyle.block.rootID});
561-
562563
updatePanelByEditor({
563564
protyle: currentTab.model.editor.protyle,
564565
focus: true,
@@ -637,11 +638,6 @@ export class Wnd {
637638
tab.callback(tab);
638639
}
639640

640-
// 当文档第一次加载到页签时更新 openAt 时间
641-
if (tab.model instanceof Editor && tab.model.editor?.protyle?.block?.rootID) {
642-
fetchPost("/api/storage/updateRecentDocOpenTime", {rootID: tab.model.editor.protyle.block.rootID});
643-
}
644-
645641
// 移除 centerLayout 中的 empty
646642
if (this.parent.type === "center" && this.children.length === 2 && !this.children[0].headElement) {
647643
this.removeTab(this.children[0].id);

0 commit comments

Comments
 (0)