diff --git a/web/src/views/AccessResults.vue b/web/src/views/AccessResults.vue index c551017..6b3f8cb 100644 --- a/web/src/views/AccessResults.vue +++ b/web/src/views/AccessResults.vue @@ -2,8 +2,12 @@

适配验证

-
+
刷新 + 导出脚本 + + 导入脚本 +
@@ -66,9 +70,31 @@ import api from '../api' import { Refresh } from '@element-plus/icons-vue' -const loading = ref(false) +const loading = ref(false), exporting = ref(false), importing = ref(false) const sites = ref([]) +const exportScripts = async () => { + exporting.value = true + try { + const r = await api.get('/admin/scripts/export', { responseType: 'blob' }) + const a = document.createElement('a') + a.href = URL.createObjectURL(new Blob([r.data])) + a.download = 'scripts.zip'; a.click(); URL.revokeObjectURL(a.href) + } catch { ElMessage.error('导出失败') } + finally { exporting.value = false } +} + +const importScripts = async (file) => { + importing.value = true + try { + const fd = new FormData(); fd.append('file', file.raw) + const r = await api.post('/admin/scripts/import', fd) + ElMessage.success('导入完成: ' + ((r.data?.ok || 0) + ' 成功, ' + (r.data?.fail || 0) + ' 失败')) + fetchAll() + } catch { ElMessage.error('导入失败') } + finally { importing.value = false } +} + const friendlyTime = (t) => { if (!t) return null const d = new Date(t), now = new Date()