性能优化
This commit is contained in:
@@ -162,6 +162,12 @@ const LinkTagExtension = Node.create({
|
||||
})
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function escapeHtml(s: string): string {
|
||||
const div = document.createElement('div')
|
||||
div.textContent = s
|
||||
return div.innerHTML
|
||||
}
|
||||
|
||||
const MentionSuggestion = (persons: PersonItem[]): any => ({
|
||||
items: ({ query }: { query: string }) =>
|
||||
persons.filter(p => p.name.toLowerCase().includes(query.toLowerCase()) || p.id.includes(query)).slice(0, 8),
|
||||
@@ -176,8 +182,8 @@ const MentionSuggestion = (persons: PersonItem[]): any => ({
|
||||
if (!popup) return
|
||||
popup.innerHTML = items.map((item, i) =>
|
||||
`<div class="mention-item ${i === selectedIndex ? 'is-selected' : ''}" data-index="${i}">
|
||||
<span class="mention-name">@${item.name}</span>
|
||||
<span class="mention-id">${item.label || item.id}</span>
|
||||
<span class="mention-name">@${escapeHtml(item.name)}</span>
|
||||
<span class="mention-id">${escapeHtml(item.label || item.id)}</span>
|
||||
</div>`
|
||||
).join('')
|
||||
popup.querySelectorAll('.mention-item').forEach(el => {
|
||||
|
||||
@@ -189,7 +189,7 @@ export function UserDetailModal({
|
||||
// 行为轨迹(用户旅程)
|
||||
try {
|
||||
const trackData = await get<{ success?: boolean; tracks?: UserTrack[] }>(
|
||||
`/api/user/track?userId=${encodeURIComponent(userId)}&limit=50`,
|
||||
`/api/admin/user/track?userId=${encodeURIComponent(userId)}&limit=50`,
|
||||
)
|
||||
if (trackData?.success && trackData.tracks) setTracks(trackData.tracks)
|
||||
} catch { setTracks([]) }
|
||||
|
||||
Reference in New Issue
Block a user