File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
frontend/src/pages/sdoc/sdoc-editor Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export default class SdocEditor extends React.Component {
19
19
20
20
componentDidMount ( ) {
21
21
this . getDirentList ( ) ;
22
+ this . cacheHistoryfiles ( ) ;
22
23
const { docName } = window . seafile ;
23
24
const fileIcon = Utils . getFileIconUrl ( docName , 192 ) ;
24
25
document . getElementById ( 'favicon' ) . href = fileIcon ;
@@ -32,6 +33,25 @@ export default class SdocEditor extends React.Component {
32
33
this . setState ( { isDraft : false } ) ;
33
34
} ;
34
35
36
+ cacheHistoryfiles = ( ) => {
37
+ const { docName, docUuid } = window . seafile ;
38
+ const rencentFiles = localStorage . getItem ( 'sdoc-recent-files' ) ? JSON . parse ( localStorage . getItem ( 'sdoc-recent-files' ) ) : [ ] ;
39
+ let arr = [ ] ;
40
+ const newFile = { file_uuid : docUuid , file_name : docName } ;
41
+ if ( rencentFiles . length > 0 ) {
42
+ const isExist = rencentFiles . find ( ( item ) => item . file_uuid === docUuid ) ;
43
+ if ( isExist ) return ;
44
+ if ( ! isExist ) {
45
+ let newRencentFiles = rencentFiles . slice ( 0 ) ;
46
+ if ( rencentFiles . length === 10 ) { newRencentFiles . shift ( ) ; }
47
+ arr = [ newFile , ...newRencentFiles ] ;
48
+ }
49
+ } else {
50
+ arr . push ( newFile ) ;
51
+ }
52
+ localStorage . setItem ( 'sdoc-recent-files' , JSON . stringify ( arr ) ) ;
53
+ } ;
54
+
35
55
getDirPath = ( ) => {
36
56
const { docPath } = window . seafile ;
37
57
const index = docPath . lastIndexOf ( '/' ) ;
You can’t perform that action at this time.
0 commit comments