feat:碎片完善
This commit is contained in:
1 parent
ec7e8e2bd2
commit
046501705f
74 files changed
+1602
-172
No files matched your search
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 拼图碎片与页面路由映射配置
|
||||
* 格式:故居名 -> 碎片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}`;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user