// 本文件是活动页面导航语义的唯一运行时所有者。页面只能使用路由键, // 不得自行复制路径、父页、允许来源、参数或流程结果规则。 const defineRoute = (route) => Object.freeze({ ...route, parentParamMap: Object.freeze(route.parentParamMap || {}), requiredParams: Object.freeze(route.requiredParams || []), optionalParams: Object.freeze(route.optionalParams || []), allowedSources: Object.freeze(route.allowedSources || []), resultOperations: Object.freeze(route.resultOperations || []), }); const defineNoticeTarget = (routeKey, params) => Object.freeze({ routeKey, params: Object.freeze(params) }); export const NOTICE_TARGETS = Object.freeze({ GENEALOGY_REVIEW: defineNoticeTarget("G10", ["genealogyId"]), GENEALOGY_HOME: defineNoticeTarget("G01", ["genealogyId"]), FAMILY_FEED: defineNoticeTarget("F03", ["genealogyId", "feedId"]), MEMO_REMINDER: defineNoticeTarget("R10", ["genealogyId", "memoId"]), CEREMONY_INVITE: defineNoticeTarget("M11", []), }); export const ROUTES = Object.freeze({ A01: defineRoute({ path: "/pages/auth/sign-in", kind: "auth-root", parent: null, resultOperations: ["password-reset"], }), A04: defineRoute({ path: "/pages/auth/register", kind: "page", parent: "A01", allowedSources: ["A01"], }), A05: defineRoute({ path: "/pages/auth/reset-password", kind: "page", parent: "A01", allowedSources: ["A01"], }), G01: defineRoute({ path: "/pages/genealogy/my-genealogies", kind: "root", parent: null, optionalParams: ["genealogyId"], resultOperations: ["genealogy-created"], }), G03: defineRoute({ path: "/pages/genealogy/create", kind: "flow", parent: "G01", allowedSources: ["G01"], }), G05: defineRoute({ path: "/pages/genealogy/overview", kind: "page", parent: "G01", requiredParams: ["genealogyId"], allowedSources: ["G01", "G03", "G06", "G09"], }), G06: defineRoute({ path: "/pages/genealogy/search", kind: "page", parent: "G01", optionalParams: ["mode"], allowedSources: ["G01", "G03", "G09"], }), G08: defineRoute({ path: "/pages/genealogy/join-application", kind: "flow", parent: "G06", requiredParams: ["genealogyId"], optionalParams: ["source"], allowedSources: ["G01", "G05", "G06", "G09"], }), G09: defineRoute({ path: "/pages/genealogy/my-applications", kind: "page", parent: "G01", optionalParams: ["status"], allowedSources: ["G01", "G05", "G06", "G08"], }), G10: defineRoute({ path: "/pages/genealogy/application-review", kind: "page", parent: "G01", requiredParams: ["genealogyId"], allowedSources: ["G01", "G05", "N01", "N02"], }), G11: defineRoute({ path: "/pages/genealogy/settings", kind: "flow", parent: "G05", requiredParams: ["genealogyId"], allowedSources: ["G05"], }), G12: defineRoute({ path: "/pages/genealogy/generation-poems", kind: "flow", parent: "G05", requiredParams: ["genealogyId"], allowedSources: ["G01", "G05"], }), G13: defineRoute({ path: "/pages/genealogy/members", kind: "page", parent: "G05", requiredParams: ["genealogyId"], allowedSources: ["G05"], }), T01: defineRoute({ path: "/pages/tree/overview", kind: "page", parent: "G05", requiredParams: ["genealogyId"], optionalParams: ["selectedId"], allowedSources: ["G01", "G05", "T02", "T04", "T06", "T07"], }), T02: defineRoute({ path: "/pages/tree/pedigree", kind: "page", parent: "G05", requiredParams: ["genealogyId"], optionalParams: ["selectedId"], allowedSources: ["G01", "G05", "T01"], }), T03: defineRoute({ path: "/pages/tree/member-profile", kind: "single", parent: "T01", parentParamMap: { selectedId: "personId" }, requiredParams: ["genealogyId", "personId"], allowedSources: ["T01", "T02", "T07", "R02"], resultOperations: ["member-open-requested", "member-updated"], }), T04: defineRoute({ path: "/pages/tree/add-relative", kind: "flow", parent: "T01", parentParamMap: { selectedId: "personId" }, requiredParams: ["genealogyId"], optionalParams: ["personId", "mode", "relationType"], allowedSources: ["T01", "T02"], }), T05: defineRoute({ path: "/pages/tree/edit-member", kind: "flow", parent: "T03", requiredParams: ["genealogyId", "personId"], allowedSources: ["T01", "T02", "T03"], }), T06: defineRoute({ path: "/pages/tree/member-rank", kind: "flow", parent: "T01", parentParamMap: { selectedId: "personId" }, requiredParams: ["genealogyId", "personId"], optionalParams: ["mode"], allowedSources: ["T01", "T02"], }), T07: defineRoute({ path: "/pages/tree/member-directory", kind: "page", parent: "T01", requiredParams: ["genealogyId"], allowedSources: ["T01", "T02"], }), T08: defineRoute({ path: "/pages/tree/member-states", kind: "page", parent: "T03", requiredParams: ["genealogyId", "personId"], allowedSources: ["T03"], }), F01: defineRoute({ path: "/pages/family/feed", kind: "root", parent: null, optionalParams: ["genealogyId"], }), F02: defineRoute({ path: "/pages/family/feed-editor", kind: "flow", parent: "F01", requiredParams: ["genealogyId", "mode"], optionalParams: ["feedId"], allowedSources: ["F01", "F03"], }), F03: defineRoute({ path: "/pages/family/feed-detail", kind: "page", parent: "F01", requiredParams: ["genealogyId", "feedId"], allowedSources: ["F01", "F02", "N02"], }), F04: defineRoute({ path: "/pages/family/articles", kind: "page", parent: "F01", requiredParams: ["genealogyId"], allowedSources: ["F01"], }), F05: defineRoute({ path: "/pages/family/article-detail", kind: "page", parent: "F04", requiredParams: ["genealogyId", "articleId"], allowedSources: ["F04"], }), F06: defineRoute({ path: "/pages/family/article-editor", kind: "flow", parent: "F04", requiredParams: ["genealogyId", "mode"], optionalParams: ["articleId"], allowedSources: ["F04", "F05"], }), F07: defineRoute({ path: "/pages/family/albums", kind: "page", parent: "F01", requiredParams: ["genealogyId"], allowedSources: ["F01"], }), F08: defineRoute({ path: "/pages/family/album-detail", kind: "page", parent: "F07", requiredParams: ["genealogyId", "albumId"], allowedSources: ["F07"], }), F09: defineRoute({ path: "/pages/family/add-photo", kind: "flow", parent: "F08", requiredParams: ["genealogyId", "albumId"], allowedSources: ["F08"], }), F10: defineRoute({ path: "/pages/family/videos", kind: "page", parent: "F01", requiredParams: ["genealogyId"], allowedSources: ["F01"], }), R01: defineRoute({ path: "/pages/records/people", kind: "page", parent: "F01", requiredParams: ["genealogyId"], allowedSources: ["F01"], }), R02: defineRoute({ path: "/pages/records/person-detail", kind: "flow", parent: "R01", requiredParams: ["genealogyId", "mode"], optionalParams: ["personId"], allowedSources: ["R01"], }), R03: defineRoute({ path: "/pages/records/relative-records", kind: "page", parent: "F01", requiredParams: ["genealogyId"], allowedSources: ["F01"], }), R04: defineRoute({ path: "/pages/records/relative-record-editor", kind: "flow", parent: "R03", requiredParams: ["genealogyId", "mode"], optionalParams: ["relativeId"], allowedSources: ["R03"], }), R05: defineRoute({ path: "/pages/records/ceremonies", kind: "page", parent: "F01", requiredParams: ["genealogyId"], allowedSources: ["F01"], }), R06: defineRoute({ path: "/pages/records/ceremony-detail", kind: "page", parent: "R05", requiredParams: ["genealogyId", "ceremonyId"], allowedSources: ["R05"], }), R07: defineRoute({ path: "/pages/records/ceremony-editor", kind: "flow", parent: "R05", requiredParams: ["genealogyId", "mode"], optionalParams: ["ceremonyId"], allowedSources: ["R05", "R06"], }), R08: defineRoute({ path: "/pages/records/growth-journal", kind: "page", parent: "R02", requiredParams: ["genealogyId", "personId"], allowedSources: ["R02", "T03"], }), R09: defineRoute({ path: "/pages/records/life-events", kind: "page", parent: "R02", requiredParams: ["genealogyId", "personId"], allowedSources: ["R02", "T03"], }), R10: defineRoute({ path: "/pages/records/memos", kind: "page", parent: "F01", requiredParams: ["genealogyId"], optionalParams: ["memoId"], allowedSources: ["F01", "N02"], }), R11: defineRoute({ path: "/pages/records/merit-records", kind: "page", parent: "F01", requiredParams: ["genealogyId"], allowedSources: ["F01"], }), N01: defineRoute({ path: "/pages/notification/message-center", kind: "page", parent: "G01", optionalParams: ["genealogyId"], allowedSources: ["G01", "M01"], }), N02: defineRoute({ path: "/pages/notification/message-detail", kind: "page", parent: "N01", requiredParams: ["id"], allowedSources: ["N01"], }), M01: defineRoute({ path: "/pages/profile/home", kind: "root", parent: null, }), M02: defineRoute({ path: "/pages/profile/edit-profile", kind: "flow", parent: "M01", allowedSources: ["M01"], }), M03: defineRoute({ path: "/pages/profile/security", kind: "page", parent: "M01", allowedSources: ["M01"], }), M04: defineRoute({ path: "/pages/profile/change-password", kind: "flow", parent: "M03", allowedSources: ["M03"], }), M05: defineRoute({ path: "/pages/profile/change-phone", kind: "flow", parent: "M03", allowedSources: ["M03"], }), M06: defineRoute({ path: "/pages/profile/help", kind: "page", parent: "M01", allowedSources: ["M01"], }), M07: defineRoute({ path: "/pages/profile/feedback", kind: "flow", parent: "M06", allowedSources: ["M01", "M06"], }), M08: defineRoute({ path: "/pages/profile/promotions", kind: "page", parent: "M01", allowedSources: ["M01"], }), M09: defineRoute({ path: "/pages/profile/vip", kind: "page", parent: "M01", allowedSources: ["M01"], }), M10: defineRoute({ path: "/pages/profile/settings", kind: "page", parent: "M01", allowedSources: ["M01"], }), M11: defineRoute({ path: "/pages/profile/ceremony-invitations", kind: "page", parent: "M01", allowedSources: ["M01", "N02"], }), M12: defineRoute({ path: "/pages/profile/earnings", kind: "page", parent: "M01", allowedSources: ["M01"], }), M13: defineRoute({ path: "/pages/profile/compliance-document", kind: "page", parent: "M10", requiredParams: ["documentKey"], allowedSources: ["M10"], }), }); export const ROOT_ROUTE_KEYS = Object.freeze(["A01", "G01", "F01", "M01"]); export const getRoute = (routeKey) => typeof routeKey === "string" && Object.prototype.hasOwnProperty.call(ROUTES, routeKey) ? ROUTES[routeKey] : null; export const getRouteKeyByPath = (path) => { if (typeof path !== "string") return null; const normalizedPath = `/${path.replace(/^\/+/, "")}`; return ( Object.keys(ROUTES).find( (routeKey) => ROUTES[routeKey].path === normalizedPath, ) || null ); };