chore(in-app-message): update icon (#5638)

* fix(plugin-notification-manager): fix compile function bug

* fix(plugin-notification-in-app-message): update icon from MailOutlined to BellOutlined
This commit is contained in:
Sheldon Guo 2024-11-12 17:45:30 +08:00 committed by GitHub
parent 50146dc8c3
commit 66e0f02216
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 18 deletions

View File

@ -140,7 +140,7 @@ const InnerInbox = (props) => {
<Button
className={styles.button}
title={t('Message')}
icon={<Icon type={'MailOutlined'} />}
icon={<Icon type={'BellOutlined'} />}
onClick={onIconClick}
/>
</Badge>

View File

@ -9,25 +9,26 @@
import { Handlebars } from '@nocobase/utils';
function deepCompile(template: unknown, data: Record<string, any>): unknown {
if (typeof template === 'string') {
const c = Handlebars.compile(template);
return c(data);
} else if (Array.isArray(template)) {
return template.map((item) => deepCompile(item, data));
} else if (typeof template === 'object') {
const result = Object.keys(template).reduce((object, key) => {
const value = deepCompile(template[key], data);
return Object.assign(object, { [key]: value });
}, {});
return result;
} else {
return template;
}
}
export function compile(template: Record<string, any>, data: Record<string, any>): Record<string, any> {
if (!template) {
return {};
}
const result = Object.keys(template).reduce((object, key) => {
let c;
let value = object[key];
switch (typeof template[key]) {
case 'object':
value = compile(template[key], data);
break;
case 'string':
c = Handlebars.compile(template[key]);
value = c(data);
break;
default:
break;
}
return Object.assign(object, { [key]: value });
}, {});
return result;
return deepCompile(template, data);
}