Files
shanghai-residences/src/config/puzzleMapping.ts
T
2026-01-11 18:18:20 +08:00

53 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 拼图碎片与页面路由映射配置
* 格式:故居名 -> 碎片ID -> 路由路径(相对于/:moduleName/)
*
* 示例:
* - 碎片1 对应 place1 页面
* - 碎片2 对应 place2 页面
* - 碎片3 对应 reflection 页面
* - 碎片4 对应 internalization 页面
*
* 注意:路由路径中的 :moduleName 会在使用时替换为实际的 moduleName
*/
export const puzzleMapping: Record<string, Record<number, string>> = {
chenyun: {
// 示例:碎片1 对应 place1 页面
1: "chenyun/place1",
// 后续可以继续添加其他碎片的映射
// 2: "chenyun/place2",
// 3: "chenyun/reflection",
// 4: "chenyun/internalization",
},
// 后续可以添加其他故居的映射
// sunzhongshan: {
// 1: "sunzhongshan/place1",
// },
};
/**
* 获取碎片对应的路由路径
* @param residence 故居名称
* @param pieceId 碎片ID
* @param moduleName 模块名称(用于替换路由中的 :moduleName)
* @returns 完整的路由路径,如果不存在则返回 null
*/
export const getPuzzleRoute = (
residence: string,
pieceId: number,
moduleName: string
): string | null => {
const residenceMapping = puzzleMapping[residence];
if (!residenceMapping) {
return null;
}
const route = residenceMapping[pieceId];
if (!route) {
return null;
}
return `/${moduleName}/${route}`;
};