diff --git a/web/src/views/SiteReview.vue b/web/src/views/SiteReview.vue index 09478cc..ee0b097 100644 --- a/web/src/views/SiteReview.vue +++ b/web/src/views/SiteReview.vue @@ -33,11 +33,15 @@ - - + + - - + + + + + + @@ -74,7 +78,7 @@ import api from '../api' const submissions = ref([]) const approveVisible = ref(false), saving = ref(false) -const approveForm = reactive({ id: null, siteId: '', name: '', baseUrl: '', siteType: '', status: 'active', notes: '' }) +const approveForm = reactive({ id: null, siteId: '', namesText: '', urlsText: '', siteType: '', status: 'active', notes: '' }) const siteTypes = [ { value: 'nexusphp', label: 'NexusPHP' }, { value: 'mtorrent', label: 'MTorrent' }, { value: 'mteam', label: 'M-Team API' }, { value: 'pttime', label: 'PTTime' }, @@ -92,8 +96,8 @@ const fetch = async () => { const handleApprove = (row) => { approveForm.id = row.id approveForm.siteId = row.siteId - approveForm.name = (row.names || []).join('\n') - approveForm.baseUrl = (row.urls || []).join('\n') + approveForm.namesText = (row.names || []).join('\n') + approveForm.urlsText = (row.urls || []).join('\n') approveForm.siteType = row.siteType || 'unknown' approveForm.status = row.siteStatus === '关停' ? 'deprecated' : 'active' approveForm.notes = row.notes || '' @@ -101,12 +105,13 @@ const handleApprove = (row) => { } const confirmApprove = async () => { - if (!approveForm.name.trim() || !approveForm.baseUrl.trim()) { ElMessage.warning('名称和地址不能为空'); return } + const name = approveForm.namesText.split('\n').map(s => s.trim()).filter(Boolean)[0] || '' + const baseUrl = approveForm.urlsText.split('\n').map(s => s.trim()).filter(Boolean)[0] || '' + if (!name || !baseUrl) { ElMessage.warning('名称和地址不能为空'); return } saving.value = true try { await api.sites.approveChange(approveForm.id, { - name: approveForm.name.trim().split('\n').filter(Boolean)[0] || '', - baseUrl: approveForm.baseUrl.trim().split('\n').filter(Boolean)[0] || '', + name, baseUrl, siteType: approveForm.siteType || 'unknown', status: approveForm.status, notes: approveForm.notes || null, diff --git a/web/src/views/Sites.vue b/web/src/views/Sites.vue index ab1ae74..42542dc 100644 --- a/web/src/views/Sites.vue +++ b/web/src/views/Sites.vue @@ -33,24 +33,16 @@ - + -
- - 删 -
- + 添加名称 +
-
- - 删 -
- + 添加地址 +
@@ -130,7 +122,7 @@ import api from '../api' const sites = ref([]) const loading = ref(false) const editVisible = ref(false), saving = ref(false) -const editForm = reactive({ id: null, siteId: '', names: [''], urls: [''], siteType: '', status: '', description: '' }) +const editForm = reactive({ id: null, siteId: '', namesText: '', urlsText: '', siteType: '', status: '', description: '' }) const siteTypes = [ { value: 'nexusphp', label: 'NexusPHP' }, { value: 'mtorrent', label: 'MTorrent' }, { value: 'mteam', label: 'M-Team API' }, { value: 'pttime', label: 'PTTime' }, @@ -156,8 +148,8 @@ const fetchAll = async () => { const handleEdit = (row) => { editForm.id = row.id editForm.siteId = row.siteId - editForm.names = (row.names && row.names.length) ? [...row.names] : [''] - editForm.urls = (row.urls && row.urls.length) ? [...row.urls] : [''] + editForm.namesText = (row.names || []).join('\n') + editForm.urlsText = (row.urls || []).join('\n') editForm.siteType = row.siteType || '' editForm.status = row.status || 'active' editForm.description = row.description || '' @@ -165,8 +157,8 @@ const handleEdit = (row) => { } const handleSave = async () => { - const names = editForm.names.filter(n => n.trim()) - const urls = editForm.urls.filter(u => u.trim()) + const names = editForm.namesText.split('\n').map(s => s.trim()).filter(Boolean) + const urls = editForm.urlsText.split('\n').map(s => s.trim()).filter(Boolean) if (names.length === 0 || urls.length === 0) { ElMessage.warning('名称和地址不能为空'); return } saving.value = true try {