fix: 下架后卡片变灰+按钮变灰,isActive存为boolean
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Failing after 1m42s

根因: oils store 存 isActive = oil.is_active ?? true
  oil.is_active=0 时 0??true=0,但检查用 ===false,0!==false

修复: isActive = oil.is_active !== 0 (true/false boolean)

UI:
- 下架后弹窗不关闭,按钮变灰显示"✓ 已下架 · 点击重新上架"
- 卡片立即变灰(oil-chip--inactive class生效)
- 重新上架后恢复正常

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 16:50:26 +00:00
parent 321b1ea585
commit e04d572f27
2 changed files with 5 additions and 4 deletions

View File

@@ -68,7 +68,7 @@ export const useOilsStore = defineStore('oils', () => {
bottlePrice: oil.bottle_price,
dropCount: oil.drop_count,
retailPrice: oil.retail_price ?? null,
isActive: oil.is_active ?? true,
isActive: oil.is_active !== 0,
enName: oil.en_name ?? null,
}
}

View File

@@ -330,9 +330,11 @@
<div style="display:flex;gap:10px;justify-content:space-between;margin-top:16px">
<button
style="padding:8px 14px;border-radius:8px;font-size:13px;cursor:pointer;font-family:inherit;border:1.5px solid #e8b4b0;background:transparent;color:#c0392b"
:style="getMeta(editingOilName)?.isActive === false
? 'padding:8px 14px;border-radius:8px;font-size:13px;cursor:pointer;font-family:inherit;border:1.5px solid #ccc;background:#f0f0f0;color:#999'
: 'padding:8px 14px;border-radius:8px;font-size:13px;cursor:pointer;font-family:inherit;border:1.5px solid #e8b4b0;background:transparent;color:#c0392b'"
@click="toggleOilActive"
>{{ getMeta(editingOilName)?.isActive === false ? '重新上架' : '下架' }}</button>
>{{ getMeta(editingOilName)?.isActive === false ? '✓ 已下架 · 点击重新上架' : '下架' }}</button>
<div style="display:flex;gap:10px">
<button class="btn-outline" @click="editingOilName = null">取消</button>
<button class="btn-primary" @click="saveEditOil">保存</button>
@@ -702,7 +704,6 @@ async function toggleOilActive() {
await oils.loadOils()
cardVersion.value++
ui.showToast(newActive ? '已重新上架' : '已下架')
editingOilName.value = null
} catch (e) {
ui.showToast('网络错误: ' + e.message)
}