"use strict";
|
Object.defineProperty(exports, "__esModule", { value: true });
|
exports.findPageByIds = findPageByIds;
|
exports.flattenForClient = flattenForClient;
|
exports.buildPageImageMap = buildPageImageMap;
|
function findPageByIds(cfg, scenarioId, pageId) {
|
for (const cat of cfg.categories) {
|
for (const sc of cat.scenarios) {
|
if (sc.id !== scenarioId)
|
continue;
|
const page = sc.pages.find((p) => p.id === pageId);
|
if (!page)
|
return null;
|
return {
|
categoryId: cat.id,
|
categoryName: cat.name,
|
scenarioId: sc.id,
|
scenarioName: sc.name,
|
page,
|
};
|
}
|
}
|
return null;
|
}
|
function flattenForClient(cfg) {
|
return cfg.categories;
|
}
|
/** 供前端「最近使用」根据 scenarioId+pageId 补全图片(旧 localStorage 可能无 image 字段) */
|
function buildPageImageMap(cfg) {
|
const map = {};
|
for (const cat of cfg.categories) {
|
for (const sc of cat.scenarios) {
|
for (const p of sc.pages) {
|
map[`${sc.id}|${p.id}`] = p.image;
|
}
|
}
|
}
|
return map;
|
}
|
//# sourceMappingURL=scenarioLookup.js.map
|