update at 2026-02-07 14:16:46
This commit is contained in:
@@ -23,10 +23,6 @@ export const useFontStore = defineStore('font', () => {
|
||||
}
|
||||
}
|
||||
|
||||
function filterSetByValidIds(source: Set<string>, validIds: Set<string>): Set<string> {
|
||||
return new Set(Array.from(source).filter(id => validIds.has(id)))
|
||||
}
|
||||
|
||||
// 状态
|
||||
const fonts = ref<FontInfo[]>([])
|
||||
const selectedFontIds = ref<Set<string>>(new Set())
|
||||
@@ -58,23 +54,6 @@ export const useFontStore = defineStore('font', () => {
|
||||
fonts.value.push(fontInfo)
|
||||
}
|
||||
|
||||
function replaceFonts(nextFonts: FontInfo[]) {
|
||||
const validIds = new Set(nextFonts.map(font => font.id))
|
||||
|
||||
selectedFontIds.value = filterSetByValidIds(selectedFontIds.value, validIds)
|
||||
favoriteFontIds.value = filterSetByValidIds(favoriteFontIds.value, validIds)
|
||||
previewFontIds.value = filterSetByValidIds(previewFontIds.value, validIds)
|
||||
|
||||
writeSet('font.favoriteFontIds', favoriteFontIds.value)
|
||||
writeSet('font.previewFontIds', previewFontIds.value)
|
||||
|
||||
fonts.value = nextFonts.map(font => ({
|
||||
...font,
|
||||
isFavorite: favoriteFontIds.value.has(font.id),
|
||||
}))
|
||||
updateFontTree()
|
||||
}
|
||||
|
||||
function removeFont(fontId: string) {
|
||||
const index = fonts.value.findIndex(f => f.id === fontId)
|
||||
if (index !== -1) {
|
||||
@@ -250,7 +229,6 @@ export const useFontStore = defineStore('font', () => {
|
||||
|
||||
// 方法
|
||||
addFont,
|
||||
replaceFonts,
|
||||
removeFont,
|
||||
selectFont,
|
||||
unselectFont,
|
||||
|
||||
Reference in New Issue
Block a user