添加背单词功能

This commit is contained in:
2025-10-30 13:48:05 +08:00
parent d2f9a58cca
commit b74e985770
14 changed files with 231 additions and 90 deletions

View File

@@ -0,0 +1,17 @@
import { useRef } from "react";
export default function useFileUpload(callback: (file: File) => void) {
const inputRef = useRef<HTMLInputElement>(null);
const upload = (type: string = "*") => {
const input = inputRef.current;
if (input) {
input.click();
input.setAttribute("accept", type);
input.onchange = () => {
const file = input.files?.[0];
if (file) callback(file);
};
}
};
return { upload, inputRef };
}