From be93aaf806bfccfa7d93a6ed88ee72d07b1b09fc Mon Sep 17 00:00:00 2001 From: ThinLiquid Date: Thu, 7 Dec 2023 13:48:27 +0000 Subject: [PATCH] =?UTF-8?q?[=E2=9C=A8]=20Files=20app=20QOL=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtin/apps/files.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/builtin/apps/files.ts b/src/builtin/apps/files.ts index 24202c8..f85bcb6 100644 --- a/src/builtin/apps/files.ts +++ b/src/builtin/apps/files.ts @@ -64,7 +64,7 @@ export default class FilesApp implements App { const separator = dir === '/' ? '' : '/' window.fs.stat(dir + separator + file, (e: NodeJS.ErrnoException, fileStat: Stats) => { const element = document.createElement('div') - element.setAttribute('style', 'padding: 5px;border-bottom: 1px solid var(--text);display:flex;align-items:center;gap: 5px;') + element.setAttribute('style', 'display: flex;gap: 5px;align-items:center;padding: 5px;border-bottom: 1px solid var(--text);display:flex;align-items:center;gap: 5px;') const genIcon = (): string => { switch (file.split('.').at(-1)) { @@ -111,8 +111,19 @@ export default class FilesApp implements App { } const icon = fileStat.isDirectory() ? 'folder' : genIcon() - element.innerHTML += `${icon} ${file}` - element.onclick = async () => { + element.innerHTML += `${icon} ${file}delete_foreveredit`; + (element.querySelector('.rename') as HTMLElement).onclick = async () => { + const value = (prompt('Rename') as string) + if (value !== null || value !== undefined) { + await window.fs.promises.rename(dir + separator + file, dir + separator + value) + await setDir(dir) + } + } + (element.querySelector('.delete') as HTMLElement).onclick = async () => { + await window.fs.promises.unlink(dir + separator + file) + await setDir(dir) + } + element.ondblclick = async () => { if (fileStat.isDirectory()) { await setDir(dir + separator + file) } else {