refactor: 统一所有页面按钮文案,合并上传逻辑到保存
1. Sites.vue: '保存' → '保存预览版' 2. SitePages.vue: '保存' → '保存预览版',移除上传按钮和uploadPages函数 3. AccessResultCheck.vue: 两处'保存' → '保存预览版' 4. SitePagesController: savePages/saveDefaultPages 直接包含CDN上传,移除 /upload 端点
This commit is contained in:
@@ -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<String, Object> 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<Map<String, Object>>) 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<Void> uploadDefaultPages(
|
||||
@PathVariable String type, @RequestBody Map<String, Object> payload, HttpServletRequest request) {
|
||||
checkAdmin(request);
|
||||
@SuppressWarnings("unchecked")
|
||||
var entries = (List<Map<String, Object>>) 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<Void> uploadSitePages(
|
||||
@PathVariable String siteId, @RequestBody Map<String, Object> payload, HttpServletRequest request) {
|
||||
checkAdmin(request);
|
||||
@SuppressWarnings("unchecked")
|
||||
var entries = (List<Map<String, Object>>) 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<String, Object> 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");
|
||||
|
||||
Reference in New Issue
Block a user