blob: f50ca21f968e5c13d794e5f7ef15038be69c9b1a [file] [log] [blame]
9563036699e95ae32025-06-02 21:42:11 +08001import React, { useState } from 'react';
2import './App.css';
3import './PublishPage.css';
4
5const PublishPage = () => {
6 const [formData, setFormData] = useState({
7 type: '',
8 torrentFile: '',
9 title: '',
10 subtitle: ''
11 });
12
13 const handleChange = (e) => {
14 const { name, value } = e.target;
15 setFormData({ ...formData, [name]: value });
16 };
17
18 const handleFileChange = (e) => {
19 const file = e.target.files[0];
20 if (file && file.name.split('.').pop() !== 'torrent') {
21 alert('仅能上传.torrent类型文件');
22 e.target.value = null; // Clear the input
23 } else {
24 setFormData({ ...formData, torrentFile: file });
25 }
26 };
27
28 const handleSubmit = (e) => {
29 e.preventDefault();
30 console.log('Form Data Submitted:', formData);
31 };
32
33 return (
34 <div className="publish-page">
35 <h1 className="page-title">发布种子</h1>
36 <form onSubmit={handleSubmit} className="publish-form">
37 <div className="form-row">
38 <label htmlFor="type">类型</label>
39 <select name="type" id="type" value={formData.type} onChange={handleChange} required>
40 <option value="">请选择类型</option>
41 <option value="电影">电影</option>
42 <option value="剧集">剧集</option>
43 <option value="音乐">音乐</option>
44 <option value="动漫">动漫</option>
45 <option value="游戏">游戏</option>
46 <option value="体育">体育</option>
47 <option value="资料">资料</option>
48 </select>
49 </div>
50
51 <div className="form-row">
52 <label htmlFor="torrentFile">种子文件</label>
53 <input
54 type="file"
55 id="torrentFile"
56 name="torrentFile"
57 onChange={handleFileChange}
58 required
59 />
60 <span style={{ fontSize: '12px', color: '#666' }}>需上传.torrent类型文件</span>
61 </div>
62
63 <div className="form-row">
64 <label htmlFor="title">标题</label>
65 <input
66 type="text"
67 id="title"
68 name="title"
69 value={formData.title}
70 onChange={handleChange}
71 required
72 />
73 </div>
74
75 <div className="form-row">
76 <label htmlFor="subtitle">副标题</label>
77 <input
78 type="text"
79 id="subtitle"
80 name="subtitle"
81 value={formData.subtitle}
82 onChange={handleChange}
83 />
84 </div>
85
86 <div className="form-row submit-row">
87 <button type="submit" className="submit-button">提交</button>
88 </div>
89 </form>
90 </div>
91 );
92};
93
94export default PublishPage;