fix-page-config-reload-empty
This commit is contained in:
@@ -29,12 +29,15 @@ public class SitePagesServiceImpl implements SitePagesService {
|
||||
.orderByDesc(SitePages::getId).last("limit 1"));
|
||||
if (sp == null) return null;
|
||||
try {
|
||||
List<Map<String, Object>> entries = om.readValue(sp.getEntriesJson(),
|
||||
new TypeReference<List<Map<String, Object>>>() {});
|
||||
// entriesJson 存储的是完整 JSON: { entries: [...], authType: "...", authValue: "..." }
|
||||
Map<String, Object> parsed = om.readValue(sp.getEntriesJson(),
|
||||
new TypeReference<Map<String, Object>>() {});
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("siteId", siteId);
|
||||
result.put("version", sp.getVersion());
|
||||
result.put("entries", entries);
|
||||
result.put("entries", parsed.getOrDefault("entries", List.of()));
|
||||
if (parsed.containsKey("authType")) result.put("authType", parsed.get("authType"));
|
||||
if (parsed.containsKey("authValue")) result.put("authValue", parsed.get("authValue"));
|
||||
result.put("updatedAt", sp.getUpdatedAt());
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
@@ -126,6 +129,7 @@ public class SitePagesServiceImpl implements SitePagesService {
|
||||
m.put("siteId", sp.getSiteId());
|
||||
m.put("version", sp.getVersion());
|
||||
m.put("updatedAt", sp.getUpdatedAt());
|
||||
m.put("entriesJson", sp.getEntriesJson());
|
||||
result.add(m);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -151,7 +151,8 @@ const fetchAll = async () => {
|
||||
const pages = pr.status==='fulfilled' ? (pr.value?.data||pr.value||[]) : []
|
||||
const map = {}
|
||||
for (const p of pages) {
|
||||
const entries = (() => { try { return JSON.parse(p.entriesJson||'[]') } catch {return []} })()
|
||||
const parsed = (() => { try { return JSON.parse(p.entriesJson||'{}') } catch {return {}} })()
|
||||
const entries = Array.isArray(parsed) ? parsed : (parsed.entries || [])
|
||||
if (!map[p.siteId] || p.version > map[p.siteId].version)
|
||||
map[p.siteId] = { version: p.version, entryCount: entries.length, updatedAt: p.updatedAt, entriesJson: p.entriesJson }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user