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
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:
@@ -68,7 +68,7 @@ export const useOilsStore = defineStore('oils', () => {
|
|||||||
bottlePrice: oil.bottle_price,
|
bottlePrice: oil.bottle_price,
|
||||||
dropCount: oil.drop_count,
|
dropCount: oil.drop_count,
|
||||||
retailPrice: oil.retail_price ?? null,
|
retailPrice: oil.retail_price ?? null,
|
||||||
isActive: oil.is_active ?? true,
|
isActive: oil.is_active !== 0,
|
||||||
enName: oil.en_name ?? null,
|
enName: oil.en_name ?? null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -330,9 +330,11 @@
|
|||||||
|
|
||||||
<div style="display:flex;gap:10px;justify-content:space-between;margin-top:16px">
|
<div style="display:flex;gap:10px;justify-content:space-between;margin-top:16px">
|
||||||
<button
|
<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"
|
@click="toggleOilActive"
|
||||||
>{{ getMeta(editingOilName)?.isActive === false ? '重新上架' : '下架' }}</button>
|
>{{ getMeta(editingOilName)?.isActive === false ? '✓ 已下架 · 点击重新上架' : '下架' }}</button>
|
||||||
<div style="display:flex;gap:10px">
|
<div style="display:flex;gap:10px">
|
||||||
<button class="btn-outline" @click="editingOilName = null">取消</button>
|
<button class="btn-outline" @click="editingOilName = null">取消</button>
|
||||||
<button class="btn-primary" @click="saveEditOil">保存</button>
|
<button class="btn-primary" @click="saveEditOil">保存</button>
|
||||||
@@ -702,7 +704,6 @@ async function toggleOilActive() {
|
|||||||
await oils.loadOils()
|
await oils.loadOils()
|
||||||
cardVersion.value++
|
cardVersion.value++
|
||||||
ui.showToast(newActive ? '已重新上架' : '已下架')
|
ui.showToast(newActive ? '已重新上架' : '已下架')
|
||||||
editingOilName.value = null
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ui.showToast('网络错误: ' + e.message)
|
ui.showToast('网络错误: ' + e.message)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user