From 5ad6b043e477d3b45896e56dc5cffda568b572c2 Mon Sep 17 00:00:00 2001
From: mediabot-pt <295750538+mediabot-pt@users.noreply.github.com>
Date: Sun, 5 Jul 2026 00:22:28 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A1=B5=E9=9D=A2=E9=85=8D=E7=BD=AE+?=
=?UTF-8?q?=E9=A3=8E=E9=99=A9=E8=A7=84=E5=88=99=E7=BC=96=E8=BE=91=E5=99=A8?=
=?UTF-8?q?=E6=94=AF=E6=8C=81=E8=A1=A8=E6=A0=BC/JSON=E5=8F=8C=E6=A8=A1?=
=?UTF-8?q?=E5=BC=8F=E5=88=87=E6=8D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/src/views/RiskRules.vue | 79 +++++++++++++++++++++++--------------
web/src/views/SitePages.vue | 64 ++++++++++++++++++++----------
2 files changed, 93 insertions(+), 50 deletions(-)
diff --git a/web/src/views/RiskRules.vue b/web/src/views/RiskRules.vue
index e48026c..e9cd1b3 100644
--- a/web/src/views/RiskRules.vue
+++ b/web/src/views/RiskRules.vue
@@ -26,34 +26,47 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 删除
-
-
+
+
+ 表格编辑
+ JSON 编辑
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 删除
+
+
+ + 添加规则
+
+
+
+
+
+
- + 添加规则
保存
@@ -66,9 +79,16 @@ import api from '../api'
const loading = ref(false), saving = ref(false)
const rulesData = ref([])
const siteTypes = ['nexusphp','mtorrent','gazelle','unit3d']
-const editorVisible = ref(false), editorType = ref('')
+const editorVisible = ref(false), editorType = ref(''), editorMode = ref('table'), editorJson = ref('')
const editingRules = ref([])
+watch(editorMode, (m) => {
+ if (m === 'json') editorJson.value = JSON.stringify(editingRules.value, null, 2)
+ else {
+ try { editingRules.value = JSON.parse(editorJson.value) } catch { /* keep table */ }
+ }
+})
+
const fmt = (t) => t ? (t.substring(0,19)||'').replace('T',' ') : '-'
const merged = computed(() => {
@@ -104,7 +124,8 @@ const showEditor = (row) => {
const saveRules = async () => {
saving.value = true
try {
- await api.raw.post('/risk-rules/' + editorType.value, { rules: editingRules.value })
+ const rules = editorMode.value === 'json' ? JSON.parse(editorJson.value) : editingRules.value
+ await api.raw.post('/risk-rules/' + editorType.value, { rules })
ElMessage.success('已保存')
editorVisible.value = false
fetchAll()
diff --git a/web/src/views/SitePages.vue b/web/src/views/SitePages.vue
index 6130fc4..f1ce44f 100644
--- a/web/src/views/SitePages.vue
+++ b/web/src/views/SitePages.vue
@@ -28,26 +28,39 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 删除
-
-
+
+
+
+ 表格编辑
+ JSON 编辑
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 删除
+
+
+ + 添加入口
+
+
+
+
+
+
- + 添加入口
保存
@@ -59,7 +72,15 @@ import api from '../api'
const loading = ref(false), saving = ref(false)
const sites = ref([]), pagesMap = ref({})
-const editorVisible = ref(false), editorSiteId = ref(''), editingEntries = ref([])
+const editorVisible = ref(false), editorSiteId = ref(''), editorMode = ref('table'), editorJson = ref('')
+const editingEntries = ref([])
+
+watch(editorMode, (m) => {
+ if (m === 'json') editorJson.value = JSON.stringify(editingEntries.value, null, 2)
+ else {
+ try { editingEntries.value = JSON.parse(editorJson.value) } catch { /* keep table data */ }
+ }
+})
const fmt = (t) => t ? (t.substring(0,19)||'').replace('T',' ') : '-'
@@ -104,7 +125,8 @@ const showEditor = (row) => {
const savePages = async () => {
saving.value = true
try {
- await api.raw.put('/sites/' + editorSiteId.value + '/pages', { entries: editingEntries.value })
+ const entries = editorMode.value === 'json' ? JSON.parse(editorJson.value) : editingEntries.value
+ await api.raw.put('/sites/' + editorSiteId.value + '/pages', { entries })
ElMessage.success('已保存')
editorVisible.value = false
fetchAll()