wip fix rename

This commit is contained in:
Rizky 2024-03-10 16:57:00 +07:00
parent 8d94e2779a
commit f05a9e14dc
2 changed files with 28 additions and 7 deletions

View File

@ -138,11 +138,13 @@ export const EdFileList = () => {
const selected = [...f.selected]; const selected = [...f.selected];
const rename_to = prompt("Rename to:", selected[0]); const rename_to = prompt("Rename to:", selected[0]);
await p.script.api._raw( if (rename_to) {
`/_file${join(f.path, selected[0])}?rename=${rename_to}` await p.script.api._raw(
); `/_file${join(f.path, selected[0])}?rename=${rename_to}`
);
reloadFileTree(p); reloadFileTree(p);
}
}, 100); }, 100);
}} }}
/> />
@ -690,7 +692,7 @@ export const reloadFileList = async (p: PG) => {
p.render(); p.render();
}; };
const join = (...arg: string[]) => { export const join = (...arg: string[]) => {
let arr: string[] = []; let arr: string[] = [];
for (const s of arg) { for (const s of arg) {

View File

@ -1,6 +1,7 @@
import { useGlobal, useLocal } from "web-utils"; import { useGlobal, useLocal } from "web-utils";
import { EDGlobal } from "../../logic/ed-global"; import { EDGlobal } from "../../logic/ed-global";
import { isImage } from "./file-list"; import { isImage, join } from "./file-list";
import { reloadFileTree } from "./file-tree";
import { FEntry } from "./type"; import { FEntry } from "./type";
export const EdFilePreview = () => { export const EdFilePreview = () => {
@ -94,7 +95,25 @@ export const EdFilePreview = () => {
)} )}
</a> </a>
<div className="p-2 border-b flex justify-between"> <div className="p-2 border-b flex justify-between">
<div>{first?.name}</div> <div
className="cursor-pointer hover:text-blue-500 hover:underline"
onClick={() => {
setTimeout(async () => {
const selected = [...f.selected];
const rename_to = prompt("Rename to:", selected[0]);
if (rename_to) {
await p.script.api._raw(
`/_file${join(f.path, selected[0])}?rename=${rename_to}`
);
reloadFileTree(p);
}
}, 100);
}}
>
{first?.name}
</div>
<div>{fileSize(first?.size || 0)}</div> <div>{fileSize(first?.size || 0)}</div>
</div> </div>
<input <input