Commit 06c01b1e26d7a5320251f22c46608d79bd5234cf
1 parent
fa35f0cf
fix: 解决面包屑导航搜索后的bug
Showing
2 changed files
with
25 additions
and
2 deletions
components/ProductDetail.vue
@@ -224,6 +224,7 @@ const routeQuery = useRouteQuery(); | @@ -224,6 +224,7 @@ const routeQuery = useRouteQuery(); | ||
224 | const dialogStore = useDialogStore(); | 224 | const dialogStore = useDialogStore(); |
225 | const href1 = ref("/products"); | 225 | const href1 = ref("/products"); |
226 | const href2 = ref("/products"); | 226 | const href2 = ref("/products"); |
227 | +const productStore = useProductListStore(); | ||
227 | // 定义单个 item 的接口 | 228 | // 定义单个 item 的接口 |
228 | interface BreadcrumbItem { | 229 | interface BreadcrumbItem { |
229 | title: string; // 标题 | 230 | title: string; // 标题 |
@@ -265,7 +266,28 @@ const props = defineProps<{ | @@ -265,7 +266,28 @@ const props = defineProps<{ | ||
265 | }>(); | 266 | }>(); |
266 | const info = props.info; | 267 | const info = props.info; |
267 | watchEffect(() => { | 268 | watchEffect(() => { |
268 | - if (routeQuery.categories) { | 269 | + if (info?.productCrumbsVO?.category1 && productStore.keyword) { |
270 | + console.log(productStore.keyword, "5656keywordy"); | ||
271 | + items.value[1].title = info.productCrumbsVO.category1; | ||
272 | + items.value[1].href = | ||
273 | + href1.value + "?categories=" + info.productCrumbsVO.category1; | ||
274 | + href1.value = href1.value + "?categories=" + info.productCrumbsVO.category1; | ||
275 | + if (info?.productCrumbsVO?.category2) { | ||
276 | + items.value[2].title = info.productCrumbsVO.category2; | ||
277 | + href2.value = href1.value + "," + info.productCrumbsVO.category2; | ||
278 | + items.value[2].href = href1.value + "," + info.productCrumbsVO.category2; | ||
279 | + } | ||
280 | + if (info?.productCrumbsVO?.function) { | ||
281 | + // items.value.push({ | ||
282 | + // title: info.productCrumbsVO.function, | ||
283 | + // disabled: false, | ||
284 | + // href: href2.value + "&function=" + info.productCrumbsVO.function, | ||
285 | + // }); | ||
286 | + items.value[3].title = info.productCrumbsVO.function; | ||
287 | + items.value[3].href = | ||
288 | + href2.value + "&function=" + info.productCrumbsVO.function; | ||
289 | + } | ||
290 | + } else if (routeQuery.categories) { | ||
269 | if (!routeQuery.categories.includes("Energy materials")) { | 291 | if (!routeQuery.categories.includes("Energy materials")) { |
270 | routeQuery.updateFunction("Not specified"); | 292 | routeQuery.updateFunction("Not specified"); |
271 | } | 293 | } |
@@ -298,6 +320,7 @@ watchEffect(() => { | @@ -298,6 +320,7 @@ watchEffect(() => { | ||
298 | // routeQuery.updateFunction(null); | 320 | // routeQuery.updateFunction(null); |
299 | } | 321 | } |
300 | } else if (info?.productCrumbsVO?.category1) { | 322 | } else if (info?.productCrumbsVO?.category1) { |
323 | + console.log(productStore.keyword, "5656keywordy"); | ||
301 | items.value[1].title = info.productCrumbsVO.category1; | 324 | items.value[1].title = info.productCrumbsVO.category1; |
302 | items.value[1].href = | 325 | items.value[1].href = |
303 | href1.value + "?categories=" + info.productCrumbsVO.category1; | 326 | href1.value + "?categories=" + info.productCrumbsVO.category1; |
pages/products/detail/[id]/index.vue
@@ -59,7 +59,7 @@ newData.productimageliststore = | @@ -59,7 +59,7 @@ newData.productimageliststore = | ||
59 | typeof newData.productimageliststore === "string" | 59 | typeof newData.productimageliststore === "string" |
60 | ? JSON.parse(newData.productimageliststore) || [] | 60 | ? JSON.parse(newData.productimageliststore) || [] |
61 | : (newData.productimageliststore as ProductImage[]); | 61 | : (newData.productimageliststore as ProductImage[]); |
62 | -newData.productimageliststore = newData?.productimageliststore.map( | 62 | +newData.productimageliststore = newData?.productimageliststore?.map( |
63 | (item: ProductImage) => ({ | 63 | (item: ProductImage) => ({ |
64 | ...item, | 64 | ...item, |
65 | // url: `http://112.74.45.244:8100/api/show/image?fileKey=${item.fileKey}` | 65 | // url: `http://112.74.45.244:8100/api/show/image?fileKey=${item.fileKey}` |