Fix: Display bug in the early stage of conversation chat #7904 (#7922)

### What problem does this PR solve?

Fix: Display bug in the early stage of conversation chat #7904

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2025-05-28 19:42:56 +08:00
committed by GitHub
parent b95747be4c
commit 7c098f9fd1

View File

@ -43,10 +43,17 @@ export const buildMessageItemReference = (
};
const oldReg = /(#{2}\d+\${2})/g;
const currentReg = /\[ID:(\d+)\]/g;
function transformReg(substring: string) {
return `~~${substring.slice(4, -1)}==`;
}
// To be compatible with the old index matching mode
export const replaceTextByOldReg = (text: string) => {
return text?.replace(oldReg, function (substring) {
return `~~${substring.slice(2, -2)}==`;
});
return text
?.replace(currentReg, transformReg)
.replace(oldReg, (substring: string) => {
return `~~${substring.slice(2, -2)}==`;
});
};