Skip to content

Commit 9b21e72

Browse files
save file
1 parent b013908 commit 9b21e72

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

utils/editors/editor/v2.0/editor-v2.0.html

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,27 +66,23 @@
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

@@ -132,7 +128,16 @@
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

0 commit comments

Comments
 (0)