chore: remove dead code (lib/file.ts, unused attachmentAdd export)
This commit is contained in:
@@ -129,8 +129,6 @@ export const bandUpsert = (p: GradeBand) => call<{ item: { id: number } }>('band
|
||||
export const bandDelete = (id: number) => call<{ ok: true }>('band_delete', { id });
|
||||
|
||||
// ---- attachment ----
|
||||
export const attachmentAdd = (p: { owner_id: number; file_name: string; mime?: string; size: number; data_b64: string; thumb_b64?: string }) =>
|
||||
call<{ item: Attachment }>('attachment_add', p);
|
||||
export const attachmentList = (owner_id: number) => call<{ items: Attachment[] }>('attachment_list', { owner_id });
|
||||
export const attachmentDelete = (id: number) => call<{ ok: true }>('attachment_delete', { id });
|
||||
export const attachmentRead = (id: number) =>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
// 附件打开/下载:图片与 PDF 新窗口预览,其余触发下载
|
||||
export function openOrDownload(fileName: string, mime?: string, b64?: string) {
|
||||
if (!b64) return;
|
||||
const bytes = Uint8Array.from(atob(b64), c => c.charCodeAt(0));
|
||||
const blob = new Blob([bytes], { type: mime || 'application/octet-stream' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
if (mime?.startsWith('image/') || mime === 'application/pdf') {
|
||||
window.open(url, '_blank');
|
||||
} else {
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = fileName;
|
||||
a.click();
|
||||
}
|
||||
setTimeout(() => URL.revokeObjectURL(url), 60_000);
|
||||
}
|
||||
Reference in New Issue
Block a user