File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import {setModelsHash} from "../window/setHeader";
88import { countBlockWord } from "../layout/status" ;
99import { App } from "../index" ;
1010import { fullscreen } from "../protyle/breadcrumb/action" ;
11+ import { fetchPost } from "../util/fetch" ;
1112
1213export 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 : {
Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments