feat: 更多改进 #21

Merged
hera merged 6 commits from feat/more-improvements into main 2026-04-10 21:26:19 +00:00
Showing only changes of commit ac3abc3c84 - Show all commits

View File

@@ -601,15 +601,22 @@ async function applyBatchTags() {
for (const id of pubIds) {
const recipe = recipeStore.recipes.find(r => r._id === id)
if (!recipe) continue
let newTags = [...recipe.tags]
let changed = false
for (const t of tagsToAdd) {
if (!recipe.tags.includes(t)) { recipe.tags.push(t); changed = true }
if (!newTags.includes(t)) { newTags.push(t); changed = true }
}
for (const t of tagsToRemove) {
const idx = recipe.tags.indexOf(t)
if (idx >= 0) { recipe.tags.splice(idx, 1); changed = true }
const idx = newTags.indexOf(t)
if (idx >= 0) { newTags.splice(idx, 1); changed = true }
}
if (changed) {
await api(`/api/recipes/${recipe._id}`, {
method: 'PUT',
body: JSON.stringify({ tags: newTags }),
})
recipe.tags = newTags
}
if (changed) await recipeStore.saveRecipe(recipe)
}
for (const id of diaryIds) {
const d = diaryStore.userDiary.find(r => r.id === id)