feat: page config upload button for normal sites, add cloud upload endpoint

- SitePagesController: add PUT /admin/site-pages/{siteId}/upload for uploading normal site pages to cloud storage

- SitePages.vue: show upload button for both default templates and normal sites
This commit is contained in:
mediabot-pt
2026-07-06 15:13:09 +08:00
parent 8724774850
commit 773ad8fdb7
2 changed files with 29 additions and 3 deletions

View File

@@ -290,6 +290,28 @@ public class SitePagesController {
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");
if (level == null || !"ADMIN".equals(level.toString())) {