enh: ot move
This commit is contained in:
1 parent
c701ebe07b
commit
0c42cd2c01
3 files changed
+97
-10
No files matched your search
@@ -21,6 +21,7 @@
|
||||
uploadToTerminal,
|
||||
createDirectory,
|
||||
deleteEntry,
|
||||
moveEntry,
|
||||
setCwd,
|
||||
type FileEntry
|
||||
} from '$lib/apis/terminal';
|
||||
@@ -323,6 +324,23 @@
|
||||
showDeleteConfirm = true;
|
||||
};
|
||||
|
||||
// ── Move (drag-and-drop) ────────────────────────────────────────────
|
||||
const handleMove = async (source: string, destFolder: string) => {
|
||||
const terminal = selectedTerminal;
|
||||
if (!terminal) return;
|
||||
|
||||
const fileName = source.split('/').pop() ?? '';
|
||||
const destination = `${destFolder}${fileName}`;
|
||||
|
||||
if (source === destination) return;
|
||||
|
||||
const result = await moveEntry(terminal.url, terminal.key, source, destination);
|
||||
toast[result ? 'success' : 'error'](
|
||||
$i18n.t(result ? 'Moved {{name}}' : 'Failed to move {{name}}', { name: fileName })
|
||||
);
|
||||
await loadDir(currentPath);
|
||||
};
|
||||
|
||||
// ── Lifecycle ────────────────────────────────────────────────────────
|
||||
onMount(async () => {
|
||||
const terminal = getTerminal();
|
||||
@@ -717,6 +735,7 @@
|
||||
onOpen={openEntry}
|
||||
onDownload={downloadFile}
|
||||
onDelete={requestDelete}
|
||||
onMove={handleMove}
|
||||
/>
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
Reference in new issue
Block a user