Spaces:
Sleeping
Sleeping
Update index.html
Browse files38 unmodified lines394041424243444546474849501 unmodified line525354555657585960616263646566676869707172737475767778798054 unmodified lines1351361371141381391405 unmodified lines14614714814915015112815215315416 unmodified lines17117217315117417517617717815617918015815918118218316116216316416516616718418518618718818917217317417517617717817918018118218318418518618718819019119219319419519619719819920020120220320420520620719219320820921021119619719819921221321421521621721821922022120622222322421 unmodified lines2462472482342492502512522532542552562572582592602612 unmodified lines26426526624326726824526927027127227327427527656 unmodified lines33333433530833633733833938 unmodified lines const [files, setFiles] = useState([]); const [youtubeUrl, setYoutubeUrl] = useState(""); const [youtubeFormat, setYoutubeFormat] = useState('mp3'); const [status, setStatus] = useState('idle'); // idle, uploading, processing, completed, failed const [status, setStatus] = useState('idle'); const [progress, setProgress] = useState(0); const [lastLog, setLastLog] = useState(""); const [downloadUrl, setDownloadUrl] = useState(null); const [error, setError] = useState(null); const [isDragging, setIsDragging] = useState(false);
const pollInterval = useRef(null);
1 unmodified line setFiles(Array.from(e.target.files)); };
// ドラッグ&ドロップハンドラ const handleDragOver = (e) => { e.preventDefault(); e.stopPropagation(); setIsDragging(true); };
const handleDragLeave = (e) => { e.preventDefault(); e.stopPropagation(); setIsDragging(false); };
const handleDrop = (e) => { e.preventDefault(); e.stopPropagation(); setIsDragging(false); const dropped = Array.from(e.dataTransfer.files); if (dropped.length > 0) { setFiles(dropped); } };
const startProcessing = async () => { if (selectedTool.id === 'youtube' && !youtubeUrl) return; if (selectedTool.id !== 'youtube' && files.length === 0) return;54 unmodified lines }, 2000); };
// ツール選択画面に完全に戻る(データを消去) const reset = () => { if (pollInterval.current) clearInterval(pollInterval.current); setSelectedTool(null);5 unmodified lines setLastLog(""); setDownloadUrl(null); setError(null); setIsDragging(false); };
// 入力画面に戻る(URLや選択ファイルを保持) const backToInput = () => { if (pollInterval.current) clearInterval(pollInterval.current); setStatus('idle');16 unmodified lines </div>
{!selectedTool ? ( <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"> <div className="grid grid-cols-2 md:grid-cols-3 gap-4"> {TOOLS.map(tool => ( <button key={tool.id} onClick={() => setSelectedTool(tool)} className="group bg-white p-6 rounded-3xl border border-slate-100 shadow-sm hover:shadow-xl hover:-translate-y-1 transition-all text-left relative overflow-hidden" className="group p-6 bg-white rounded-3xl shadow-sm hover:shadow-xl transition-all duration-300 text-left border border-slate-100 hover:border-indigo-200 hover:-translate-y-1" > <div className={`w-12 h-12 ${tool.color} rounded-2xl flex items-center justify-center mb-4 group-hover:scale-110 transition-transform`}> <Icon name={tool.icon} className="text-white w-6 h-6" /> <div className={`inline-flex p-3 ${tool.color} rounded-2xl mb-4 shadow-lg`}> <Icon name={tool.icon} className="w-6 h-6 text-white" /> </div> <h3 className="font-bold text-slate-900 mb-1">{tool.title}</h3> <p className="text-xs text-slate-500 leading-relaxed">{tool.description}</p> {tool.id === 'youtube' && ( <div className="absolute top-2 right-2 bg-amber-100 text-amber-700 text-[10px] px-2 py-0.5 rounded-full font-bold"> 要Colab設定 </div> )} <p className="font-black text-slate-900 mb-1">{tool.title}</p> <p className="text-xs text-slate-400 font-medium leading-relaxed">{tool.description}</p> </button> ))} </div> ) : ( <div className="bg-white rounded-[2.5rem] border border-slate-100 shadow-2xl overflow-hidden animate-in fade-in zoom-in duration-300"> <div className="p-8"> <button onClick={reset} className="flex items-center text-slate-400 hover:text-indigo-600 font-bold mb-8 transition-colors" > <Icon name="arrow-left" className="w-5 h-5 mr-2" /> ツール選択に戻る </button>
<div className="flex items-center gap-4 mb-8"> <div className={`w-14 h-14 ${selectedTool.color} rounded-2xl flex items-center justify-center shadow-lg`}> <Icon name={selectedTool.icon} className="text-white w-7 h-7" /> </div> <div> <h2 className="text-2xl font-black text-slate-900">{selectedTool.title}</h2> <p className="text-slate-500 font-medium">{selectedTool.description}</p> <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={`${selectedTool.color} 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={selectedTool.icon} className="w-8 h-8 text-white" /> <div> <h2 className="text-xl font-black text-white">{selectedTool.title}</h2> <p className="text-white/70 text-sm font-medium">{selectedTool.description}</p> </div> </div> </div>
{/* Content */} <div className="space-y-6"> {status === 'idle' ? ( <div className="p-6 space-y-4"> {status === 'idle' || status === 'uploading' ? ( <> {selectedTool.id === 'youtube' ? ( <div className="space-y-4 animate-in fade-in duration-300"> <div className="space-y-2"> <label className="block text-sm font-bold text-slate-700">YouTube URL (1行に1つ)</label> <textarea <div className="space-y-4"> <div> <label className="block text-sm font-bold text-slate-600 mb-2">YouTube URL(複数行入力可)</label> <textarea placeholder="https://www.youtube.com/watch?v=..." className="w-full h-32 p-4 bg-slate-50 border-2 border-slate-100 rounded-2xl focus:border-indigo-500 focus:outline-none transition-all font-mono text-sm" value={youtubeUrl} onChange={(e) => setYoutubeUrl(e.target.value)} /> </div> {/* 保存形式の選択 */} <div className="flex gap-4 p-4 bg-slate-50 rounded-2xl border border-slate-100"> <span className="text-sm font-bold text-slate-500 flex items-center">保存形式:</span> <label className="flex items-center gap-2 cursor-pointer group">21 unmodified lines </div> </div> ) : ( <div className="border-2 border-dashed border-slate-200 rounded-3xl p-12 text-center hover:border-indigo-400 transition-all bg-slate-50 group"> <div className={`border-2 border-dashed rounded-3xl p-12 text-center transition-all ${ isDragging ? 'border-indigo-500 bg-indigo-50' : 'border-slate-200 bg-slate-50 hover:border-indigo-400' }`} onDragOver={handleDragOver} onDragLeave={handleDragLeave} onDrop={handleDrop} > <input type="file" multiple 2 unmodified lines onChange={handleFileChange} /> <label htmlFor="fileInput" className="cursor-pointer block"> <Icon name="upload-cloud" className="w-12 h-12 text-slate-300 mx-auto mb-4 group-hover:text-indigo-500 transition-colors" /> <Icon name="upload-cloud" className={`w-12 h-12 mx-auto mb-4 transition-colors ${isDragging ? 'text-indigo-500' : 'text-slate-300'}`} /> <p className="text-slate-600 font-bold mb-1"> {files.length > 0 ? `${files.length}個のファイルを選択中` : 'ファイルをドラッグ&ドロップ'} {files.length > 0 ? `${files.length}個のファイルを選択中` : isDragging ? 'ここにドロップ' : 'ファイルをドラッグ&ドロップ'} </p> <p className="text-slate-400 text-sm font-medium">またはクリックしてファイルを選択</p> </label>56 unmodified lines )} </div>
{/* Footer / Copyright */} {/* Footer */} <footer className="py-8 text-center border-t border-slate-100"> <div className="flex items-center justify-center gap-2 text-slate-400 text-sm font-medium"> <span>© {new Date().getFullYear()}</span>index.html+70-42