fix: highlight keywords in logs (#405)

This commit is contained in:
Fine0830 2024-07-30 10:39:18 +08:00 committed by GitHub
parent 8f179f00a2
commit 4e00073ec2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 4 deletions

View File

@ -53,9 +53,6 @@ export const logStore = defineStore({
setLogCondition(data: Recordable) { setLogCondition(data: Recordable) {
this.conditions = { ...this.conditions, ...data }; this.conditions = { ...this.conditions, ...data };
}, },
getLogKeywords() {
return this.conditions.keywordsOfContent;
},
resetState() { resetState() {
this.logs = []; this.logs = [];
this.conditions = { this.conditions = {

View File

@ -61,7 +61,7 @@ limitations under the License. -->
return (props.data.tags.find((d: { key: string; value: string }) => d.key === "level") || {}).value || ""; return (props.data.tags.find((d: { key: string; value: string }) => d.key === "level") || {}).value || "";
}); });
const highlightKeywords = (data: string) => { const highlightKeywords = (data: string) => {
const keywords = Object.values(logStore.getLogKeywords()); const keywords = Object.values(logStore.conditions.keywordsOfContent || {});
const regex = new RegExp(keywords.join("|"), "gi"); const regex = new RegExp(keywords.join("|"), "gi");
return data.replace(regex, (match) => `<span style="color: red">${match}</span>`); return data.replace(regex, (match) => `<span style="color: red">${match}</span>`);
}; };