From fafe1b599718dc1b3c7451196e61dcf0b3eb8501 Mon Sep 17 00:00:00 2001 From: Zihao Xu Date: Sun, 4 Jan 2026 02:07:47 -0800 Subject: [PATCH] feat: highlight avatar names with unique colors in event panel --- web/src/components/panels/EventPanel.vue | 13 +++++- web/src/utils/eventHelper.ts | 57 ++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/web/src/components/panels/EventPanel.vue b/web/src/components/panels/EventPanel.vue index 6c622f1..f360dbc 100644 --- a/web/src/components/panels/EventPanel.vue +++ b/web/src/components/panels/EventPanel.vue @@ -2,6 +2,8 @@ import { computed, ref, watch, nextTick } from 'vue' import { useWorldStore } from '../../stores/world' import { NSelect } from 'naive-ui' +import { highlightAvatarNames, buildAvatarColorMap } from '../../utils/eventHelper' +import type { GameEvent } from '../../types/core' const worldStore = useWorldStore() const filterValue = ref('all') @@ -67,6 +69,15 @@ const emptyEventMessage = computed(() => ( function formatEventDate(event: { year: number; month: number }) { return `${event.year}年${event.month}月` } + +// 构建角色名 -> 颜色映射表。 +const avatarColorMap = computed(() => buildAvatarColorMap(worldStore.avatarList)) + +// 渲染事件内容,高亮角色名。 +function renderEventContent(event: GameEvent): string { + const text = event.content || event.text || '' + return highlightAvatarNames(text, avatarColorMap.value) +}