上传下载种子
Change-Id: I7fefe993fbfb05279ce03189f2c8aaa901d57998
diff --git a/front/src/PublishPage.js b/front/src/PublishPage.js
new file mode 100644
index 0000000..f50ca21
--- /dev/null
+++ b/front/src/PublishPage.js
@@ -0,0 +1,94 @@
+import React, { useState } from 'react';
+import './App.css';
+import './PublishPage.css';
+
+const PublishPage = () => {
+ const [formData, setFormData] = useState({
+ type: '',
+ torrentFile: '',
+ title: '',
+ subtitle: ''
+ });
+
+ const handleChange = (e) => {
+ const { name, value } = e.target;
+ setFormData({ ...formData, [name]: value });
+ };
+
+ const handleFileChange = (e) => {
+ const file = e.target.files[0];
+ if (file && file.name.split('.').pop() !== 'torrent') {
+ alert('仅能上传.torrent类型文件');
+ e.target.value = null; // Clear the input
+ } else {
+ setFormData({ ...formData, torrentFile: file });
+ }
+ };
+
+ const handleSubmit = (e) => {
+ e.preventDefault();
+ console.log('Form Data Submitted:', formData);
+ };
+
+ return (
+ <div className="publish-page">
+ <h1 className="page-title">发布种子</h1>
+ <form onSubmit={handleSubmit} className="publish-form">
+ <div className="form-row">
+ <label htmlFor="type">类型</label>
+ <select name="type" id="type" value={formData.type} onChange={handleChange} required>
+ <option value="">请选择类型</option>
+ <option value="电影">电影</option>
+ <option value="剧集">剧集</option>
+ <option value="音乐">音乐</option>
+ <option value="动漫">动漫</option>
+ <option value="游戏">游戏</option>
+ <option value="体育">体育</option>
+ <option value="资料">资料</option>
+ </select>
+ </div>
+
+ <div className="form-row">
+ <label htmlFor="torrentFile">种子文件</label>
+ <input
+ type="file"
+ id="torrentFile"
+ name="torrentFile"
+ onChange={handleFileChange}
+ required
+ />
+ <span style={{ fontSize: '12px', color: '#666' }}>需上传.torrent类型文件</span>
+ </div>
+
+ <div className="form-row">
+ <label htmlFor="title">标题</label>
+ <input
+ type="text"
+ id="title"
+ name="title"
+ value={formData.title}
+ onChange={handleChange}
+ required
+ />
+ </div>
+
+ <div className="form-row">
+ <label htmlFor="subtitle">副标题</label>
+ <input
+ type="text"
+ id="subtitle"
+ name="subtitle"
+ value={formData.subtitle}
+ onChange={handleChange}
+ />
+ </div>
+
+ <div className="form-row submit-row">
+ <button type="submit" className="submit-button">提交</button>
+ </div>
+ </form>
+ </div>
+ );
+};
+
+export default PublishPage;
\ No newline at end of file