mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 16:15:44 +00:00
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:
parent
50146dc8c3
commit
66e0f02216
@ -140,7 +140,7 @@ const InnerInbox = (props) => {
|
|||||||
<Button
|
<Button
|
||||||
className={styles.button}
|
className={styles.button}
|
||||||
title={t('Message')}
|
title={t('Message')}
|
||||||
icon={<Icon type={'MailOutlined'} />}
|
icon={<Icon type={'BellOutlined'} />}
|
||||||
onClick={onIconClick}
|
onClick={onIconClick}
|
||||||
/>
|
/>
|
||||||
</Badge>
|
</Badge>
|
||||||
|
@ -9,25 +9,26 @@
|
|||||||
|
|
||||||
import { Handlebars } from '@nocobase/utils';
|
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> {
|
export function compile(template: Record<string, any>, data: Record<string, any>): Record<string, any> {
|
||||||
if (!template) {
|
if (!template) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const result = Object.keys(template).reduce((object, key) => {
|
return deepCompile(template, data);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user