diff --git a/apps/admin-web/src/components/AdminStorePackagesSection.tsx b/apps/admin-web/src/components/AdminStorePackagesSection.tsx index ae92c5d..29ed6c8 100644 --- a/apps/admin-web/src/components/AdminStorePackagesSection.tsx +++ b/apps/admin-web/src/components/AdminStorePackagesSection.tsx @@ -101,11 +101,11 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string usableTime: item.usableTime?.trim() || null, otherNotes: item.otherNotes?.trim() || null, imageUrl: imageUrls[0] ?? null, - imageUrls: imageUrls.length ? imageUrls : null, + imageUrls, sortOrder: index, }; }) - .filter((item) => item.name || item.dishes || item.price || (item.imageUrls?.length ?? 0) > 0); + .filter((item) => item.name || item.dishes || item.price || item.imageUrls.length > 0); for (let i = 0; i < filled.length; i++) { const item = filled[i]; @@ -130,13 +130,27 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string setSaving(true); try { - await request(`/admin/stores/${storeId}/packages`, { + const data = await request<{ live: PackageRow[] }>(`/admin/stores/${storeId}/packages`, { method: 'PUT', body: JSON.stringify({ packages: filled.map((p) => ({ ...p, price: Number(p.price).toFixed(2) })), }), }); message.success('套餐已保存并生效'); + setItems( + data.live?.length + ? data.live.map((p, i) => { + const imageUrls = normalizeStorePackageImageUrls(p); + return { + ...p, + price: String(p.price), + imageUrl: imageUrls[0] ?? '', + imageUrls, + sortOrder: i, + }; + }) + : [emptyRow()], + ); } catch (e) { message.error(e instanceof Error ? e.message : '保存失败'); } finally { @@ -271,7 +285,7 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string ) : null} - 修改后点击下方按钮保存,C 端将立即展示生效套餐。 + 上传图片后须点击下方「保存套餐」才会写入数据库;仅上传未保存,刷新后会丢失。