Commit 5334f32510ef8bdd19664e6df0cde34005c1be2e

Authored by 曾国涛
1 parent c1827306

fix(product-list): 修复产品列表中 imgList 的解析和显示- 在解析 productimageliststore时添加了条件判断,避免解析空值

- 优化了 imgList 的生成逻辑,提高了代码的健壮性和可读性
Showing 1 changed file with 2 additions and 2 deletions
stores/product_list.ts
... ... @@ -29,11 +29,11 @@ export const useProductListStore = defineStore("productList", () => {
29 29 (data.value?.data?.records || []).map((record: Product) => ({
30 30 ...record,
31 31 // http://112.74.45.244:8100/api/show/image?fileKey=ac82abea34243b7f7a56e5c3ca03f3a9
32   - imgList: JSON.parse(
  32 + imgList: record.productimageliststore ? JSON.parse(
33 33 record.productimageliststore as unknown as string
34 34 ).map((item: ProductImage) => ({
35 35 url: `/api/show/image?fileKey=${item.fileKey}&psize=p256`,
36   - })),
  36 + })): [],
37 37 })) || [];
38 38 total.value = data.value?.data?.total || 0;
39 39 }
... ...