fix: 修复快照两阶段发布方案的缓存一致性和前端问题
1. updateSnapshot() 自动触发生成 draft 后刷新 draft/preview 缓存 2. saveDraft() 同时刷新 previewJsonCache 3. 前端编辑页新增「保存站点」按钮,确保站点基本信息可持久化 4. publishManifest() 兼容 bundle 改用缓存 JSON,避免重复 buildSnapshot
This commit is contained in:
@@ -357,23 +357,18 @@ public class AdminController {
|
||||
// 2. 使用快照服务发布有变更的站点
|
||||
int publishedCount = snapshotService.publishChanged();
|
||||
|
||||
// 3. 兼容:为所有站点生成旧的 bundles/ 路径(从快照读取)
|
||||
// 3. 兼容:为有 published 快照的站点生成旧的 bundles/ 路径
|
||||
int bundleCount = 0;
|
||||
@SuppressWarnings("unchecked")
|
||||
var sites = (List<Map<String, Object>>) manifest.get("sites");
|
||||
for (var site : sites) {
|
||||
String siteId = (String) site.get("siteId");
|
||||
try {
|
||||
var active = snapshotService.getActive(siteId);
|
||||
if (active != null) {
|
||||
// 生成兼容的 bundle JSON 并上传到旧路径
|
||||
Map<String, Object> bundle = snapshotService.buildSnapshot(siteId);
|
||||
if (bundle != null) {
|
||||
String bundleJson = new com.fasterxml.jackson.databind.ObjectMapper()
|
||||
.writeValueAsString(bundle);
|
||||
storageService.store("bundles/" + siteId + ".json", bundleJson);
|
||||
bundleCount++;
|
||||
}
|
||||
// 直接读取已发布的快照(此时 publishChanged 已执行完毕,缓存中有最新数据)
|
||||
String activeJson = snapshotService.getActiveBundleJson(siteId);
|
||||
if (activeJson != null && !activeJson.isEmpty()) {
|
||||
storageService.store("bundles/" + siteId + ".json", activeJson);
|
||||
bundleCount++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("生成兼容 bundle 失败 siteId={}: {}", siteId, e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user