From 45f16f2b541aeac91269a96c4088e5beee3259ac Mon Sep 17 00:00:00 2001 From: mediabot-pt <295750538+mediabot-pt@users.noreply.github.com> Date: Tue, 7 Jul 2026 18:02:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=BB=9F=E4=B8=80=E6=89=80?= =?UTF-8?q?=E6=9C=89=E9=A1=B5=E9=9D=A2=E6=8C=89=E9=92=AE=E6=96=87=E6=A1=88?= =?UTF-8?q?=EF=BC=8C=E5=90=88=E5=B9=B6=E4=B8=8A=E4=BC=A0=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=88=B0=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Sites.vue: '保存' → '保存预览版' 2. SitePages.vue: '保存' → '保存预览版',移除上传按钮和uploadPages函数 3. AccessResultCheck.vue: 两处'保存' → '保存预览版' 4. SitePagesController: savePages/saveDefaultPages 直接包含CDN上传,移除 /upload 端点 --- .../api/controller/SitePagesController.java | 51 +++++-------------- web/src/views/AccessResultCheck.vue | 4 +- web/src/views/SitePages.vue | 21 ++------ web/src/views/Sites.vue | 2 +- 4 files changed, 20 insertions(+), 58 deletions(-) diff --git a/par-api/src/main/java/com/par/api/controller/SitePagesController.java b/par-api/src/main/java/com/par/api/controller/SitePagesController.java index 76d991e..ddf2650 100644 --- a/par-api/src/main/java/com/par/api/controller/SitePagesController.java +++ b/par-api/src/main/java/com/par/api/controller/SitePagesController.java @@ -73,6 +73,15 @@ public class SitePagesController { String authType = (String) payload.get("authType"); String authValue = (String) payload.get("authValue"); sitePagesService.savePages(siteId, entries, authType, authValue); + try { + Map config = new LinkedHashMap<>(); + config.put("siteId", siteId); + if (authType != null) config.put("authType", authType); + if (authValue != null) config.put("authValue", authValue); + config.put("entries", entries); + storageService.store("pages/site/" + siteId + ".json", + new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(config)); + } catch (Exception ignored) {} return ApiResponse.success(); } @@ -270,47 +279,13 @@ public class SitePagesController { var entries = (List>) payload.get("entries"); String authType = (String) payload.get("authType"); String authValue = (String) payload.get("authValue"); - sitePagesService.savePages("default:" + type, entries != null ? entries : List.of(), authType, authValue); + if (entries == null) entries = List.of(); + sitePagesService.savePages("default:" + type, entries, authType, authValue); + try { storageService.store("pages/default/" + type + ".json", + new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(entries)); } catch (Exception ignored) {} return ApiResponse.success(); } - /** 发布默认页面模板到云存储 */ - @PutMapping("/api/v1/admin/default-pages/{type}/upload") - public ApiResponse uploadDefaultPages( - @PathVariable String type, @RequestBody Map payload, HttpServletRequest request) { - checkAdmin(request); - @SuppressWarnings("unchecked") - var entries = (List>) payload.get("entries"); - sitePagesService.savePages("default:" + type, entries != null ? entries : List.of()); - try { - String json = entries != null - ? new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(entries) : "[]"; - storageService.store("pages/default/" + type + ".json", json); - } catch (Exception ignored) {} - return ApiResponse.success(); - } - - /** 发布普通站点页面配置到云存储 */ - @PutMapping("/api/v1/admin/site-pages/{siteId}/upload") - public ApiResponse uploadSitePages( - @PathVariable String siteId, @RequestBody Map payload, HttpServletRequest request) { - checkAdmin(request); - @SuppressWarnings("unchecked") - var entries = (List>) payload.get("entries"); - String authType = (String) payload.get("authType"); - String authValue = (String) payload.get("authValue"); - sitePagesService.savePages(siteId, entries != null ? entries : List.of(), authType, authValue); - try { - Map config = new LinkedHashMap<>(); - config.put("siteId", siteId); - if (authType != null) config.put("authType", authType); - if (authValue != null) config.put("authValue", authValue); - config.put("entries", entries != null ? entries : List.of()); - String json = objectMapper.writeValueAsString(config); - storageService.store("pages/site/" + siteId + ".json", json); - } catch (Exception ignored) {} - return ApiResponse.success(); - } private void checkAdmin(HttpServletRequest request) { var level = request.getAttribute("trustLevel"); diff --git a/web/src/views/AccessResultCheck.vue b/web/src/views/AccessResultCheck.vue index cf28b36..c4c1ae2 100644 --- a/web/src/views/AccessResultCheck.vue +++ b/web/src/views/AccessResultCheck.vue @@ -49,7 +49,7 @@ 回滚 重置 - 保存 + 保存预览版 删除 - 保存 + 保存预览版