[✨] Files app QOL update
This commit is contained in:
parent
70d90d1594
commit
be93aaf806
1 changed files with 14 additions and 3 deletions
|
|
@ -64,7 +64,7 @@ export default class FilesApp implements App {
|
||||||
const separator = dir === '/' ? '' : '/'
|
const separator = dir === '/' ? '' : '/'
|
||||||
window.fs.stat(dir + separator + file, (e: NodeJS.ErrnoException, fileStat: Stats) => {
|
window.fs.stat(dir + separator + file, (e: NodeJS.ErrnoException, fileStat: Stats) => {
|
||||||
const element = document.createElement('div')
|
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 => {
|
const genIcon = (): string => {
|
||||||
switch (file.split('.').at(-1)) {
|
switch (file.split('.').at(-1)) {
|
||||||
|
|
@ -111,8 +111,19 @@ export default class FilesApp implements App {
|
||||||
}
|
}
|
||||||
const icon = fileStat.isDirectory() ? '<span class="material-symbols-rounded">folder</span>' : genIcon()
|
const icon = fileStat.isDirectory() ? '<span class="material-symbols-rounded">folder</span>' : genIcon()
|
||||||
|
|
||||||
element.innerHTML += `${icon} ${file}`
|
element.innerHTML += `${icon} <span style="flex:1;">${file}</span><span class="material-symbols-rounded delete">delete_forever</span><span class="material-symbols-rounded rename">edit</span>`;
|
||||||
element.onclick = async () => {
|
(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()) {
|
if (fileStat.isDirectory()) {
|
||||||
await setDir(dir + separator + file)
|
await setDir(dir + separator + file)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue