diff --git a/app/src/admin/channel.ts b/app/src/admin/channel.ts index 361675f..9eacf75 100644 --- a/app/src/admin/channel.ts +++ b/app/src/admin/channel.ts @@ -1,4 +1,4 @@ -import {getUniqueList} from "@/utils/base.ts"; +import { getUniqueList } from "@/utils/base.ts"; export type Channel = { id: number; @@ -208,9 +208,9 @@ export const ChannelInfos: Record = { }, }; -export const channelModels: string[] = getUniqueList(Object.values(ChannelInfos).flatMap( - (info) => info.models, -)); +export const channelModels: string[] = getUniqueList( + Object.values(ChannelInfos).flatMap((info) => info.models), +); export const channelGroups: string[] = [ "anonymous", diff --git a/app/src/components/FileProvider.tsx b/app/src/components/FileProvider.tsx index 21cde7a..dc0f3f2 100644 --- a/app/src/components/FileProvider.tsx +++ b/app/src/components/FileProvider.tsx @@ -54,9 +54,10 @@ function FileProvider({ value, onChange }: FileProviderProps) { }); }, []); - const triggerFile = async (files: File[]) => { + const triggerFile = async (files: (File | null)[]) => { setLoading(true); for (const file of files) { + if (!file) continue; if (file.size > MaxFileSize) { toast({ title: t("file.over-size"), @@ -243,7 +244,7 @@ type FileInputProps = { id: string; loading: boolean; className?: string; - handleEvent: (files: File[]) => void; + handleEvent: (files: (File | null)[]) => void; }; function FileInput({ id, loading, className, handleEvent }: FileInputProps) { @@ -273,6 +274,14 @@ function FileInput({ id, loading, className, handleEvent }: FileInputProps) { onChange={(e) => handleEvent(Array.from(e.target?.files || []))} accept="*" style={{ display: "none" }} + // on transfer file + onPaste={(e) => { + const items = e.clipboardData.items; + const files = Array.from(items).filter( + (item) => item.kind === "file", + ); + handleEvent(files.map((file) => file.getAsFile())); + }} /> );