Spaces:
Sleeping
Sleeping
Update index.html
Browse files31 unmodified lines3233343536378 unmodified lines464748495051107 unmodified lines15916016116216316422 unmodified lines187188189190191192158 unmodified lines35135235335431 unmodified lines{ id: 'jpeg-pdf', title: '画像 → PDF', icon: 'file-text', color: 'bg-red-500', description: '複数の画像を1つのPDFに結合' },{ id: 'pdf-png', title: 'PDF → PNG', icon: 'files', color: 'bg-emerald-500', description: 'PDFの各ページを画像に変換' },{ id: 'youtube', title: 'YouTube 保存', icon: 'youtube', color: 'bg-rose-600', description: '動画・音声を最高画質で保存 (Colab経由)' },];function App() {8 unmodified linesconst [error, setError] = useState(null);const [isDragging, setIsDragging] = useState(false);const pollInterval = useRef(null);const handleFileChange = (e) => {107 unmodified linessetError(null);};return (<div className="flex flex-col min-h-screen"><div className="max-w-4xl mx-auto px-4 py-12 flex-grow w-full">22 unmodified lines</button>))}</div>) : (<div className="max-w-lg mx-auto"><div className="bg-white rounded-3xl shadow-sm border border-slate-100 overflow-hidden">158 unmodified linesroot.render(<App />);</script></body></html>31 unmodified lines323334353637388 unmodified lines474849505152535455565758107 unmodified lines16616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421522 unmodified lines238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329158 unmodified lines48848949049131 unmodified lines{ id: 'jpeg-pdf', title: '画像 → PDF', icon: 'file-text', color: 'bg-red-500', description: '複数の画像を1つのPDFに結合' },{ id: 'pdf-png', title: 'PDF → PNG', icon: 'files', color: 'bg-emerald-500', description: 'PDFの各ページを画像に変換' },{ id: 'youtube', title: 'YouTube 保存', icon: 'youtube', color: 'bg-rose-600', description: '動画・音声を最高画質で保存 (Colab経由)' },{ id: 'file-download', title: 'ファイル配布', icon: 'folder-down', color: 'bg-teal-500', description: 'パスワード認証でファイルをダウンロード' },];function App() {8 unmodified linesconst [error, setError] = useState(null);const [isDragging, setIsDragging] = useState(false);const [filePassword, setFilePassword] = useState("");const [fileList, setFileList] = useState([]);const [selectedFiles, setSelectedFiles] = useState([]);const [fileError, setFileError] = useState(null);const [fileDownloading, setFileDownloading] = useState(false);const pollInterval = useRef(null);const handleFileChange = (e) => {107 unmodified linessetError(null);};const handleFileAuth = async () => {setFileError(null);try {const res = await fetch('/api/files/auth', {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({ password: filePassword }),});const data = await res.json();if (!res.ok) throw new Error(data.detail || "認証に失敗しました");setFileList(data.files);} catch (err) {setFileError(err.message);}};const handleFilesDownload = async () => {if (selectedFiles.length === 0) return;setFileDownloading(true);setFileError(null);try {const res = await fetch('/api/files/download', {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({ password: filePassword, filenames: selectedFiles }),});if (!res.ok) {const data = await res.json();throw new Error(data.detail || "ダウンロードに失敗しました");}const blob = await res.blob();const url = URL.createObjectURL(blob);const a = document.createElement('a');a.href = url;a.download = 'download.zip';a.click();URL.revokeObjectURL(url);} catch (err) {setFileError(err.message);} finally {setFileDownloading(false);}};return (<div className="flex flex-col min-h-screen"><div className="max-w-4xl mx-auto px-4 py-12 flex-grow w-full">22 unmodified lines</button>))}</div>) : selectedTool.id === 'file-download' ? (<div className="max-w-lg mx-auto"><div className="bg-white rounded-3xl shadow-sm border border-slate-100 overflow-hidden">{/* Tool Header */}<div className="bg-teal-500 p-6"><button onClick={reset} className="flex items-center gap-2 text-white/80 hover:text-white mb-4 text-sm font-bold transition-colors"><Icon name="arrow-left" className="w-4 h-4" />ツール選択に戻る</button><div className="flex items-center gap-3"><Icon name="folder-down" className="w-8 h-8 text-white" /><div><h2 className="text-xl font-black text-white">ファイル配布</h2><p className="text-white/70 text-sm font-medium">パスワード認証でファイルをダウンロード</p></div></div></div>{/* Content */}<div className="p-6 space-y-4">{fileList.length === 0 ? (<div className="space-y-4"><div><label className="block text-sm font-bold text-slate-600 mb-2">パスワード</label><inputtype="password"className="w-full p-4 bg-slate-50 border-2 border-slate-100 rounded-2xl focus:border-teal-500 focus:outline-none transition-all"placeholder="パスワードを入力"value={filePassword}onChange={(e) => setFilePassword(e.target.value)}onKeyDown={(e) => e.key === 'Enter' && handleFileAuth()}/></div>{fileError && (<div className="p-4 bg-rose-50 border border-rose-100 rounded-2xl text-rose-600 font-bold text-center text-sm">{fileError}</div>)}<buttononClick={handleFileAuth}disabled={!filePassword}className="w-full bg-slate-900 text-white py-4 rounded-2xl font-bold hover:bg-teal-600 disabled:bg-slate-200 transition-all">認証する</button></div>) : (<div className="space-y-4"><p className="text-sm font-bold text-slate-600">ダウンロードするファイルを選択してください</p><div className="space-y-2 max-h-64 overflow-y-auto">{fileList.map(fname => (<label key={fname} className="flex items-center gap-3 p-3 bg-slate-50 rounded-2xl cursor-pointer hover:bg-teal-50 transition-colors"><inputtype="checkbox"className="w-4 h-4 accent-teal-500"checked={selectedFiles.includes(fname)}onChange={(e) => {if (e.target.checked) {setSelectedFiles([...selectedFiles, fname]);} else {setSelectedFiles(selectedFiles.filter(f => f !== fname));}}}/><Icon name="file" className="w-4 h-4 text-slate-400" /><span className="text-sm font-medium text-slate-700">{fname}</span></label>))}</div>{fileError && (<div className="p-4 bg-rose-50 border border-rose-100 rounded-2xl text-rose-600 font-bold text-center text-sm">{fileError}</div>)}<buttononClick={handleFilesDownload}disabled={selectedFiles.length === 0 || fileDownloading}className="w-full bg-slate-900 text-white py-4 rounded-2xl font-bold hover:bg-teal-600 disabled:bg-slate-200 transition-all flex items-center justify-center gap-2"><Icon name="download" className="w-5 h-5" />{fileDownloading ? 'ダウンロード中...' : `${selectedFiles.length}件をダウンロード`}</button></div>)}</div></div></div>) : (<div className="max-w-lg mx-auto"><div className="bg-white rounded-3xl shadow-sm border border-slate-100 overflow-hidden">158 unmodified linesroot.render(<App />);</script></body></html>
index.html+138-1