File tree Expand file tree Collapse file tree 1 file changed +20
-15
lines changed
utils/editors/editor/v2.0 Expand file tree Collapse file tree 1 file changed +20
-15
lines changed Original file line number Diff line number Diff line change 6666 var output ;
6767 var log ;
6868
69+ var openfile ;
70+
6971
7072 var icon = { } ;
7173
7274
7375 //:
7476
75-
76- console . log ( window . electronAPI ) ;
77- var encoder = new TextEncoder ( ) ;
78-
79- window . electronAPI ?. onOpenFile ( async ( { path} ) => {
77+ window . electronAPI && console . log ( 'electronAPI' ) ;
78+ window . electronAPI ?. onOpenFile ( async ( { path} ) => {
8079 console . log ( 'openfile' , path ) ;
81- var buf = await window . electronAPI . readFile ( { path} ) ;
82- console . log ( 'buf' , buf ) ;
83- var blob = new Blob ( [ buf ] ) ;
84- var txt = await blob . text ( ) ;
85- txt += '123' ;
86- var buf = encoder . encode ( txt ) ;
87- await window . electronAPI . writeFile ( { path, buf} ) ;
88-
89- } ) ;
80+ if ( path [ 1 ] == ':' ) {
81+ path = path . slice ( 2 ) ;
82+ }
83+ openfile = path ;
84+
85+ } ) ;
9086
9187
9288
132128
133129 initdom ( document . body ) ;
134130
135-
131+
132+ if ( openfile ) {
133+ var parts = openfile . split ( '/' ) ;
134+ var path = '/' + parts . slice ( 0 , - 1 ) . join ( '/' ) ;
135+ if ( path . length > 1 ) {
136+ path += '/' ;
137+ }
138+ var filename = parts . at ( - 1 ) ;
139+ electron . load . ui ( path , filename ) ;
140+ }
136141
137142 } //init
138143
You can’t perform that action at this time.
0 commit comments