Add save actions and cross-platform file manager support (#848)
* files-download-feature * feat: add save option to file directory context menus and viewer * fix: open files in the system file manager
This commit is contained in:
@@ -115,7 +115,6 @@ export const createVSCodeFilesAPI = (): FilesAPI => ({
|
||||
|
||||
async execCommands(commands: string[], cwd: string): Promise<{ success: boolean; results: CommandExecResult[] }> {
|
||||
const targetCwd = normalizePath(cwd);
|
||||
// Use extended timeout for command execution (5 minutes)
|
||||
const data = await sendBridgeMessageWithOptions<{ success: boolean; results?: CommandExecResult[] }>('api:fs:exec', {
|
||||
commands,
|
||||
cwd: targetCwd,
|
||||
@@ -126,4 +125,15 @@ export const createVSCodeFilesAPI = (): FilesAPI => ({
|
||||
results: Array.isArray(data?.results) ? data.results : [],
|
||||
};
|
||||
},
|
||||
|
||||
async downloadFile(path: string): Promise<void> {
|
||||
const target = normalizePath(path);
|
||||
const url = `/api/fs/raw?path=${encodeURIComponent(target)}&download=true`;
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = target.split('/').pop() || 'file';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user