diff --git a/src/pages/home/toolbar/BatchRename.tsx b/src/pages/home/toolbar/BatchRename.tsx index c5d23e12..2986497e 100644 --- a/src/pages/home/toolbar/BatchRename.tsx +++ b/src/pages/home/toolbar/BatchRename.tsx @@ -143,7 +143,7 @@ export const BatchRename = () => { const renameObj: RenameObj = { src_name: obj.name, - new_name: srcName() + tempNum + "." + suffix, + new_name: srcName() + tempNum + (suffix == "" ? "" : "." + suffix), } tempNum = (parseInt(tempNum) + 1) .toString() diff --git a/src/pages/home/toolbar/Delete.tsx b/src/pages/home/toolbar/Delete.tsx index 6666dca0..75c1c6ba 100644 --- a/src/pages/home/toolbar/Delete.tsx +++ b/src/pages/home/toolbar/Delete.tsx @@ -54,7 +54,10 @@ export const Delete = () => { onClick={async () => { const resp = await ok( pathname(), - selectedObjs().map((obj) => obj.name), + selectedObjs().map((obj) => ({ + id: obj.id, + name: obj.name, + })), ) handleRespWithNotifySuccess(resp, () => { refresh() diff --git a/src/types/obj.ts b/src/types/obj.ts index 0c64731e..fae9454e 100644 --- a/src/types/obj.ts +++ b/src/types/obj.ts @@ -9,6 +9,7 @@ export enum ObjType { } export interface Obj { + id: string name: string size: number is_dir: boolean @@ -24,6 +25,11 @@ export type StoreObj = Obj & { selected?: boolean } +export type IDName = { + id: string + name: string +} + export type RenameObj = { src_name: string new_name: string diff --git a/src/utils/api.ts b/src/utils/api.ts index f2241507..a9234d85 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -9,6 +9,7 @@ import { RenameObj, ArchiveMeta, ArchiveList, + IDName, } from "~/types" import { r } from "." @@ -104,8 +105,16 @@ export const fsCopy = ( return r.post("/fs/copy", { src_dir, dst_dir, names, overwrite }) } -export const fsRemove = (dir: string, names: string[]): PEmptyResp => { - return r.post("/fs/remove", { dir, names }) +export const fsRemove = (dir: string, names: IDName[]): PEmptyResp => { + return r.post( + "/fs/remove", + { names }, + { + headers: { + "File-Path": encodeURIComponent(dir), + }, + }, + ) } export const fsRemoveEmptyDirectory = (src_dir: string): PEmptyResp => {