fix: 精油编辑统一保存到 DB + 导出 Excel 增加功效列
Some checks failed
Test / unit-test (push) Successful in 7s
Test / build-check (push) Successful in 4s
PR Preview / teardown-preview (pull_request) Has been skipped
Test / e2e-test (push) Failing after 1m12s
PR Preview / test (pull_request) Successful in 7s
PR Preview / deploy-preview (pull_request) Successful in 19s
Some checks failed
Test / unit-test (push) Successful in 7s
Test / build-check (push) Successful in 4s
PR Preview / teardown-preview (pull_request) Has been skipped
Test / e2e-test (push) Failing after 1m12s
PR Preview / test (pull_request) Successful in 7s
PR Preview / deploy-preview (pull_request) Successful in 19s
- 新增 oil_cards 表,持久化知识卡片(功效/用法/方法/注意/emoji) - POST /api/oils 扩展接受 card_* 字段,在同一事务里 upsert oil_cards - GET /api/oil-cards 返回全部卡片 - 前端 getOilCard 优先查 DB,再 fallback 静态表 - saveEditOil 统一走 saveOil,不再分两套保存 - 精油价目 Excel 导出增加「功效」列 - 首次部署自动从静态 OIL_CARDS 播种到 oil_cards 表 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ export const VOLUME_DROPS = {
|
||||
export const useOilsStore = defineStore('oils', () => {
|
||||
const oils = ref({})
|
||||
const oilsMeta = ref({})
|
||||
const oilCards = ref({})
|
||||
|
||||
// Getters
|
||||
const oilNames = computed(() =>
|
||||
@@ -79,9 +80,28 @@ export const useOilsStore = defineStore('oils', () => {
|
||||
}
|
||||
oils.value = newOils
|
||||
oilsMeta.value = newMeta
|
||||
|
||||
// Also fetch oil cards from DB
|
||||
try {
|
||||
const cards = await api.get('/api/oil-cards')
|
||||
const newCards = {}
|
||||
for (const card of cards) {
|
||||
newCards[card.name] = {
|
||||
emoji: card.emoji || '',
|
||||
en: card.en || '',
|
||||
effects: card.effects || '',
|
||||
usage: card.usage || '',
|
||||
method: card.method || '',
|
||||
caution: card.caution || '',
|
||||
}
|
||||
}
|
||||
oilCards.value = newCards
|
||||
} catch {
|
||||
// oil_cards table may not exist yet on older backends
|
||||
}
|
||||
}
|
||||
|
||||
async function saveOil(name, bottlePrice, dropCount, retailPrice, enName = null, unit = null) {
|
||||
async function saveOil(name, bottlePrice, dropCount, retailPrice, enName = null, unit = null, card = null) {
|
||||
const payload = {
|
||||
name,
|
||||
bottle_price: bottlePrice,
|
||||
@@ -90,6 +110,13 @@ export const useOilsStore = defineStore('oils', () => {
|
||||
en_name: enName,
|
||||
}
|
||||
if (unit) payload.unit = unit
|
||||
if (card) {
|
||||
payload.card_emoji = card.emoji ?? null
|
||||
payload.card_effects = card.effects ?? null
|
||||
payload.card_usage = card.usage ?? null
|
||||
payload.card_method = card.method ?? null
|
||||
payload.card_caution = card.caution ?? null
|
||||
}
|
||||
await api.post('/api/oils', payload)
|
||||
await loadOils()
|
||||
}
|
||||
@@ -138,6 +165,7 @@ export const useOilsStore = defineStore('oils', () => {
|
||||
return {
|
||||
oils,
|
||||
oilsMeta,
|
||||
oilCards,
|
||||
oilNames,
|
||||
pricePerDrop,
|
||||
calcCost,
|
||||
|
||||
Reference in New Issue
Block a user