feat: add save file support · inherd/uncode@bfd6a46 · GitHub
Skip to content

Commit bfd6a46

Browse files
committed
feat: add save file support
1 parent c509f53 commit bfd6a46

5 files changed

Lines changed: 34 additions & 7 deletions

File tree

‎src-tauri/src/cmd.rs‎

Lines changed: 15 additions & 1 deletion

‎src-tauri/src/main.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ fn main() {
110110

111111

112112
cmd::open_file,
113+
cmd::save_file,
113114
cmd::open_dir,
114115

115116
// design

‎uncode-ui/src/app/pages/CodePage/index.tsx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ export function CodePage() {
125125
if (nodeIds.endsWith('?is_dir=true')) {
126126
return;
127127
}
128+
129+
UncodeBridge.views.currentFile = nodeIds;
128130
UncodeBridge.open_file(nodeIds).then(data => {
129131
setContent(data);
130132
});
@@ -136,15 +138,13 @@ export function CodePage() {
136138
) => {
137139
setTimeout(() => {
138140
editor.addAction({
139-
id: 'my-unique-id',
140-
label: 'My Label!!!',
141+
id: 'save-file',
142+
label: 'Save File',
141143
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_S],
142-
// precondition: null,
143-
// keybindingContext: null,
144144
contextMenuGroupId: 'navigation',
145145
contextMenuOrder: 1.5,
146146
run: function (ed, any) {
147-
console.log(ed, any);
147+
UncodeBridge.save_file(ed.getValue()).then(() => {});
148148
},
149149
});
150150
}, 300);

‎uncode-ui/src/uncode-bridge.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ const UncodeBridge = {
4949
},
5050
},
5151

52+
views: {
53+
currentFile: '',
54+
},
55+
5256
exit() {
5357
exit();
5458
},
@@ -116,6 +120,13 @@ const UncodeBridge = {
116120
return invoke_wrapper('open_file', { path });
117121
},
118122

123+
save_file(value: string): Promise<string> {
124+
return invoke_wrapper('save_file', {
125+
path: UncodeBridge.views.currentFile,
126+
value,
127+
});
128+
},
129+
119130
build_modeling() {
120131
this.emit_event('build_modeling', {
121132
root: this.config.uncode.path,

‎uncode/README.md‎

Lines changed: 2 additions & 1 deletion

0 commit comments

Comments
 (0)