wangzhibo
2026-05-09 53418655c061ac26f66058253f39200aced1ab1d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"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