From c46aef725da4ec2e0d29381827301a46e0eee3c9 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 11 Aug 2026 19:59:30 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=AF=86=E5=88=AB=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/NameTestView.vue | 42 ++----------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/src/views/system/NameTestView.vue b/src/views/system/NameTestView.vue index ef42f2c1..4d9132ed 100644 --- a/src/views/system/NameTestView.vue +++ b/src/views/system/NameTestView.vue @@ -60,9 +60,6 @@ const MEDIA_SOURCE_ICONS: Record = { musicbrainz: { icon: 'mdi-album', color: '#eb743b' }, } -const NAME_TEST_TITLE_HISTORY_KEY = 'MP_NAME_TEST_TITLE_HISTORY' -const NAME_TEST_TITLE_HISTORY_LIMIT = 5 - const emit = defineEmits<{ close: [] }>() // 国际化 @@ -100,41 +97,6 @@ const nameTestForm = reactive({ // MusicBrainz 仅支持音乐识别,音乐不应用自定义识别词,隐藏输入区避免误导 const showCustomWords = computed(() => nameTestForm.source !== 'musicbrainz') -/** 从本地存储读取最近使用的识别标题。 */ -function loadTitleHistory() { - try { - const storedHistory: unknown = JSON.parse(localStorage.getItem(NAME_TEST_TITLE_HISTORY_KEY) || '[]') - if (!Array.isArray(storedHistory)) return [] - - return storedHistory - .filter((title): title is string => typeof title === 'string' && Boolean(title.trim())) - .map(title => title.trim()) - .filter((title, index, titles) => titles.indexOf(title) === index) - .slice(0, NAME_TEST_TITLE_HISTORY_LIMIT) - } catch { - return [] - } -} - -const nameTestTitleHistory = ref(loadTitleHistory()) - -/** 将本次提交的标题移到历史记录首位,并只保留最新五条。 */ -function saveTitleHistory(title: string) { - const normalizedTitle = title.trim() - if (!normalizedTitle) return - - nameTestTitleHistory.value = [ - normalizedTitle, - ...nameTestTitleHistory.value.filter(historyTitle => historyTitle !== normalizedTitle), - ].slice(0, NAME_TEST_TITLE_HISTORY_LIMIT) - - try { - localStorage.setItem(NAME_TEST_TITLE_HISTORY_KEY, JSON.stringify(nameTestTitleHistory.value)) - } catch { - // 本地存储不可用时仍继续执行本次识别。 - } -} - // 识别按钮状态 const nameTestLoading = ref(false) @@ -393,14 +355,14 @@ async function saveCustomWords() { -