@hkyhy/marsun-components-core 0.1.101 → 0.1.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Editor/VariablePicker.js +13 -13
- package/dist/components/Editor/VariablePicker.js.map +1 -1
- package/dist/components/Filter/createKneFilterField.js +42 -39
- package/dist/components/Filter/createKneFilterField.js.map +1 -1
- package/dist/components/Form/SuperSelect.js +48 -45
- package/dist/components/Form/SuperSelect.js.map +1 -1
- package/dist/components/FormInfo/RichTextField/index.js +46 -69
- package/dist/components/FormInfo/RichTextField/index.js.map +1 -1
- package/dist/components/FormInfo/VariableMentionInput/index.d.ts +1 -0
- package/dist/components/FormInfo/VariableMentionInput/index.js +53 -47
- package/dist/components/FormInfo/VariableMentionInput/index.js.map +1 -1
- package/dist/components/FormInfo/VariableMentionInput/style.module.scss.js +6 -5
- package/dist/components/FormInfo/VariableMentionInput/style.module.scss.js.map +1 -1
- package/dist/components/ReactFilter/fields/index.js +33 -26
- package/dist/components/ReactFilter/fields/index.js.map +1 -1
- package/dist/components/ReactFilter/renderSelectListItemContent.d.ts +8 -0
- package/dist/components/ReactFilter/renderSelectListItemContent.js +12 -0
- package/dist/components/ReactFilter/renderSelectListItemContent.js.map +1 -0
- package/dist/components/Tools/Inbox/InboxBell/InboxBell.d.ts +3 -0
- package/dist/components/Tools/Inbox/InboxBell/InboxBell.js +59 -49
- package/dist/components/Tools/Inbox/InboxBell/InboxBell.js.map +1 -1
- package/dist/components/Tools/Inbox/InboxBell/style.module.scss.js +20 -18
- package/dist/components/Tools/Inbox/InboxBell/style.module.scss.js.map +1 -1
- package/dist/components/Tools/Inbox/index.d.ts +1 -0
- package/dist/components/Tools/Inbox/sanitizeInboxHtml.d.ts +5 -0
- package/dist/components/Tools/Inbox/sanitizeInboxHtml.js +14 -0
- package/dist/components/Tools/Inbox/sanitizeInboxHtml.js.map +1 -0
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/MessageTemplateAdmin.d.ts +1 -1
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/MessageTemplateAdmin.js +158 -137
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/MessageTemplateAdmin.js.map +1 -1
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/Modal/TemplateFormModal.js +217 -124
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/Modal/TemplateFormModal.js.map +1 -1
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/PushRulesPanel/index.d.ts +8 -1
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/PushRulesPanel/index.js +312 -170
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/PushRulesPanel/index.js.map +1 -1
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/VariablesPanel/index.js +87 -76
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/VariablesPanel/index.js.map +1 -1
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/audienceSlots.d.ts +14 -0
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/audienceSlots.js +31 -0
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/audienceSlots.js.map +1 -0
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/index.d.ts +3 -1
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/style.module.scss.js +18 -6
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/style.module.scss.js.map +1 -1
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/types.d.ts +27 -0
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/types.js.map +1 -1
- package/dist/components/Tools/MessageCenter/MsgCenterAppSwitcher/MsgCenterAppSwitcher.d.ts +22 -0
- package/dist/components/Tools/MessageCenter/MsgCenterAppSwitcher/MsgCenterAppSwitcher.js +64 -0
- package/dist/components/Tools/MessageCenter/MsgCenterAppSwitcher/MsgCenterAppSwitcher.js.map +1 -0
- package/dist/components/Tools/MessageCenter/MsgCenterAppSwitcher/index.d.ts +2 -0
- package/dist/components/Tools/MessageCenter/index.d.ts +8 -1
- package/dist/components/Tools/MessageCenter/msgCenterAppSwitch.d.ts +39 -0
- package/dist/components/Tools/MessageCenter/msgCenterAppSwitch.js +94 -0
- package/dist/components/Tools/MessageCenter/msgCenterAppSwitch.js.map +1 -0
- package/dist/components/Tools/MessageCenter/useMsgCenterAppKey.d.ts +2 -0
- package/dist/components/Tools/MessageCenter/useMsgCenterAppKey.js +18 -0
- package/dist/components/Tools/MessageCenter/useMsgCenterAppKey.js.map +1 -0
- package/dist/components/Tools/MessageCenter/utils/audienceUserSelectOptions.d.ts +16 -0
- package/dist/components/Tools/MessageCenter/utils/audienceUserSelectOptions.js +33 -0
- package/dist/components/Tools/MessageCenter/utils/audienceUserSelectOptions.js.map +1 -0
- package/dist/components/Tools/MessageCenter/utils/templateCode.js +11 -17
- package/dist/components/Tools/MessageCenter/utils/templateCode.js.map +1 -1
- package/dist/components/Tools/index.d.ts +3 -2
- package/dist/index.js +641 -626
- package/dist/index.js.map +1 -1
- package/dist/marsun-components-core.css +1 -1
- package/dist/node_modules/dompurify/dist/purify.es.js +908 -0
- package/dist/node_modules/dompurify/dist/purify.es.js.map +1 -0
- package/dist/node_modules/isomorphic-dompurify/dist/browser.js +17 -0
- package/dist/node_modules/isomorphic-dompurify/dist/browser.js.map +1 -0
- package/dist/styles/global.css +1 -1
- package/package.json +9 -1
|
@@ -28,6 +28,8 @@ export type MessageTemplateAdminItem = {
|
|
|
28
28
|
bodyTemplate?: string;
|
|
29
29
|
audienceRoles?: string[];
|
|
30
30
|
roles?: string[];
|
|
31
|
+
/** 受众槽位码(与 mc audienceSlots 对齐) */
|
|
32
|
+
audienceSlots?: string[];
|
|
31
33
|
enabled?: boolean;
|
|
32
34
|
channel?: string;
|
|
33
35
|
};
|
|
@@ -45,6 +47,11 @@ export type MessageEventCatalogPayload = {
|
|
|
45
47
|
label?: string;
|
|
46
48
|
}>;
|
|
47
49
|
variables?: MessageTemplateVariable[];
|
|
50
|
+
/** 受众槽位 options(与 core AUDIENCE_SLOT_OPTIONS 对齐;有则优先) */
|
|
51
|
+
audienceSlotOptions?: {
|
|
52
|
+
value: string;
|
|
53
|
+
label: string;
|
|
54
|
+
}[];
|
|
48
55
|
};
|
|
49
56
|
export type MessageAudienceRoleOption = {
|
|
50
57
|
/** 写入模板的角色码 */
|
|
@@ -52,6 +59,18 @@ export type MessageAudienceRoleOption = {
|
|
|
52
59
|
/** 展示名(来自 SSO / fixture) */
|
|
53
60
|
name: string;
|
|
54
61
|
};
|
|
62
|
+
/** 推送规则例外抄送选项(SSO 本租户用户;展示名取自接口) */
|
|
63
|
+
export type MessageAudienceUserOption = {
|
|
64
|
+
id: string;
|
|
65
|
+
/** displayName 优先 */
|
|
66
|
+
name: string;
|
|
67
|
+
/** 工号(SSO employeeId) */
|
|
68
|
+
employeeId?: string;
|
|
69
|
+
/** 主部门 / 首个组织名(SSO orgs) */
|
|
70
|
+
departmentName?: string;
|
|
71
|
+
/** 角色展示名,顿号拼接(SSO roles.name) */
|
|
72
|
+
roleNames?: string;
|
|
73
|
+
};
|
|
55
74
|
export type MessageTemplateVariable = {
|
|
56
75
|
key: string;
|
|
57
76
|
/** 可选中文说明;无则下拉只显示 code */
|
|
@@ -71,6 +90,7 @@ export type PushRuleAdminItem = {
|
|
|
71
90
|
templateCode?: string;
|
|
72
91
|
audienceRoles?: string[];
|
|
73
92
|
audienceUserIds?: string[];
|
|
93
|
+
audienceSlots?: string[];
|
|
74
94
|
channels?: string[];
|
|
75
95
|
slaHours?: number;
|
|
76
96
|
scanLookbackDays?: number;
|
|
@@ -90,6 +110,12 @@ export type MessageTemplateAdminProps = {
|
|
|
90
110
|
* 受众角色选项(SSO 本系统角色)。未传且无 renderAudienceField 时用空 Select(禁 tags 手输码)。
|
|
91
111
|
*/
|
|
92
112
|
fetchAudienceRoles?: () => Promise<MessageAudienceRoleOption[]>;
|
|
113
|
+
/**
|
|
114
|
+
* 推送规则「例外抄送」多选 options(SSO 本租户用户;静态 userIds)。
|
|
115
|
+
* 未传则例外抄送 Select 为空(禁手输 id);展示名须来自接口 displayName。
|
|
116
|
+
* 任务认领人/分配人等当事人由业务 emit 传 userIds,勿靠配置面点名。
|
|
117
|
+
*/
|
|
118
|
+
fetchAudienceUsers?: () => Promise<MessageAudienceUserOption[]>;
|
|
93
119
|
/**
|
|
94
120
|
* @deprecated 变量须来自 catalog;仅联调 fixture 可传。业务页勿硬编码平行表。
|
|
95
121
|
*/
|
|
@@ -106,6 +132,7 @@ export type MessageTemplateAdminProps = {
|
|
|
106
132
|
* 传入后优先于 canWrite。
|
|
107
133
|
*/
|
|
108
134
|
permissions?: MessageAdminPermissions;
|
|
135
|
+
/** 模板受众角色插槽;须保持多选下拉语义,禁止 Tree 盖壳默认 Select */
|
|
109
136
|
renderAudienceField?: (ctx: {
|
|
110
137
|
roles: string[];
|
|
111
138
|
onChange: (roles: string[]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../../src/components/Tools/MessageCenter/MessageTemplateAdmin/types.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nexport type MessageCrudFlags = {\n create: boolean;\n read: boolean;\n update: boolean;\n delete: boolean;\n};\n\nexport type MessageAdminPermissions = {\n template?: Partial<MessageCrudFlags>;\n push?: Partial<MessageCrudFlags>;\n variable?: Partial<MessageCrudFlags>;\n};\n\nconst ALL_CRUD_OFF: MessageCrudFlags = {\n create: false,\n read: false,\n update: false,\n delete: false,\n};\n\nconst ALL_CRUD_ON: MessageCrudFlags = {\n create: true,\n read: true,\n update: true,\n delete: true,\n};\n\nfunction mergeCrud(\n partial: Partial<MessageCrudFlags> | undefined,\n fallback: MessageCrudFlags,\n): MessageCrudFlags {\n return {\n create: partial?.create ?? fallback.create,\n read: partial?.read ?? fallback.read,\n update: partial?.update ?? fallback.update,\n delete: partial?.delete ?? fallback.delete,\n };\n}\n\n/** 解析 Admin 门禁:有 permissions 用细粒度;否则 canWrite 作 Showcase 全开/全关。 */\nexport function resolveMessageAdminPermissions(\n permissions: MessageAdminPermissions | undefined,\n canWrite: boolean | undefined,\n): { template: MessageCrudFlags; push: MessageCrudFlags; variable: MessageCrudFlags } {\n const fallback = canWrite ? ALL_CRUD_ON : ALL_CRUD_OFF;\n if (!permissions) {\n return { template: fallback, push: fallback, variable: fallback };\n }\n return {\n template: mergeCrud(permissions.template, ALL_CRUD_OFF),\n push: mergeCrud(permissions.push, ALL_CRUD_OFF),\n variable: mergeCrud(permissions.variable, ALL_CRUD_OFF),\n };\n}\n\nexport type MessageTemplateAdminItem = {\n id?: string;\n code?: string;\n eventKey?: string;\n scenario?: string;\n label?: string;\n messageType?: string;\n titleTemplate?: string;\n titlePreview?: string;\n bodyTemplate?: string;\n audienceRoles?: string[];\n roles?: string[];\n enabled?: boolean;\n channel?: string;\n};\n\nexport type MessageEventCatalogItem = {\n eventKey: string;\n label: string;\n messageType?: string;\n};\n\n/** catalog API 完整载荷(含变量 SSOT) */\nexport type MessageEventCatalogPayload = {\n events: MessageEventCatalogItem[];\n /** 原始 schema;优先用 variables */\n contextSchema?: Record<string, string | { type?: string; label?: string }>;\n variables?: MessageTemplateVariable[];\n};\n\nexport type MessageAudienceRoleOption = {\n /** 写入模板的角色码 */\n code: string;\n /** 展示名(来自 SSO / fixture) */\n name: string;\n};\n\nexport type MessageTemplateVariable = {\n key: string;\n /** 可选中文说明;无则下拉只显示 code */\n label?: string;\n type?: string;\n source?: 'catalog' | 'tenant';\n baseline?: boolean;\n};\n\n/** 变量管理行 */\nexport type MessageTemplateVariableAdmin = MessageTemplateVariable;\n\nexport type PushRuleAdminItem = {\n id?: string;\n code?: string;\n label?: string;\n eventKey?: string;\n levels?: string[];\n templateCode?: string;\n audienceRoles?: string[];\n audienceUserIds?: string[];\n channels?: string[];\n slaHours?: number;\n scanLookbackDays?: number;\n enabled?: boolean;\n};\n\nexport type MessageTemplateAdminProps = {\n fetchTemplates: () => Promise<MessageTemplateAdminItem[]>;\n saveTemplate?: (item: MessageTemplateAdminItem) => Promise<void>;\n /**\n * 事件目录。可返回数组(仅 events)或完整 payload(含 variables / contextSchema)。\n * 变量优先取 payload.variables,否则从 contextSchema 推导;**禁止** FE 平行 DEFAULT_VARS。\n */\n fetchEventCatalog?: () => Promise<MessageEventCatalogItem[] | MessageEventCatalogPayload>;\n /** 列表行切换启用(不经新建表单) */\n setTemplateEnabled?: (item: MessageTemplateAdminItem, enabled: boolean) => Promise<void>;\n /**\n * 受众角色选项(SSO 本系统角色)。未传且无 renderAudienceField 时用空 Select(禁 tags 手输码)。\n */\n fetchAudienceRoles?: () => Promise<MessageAudienceRoleOption[]>;\n /**\n * @deprecated 变量须来自 catalog;仅联调 fixture 可传。业务页勿硬编码平行表。\n */\n templateVariables?: MessageTemplateVariable[];\n /** 预览用示例值;未传则按 variables 生成 */\n previewVars?: Record<string, string>;\n /**\n * Showcase 快捷:true→十二项全开,false→全关。\n * 业务仓须传 permissions,禁止只靠 canWrite 当真门禁。\n */\n canWrite?: boolean;\n /**\n * 细粒度 CRUD 门禁(模板 / 推送 / 变量 × create|read|update|delete)。\n * 传入后优先于 canWrite。\n */\n permissions?: MessageAdminPermissions;\n renderAudienceField?: (ctx: {\n roles: string[];\n onChange: (roles: string[]) => void;\n }) => ReactNode;\n /** @deprecated 优先传 fetchPushRules */\n pushRulesSlot?: ReactNode;\n fetchPushRules?: () => Promise<PushRuleAdminItem[]>;\n savePushRule?: (item: PushRuleAdminItem) => Promise<void>;\n setPushRuleEnabled?: (item: PushRuleAdminItem, enabled: boolean) => Promise<void>;\n deletePushRule?: (item: PushRuleAdminItem) => Promise<void>;\n fetchVariables?: () => Promise<MessageTemplateVariableAdmin[]>;\n saveVariable?: (item: MessageTemplateVariableAdmin) => Promise<void>;\n deleteVariable?: (item: MessageTemplateVariableAdmin) => Promise<void>;\n emptyText?: string;\n className?: string;\n /** 自动编号前缀,默认 MEQ */\n codePrefix?: string;\n};\n\nexport function variablesFromCatalog(\n payload: MessageEventCatalogPayload | null | undefined,\n): MessageTemplateVariable[] {\n if (!payload) return [];\n if (Array.isArray(payload.variables) && payload.variables.length) {\n return payload.variables\n .map((v) => ({\n key: String(v.key || '').trim(),\n label: v.label,\n type: v.type,\n source: v.source,\n baseline: v.baseline,\n }))\n .filter((v) => v.key);\n }\n const schema = payload.contextSchema;\n if (!schema || typeof schema !== 'object') return [];\n return Object.entries(schema)\n .map(([key, raw]) => {\n if (typeof raw === 'string') return { key, type: raw };\n if (raw && typeof raw === 'object') {\n return {\n key,\n type: raw.type || 'string',\n label: raw.label,\n };\n }\n return { key };\n })\n .filter((v) => v.key);\n}\n\nexport function previewVarsFromVariables(vars: MessageTemplateVariable[]): Record<string, string> {\n const out: Record<string, string> = {};\n for (const v of vars) {\n out[v.key] = v.type === 'number' ? '1' : v.label || v.key;\n }\n return out;\n}\n"],"names":["ALL_CRUD_OFF","ALL_CRUD_ON","mergeCrud","partial","fallback","resolveMessageAdminPermissions","permissions","canWrite","variablesFromCatalog","payload","v","schema","key","raw","previewVarsFromVariables","vars","out"],"mappings":"AAeA,MAAMA,IAAiC;AAAA,EACrC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV,GAEMC,IAAgC;AAAA,EACpC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV;AAEA,SAASC,EACPC,GACAC,GACkB;AAClB,SAAO;AAAA,IACL,SAAQD,KAAA,gBAAAA,EAAS,WAAUC,EAAS;AAAA,IACpC,OAAMD,KAAA,gBAAAA,EAAS,SAAQC,EAAS;AAAA,IAChC,SAAQD,KAAA,gBAAAA,EAAS,WAAUC,EAAS;AAAA,IACpC,SAAQD,KAAA,gBAAAA,EAAS,WAAUC,EAAS;AAAA,EAAA;AAExC;AAGO,SAASC,EACdC,GACAC,GACoF;AACpF,QAAMH,IAAWG,IAAWN,IAAcD;AAC1C,SAAKM,IAGE;AAAA,IACL,UAAUJ,EAAUI,EAAY,UAAUN,CAAY;AAAA,IACtD,MAAME,EAAUI,EAAY,MAAMN,CAAY;AAAA,IAC9C,UAAUE,EAAUI,EAAY,UAAUN,CAAY;AAAA,EAAA,IAL/C,EAAE,UAAUI,GAAU,MAAMA,GAAU,UAAUA,EAAA;AAO3D;
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../src/components/Tools/MessageCenter/MessageTemplateAdmin/types.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nexport type MessageCrudFlags = {\n create: boolean;\n read: boolean;\n update: boolean;\n delete: boolean;\n};\n\nexport type MessageAdminPermissions = {\n template?: Partial<MessageCrudFlags>;\n push?: Partial<MessageCrudFlags>;\n variable?: Partial<MessageCrudFlags>;\n};\n\nconst ALL_CRUD_OFF: MessageCrudFlags = {\n create: false,\n read: false,\n update: false,\n delete: false,\n};\n\nconst ALL_CRUD_ON: MessageCrudFlags = {\n create: true,\n read: true,\n update: true,\n delete: true,\n};\n\nfunction mergeCrud(\n partial: Partial<MessageCrudFlags> | undefined,\n fallback: MessageCrudFlags,\n): MessageCrudFlags {\n return {\n create: partial?.create ?? fallback.create,\n read: partial?.read ?? fallback.read,\n update: partial?.update ?? fallback.update,\n delete: partial?.delete ?? fallback.delete,\n };\n}\n\n/** 解析 Admin 门禁:有 permissions 用细粒度;否则 canWrite 作 Showcase 全开/全关。 */\nexport function resolveMessageAdminPermissions(\n permissions: MessageAdminPermissions | undefined,\n canWrite: boolean | undefined,\n): { template: MessageCrudFlags; push: MessageCrudFlags; variable: MessageCrudFlags } {\n const fallback = canWrite ? ALL_CRUD_ON : ALL_CRUD_OFF;\n if (!permissions) {\n return { template: fallback, push: fallback, variable: fallback };\n }\n return {\n template: mergeCrud(permissions.template, ALL_CRUD_OFF),\n push: mergeCrud(permissions.push, ALL_CRUD_OFF),\n variable: mergeCrud(permissions.variable, ALL_CRUD_OFF),\n };\n}\n\nexport type MessageTemplateAdminItem = {\n id?: string;\n code?: string;\n eventKey?: string;\n scenario?: string;\n label?: string;\n messageType?: string;\n titleTemplate?: string;\n titlePreview?: string;\n bodyTemplate?: string;\n audienceRoles?: string[];\n roles?: string[];\n /** 受众槽位码(与 mc audienceSlots 对齐) */\n audienceSlots?: string[];\n enabled?: boolean;\n channel?: string;\n};\n\nexport type MessageEventCatalogItem = {\n eventKey: string;\n label: string;\n messageType?: string;\n};\n\n/** catalog API 完整载荷(含变量 SSOT) */\nexport type MessageEventCatalogPayload = {\n events: MessageEventCatalogItem[];\n /** 原始 schema;优先用 variables */\n contextSchema?: Record<string, string | { type?: string; label?: string }>;\n variables?: MessageTemplateVariable[];\n /** 受众槽位 options(与 core AUDIENCE_SLOT_OPTIONS 对齐;有则优先) */\n audienceSlotOptions?: { value: string; label: string }[];\n};\n\nexport type MessageAudienceRoleOption = {\n /** 写入模板的角色码 */\n code: string;\n /** 展示名(来自 SSO / fixture) */\n name: string;\n};\n\n/** 推送规则例外抄送选项(SSO 本租户用户;展示名取自接口) */\nexport type MessageAudienceUserOption = {\n id: string;\n /** displayName 优先 */\n name: string;\n /** 工号(SSO employeeId) */\n employeeId?: string;\n /** 主部门 / 首个组织名(SSO orgs) */\n departmentName?: string;\n /** 角色展示名,顿号拼接(SSO roles.name) */\n roleNames?: string;\n};\n\nexport type MessageTemplateVariable = {\n key: string;\n /** 可选中文说明;无则下拉只显示 code */\n label?: string;\n type?: string;\n source?: 'catalog' | 'tenant';\n baseline?: boolean;\n};\n\n/** 变量管理行 */\nexport type MessageTemplateVariableAdmin = MessageTemplateVariable;\n\nexport type PushRuleAdminItem = {\n id?: string;\n code?: string;\n label?: string;\n eventKey?: string;\n levels?: string[];\n templateCode?: string;\n audienceRoles?: string[];\n audienceUserIds?: string[];\n audienceSlots?: string[];\n channels?: string[];\n slaHours?: number;\n scanLookbackDays?: number;\n enabled?: boolean;\n};\n\nexport type MessageTemplateAdminProps = {\n fetchTemplates: () => Promise<MessageTemplateAdminItem[]>;\n saveTemplate?: (item: MessageTemplateAdminItem) => Promise<void>;\n /**\n * 事件目录。可返回数组(仅 events)或完整 payload(含 variables / contextSchema)。\n * 变量优先取 payload.variables,否则从 contextSchema 推导;**禁止** FE 平行 DEFAULT_VARS。\n */\n fetchEventCatalog?: () => Promise<MessageEventCatalogItem[] | MessageEventCatalogPayload>;\n /** 列表行切换启用(不经新建表单) */\n setTemplateEnabled?: (item: MessageTemplateAdminItem, enabled: boolean) => Promise<void>;\n /**\n * 受众角色选项(SSO 本系统角色)。未传且无 renderAudienceField 时用空 Select(禁 tags 手输码)。\n */\n fetchAudienceRoles?: () => Promise<MessageAudienceRoleOption[]>;\n /**\n * 推送规则「例外抄送」多选 options(SSO 本租户用户;静态 userIds)。\n * 未传则例外抄送 Select 为空(禁手输 id);展示名须来自接口 displayName。\n * 任务认领人/分配人等当事人由业务 emit 传 userIds,勿靠配置面点名。\n */\n fetchAudienceUsers?: () => Promise<MessageAudienceUserOption[]>;\n /**\n * @deprecated 变量须来自 catalog;仅联调 fixture 可传。业务页勿硬编码平行表。\n */\n templateVariables?: MessageTemplateVariable[];\n /** 预览用示例值;未传则按 variables 生成 */\n previewVars?: Record<string, string>;\n /**\n * Showcase 快捷:true→十二项全开,false→全关。\n * 业务仓须传 permissions,禁止只靠 canWrite 当真门禁。\n */\n canWrite?: boolean;\n /**\n * 细粒度 CRUD 门禁(模板 / 推送 / 变量 × create|read|update|delete)。\n * 传入后优先于 canWrite。\n */\n permissions?: MessageAdminPermissions;\n /** 模板受众角色插槽;须保持多选下拉语义,禁止 Tree 盖壳默认 Select */\n renderAudienceField?: (ctx: {\n roles: string[];\n onChange: (roles: string[]) => void;\n }) => ReactNode;\n /** @deprecated 优先传 fetchPushRules */\n pushRulesSlot?: ReactNode;\n fetchPushRules?: () => Promise<PushRuleAdminItem[]>;\n savePushRule?: (item: PushRuleAdminItem) => Promise<void>;\n setPushRuleEnabled?: (item: PushRuleAdminItem, enabled: boolean) => Promise<void>;\n deletePushRule?: (item: PushRuleAdminItem) => Promise<void>;\n fetchVariables?: () => Promise<MessageTemplateVariableAdmin[]>;\n saveVariable?: (item: MessageTemplateVariableAdmin) => Promise<void>;\n deleteVariable?: (item: MessageTemplateVariableAdmin) => Promise<void>;\n emptyText?: string;\n className?: string;\n /** 自动编号前缀,默认 MEQ */\n codePrefix?: string;\n};\n\nexport function variablesFromCatalog(\n payload: MessageEventCatalogPayload | null | undefined,\n): MessageTemplateVariable[] {\n if (!payload) return [];\n if (Array.isArray(payload.variables) && payload.variables.length) {\n return payload.variables\n .map((v) => ({\n key: String(v.key || '').trim(),\n label: v.label,\n type: v.type,\n source: v.source,\n baseline: v.baseline,\n }))\n .filter((v) => v.key);\n }\n const schema = payload.contextSchema;\n if (!schema || typeof schema !== 'object') return [];\n return Object.entries(schema)\n .map(([key, raw]) => {\n if (typeof raw === 'string') return { key, type: raw };\n if (raw && typeof raw === 'object') {\n return {\n key,\n type: raw.type || 'string',\n label: raw.label,\n };\n }\n return { key };\n })\n .filter((v) => v.key);\n}\n\nexport function previewVarsFromVariables(vars: MessageTemplateVariable[]): Record<string, string> {\n const out: Record<string, string> = {};\n for (const v of vars) {\n out[v.key] = v.type === 'number' ? '1' : v.label || v.key;\n }\n return out;\n}\n"],"names":["ALL_CRUD_OFF","ALL_CRUD_ON","mergeCrud","partial","fallback","resolveMessageAdminPermissions","permissions","canWrite","variablesFromCatalog","payload","v","schema","key","raw","previewVarsFromVariables","vars","out"],"mappings":"AAeA,MAAMA,IAAiC;AAAA,EACrC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV,GAEMC,IAAgC;AAAA,EACpC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV;AAEA,SAASC,EACPC,GACAC,GACkB;AAClB,SAAO;AAAA,IACL,SAAQD,KAAA,gBAAAA,EAAS,WAAUC,EAAS;AAAA,IACpC,OAAMD,KAAA,gBAAAA,EAAS,SAAQC,EAAS;AAAA,IAChC,SAAQD,KAAA,gBAAAA,EAAS,WAAUC,EAAS;AAAA,IACpC,SAAQD,KAAA,gBAAAA,EAAS,WAAUC,EAAS;AAAA,EAAA;AAExC;AAGO,SAASC,EACdC,GACAC,GACoF;AACpF,QAAMH,IAAWG,IAAWN,IAAcD;AAC1C,SAAKM,IAGE;AAAA,IACL,UAAUJ,EAAUI,EAAY,UAAUN,CAAY;AAAA,IACtD,MAAME,EAAUI,EAAY,MAAMN,CAAY;AAAA,IAC9C,UAAUE,EAAUI,EAAY,UAAUN,CAAY;AAAA,EAAA,IAL/C,EAAE,UAAUI,GAAU,MAAMA,GAAU,UAAUA,EAAA;AAO3D;AA4IO,SAASI,EACdC,GAC2B;AAC3B,MAAI,CAACA,EAAS,QAAO,CAAA;AACrB,MAAI,MAAM,QAAQA,EAAQ,SAAS,KAAKA,EAAQ,UAAU;AACxD,WAAOA,EAAQ,UACZ,IAAI,CAACC,OAAO;AAAA,MACX,KAAK,OAAOA,EAAE,OAAO,EAAE,EAAE,KAAA;AAAA,MACzB,OAAOA,EAAE;AAAA,MACT,MAAMA,EAAE;AAAA,MACR,QAAQA,EAAE;AAAA,MACV,UAAUA,EAAE;AAAA,IAAA,EACZ,EACD,OAAO,CAACA,MAAMA,EAAE,GAAG;AAExB,QAAMC,IAASF,EAAQ;AACvB,SAAI,CAACE,KAAU,OAAOA,KAAW,WAAiB,CAAA,IAC3C,OAAO,QAAQA,CAAM,EACzB,IAAI,CAAC,CAACC,GAAKC,CAAG,MACT,OAAOA,KAAQ,WAAiB,EAAE,KAAAD,GAAK,MAAMC,EAAA,IAC7CA,KAAO,OAAOA,KAAQ,WACjB;AAAA,IACL,KAAAD;AAAA,IACA,MAAMC,EAAI,QAAQ;AAAA,IAClB,OAAOA,EAAI;AAAA,EAAA,IAGR,EAAE,KAAAD,EAAA,CACV,EACA,OAAO,CAACF,MAAMA,EAAE,GAAG;AACxB;AAEO,SAASI,EAAyBC,GAAyD;AAChG,QAAMC,IAA8B,CAAA;AACpC,aAAWN,KAAKK;AACd,IAAAC,EAAIN,EAAE,GAAG,IAAIA,EAAE,SAAS,WAAW,MAAMA,EAAE,SAASA,EAAE;AAExD,SAAOM;AACT;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type MsgCenterAppSwitcherProps = {
|
|
3
|
+
/**
|
|
4
|
+
* 返回当前用户**有权进入**的 SystemApp(须调用方用 EP 过滤;本组件再收窄到可切换 appKey)。
|
|
5
|
+
* 禁止传入全量 Agent 目录。
|
|
6
|
+
*/
|
|
7
|
+
listAuthorizedSystemApps: () => Promise<Array<{
|
|
8
|
+
code: string;
|
|
9
|
+
name: string;
|
|
10
|
+
}>>;
|
|
11
|
+
/** 本壳默认 appKey(无 session 时) */
|
|
12
|
+
fallbackAppKey: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
/** 切换成功回调(铃铛/Admin 另订阅 store) */
|
|
16
|
+
onAppKeyChange?: (appKey: string) => void;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* AgentHub 消息中心 App 切换器:仅有权 + 本期可切换对;展示名取 SSO name。
|
|
20
|
+
*/
|
|
21
|
+
declare const MsgCenterAppSwitcher: React.FC<MsgCenterAppSwitcherProps>;
|
|
22
|
+
export default MsgCenterAppSwitcher;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsxs as x, jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import { Typography as j, Select as v } from "antd";
|
|
3
|
+
import { useState as o, useCallback as K, useEffect as M, useMemo as T } from "react";
|
|
4
|
+
import { getMsgCenterAppKey as h, filterMsgCenterSwitchableApps as F, resolveMsgCenterSwitchState as L, setMsgCenterAppKey as w, subscribeMsgCenterAppKey as P } from "../msgCenterAppSwitch.js";
|
|
5
|
+
const D = ({
|
|
6
|
+
listAuthorizedSystemApps: l,
|
|
7
|
+
fallbackAppKey: s,
|
|
8
|
+
className: p,
|
|
9
|
+
style: c,
|
|
10
|
+
onAppKeyChange: a
|
|
11
|
+
}) => {
|
|
12
|
+
const [n, u] = o([]), [f, m] = o(!1), [g, d] = o(null), [S, i] = o(() => h(s)), y = K(async () => {
|
|
13
|
+
m(!0), d(null);
|
|
14
|
+
try {
|
|
15
|
+
const e = await l(), t = F(e || []);
|
|
16
|
+
u(t);
|
|
17
|
+
const r = L(t, s);
|
|
18
|
+
i(r.currentAppKey), h(s) !== r.currentAppKey && t.length && w(
|
|
19
|
+
r.currentAppKey,
|
|
20
|
+
t.map((b) => b.appKey)
|
|
21
|
+
);
|
|
22
|
+
} catch (e) {
|
|
23
|
+
d(e instanceof Error ? e.message : String(e)), u([]);
|
|
24
|
+
} finally {
|
|
25
|
+
m(!1);
|
|
26
|
+
}
|
|
27
|
+
}, [s, l]);
|
|
28
|
+
M(() => {
|
|
29
|
+
y();
|
|
30
|
+
}, [y]), M(() => P((e) => {
|
|
31
|
+
e && i(e);
|
|
32
|
+
}), []);
|
|
33
|
+
const C = T(
|
|
34
|
+
() => n.map((e) => ({
|
|
35
|
+
value: e.appKey,
|
|
36
|
+
label: e.name
|
|
37
|
+
})),
|
|
38
|
+
[n]
|
|
39
|
+
);
|
|
40
|
+
return g ? /* @__PURE__ */ x(j.Text, { type: "danger", className: p, style: c, children: [
|
|
41
|
+
"应用列表不可用:",
|
|
42
|
+
g
|
|
43
|
+
] }) : !f && n.length <= 1 ? null : /* @__PURE__ */ E(
|
|
44
|
+
v,
|
|
45
|
+
{
|
|
46
|
+
className: p,
|
|
47
|
+
style: { minWidth: 180, ...c },
|
|
48
|
+
loading: f,
|
|
49
|
+
value: S,
|
|
50
|
+
options: C,
|
|
51
|
+
optionFilterProp: "label",
|
|
52
|
+
placeholder: "消息应用",
|
|
53
|
+
"aria-label": "消息中心应用切换",
|
|
54
|
+
onChange: (e) => {
|
|
55
|
+
const t = n.map((r) => r.appKey);
|
|
56
|
+
w(e, t), i(e), a == null || a(e);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
D as default
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=MsgCenterAppSwitcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MsgCenterAppSwitcher.js","sources":["../../../../../src/components/Tools/MessageCenter/MsgCenterAppSwitcher/MsgCenterAppSwitcher.tsx"],"sourcesContent":["import { Select, Typography } from 'antd';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport {\n filterMsgCenterSwitchableApps,\n getMsgCenterAppKey,\n resolveMsgCenterSwitchState,\n setMsgCenterAppKey,\n subscribeMsgCenterAppKey,\n type MsgCenterSwitchableApp,\n} from '../msgCenterAppSwitch';\n\nexport type MsgCenterAppSwitcherProps = {\n /**\n * 返回当前用户**有权进入**的 SystemApp(须调用方用 EP 过滤;本组件再收窄到可切换 appKey)。\n * 禁止传入全量 Agent 目录。\n */\n listAuthorizedSystemApps: () => Promise<Array<{ code: string; name: string }>>;\n /** 本壳默认 appKey(无 session 时) */\n fallbackAppKey: string;\n className?: string;\n style?: React.CSSProperties;\n /** 切换成功回调(铃铛/Admin 另订阅 store) */\n onAppKeyChange?: (appKey: string) => void;\n};\n\n/**\n * AgentHub 消息中心 App 切换器:仅有权 + 本期可切换对;展示名取 SSO name。\n */\nconst MsgCenterAppSwitcher: React.FC<MsgCenterAppSwitcherProps> = ({\n listAuthorizedSystemApps,\n fallbackAppKey,\n className,\n style,\n onAppKeyChange,\n}) => {\n const [apps, setApps] = useState<MsgCenterSwitchableApp[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [current, setCurrent] = useState(() => getMsgCenterAppKey(fallbackAppKey));\n\n const reload = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const raw = await listAuthorizedSystemApps();\n const filtered = filterMsgCenterSwitchableApps(raw || []);\n setApps(filtered);\n const state = resolveMsgCenterSwitchState(filtered, fallbackAppKey);\n setCurrent(state.currentAppKey);\n if (getMsgCenterAppKey(fallbackAppKey) !== state.currentAppKey && filtered.length) {\n setMsgCenterAppKey(\n state.currentAppKey,\n filtered.map((a) => a.appKey),\n );\n }\n } catch (e) {\n setError(e instanceof Error ? e.message : String(e));\n setApps([]);\n } finally {\n setLoading(false);\n }\n }, [fallbackAppKey, listAuthorizedSystemApps]);\n\n useEffect(() => {\n void reload();\n }, [reload]);\n\n useEffect(() => {\n return subscribeMsgCenterAppKey((next) => {\n if (next) setCurrent(next);\n });\n }, []);\n\n const options = useMemo(\n () =>\n apps.map((a) => ({\n value: a.appKey,\n label: a.name,\n })),\n [apps],\n );\n\n if (error) {\n return (\n <Typography.Text type=\"danger\" className={className} style={style}>\n 应用列表不可用:{error}\n </Typography.Text>\n );\n }\n\n if (!loading && apps.length <= 1) {\n // 单权或无可切换:不展示切换器(PB-01:无第二项)\n return null;\n }\n\n return (\n <Select\n className={className}\n style={{ minWidth: 180, ...style }}\n loading={loading}\n value={current}\n options={options}\n optionFilterProp=\"label\"\n placeholder=\"消息应用\"\n aria-label=\"消息中心应用切换\"\n onChange={(value: string) => {\n const allowed = apps.map((a) => a.appKey);\n setMsgCenterAppKey(value, allowed);\n setCurrent(value);\n onAppKeyChange?.(value);\n }}\n />\n );\n};\n\nexport default MsgCenterAppSwitcher;\n"],"names":["MsgCenterAppSwitcher","listAuthorizedSystemApps","fallbackAppKey","className","style","onAppKeyChange","apps","setApps","useState","loading","setLoading","error","setError","current","setCurrent","getMsgCenterAppKey","reload","useCallback","raw","filtered","filterMsgCenterSwitchableApps","state","resolveMsgCenterSwitchState","setMsgCenterAppKey","a","useEffect","subscribeMsgCenterAppKey","next","options","useMemo","Typography","jsx","Select","value","allowed"],"mappings":";;;;AA4BA,MAAMA,IAA4D,CAAC;AAAA,EACjE,0BAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,gBAAAC;AACF,MAAM;AACJ,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAmC,CAAA,CAAE,GACvD,CAACC,GAASC,CAAU,IAAIF,EAAS,EAAK,GACtC,CAACG,GAAOC,CAAQ,IAAIJ,EAAwB,IAAI,GAChD,CAACK,GAASC,CAAU,IAAIN,EAAS,MAAMO,EAAmBb,CAAc,CAAC,GAEzEc,IAASC,EAAY,YAAY;AACrC,IAAAP,EAAW,EAAI,GACfE,EAAS,IAAI;AACb,QAAI;AACF,YAAMM,IAAM,MAAMjB,EAAA,GACZkB,IAAWC,EAA8BF,KAAO,EAAE;AACxD,MAAAX,EAAQY,CAAQ;AAChB,YAAME,IAAQC,EAA4BH,GAAUjB,CAAc;AAClE,MAAAY,EAAWO,EAAM,aAAa,GAC1BN,EAAmBb,CAAc,MAAMmB,EAAM,iBAAiBF,EAAS,UACzEI;AAAA,QACEF,EAAM;AAAA,QACNF,EAAS,IAAI,CAACK,MAAMA,EAAE,MAAM;AAAA,MAAA;AAAA,IAGlC,SAAS,GAAG;AACV,MAAAZ,EAAS,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC,GACnDL,EAAQ,CAAA,CAAE;AAAA,IACZ,UAAA;AACE,MAAAG,EAAW,EAAK;AAAA,IAClB;AAAA,EACF,GAAG,CAACR,GAAgBD,CAAwB,CAAC;AAE7C,EAAAwB,EAAU,MAAM;AACd,IAAKT,EAAA;AAAA,EACP,GAAG,CAACA,CAAM,CAAC,GAEXS,EAAU,MACDC,EAAyB,CAACC,MAAS;AACxC,IAAIA,OAAiBA,CAAI;AAAA,EAC3B,CAAC,GACA,CAAA,CAAE;AAEL,QAAMC,IAAUC;AAAA,IACd,MACEvB,EAAK,IAAI,CAACkB,OAAO;AAAA,MACf,OAAOA,EAAE;AAAA,MACT,OAAOA,EAAE;AAAA,IAAA,EACT;AAAA,IACJ,CAAClB,CAAI;AAAA,EAAA;AAGP,SAAIK,sBAECmB,EAAW,MAAX,EAAgB,MAAK,UAAS,WAAA3B,GAAsB,OAAAC,GAAc,UAAA;AAAA,IAAA;AAAA,IACxDO;AAAA,EAAA,GACX,IAIA,CAACF,KAAWH,EAAK,UAAU,IAEtB,OAIP,gBAAAyB;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,WAAA7B;AAAA,MACA,OAAO,EAAE,UAAU,KAAK,GAAGC,EAAA;AAAA,MAC3B,SAAAK;AAAA,MACA,OAAOI;AAAA,MACP,SAAAe;AAAA,MACA,kBAAiB;AAAA,MACjB,aAAY;AAAA,MACZ,cAAW;AAAA,MACX,UAAU,CAACK,MAAkB;AAC3B,cAAMC,IAAU5B,EAAK,IAAI,CAACkB,MAAMA,EAAE,MAAM;AACxC,QAAAD,EAAmBU,GAAOC,CAAO,GACjCpB,EAAWmB,CAAK,GAChB5B,KAAA,QAAAA,EAAiB4B;AAAA,MACnB;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export { MessageTemplateAdmin } from './MessageTemplateAdmin';
|
|
2
|
-
export type { MessageTemplateAdminProps, MessageTemplateAdminItem, MessageEventCatalogItem, MessageEventCatalogPayload, MessageAudienceRoleOption, MessageTemplateVariable, MessageTemplateVariableAdmin, PushRuleAdminItem, MessageCrudFlags, MessageAdminPermissions, } from './MessageTemplateAdmin';
|
|
2
|
+
export type { MessageTemplateAdminProps, MessageTemplateAdminItem, MessageEventCatalogItem, MessageEventCatalogPayload, MessageAudienceRoleOption, MessageAudienceUserOption, MessageTemplateVariable, MessageTemplateVariableAdmin, PushRuleAdminItem, MessageCrudFlags, MessageAdminPermissions, } from './MessageTemplateAdmin';
|
|
3
3
|
export { generateTemplateCode, normalizeTemplatePlaceholders, applyTemplateVars, stripHtmlToText, } from './utils/templateCode';
|
|
4
4
|
export { resolveMessageAdminPermissions } from './MessageTemplateAdmin';
|
|
5
|
+
export { MSG_CENTER_APP_SWITCH_STORAGE_KEY, SYSTEM_APP_TO_MSG_CENTER_APP_KEY, MSG_CENTER_SWITCHABLE_APP_KEYS, msgCenterAppKeyFromSystemAppCode, filterMsgCenterSwitchableApps, getMsgCenterAppKey, setMsgCenterAppKey, subscribeMsgCenterAppKey, bindMsgCenterAppKeyStorageSync, resolveMsgCenterSwitchState, } from './msgCenterAppSwitch';
|
|
6
|
+
export { AUDIENCE_SLOT_OPTIONS, ORG_TENANT_SLOT, normalizeAudienceSlots, hasAudienceSelection, } from './MessageTemplateAdmin';
|
|
7
|
+
export type { AudienceSlotOption } from './MessageTemplateAdmin';
|
|
8
|
+
export type { MsgCenterAppSwitchState, MsgCenterSwitchableApp, MsgCenterSwitchableAppKey, } from './msgCenterAppSwitch';
|
|
9
|
+
export { useMsgCenterAppKey } from './useMsgCenterAppKey';
|
|
10
|
+
export { MsgCenterAppSwitcher } from './MsgCenterAppSwitcher';
|
|
11
|
+
export type { MsgCenterAppSwitcherProps } from './MsgCenterAppSwitcher';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 消息中心运行时 appKey 切换(Phase B)。
|
|
3
|
+
* Hub 写入;各业务 App 铃铛/Admin 读取。跨页签用 sessionStorage + storage 事件。
|
|
4
|
+
* 禁 Hub=全 Agent;仅 catalog 可切换对。
|
|
5
|
+
*/
|
|
6
|
+
export declare const MSG_CENTER_APP_SWITCH_STORAGE_KEY = "marsun.msgCenter.currentAppKey";
|
|
7
|
+
/** SystemApp.code → mc catalog appKey(非中文表;仅 Quality 例外) */
|
|
8
|
+
export declare const SYSTEM_APP_TO_MSG_CENTER_APP_KEY: Readonly<Record<string, string>>;
|
|
9
|
+
/** 本期允许出现在切换器中的 mc appKey */
|
|
10
|
+
export declare const MSG_CENTER_SWITCHABLE_APP_KEYS: readonly ["equipment-agent", "s3-quality"];
|
|
11
|
+
export type MsgCenterSwitchableAppKey = (typeof MSG_CENTER_SWITCHABLE_APP_KEYS)[number];
|
|
12
|
+
export type MsgCenterAppSwitchState = {
|
|
13
|
+
currentAppKey: string;
|
|
14
|
+
currentSystemAppCode: string;
|
|
15
|
+
currentSystemAppName: string;
|
|
16
|
+
};
|
|
17
|
+
export type MsgCenterSwitchableApp = {
|
|
18
|
+
appKey: string;
|
|
19
|
+
systemAppCode: string;
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
type Listener = (appKey: string) => void;
|
|
23
|
+
/** 从 SystemApp.code 解析 mc appKey;未知则原样返回(调用方须再过滤) */
|
|
24
|
+
export declare function msgCenterAppKeyFromSystemAppCode(systemAppCode: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* 仅保留本期可切换且用户有权进入的项(禁全量 Agent)。
|
|
27
|
+
* `apps` 须已是「有权进入」子集(由 Hub 用 EP 过滤后再传入)。
|
|
28
|
+
*/
|
|
29
|
+
export declare function filterMsgCenterSwitchableApps(apps: Array<{
|
|
30
|
+
code: string;
|
|
31
|
+
name: string;
|
|
32
|
+
}>): MsgCenterSwitchableApp[];
|
|
33
|
+
export declare function getMsgCenterAppKey(fallbackAppKey: string): string;
|
|
34
|
+
export declare function setMsgCenterAppKey(appKey: string, allowed?: readonly string[]): void;
|
|
35
|
+
export declare function subscribeMsgCenterAppKey(listener: Listener): () => void;
|
|
36
|
+
/** 浏览器多页签:storage 事件(仅跨 tab;同页靠 subscribe) */
|
|
37
|
+
export declare function bindMsgCenterAppKeyStorageSync(): () => void;
|
|
38
|
+
export declare function resolveMsgCenterSwitchState(apps: MsgCenterSwitchableApp[], fallbackAppKey: string): MsgCenterAppSwitchState;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const c = "marsun.msgCenter.currentAppKey", S = {
|
|
2
|
+
"equipment-agent": "equipment-agent",
|
|
3
|
+
"s3-agent": "s3-quality"
|
|
4
|
+
}, g = ["equipment-agent", "s3-quality"], u = /* @__PURE__ */ new Set();
|
|
5
|
+
function m() {
|
|
6
|
+
if (typeof sessionStorage > "u") return "";
|
|
7
|
+
try {
|
|
8
|
+
return String(sessionStorage.getItem(c) || "").trim();
|
|
9
|
+
} catch {
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function y(t) {
|
|
14
|
+
if (!(typeof sessionStorage > "u"))
|
|
15
|
+
try {
|
|
16
|
+
sessionStorage.setItem(c, t);
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function p(t) {
|
|
21
|
+
u.forEach((e) => {
|
|
22
|
+
try {
|
|
23
|
+
e(t);
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function a(t) {
|
|
29
|
+
const e = String(t || "").trim();
|
|
30
|
+
return e ? S[e] || e : "";
|
|
31
|
+
}
|
|
32
|
+
function f(t) {
|
|
33
|
+
const e = [], o = /* @__PURE__ */ new Set();
|
|
34
|
+
for (const r of t) {
|
|
35
|
+
const n = String((r == null ? void 0 : r.code) || "").trim(), i = String((r == null ? void 0 : r.name) || "").trim() || n;
|
|
36
|
+
if (!n) continue;
|
|
37
|
+
const s = a(n);
|
|
38
|
+
g.includes(s) && (o.has(s) || (o.add(s), e.push({ appKey: s, systemAppCode: n, name: i })));
|
|
39
|
+
}
|
|
40
|
+
return e;
|
|
41
|
+
}
|
|
42
|
+
function d(t) {
|
|
43
|
+
const e = m();
|
|
44
|
+
return e || String(t || "").trim();
|
|
45
|
+
}
|
|
46
|
+
function A(t, e) {
|
|
47
|
+
const o = String(t || "").trim();
|
|
48
|
+
if (o) {
|
|
49
|
+
if (e && e.length > 0 && !e.includes(o))
|
|
50
|
+
throw new Error(`appKey 不在可切换列表:${o}`);
|
|
51
|
+
y(o), p(o);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function C(t) {
|
|
55
|
+
return u.add(t), () => {
|
|
56
|
+
u.delete(t);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function E() {
|
|
60
|
+
if (typeof window > "u") return () => {
|
|
61
|
+
};
|
|
62
|
+
const t = (e) => {
|
|
63
|
+
e.storageArea === sessionStorage && e.key === c && p(String(e.newValue || "").trim());
|
|
64
|
+
};
|
|
65
|
+
return window.addEventListener("storage", t), () => window.removeEventListener("storage", t);
|
|
66
|
+
}
|
|
67
|
+
function _(t, e) {
|
|
68
|
+
const o = d(e), r = t.find((i) => i.appKey === o);
|
|
69
|
+
if (r)
|
|
70
|
+
return {
|
|
71
|
+
currentAppKey: r.appKey,
|
|
72
|
+
currentSystemAppCode: r.systemAppCode,
|
|
73
|
+
currentSystemAppName: r.name
|
|
74
|
+
};
|
|
75
|
+
const n = t.find((i) => i.appKey === e) || t[0];
|
|
76
|
+
return {
|
|
77
|
+
currentAppKey: (n == null ? void 0 : n.appKey) || e,
|
|
78
|
+
currentSystemAppCode: (n == null ? void 0 : n.systemAppCode) || e,
|
|
79
|
+
currentSystemAppName: (n == null ? void 0 : n.name) || e
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
c as MSG_CENTER_APP_SWITCH_STORAGE_KEY,
|
|
84
|
+
g as MSG_CENTER_SWITCHABLE_APP_KEYS,
|
|
85
|
+
S as SYSTEM_APP_TO_MSG_CENTER_APP_KEY,
|
|
86
|
+
E as bindMsgCenterAppKeyStorageSync,
|
|
87
|
+
f as filterMsgCenterSwitchableApps,
|
|
88
|
+
d as getMsgCenterAppKey,
|
|
89
|
+
a as msgCenterAppKeyFromSystemAppCode,
|
|
90
|
+
_ as resolveMsgCenterSwitchState,
|
|
91
|
+
A as setMsgCenterAppKey,
|
|
92
|
+
C as subscribeMsgCenterAppKey
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=msgCenterAppSwitch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msgCenterAppSwitch.js","sources":["../../../../src/components/Tools/MessageCenter/msgCenterAppSwitch.ts"],"sourcesContent":["/**\n * 消息中心运行时 appKey 切换(Phase B)。\n * Hub 写入;各业务 App 铃铛/Admin 读取。跨页签用 sessionStorage + storage 事件。\n * 禁 Hub=全 Agent;仅 catalog 可切换对。\n */\n\nexport const MSG_CENTER_APP_SWITCH_STORAGE_KEY = 'marsun.msgCenter.currentAppKey';\n\n/** SystemApp.code → mc catalog appKey(非中文表;仅 Quality 例外) */\nexport const SYSTEM_APP_TO_MSG_CENTER_APP_KEY: Readonly<Record<string, string>> = {\n 'equipment-agent': 'equipment-agent',\n 's3-agent': 's3-quality',\n};\n\n/** 本期允许出现在切换器中的 mc appKey */\nexport const MSG_CENTER_SWITCHABLE_APP_KEYS = ['equipment-agent', 's3-quality'] as const;\n\nexport type MsgCenterSwitchableAppKey = (typeof MSG_CENTER_SWITCHABLE_APP_KEYS)[number];\n\nexport type MsgCenterAppSwitchState = {\n currentAppKey: string;\n currentSystemAppCode: string;\n currentSystemAppName: string;\n};\n\nexport type MsgCenterSwitchableApp = {\n appKey: string;\n systemAppCode: string;\n name: string;\n};\n\ntype Listener = (appKey: string) => void;\n\nconst listeners = new Set<Listener>();\n\nfunction readStorage(): string {\n if (typeof sessionStorage === 'undefined') return '';\n try {\n return String(sessionStorage.getItem(MSG_CENTER_APP_SWITCH_STORAGE_KEY) || '').trim();\n } catch {\n return '';\n }\n}\n\nfunction writeStorage(appKey: string): void {\n if (typeof sessionStorage === 'undefined') return;\n try {\n sessionStorage.setItem(MSG_CENTER_APP_SWITCH_STORAGE_KEY, appKey);\n } catch {\n /* ignore quota */\n }\n}\n\nfunction notify(appKey: string): void {\n listeners.forEach((fn) => {\n try {\n fn(appKey);\n } catch {\n /* listener error 不阻断 */\n }\n });\n}\n\n/** 从 SystemApp.code 解析 mc appKey;未知则原样返回(调用方须再过滤) */\nexport function msgCenterAppKeyFromSystemAppCode(systemAppCode: string): string {\n const code = String(systemAppCode || '').trim();\n if (!code) return '';\n return SYSTEM_APP_TO_MSG_CENTER_APP_KEY[code] || code;\n}\n\n/**\n * 仅保留本期可切换且用户有权进入的项(禁全量 Agent)。\n * `apps` 须已是「有权进入」子集(由 Hub 用 EP 过滤后再传入)。\n */\nexport function filterMsgCenterSwitchableApps(\n apps: Array<{ code: string; name: string }>,\n): MsgCenterSwitchableApp[] {\n const out: MsgCenterSwitchableApp[] = [];\n const seen = new Set<string>();\n for (const raw of apps) {\n const systemAppCode = String(raw?.code || '').trim();\n const name = String(raw?.name || '').trim() || systemAppCode;\n if (!systemAppCode) continue;\n const appKey = msgCenterAppKeyFromSystemAppCode(systemAppCode);\n if (!(MSG_CENTER_SWITCHABLE_APP_KEYS as readonly string[]).includes(appKey)) continue;\n if (seen.has(appKey)) continue;\n seen.add(appKey);\n out.push({ appKey, systemAppCode, name });\n }\n return out;\n}\n\nexport function getMsgCenterAppKey(fallbackAppKey: string): string {\n const fromStore = readStorage();\n if (fromStore) return fromStore;\n return String(fallbackAppKey || '').trim();\n}\n\nexport function setMsgCenterAppKey(appKey: string, allowed?: readonly string[]): void {\n const next = String(appKey || '').trim();\n if (!next) return;\n if (allowed && allowed.length > 0 && !allowed.includes(next)) {\n throw new Error(`appKey 不在可切换列表:${next}`);\n }\n writeStorage(next);\n notify(next);\n}\n\nexport function subscribeMsgCenterAppKey(listener: Listener): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\n/** 浏览器多页签:storage 事件(仅跨 tab;同页靠 subscribe) */\nexport function bindMsgCenterAppKeyStorageSync(): () => void {\n if (typeof window === 'undefined') return () => undefined;\n const onStorage = (ev: StorageEvent) => {\n if (ev.storageArea !== sessionStorage) return;\n if (ev.key !== MSG_CENTER_APP_SWITCH_STORAGE_KEY) return;\n notify(String(ev.newValue || '').trim());\n };\n window.addEventListener('storage', onStorage);\n return () => window.removeEventListener('storage', onStorage);\n}\n\nexport function resolveMsgCenterSwitchState(\n apps: MsgCenterSwitchableApp[],\n fallbackAppKey: string,\n): MsgCenterAppSwitchState {\n const currentAppKey = getMsgCenterAppKey(fallbackAppKey);\n const hit = apps.find((a) => a.appKey === currentAppKey);\n if (hit) {\n return {\n currentAppKey: hit.appKey,\n currentSystemAppCode: hit.systemAppCode,\n currentSystemAppName: hit.name,\n };\n }\n const fb = apps.find((a) => a.appKey === fallbackAppKey) || apps[0];\n return {\n currentAppKey: fb?.appKey || fallbackAppKey,\n currentSystemAppCode: fb?.systemAppCode || fallbackAppKey,\n currentSystemAppName: fb?.name || fallbackAppKey,\n };\n}\n"],"names":["MSG_CENTER_APP_SWITCH_STORAGE_KEY","SYSTEM_APP_TO_MSG_CENTER_APP_KEY","MSG_CENTER_SWITCHABLE_APP_KEYS","listeners","readStorage","writeStorage","appKey","notify","fn","msgCenterAppKeyFromSystemAppCode","systemAppCode","code","filterMsgCenterSwitchableApps","apps","out","seen","raw","name","getMsgCenterAppKey","fallbackAppKey","fromStore","setMsgCenterAppKey","allowed","next","subscribeMsgCenterAppKey","listener","bindMsgCenterAppKeyStorageSync","onStorage","ev","resolveMsgCenterSwitchState","currentAppKey","hit","a","fb"],"mappings":"AAMO,MAAMA,IAAoC,kCAGpCC,IAAqE;AAAA,EAChF,mBAAmB;AAAA,EACnB,YAAY;AACd,GAGaC,IAAiC,CAAC,mBAAmB,YAAY,GAkBxEC,wBAAgB,IAAA;AAEtB,SAASC,IAAsB;AAC7B,MAAI,OAAO,iBAAmB,IAAa,QAAO;AAClD,MAAI;AACF,WAAO,OAAO,eAAe,QAAQJ,CAAiC,KAAK,EAAE,EAAE,KAAA;AAAA,EACjF,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAASK,EAAaC,GAAsB;AAC1C,MAAI,SAAO,iBAAmB;AAC9B,QAAI;AACF,qBAAe,QAAQN,GAAmCM,CAAM;AAAA,IAClE,QAAQ;AAAA,IAER;AACF;AAEA,SAASC,EAAOD,GAAsB;AACpC,EAAAH,EAAU,QAAQ,CAACK,MAAO;AACxB,QAAI;AACF,MAAAA,EAAGF,CAAM;AAAA,IACX,QAAQ;AAAA,IAER;AAAA,EACF,CAAC;AACH;AAGO,SAASG,EAAiCC,GAA+B;AAC9E,QAAMC,IAAO,OAAOD,KAAiB,EAAE,EAAE,KAAA;AACzC,SAAKC,IACEV,EAAiCU,CAAI,KAAKA,IAD/B;AAEpB;AAMO,SAASC,EACdC,GAC0B;AAC1B,QAAMC,IAAgC,CAAA,GAChCC,wBAAW,IAAA;AACjB,aAAWC,KAAOH,GAAM;AACtB,UAAMH,IAAgB,QAAOM,KAAA,gBAAAA,EAAK,SAAQ,EAAE,EAAE,KAAA,GACxCC,IAAO,QAAOD,KAAA,gBAAAA,EAAK,SAAQ,EAAE,EAAE,UAAUN;AAC/C,QAAI,CAACA,EAAe;AACpB,UAAMJ,IAASG,EAAiCC,CAAa;AAC7D,IAAMR,EAAqD,SAASI,CAAM,MACtES,EAAK,IAAIT,CAAM,MACnBS,EAAK,IAAIT,CAAM,GACfQ,EAAI,KAAK,EAAE,QAAAR,GAAQ,eAAAI,GAAe,MAAAO,GAAM;AAAA,EAC1C;AACA,SAAOH;AACT;AAEO,SAASI,EAAmBC,GAAgC;AACjE,QAAMC,IAAYhB,EAAA;AAClB,SAAIgB,KACG,OAAOD,KAAkB,EAAE,EAAE,KAAA;AACtC;AAEO,SAASE,EAAmBf,GAAgBgB,GAAmC;AACpF,QAAMC,IAAO,OAAOjB,KAAU,EAAE,EAAE,KAAA;AAClC,MAAKiB,GACL;AAAA,QAAID,KAAWA,EAAQ,SAAS,KAAK,CAACA,EAAQ,SAASC,CAAI;AACzD,YAAM,IAAI,MAAM,kBAAkBA,CAAI,EAAE;AAE1C,IAAAlB,EAAakB,CAAI,GACjBhB,EAAOgB,CAAI;AAAA;AACb;AAEO,SAASC,EAAyBC,GAAgC;AACvE,SAAAtB,EAAU,IAAIsB,CAAQ,GACf,MAAM;AACX,IAAAtB,EAAU,OAAOsB,CAAQ;AAAA,EAC3B;AACF;AAGO,SAASC,IAA6C;AAC3D,MAAI,OAAO,SAAW,IAAa,QAAO;;AAC1C,QAAMC,IAAY,CAACC,MAAqB;AACtC,IAAIA,EAAG,gBAAgB,kBACnBA,EAAG,QAAQ5B,KACfO,EAAO,OAAOqB,EAAG,YAAY,EAAE,EAAE,MAAM;AAAA,EACzC;AACA,gBAAO,iBAAiB,WAAWD,CAAS,GACrC,MAAM,OAAO,oBAAoB,WAAWA,CAAS;AAC9D;AAEO,SAASE,EACdhB,GACAM,GACyB;AACzB,QAAMW,IAAgBZ,EAAmBC,CAAc,GACjDY,IAAMlB,EAAK,KAAK,CAACmB,MAAMA,EAAE,WAAWF,CAAa;AACvD,MAAIC;AACF,WAAO;AAAA,MACL,eAAeA,EAAI;AAAA,MACnB,sBAAsBA,EAAI;AAAA,MAC1B,sBAAsBA,EAAI;AAAA,IAAA;AAG9B,QAAME,IAAKpB,EAAK,KAAK,CAACmB,MAAMA,EAAE,WAAWb,CAAc,KAAKN,EAAK,CAAC;AAClE,SAAO;AAAA,IACL,gBAAeoB,KAAA,gBAAAA,EAAI,WAAUd;AAAA,IAC7B,uBAAsBc,KAAA,gBAAAA,EAAI,kBAAiBd;AAAA,IAC3C,uBAAsBc,KAAA,gBAAAA,EAAI,SAAQd;AAAA,EAAA;AAEtC;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useState as p, useEffect as g } from "react";
|
|
2
|
+
import { getMsgCenterAppKey as t, subscribeMsgCenterAppKey as i, bindMsgCenterAppKeyStorageSync as c } from "./msgCenterAppSwitch.js";
|
|
3
|
+
function C(e) {
|
|
4
|
+
const [r, n] = p(() => t(e));
|
|
5
|
+
return g(() => {
|
|
6
|
+
n(t(e));
|
|
7
|
+
const s = i((u) => {
|
|
8
|
+
n(u || t(e));
|
|
9
|
+
}), o = c();
|
|
10
|
+
return () => {
|
|
11
|
+
s(), o();
|
|
12
|
+
};
|
|
13
|
+
}, [e]), r;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
C as useMsgCenterAppKey
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useMsgCenterAppKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMsgCenterAppKey.js","sources":["../../../../src/components/Tools/MessageCenter/useMsgCenterAppKey.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport {\n getMsgCenterAppKey,\n subscribeMsgCenterAppKey,\n bindMsgCenterAppKeyStorageSync,\n} from './msgCenterAppSwitch';\n\n/** 订阅当前消息中心 appKey(Hub 切换后触发重渲染) */\nexport function useMsgCenterAppKey(fallbackAppKey: string): string {\n const [appKey, setAppKey] = useState(() => getMsgCenterAppKey(fallbackAppKey));\n\n useEffect(() => {\n setAppKey(getMsgCenterAppKey(fallbackAppKey));\n const unsub = subscribeMsgCenterAppKey((next) => {\n setAppKey(next || getMsgCenterAppKey(fallbackAppKey));\n });\n const unbind = bindMsgCenterAppKeyStorageSync();\n return () => {\n unsub();\n unbind();\n };\n }, [fallbackAppKey]);\n\n return appKey;\n}\n"],"names":["useMsgCenterAppKey","fallbackAppKey","appKey","setAppKey","useState","getMsgCenterAppKey","useEffect","unsub","subscribeMsgCenterAppKey","next","unbind","bindMsgCenterAppKeyStorageSync"],"mappings":";;AAQO,SAASA,EAAmBC,GAAgC;AACjE,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,MAAMC,EAAmBJ,CAAc,CAAC;AAE7E,SAAAK,EAAU,MAAM;AACd,IAAAH,EAAUE,EAAmBJ,CAAc,CAAC;AAC5C,UAAMM,IAAQC,EAAyB,CAACC,MAAS;AAC/C,MAAAN,EAAUM,KAAQJ,EAAmBJ,CAAc,CAAC;AAAA,IACtD,CAAC,GACKS,IAASC,EAAA;AACf,WAAO,MAAM;AACX,MAAAJ,EAAA,GACAG,EAAA;AAAA,IACF;AAAA,EACF,GAAG,CAACT,CAAc,CAAC,GAEZC;AACT;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MessageAudienceUserOption } from '../MessageTemplateAdmin/types';
|
|
2
|
+
export type AudienceUserSelectOption = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
/** 副文案:角色 · 工号 */
|
|
6
|
+
description?: string;
|
|
7
|
+
/** 搜索用拼接串 */
|
|
8
|
+
searchText: string;
|
|
9
|
+
};
|
|
10
|
+
export type AudienceUserSelectGroup = {
|
|
11
|
+
label: string;
|
|
12
|
+
title: string;
|
|
13
|
+
options: AudienceUserSelectOption[];
|
|
14
|
+
};
|
|
15
|
+
/** 按部门 OptGroup;组内按展示名排序。禁 FE 造中文平行表,部门名取自 SSO orgs。 */
|
|
16
|
+
export declare function buildAudienceUserSelectGroups(users: MessageAudienceUserOption[]): AudienceUserSelectGroup[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const c = "未分配部门";
|
|
2
|
+
function p(i) {
|
|
3
|
+
const n = [], s = String(i.roleNames || "").trim(), e = String(i.employeeId || "").trim();
|
|
4
|
+
return s && n.push(s), e && n.push(`工号 ${e}`), n.join(" · ");
|
|
5
|
+
}
|
|
6
|
+
function a(i) {
|
|
7
|
+
const n = /* @__PURE__ */ new Map();
|
|
8
|
+
for (const e of i) {
|
|
9
|
+
if (!(e != null && e.id)) continue;
|
|
10
|
+
const o = String(e.departmentName || "").trim() || c, t = n.get(o);
|
|
11
|
+
t ? t.push(e) : n.set(o, [e]);
|
|
12
|
+
}
|
|
13
|
+
return [...n.keys()].sort((e, o) => e === c ? 1 : o === c ? -1 : e.localeCompare(o, "zh-CN")).map((e) => {
|
|
14
|
+
const o = (n.get(e) || []).slice().sort((t, r) => String(t.name || t.id).localeCompare(String(r.name || r.id), "zh-CN"));
|
|
15
|
+
return {
|
|
16
|
+
label: e,
|
|
17
|
+
title: e,
|
|
18
|
+
options: o.map((t) => {
|
|
19
|
+
const r = p(t), l = String(t.name || t.id);
|
|
20
|
+
return {
|
|
21
|
+
value: t.id,
|
|
22
|
+
label: l,
|
|
23
|
+
description: r || void 0,
|
|
24
|
+
searchText: [l, r, e, t.employeeId, t.roleNames].filter(Boolean).join(" ")
|
|
25
|
+
};
|
|
26
|
+
})
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
a as buildAudienceUserSelectGroups
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=audienceUserSelectOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audienceUserSelectOptions.js","sources":["../../../../../src/components/Tools/MessageCenter/utils/audienceUserSelectOptions.ts"],"sourcesContent":["import type { MessageAudienceUserOption } from '../MessageTemplateAdmin/types';\n\nconst UNASSIGNED_DEPT = '未分配部门';\n\nexport type AudienceUserSelectOption = {\n value: string;\n label: string;\n /** 副文案:角色 · 工号 */\n description?: string;\n /** 搜索用拼接串 */\n searchText: string;\n};\n\nexport type AudienceUserSelectGroup = {\n label: string;\n title: string;\n options: AudienceUserSelectOption[];\n};\n\nfunction optionDescription(u: MessageAudienceUserOption): string {\n const parts: string[] = [];\n const roles = String(u.roleNames || '').trim();\n const emp = String(u.employeeId || '').trim();\n if (roles) parts.push(roles);\n if (emp) parts.push(`工号 ${emp}`);\n return parts.join(' · ');\n}\n\n/** 按部门 OptGroup;组内按展示名排序。禁 FE 造中文平行表,部门名取自 SSO orgs。 */\nexport function buildAudienceUserSelectGroups(\n users: MessageAudienceUserOption[],\n): AudienceUserSelectGroup[] {\n const byDept = new Map<string, MessageAudienceUserOption[]>();\n for (const u of users) {\n if (!u?.id) continue;\n const dept = String(u.departmentName || '').trim() || UNASSIGNED_DEPT;\n const bucket = byDept.get(dept);\n if (bucket) bucket.push(u);\n else byDept.set(dept, [u]);\n }\n const deptNames = [...byDept.keys()].sort((a, b) => {\n if (a === UNASSIGNED_DEPT) return 1;\n if (b === UNASSIGNED_DEPT) return -1;\n return a.localeCompare(b, 'zh-CN');\n });\n return deptNames.map((dept) => {\n const list = (byDept.get(dept) || [])\n .slice()\n .sort((a, b) => String(a.name || a.id).localeCompare(String(b.name || b.id), 'zh-CN'));\n return {\n label: dept,\n title: dept,\n options: list.map((u) => {\n const description = optionDescription(u);\n const label = String(u.name || u.id);\n return {\n value: u.id,\n label,\n description: description || undefined,\n searchText: [label, description, dept, u.employeeId, u.roleNames]\n .filter(Boolean)\n .join(' '),\n };\n }),\n };\n });\n}\n"],"names":["UNASSIGNED_DEPT","optionDescription","u","parts","roles","emp","buildAudienceUserSelectGroups","users","byDept","dept","bucket","a","b","list","description","label"],"mappings":"AAEA,MAAMA,IAAkB;AAiBxB,SAASC,EAAkBC,GAAsC;AAC/D,QAAMC,IAAkB,CAAA,GAClBC,IAAQ,OAAOF,EAAE,aAAa,EAAE,EAAE,KAAA,GAClCG,IAAM,OAAOH,EAAE,cAAc,EAAE,EAAE,KAAA;AACvC,SAAIE,KAAOD,EAAM,KAAKC,CAAK,GACvBC,KAAKF,EAAM,KAAK,MAAME,CAAG,EAAE,GACxBF,EAAM,KAAK,KAAK;AACzB;AAGO,SAASG,EACdC,GAC2B;AAC3B,QAAMC,wBAAa,IAAA;AACnB,aAAWN,KAAKK,GAAO;AACrB,QAAI,EAACL,KAAA,QAAAA,EAAG,IAAI;AACZ,UAAMO,IAAO,OAAOP,EAAE,kBAAkB,EAAE,EAAE,UAAUF,GAChDU,IAASF,EAAO,IAAIC,CAAI;AAC9B,IAAIC,IAAQA,EAAO,KAAKR,CAAC,IACpBM,EAAO,IAAIC,GAAM,CAACP,CAAC,CAAC;AAAA,EAC3B;AAMA,SALkB,CAAC,GAAGM,EAAO,KAAA,CAAM,EAAE,KAAK,CAACG,GAAGC,MACxCD,MAAMX,IAAwB,IAC9BY,MAAMZ,IAAwB,KAC3BW,EAAE,cAAcC,GAAG,OAAO,CAClC,EACgB,IAAI,CAACH,MAAS;AAC7B,UAAMI,KAAQL,EAAO,IAAIC,CAAI,KAAK,IAC/B,QACA,KAAK,CAACE,GAAGC,MAAM,OAAOD,EAAE,QAAQA,EAAE,EAAE,EAAE,cAAc,OAAOC,EAAE,QAAQA,EAAE,EAAE,GAAG,OAAO,CAAC;AACvF,WAAO;AAAA,MACL,OAAOH;AAAA,MACP,OAAOA;AAAA,MACP,SAASI,EAAK,IAAI,CAACX,MAAM;AACvB,cAAMY,IAAcb,EAAkBC,CAAC,GACjCa,IAAQ,OAAOb,EAAE,QAAQA,EAAE,EAAE;AACnC,eAAO;AAAA,UACL,OAAOA,EAAE;AAAA,UACT,OAAAa;AAAA,UACA,aAAaD,KAAe;AAAA,UAC5B,YAAY,CAACC,GAAOD,GAAaL,GAAMP,EAAE,YAAYA,EAAE,SAAS,EAC7D,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,QAAA;AAAA,MAEf,CAAC;AAAA,IAAA;AAAA,EAEL,CAAC;AACH;"}
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
return `${
|
|
1
|
+
function l(t = "MEQ") {
|
|
2
|
+
const e = /* @__PURE__ */ new Date(), a = e.getFullYear(), o = String(e.getMonth() + 1).padStart(2, "0"), r = String(e.getDate()).padStart(2, "0"), n = String(Math.floor(1e4 + Math.random() * 9e4));
|
|
3
|
+
return `${t}${a}${o}${r}${n}`;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
return String(
|
|
5
|
+
function c(t) {
|
|
6
|
+
return String(t || "").replace(/\{\{(\w+)\}\}/g, "\0$1\0").replace(/\{(\w+)\}/g, "{{$1}}").replace(/\u0000(\w+)\u0000/g, "{{$1}}");
|
|
7
7
|
}
|
|
8
|
-
function g(
|
|
9
|
-
return
|
|
10
|
-
const
|
|
11
|
-
return
|
|
8
|
+
function g(t, e) {
|
|
9
|
+
return c(t).replace(/\{\{(\w+)\}\}/g, (o, r) => {
|
|
10
|
+
const n = e[r];
|
|
11
|
+
return n == null ? `{{${r}}}` : String(n);
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
-
function o(e) {
|
|
15
|
-
return String(e || "").replace(/<br\s*\/?>/gi, `
|
|
16
|
-
`).replace(/<\/p>/gi, `
|
|
17
|
-
`).replace(/<[^>]+>/g, "").replace(/ /g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").trim();
|
|
18
|
-
}
|
|
19
14
|
export {
|
|
20
15
|
g as applyTemplateVars,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
o as stripHtmlToText
|
|
16
|
+
l as generateTemplateCode,
|
|
17
|
+
c as normalizeTemplatePlaceholders
|
|
24
18
|
};
|
|
25
19
|
//# sourceMappingURL=templateCode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateCode.js","sources":["../../../../../src/components/Tools/MessageCenter/utils/templateCode.ts"],"sourcesContent":["/** 模板编号:MEQ + yyyyMMdd + 5 位随机数(对齐 EAM createBlankTemplate) */\nexport function generateTemplateCode(prefix = 'MEQ'): string {\n const now = new Date();\n const y = now.getFullYear();\n const m = String(now.getMonth() + 1).padStart(2, '0');\n const d = String(now.getDate()).padStart(2, '0');\n const rand = String(Math.floor(10000 + Math.random() * 90000));\n return `${prefix}${y}${m}${d}${rand}`;\n}\n\n/**\n * 占位符统一 `{{var}}`;兼容读入旧 `{var}`(不把已是双括号的再包一层)。\n */\nexport function normalizeTemplatePlaceholders(text: string): string {\n return String(text || '')\n .replace(/\\{\\{(\\w+)\\}\\}/g, '\\u0000$1\\u0000')\n .replace(/\\{(\\w+)\\}/g, '{{$1}}')\n .replace(/\\u0000(\\w+)\\u0000/g, '{{$1}}');\n}\n\nexport function applyTemplateVars(\n text: string,\n vars: Record<string, string | number | undefined>,\n): string {\n const src = normalizeTemplatePlaceholders(text);\n return src.replace(/\\{\\{(\\w+)\\}\\}/g, (_, key: string) => {\n const v = vars[key];\n return v === undefined || v === null ? `{{${key}}}` : String(v);\n });\n}\n\nexport function stripHtmlToText(html: string): string {\n return String(html || '')\n .replace(/<br\\s*\\/?>/gi, '\\n')\n .replace(/<\\/p>/gi, '\\n')\n .replace(/<[^>]+>/g, '')\n .replace(/ /g, ' ')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/&/g, '&')\n .trim();\n}\n"],"names":["generateTemplateCode","prefix","now","y","m","d","rand","normalizeTemplatePlaceholders","text","applyTemplateVars","vars","_","key","v"
|
|
1
|
+
{"version":3,"file":"templateCode.js","sources":["../../../../../src/components/Tools/MessageCenter/utils/templateCode.ts"],"sourcesContent":["/** 模板编号:MEQ + yyyyMMdd + 5 位随机数(对齐 EAM createBlankTemplate) */\nexport function generateTemplateCode(prefix = 'MEQ'): string {\n const now = new Date();\n const y = now.getFullYear();\n const m = String(now.getMonth() + 1).padStart(2, '0');\n const d = String(now.getDate()).padStart(2, '0');\n const rand = String(Math.floor(10000 + Math.random() * 90000));\n return `${prefix}${y}${m}${d}${rand}`;\n}\n\n/**\n * 占位符统一 `{{var}}`;兼容读入旧 `{var}`(不把已是双括号的再包一层)。\n */\nexport function normalizeTemplatePlaceholders(text: string): string {\n return String(text || '')\n .replace(/\\{\\{(\\w+)\\}\\}/g, '\\u0000$1\\u0000')\n .replace(/\\{(\\w+)\\}/g, '{{$1}}')\n .replace(/\\u0000(\\w+)\\u0000/g, '{{$1}}');\n}\n\nexport function applyTemplateVars(\n text: string,\n vars: Record<string, string | number | undefined>,\n): string {\n const src = normalizeTemplatePlaceholders(text);\n return src.replace(/\\{\\{(\\w+)\\}\\}/g, (_, key: string) => {\n const v = vars[key];\n return v === undefined || v === null ? `{{${key}}}` : String(v);\n });\n}\n\nexport function stripHtmlToText(html: string): string {\n return String(html || '')\n .replace(/<br\\s*\\/?>/gi, '\\n')\n .replace(/<\\/p>/gi, '\\n')\n .replace(/<[^>]+>/g, '')\n .replace(/ /g, ' ')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/&/g, '&')\n .trim();\n}\n"],"names":["generateTemplateCode","prefix","now","y","m","d","rand","normalizeTemplatePlaceholders","text","applyTemplateVars","vars","_","key","v"],"mappings":"AACO,SAASA,EAAqBC,IAAS,OAAe;AAC3D,QAAMC,wBAAU,KAAA,GACVC,IAAID,EAAI,YAAA,GACRE,IAAI,OAAOF,EAAI,SAAA,IAAa,CAAC,EAAE,SAAS,GAAG,GAAG,GAC9CG,IAAI,OAAOH,EAAI,QAAA,CAAS,EAAE,SAAS,GAAG,GAAG,GACzCI,IAAO,OAAO,KAAK,MAAM,MAAQ,KAAK,WAAW,GAAK,CAAC;AAC7D,SAAO,GAAGL,CAAM,GAAGE,CAAC,GAAGC,CAAC,GAAGC,CAAC,GAAGC,CAAI;AACrC;AAKO,SAASC,EAA8BC,GAAsB;AAClE,SAAO,OAAOA,KAAQ,EAAE,EACrB,QAAQ,kBAAkB,QAAgB,EAC1C,QAAQ,cAAc,QAAQ,EAC9B,QAAQ,sBAAsB,QAAQ;AAC3C;AAEO,SAASC,EACdD,GACAE,GACQ;AAER,SADYH,EAA8BC,CAAI,EACnC,QAAQ,kBAAkB,CAACG,GAAGC,MAAgB;AACvD,UAAMC,IAAIH,EAAKE,CAAG;AAClB,WAA0BC,KAAM,OAAO,KAAKD,CAAG,OAAO,OAAOC,CAAC;AAAA,EAChE,CAAC;AACH;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { InboxBell } from './Inbox';
|
|
2
2
|
export type { InboxBellItem, InboxBellListResult, InboxBellListParams, InboxBellProps, InboxBellMessageType, } from './Inbox';
|
|
3
3
|
export { MessageTemplateAdmin } from './MessageCenter';
|
|
4
|
-
export type { MessageTemplateAdminProps, MessageTemplateAdminItem, MessageEventCatalogItem, MessageEventCatalogPayload, MessageAudienceRoleOption, MessageTemplateVariable, MessageTemplateVariableAdmin, PushRuleAdminItem, MessageCrudFlags, MessageAdminPermissions, } from './MessageCenter';
|
|
5
|
-
export { generateTemplateCode, normalizeTemplatePlaceholders, applyTemplateVars, resolveMessageAdminPermissions, } from './MessageCenter';
|
|
4
|
+
export type { MessageTemplateAdminProps, MessageTemplateAdminItem, MessageEventCatalogItem, MessageEventCatalogPayload, MessageAudienceRoleOption, MessageAudienceUserOption, MessageTemplateVariable, MessageTemplateVariableAdmin, PushRuleAdminItem, MessageCrudFlags, MessageAdminPermissions, } from './MessageCenter';
|
|
5
|
+
export { generateTemplateCode, normalizeTemplatePlaceholders, applyTemplateVars, resolveMessageAdminPermissions, MSG_CENTER_APP_SWITCH_STORAGE_KEY, SYSTEM_APP_TO_MSG_CENTER_APP_KEY, MSG_CENTER_SWITCHABLE_APP_KEYS, msgCenterAppKeyFromSystemAppCode, filterMsgCenterSwitchableApps, getMsgCenterAppKey, setMsgCenterAppKey, subscribeMsgCenterAppKey, bindMsgCenterAppKeyStorageSync, resolveMsgCenterSwitchState, useMsgCenterAppKey, MsgCenterAppSwitcher, } from './MessageCenter';
|
|
6
|
+
export type { MsgCenterAppSwitchState, MsgCenterSwitchableApp, MsgCenterSwitchableAppKey, MsgCenterAppSwitcherProps, } from './MessageCenter';
|