mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: support mention notification
This commit is contained in:
1 parent
d66c161e66
commit
ca00dda575
14 files changed
+67
-24
No files matched your search
@@ -41,11 +41,24 @@ export default connect(mapStateToProps)(class MessagePadDialogueContentContainer
|
||||
}
|
||||
|
||||
renderContent(msg) {
|
||||
// TODO: FLAG_RICHTEXT
|
||||
if (msg.from === 1) {
|
||||
// Is system message
|
||||
try {
|
||||
const data = JSON.parse(msg.content);
|
||||
return i18n(data.message, ...data.params);
|
||||
const str = i18n(data.message).replace(/\{([^{}]+)\}/g, (match, key) => `%substitude%${key}%substitude%`);
|
||||
const arr = str.split('%substitude%');
|
||||
data.params = data.params || {};
|
||||
for (let i = 1; i < arr.length; i += 2) {
|
||||
if (arr[i].endsWith(':link')) {
|
||||
const link = data.params[arr[i].split(':link')[0]];
|
||||
if (!link) continue;
|
||||
arr[i] = <a style={{ color: 'wheat' }} href={link} key={i} target="_blank" rel="noreferrer">{link}</a>;
|
||||
} else {
|
||||
arr[i] = <span style={{ color: 'wheat' }} key={i}>{data.params[arr[i]]}</span>;
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
} catch (e) { }
|
||||
return i18n(msg.content);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user