diff --git a/SproutWorkCollect-Frontend/src/components/WorkEditor.js b/SproutWorkCollect-Frontend/src/components/WorkEditor.js index ae780cb..49d884b 100644 --- a/SproutWorkCollect-Frontend/src/components/WorkEditor.js +++ b/SproutWorkCollect-Frontend/src/components/WorkEditor.js @@ -84,6 +84,29 @@ const Button = styled.button` } `; +const SmallButton = styled.button` + background: ${props => { + if (props.variant === 'danger') return '#f44336'; + if (props.variant === 'secondary') return '#757575'; + return '#81c784'; + }}; + color: white; + border: none; + padding: 6px 12px; + border-radius: 6px; + cursor: pointer; + font-size: 12px; + transition: background 0.3s ease; + + &:hover { + background: ${props => { + if (props.variant === 'danger') return '#d32f2f'; + if (props.variant === 'secondary') return '#616161'; + return '#66bb6a'; + }}; + } +`; + const FormSection = styled.div` background: white; border-radius: 15px; @@ -445,6 +468,7 @@ const WorkEditor = ({ work, onClose }) => { const [uploadItems, setUploadItems] = useState({}); const [uploading, setUploading] = useState(false); const [showUploadModal, setShowUploadModal] = useState(false); + const [newExternalLinks, setNewExternalLinks] = useState({}); const platforms = ['Windows', 'Android', 'Linux', 'iOS', 'macOS']; const categories = ['游戏', '工具', '应用', '网站', '其他']; @@ -495,9 +519,53 @@ const WorkEditor = ({ work, onClose }) => { const newFileNames = { ...formData.文件名称 }; delete newFileNames[platform]; handleInputChange('文件名称', newFileNames); + + // 移除该平台的外部下载 + const newExternal = { ...(formData.外部下载 || {}) }; + delete newExternal[platform]; + handleInputChange('外部下载', newExternal); } }; + const updateNewExternal = (platform, field, value) => { + setNewExternalLinks(prev => ({ + ...prev, + [platform]: { + ...(prev[platform] || { 别名: '', 链接: '' }), + [field]: value, + } + })); + }; + + const handleAddExternalLink = (platform) => { + const draft = newExternalLinks[platform] || {}; + const alias = (draft.别名 || '').trim(); + const url = (draft.链接 || '').trim(); + if (!url) { + setError('外部下载链接不能为空'); + return; + } + + const list = Array.isArray(formData.外部下载?.[platform]) ? formData.外部下载[platform] : []; + const next = { ...(formData.外部下载 || {}) }; + next[platform] = [...list, { 别名: alias || '外部下载', 链接: url }]; + handleInputChange('外部下载', next); + + setNewExternalLinks(prev => ({ + ...prev, + [platform]: { 别名: '', 链接: '' } + })); + setSuccess(`已添加 ${platform} 外部下载链接`); + }; + + const handleDeleteExternalLink = (platform, index) => { + const list = Array.isArray(formData.外部下载?.[platform]) ? formData.外部下载[platform] : []; + const next = { ...(formData.外部下载 || {}) }; + next[platform] = list.filter((_, i) => i !== index); + handleInputChange('外部下载', next); + setSuccess(`已删除 ${platform} 外部下载链接`); + }; + const handleFileUpload = async (files, fileType, platform = null) => { if (!formData.作品ID) { setError('请先保存作品基本信息后再上传文件'); @@ -1030,6 +1098,59 @@ const WorkEditor = ({ work, onClose }) => { ))} )} + + {/* 外部下载链接(带别名) */} + +

+ 其他地址下载(外部链接) +

+

+ 可为 {platform} 配置多个外部下载地址(网盘/商店/直链等),并设置显示别名。 +

+ + + updateNewExternal(platform, '别名', e.target.value)} + placeholder="别名(例如:夸克网盘 / GitHub Releases)" + /> + updateNewExternal(platform, '链接', e.target.value)} + placeholder="外部下载链接(https://...)" + /> + + + + {Array.isArray(formData.外部下载?.[platform]) && formData.外部下载[platform].length > 0 && ( + + {formData.外部下载[platform].map((item, idx) => ( + + + {item.别名 || '外部下载'} + + {item.链接} + + + handleDeleteExternalLink(platform, idx)} + > + 删除 + + + ))} + + )} +
))}