Skip to content
This repository was archived by the owner on Jul 17, 2026. It is now read-only.

Commit 97c6439

Browse files
committed
refactor(setting): 重命名排除歌词和评论相关字段
起码好点了 不是吗.jpg
1 parent 90afc47 commit 97c6439

4 files changed

Lines changed: 50 additions & 31 deletions

File tree

src/components/Modal/Setting/ExcludeLyrics.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ const emit = defineEmits(["close"]);
115115
const settingStore = useSettingStore();
116116
117117
const enableExcludeLyrics = ref(settingStore.enableExcludeLyrics);
118-
const enableExcludeTTML = ref(settingStore.enableExcludeTTML);
119-
const enableExcludeLocalLyrics = ref(settingStore.enableExcludeLocalLyrics);
118+
const enableExcludeTTML = ref(settingStore.enableExcludeLyricsTTML);
119+
const enableExcludeLocalLyrics = ref(settingStore.enableExcludeLyricsLocal);
120120
121121
const filterKeywords = ref<string[]>([]);
122122
const filterRegexes = ref<string[]>([]);
@@ -141,8 +141,8 @@ const clearAll = () => {
141141
// 导出规则
142142
const exportFilters = () => {
143143
const data = {
144-
keywords: settingStore.excludeUserKeywords || [],
145-
regexes: settingStore.excludeUserRegexes || [],
144+
keywords: settingStore.excludeLyricsUserKeywords || [],
145+
regexes: settingStore.excludeLyricsUserRegexes || [],
146146
};
147147
const blob = new Blob([JSON.stringify(data, null, 2)], { type: "application/json" });
148148
const url = URL.createObjectURL(blob);
@@ -185,10 +185,10 @@ const importFilters = () => {
185185
// 保存过滤
186186
const saveFilter = () => {
187187
settingStore.enableExcludeLyrics = enableExcludeLyrics.value;
188-
settingStore.enableExcludeTTML = enableExcludeTTML.value;
189-
settingStore.enableExcludeLocalLyrics = enableExcludeLocalLyrics.value;
190-
settingStore.excludeUserKeywords = filterKeywords.value;
191-
settingStore.excludeUserRegexes = filterRegexes.value;
188+
settingStore.enableExcludeLyricsTTML = enableExcludeTTML.value;
189+
settingStore.enableExcludeLyricsLocal = enableExcludeLocalLyrics.value;
190+
settingStore.excludeLyricsUserKeywords = filterKeywords.value;
191+
settingStore.excludeLyricsUserRegexes = filterRegexes.value;
192192
window.$message.success("设置已保存");
193193
handleClose();
194194
};
@@ -199,10 +199,10 @@ const handleClose = () => {
199199
200200
onMounted(() => {
201201
enableExcludeLyrics.value = settingStore.enableExcludeLyrics;
202-
enableExcludeTTML.value = settingStore.enableExcludeTTML;
203-
enableExcludeLocalLyrics.value = settingStore.enableExcludeLocalLyrics;
204-
filterKeywords.value = [...(settingStore.excludeUserKeywords || [])];
205-
filterRegexes.value = [...(settingStore.excludeUserRegexes || [])];
202+
enableExcludeTTML.value = settingStore.enableExcludeLyricsTTML;
203+
enableExcludeLocalLyrics.value = settingStore.enableExcludeLyricsLocal;
204+
filterKeywords.value = [...(settingStore.excludeLyricsUserKeywords || [])];
205+
filterRegexes.value = [...(settingStore.excludeLyricsUserRegexes || [])];
206206
});
207207
</script>
208208

src/core/player/LyricManager.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,14 @@ class LyricManager {
583583
const statusStore = useStatusStore();
584584
const musicStore = useMusicStore();
585585

586-
const { enableExcludeLyrics, excludeUserKeywords, excludeUserRegexes } = settingStore;
586+
const { enableExcludeLyrics, excludeLyricsUserKeywords, excludeLyricsUserRegexes } =
587+
settingStore;
587588

588589
if (!enableExcludeLyrics) return lyricData;
589590

590591
// 合并默认规则和用户自定义规则
591-
const mergedKeywords = [...new Set([...defaultKeywords, ...(excludeUserKeywords ?? [])])];
592-
const mergedRegexes = [...new Set([...defaultRegexes, ...(excludeUserRegexes ?? [])])];
592+
const mergedKeywords = [...new Set([...defaultKeywords, ...(excludeLyricsUserKeywords ?? [])])];
593+
const mergedRegexes = [...new Set([...defaultRegexes, ...(excludeLyricsUserRegexes ?? [])])];
593594

594595
const { name, artists } = musicStore.playSong;
595596
const songMetadataRegexes: string[] = [];
@@ -622,7 +623,7 @@ class LyricManager {
622623
const lrcData = stripLyricMetadata(lyricData.lrcData || [], options);
623624
let yrcData = lyricData.yrcData || [];
624625

625-
if (!statusStore.usingTTMLLyric || settingStore.enableExcludeTTML) {
626+
if (!statusStore.usingTTMLLyric || settingStore.enableExcludeLyricsTTML) {
626627
yrcData = stripLyricMetadata(yrcData, options);
627628
}
628629

@@ -836,14 +837,14 @@ class LyricManager {
836837
// 进行本地歌词对齐
837838
lyricData = this.alignLocalLyrics(lyricData);
838839
// 排除本地歌词内容
839-
if (settingStore.enableExcludeLocalLyrics) {
840+
if (settingStore.enableExcludeLyricsLocal) {
840841
lyricData = this.handleLyricExclude(lyricData);
841842
}
842843
lyricData = await this.applyChineseVariant(lyricData);
843844
} else if (song.path) {
844845
lyricData = await this.handleLocalLyric(song.path);
845846
// 排除本地歌词内容
846-
if (settingStore.enableExcludeLocalLyrics) {
847+
if (settingStore.enableExcludeLyricsLocal) {
847848
lyricData = this.handleLyricExclude(lyricData);
848849
}
849850
} else {

src/stores/migrations/settingMigrations.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { SettingState } from "../setting";
66
/**
77
* 当前设置 Schema 版本号
88
*/
9-
export const CURRENT_SETTING_SCHEMA_VERSION = 7;
9+
export const CURRENT_SETTING_SCHEMA_VERSION = 8;
1010

1111
/**
1212
* 迁移函数类型
@@ -73,9 +73,10 @@ export const settingMigrations: Record<number, MigrationFunction> = {
7373
}
7474

7575
return {
76+
// 这些字段在 Schema Version 8 时被重命名,导致类型检查报错
7677
excludeUserKeywords: userKeywords,
7778
excludeUserRegexes: userRegexes,
78-
};
79+
} as Partial<SettingState>;
7980
},
8081
6: (state) => {
8182
interface OldSettingState extends Partial<SettingState> {
@@ -149,4 +150,21 @@ export const settingMigrations: Record<number, MigrationFunction> = {
149150

150151
return {};
151152
},
153+
8: (state) => {
154+
interface OldSettingState extends Partial<SettingState> {
155+
enableExcludeTTML?: boolean;
156+
enableExcludeLocalLyrics?: boolean;
157+
excludeUserKeywords?: string[];
158+
excludeUserRegexes?: string[];
159+
}
160+
161+
const oldState = state as OldSettingState;
162+
163+
return {
164+
enableExcludeLyricsTTML: oldState.enableExcludeTTML,
165+
enableExcludeLyricsLocal: oldState.enableExcludeLocalLyrics,
166+
excludeLyricsUserKeywords: oldState.excludeUserKeywords,
167+
excludeLyricsUserRegexes: oldState.excludeUserRegexes,
168+
};
169+
},
152170
};

src/stores/setting.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,18 +229,18 @@ export interface SettingState {
229229
dynamicCover: boolean;
230230
/** 是否使用 keep-alive */
231231
useKeepAlive: boolean;
232-
/** 是否启用评论排除 */
233-
enableExcludeComments: boolean;
234232
/** 是否启用排除歌词 */
235233
enableExcludeLyrics: boolean;
236234
/** 「排除歌词」是否适用于 TTML */
237-
enableExcludeTTML: boolean;
235+
enableExcludeLyricsTTML: boolean;
238236
/** 「排除歌词」是否适用于本地歌词 */
239-
enableExcludeLocalLyrics: boolean;
237+
enableExcludeLyricsLocal: boolean;
240238
/** 用户自定义的排除歌词关键字 */
241-
excludeUserKeywords: string[];
239+
excludeLyricsUserKeywords: string[];
242240
/** 用户自定义的排除歌词正则表达式 */
243-
excludeUserRegexes: string[];
241+
excludeLyricsUserRegexes: string[];
242+
/** 是否启用评论排除 */
243+
enableExcludeComments: boolean;
244244
/** 排除评论关键词 */
245245
excludeCommentKeywords: string[];
246246
/** 排除评论正则表达式 */
@@ -431,12 +431,12 @@ export const useSettingStore = defineStore("setting", {
431431
lyricHorizontalOffset: 10,
432432
lyricAlignRight: false,
433433
hideLyricBrackets: false,
434-
enableExcludeComments: false,
435434
enableExcludeLyrics: true,
436-
enableExcludeTTML: false,
437-
enableExcludeLocalLyrics: false,
438-
excludeUserKeywords: [],
439-
excludeUserRegexes: [],
435+
enableExcludeLyricsTTML: false,
436+
enableExcludeLyricsLocal: false,
437+
excludeLyricsUserKeywords: [],
438+
excludeLyricsUserRegexes: [],
439+
enableExcludeComments: false,
440440
excludeCommentKeywords: [],
441441
excludeCommentRegexes: [],
442442
localFilesPath: [],

0 commit comments

Comments
 (0)