Commit 47de375a0ad90ce7db925b38dd1cfd3fc18f4e5a
1 parent
bb644353
fix: prod2-51/52
Showing
4 changed files
with
41 additions
and
67 deletions
components/ProductDetail.vue
... | ... | @@ -255,7 +255,9 @@ |
255 | 255 | style="width: 100%" |
256 | 256 | > |
257 | 257 | <v-tab :value="1">Product Details</v-tab> |
258 | - <v-tab :value="2">Specification</v-tab> | |
258 | + <v-tab :value="2" v-if="info.productAttributeList" | |
259 | + >Specification</v-tab | |
260 | + > | |
259 | 261 | <!-- <v-tab :value="3">商品百科</v-tab> --> |
260 | 262 | </v-tabs> |
261 | 263 | <v-window |
... | ... | @@ -272,32 +274,32 @@ |
272 | 274 | <v-window-item key="1" :value="1"> |
273 | 275 | <!-- 修改位置 1: 使用 clearSpanStyle 方法清理 info.advantage --> |
274 | 276 | <div v-if="info.advantage" class="tw-mb-[24px]"> |
275 | - <div class="text-h6">Advantage</div> | |
276 | - <v-divider class="tw-mb-[12px]"></v-divider> | |
277 | + <!-- <div class="text-h6">Advantage</div> | |
278 | + <v-divider class="tw-mb-[12px]"></v-divider> --> | |
277 | 279 | <div v-html="clearSpanStyle(info.advantage)"></div> |
278 | 280 | </div> |
279 | 281 | <!-- 修改位置 2: 使用 clearSpanStyle 方法清理 info.physicalproperty --> |
280 | 282 | <div v-if="info.physicalproperty" class="tw-mb-[24px]"> |
281 | - <div class="text-h6">Physical Property</div> | |
282 | - <v-divider class="tw-mb-[12px] html-content"></v-divider> | |
283 | + <!-- <div class="text-h6">Physical Property</div> | |
284 | + <v-divider class="tw-mb-[12px] html-content"></v-divider> --> | |
283 | 285 | <div v-html="clearSpanStyle(info.physicalproperty)"></div> |
284 | 286 | </div> |
285 | 287 | <!-- 修改位置 3: 使用 clearSpanStyle 方法清理 info.storage --> |
286 | 288 | <div v-if="info.storage" class="tw-mb-[24px]"> |
287 | - <div class="text-h6">Storage</div> | |
288 | - <v-divider class="tw-mb-[12px]"></v-divider> | |
289 | + <!-- <div class="text-h6">Storage</div> | |
290 | + <v-divider class="tw-mb-[12px]"></v-divider> --> | |
289 | 291 | <div v-html="clearSpanStyle(info.storage)"></div> |
290 | 292 | </div> |
291 | 293 | <!-- 修改位置 4: 使用 clearSpanStyle 方法清理 info.introduction --> |
292 | 294 | <div v-if="info.introduction" class="tw-mb-[24px]"> |
293 | - <div class="text-h6">Introduction</div> | |
294 | - <v-divider class="tw-mb-[12px]"></v-divider> | |
295 | + <!-- <div class="text-h6">Introduction</div> | |
296 | + <v-divider class="tw-mb-[12px]"></v-divider> --> | |
295 | 297 | <div v-html="clearSpanStyle(info.introduction)"></div> |
296 | 298 | </div> |
297 | 299 | <!-- 修改位置 5: 使用 clearSpanStyle 方法清理 info.description --> |
298 | 300 | <div v-if="info.description" class="tw-mb-[24px]"> |
299 | - <div class="text-h6">Description</div> | |
300 | - <v-divider class="tw-mb-[12px]"></v-divider> | |
301 | + <!-- <div class="text-h6">Description</div> | |
302 | + <v-divider class="tw-mb-[12px]"></v-divider> --> | |
301 | 303 | <div v-html="clearSpanStyle(info.description)"></div> |
302 | 304 | </div> |
303 | 305 | </v-window-item> |
... | ... | @@ -631,13 +633,34 @@ const clearSpanStyle = (htmlContent) => { |
631 | 633 | span.removeAttribute("style"); // 清空 style 属性 |
632 | 634 | }); |
633 | 635 | |
634 | - // 修改 img 的 style 属性,追加 width: 100% | |
636 | + // const imgs = doc.querySelectorAll("img"); | |
637 | + // imgs.forEach((img) => { | |
638 | + // const style = img.getAttribute("style") || ""; // 获取现有 style | |
639 | + // if (!style.includes("width: 100%")) { | |
640 | + // img.setAttribute("style", `${style} width: 100%; height: auto;`.trim()); // 添加 width: 100% 和 height: auto | |
641 | + // } | |
642 | + // }); | |
635 | 643 | const imgs = doc.querySelectorAll("img"); |
644 | + | |
636 | 645 | imgs.forEach((img) => { |
637 | - const style = img.getAttribute("style") || ""; // 获取现有 style | |
638 | - if (!style.includes("width: 100%")) { | |
639 | - img.setAttribute("style", `${style} width: 100%;`.trim()); // 添加 width: 100% | |
646 | + // 去除 img 标签内的 width 和 height 属性,如果存在的话 | |
647 | + if (img.hasAttribute("width")) { | |
648 | + img.removeAttribute("width"); | |
640 | 649 | } |
650 | + if (img.hasAttribute("height")) { | |
651 | + img.removeAttribute("height"); | |
652 | + } | |
653 | + | |
654 | + // 获取现有的 style 属性,如果存在的话 | |
655 | + let style = img.getAttribute("style") || ""; | |
656 | + | |
657 | + // 如果 style 中有 width 和 height,移除它们 | |
658 | + style = style | |
659 | + .replace(/width\s*:\s*[^;]+;?/gi, "") | |
660 | + .replace(/height\s*:\s*[^;]+;?/gi, ""); | |
661 | + | |
662 | + // 添加 width: 100% 和 height: auto 样式 | |
663 | + img.setAttribute("style", `${style} width: 100%; height: auto;`.trim()); | |
641 | 664 | }); |
642 | 665 | |
643 | 666 | // 返回处理后的 HTML | ... | ... |
deploy/prod2.sh
pages/products/detail/[id]/index.vue
... | ... | @@ -64,7 +64,7 @@ newData.productimageliststore = newData?.productimageliststore?.map( |
64 | 64 | (item: ProductImage) => ({ |
65 | 65 | ...item, |
66 | 66 | // url: `http://112.74.45.244:8100/api/show/image?fileKey=${item.fileKey}` |
67 | - url: `https://www.canrud.com/api/show/image?fileKey=${item.fileKey}&psize=p512`, | |
67 | + url: `/api/show/image?fileKey=${item.fileKey}&psize=p512`, | |
68 | 68 | }) |
69 | 69 | ); |
70 | 70 | ... | ... |
pages/products/index.vue
... | ... | @@ -2,55 +2,6 @@ |
2 | 2 | <div class="tw-m-auto tw-pb-[64px]" style="padding-bottom: 0px"> |
3 | 3 | <CategoryList v-if="categoryStore.categoryVisible && !isMobile()" /> |
4 | 4 | <MobileCategoryList v-if="categoryStore.categoryVisible && isMobile()" /> |
5 | - <!-- <v-tabs | |
6 | - class="tabs" | |
7 | - v-model="tabRecom" | |
8 | - style="margin-top: 25px" | |
9 | - color="white" | |
10 | - bg-color="#eeeeee" | |
11 | - slider-color="blue-lighten-1" | |
12 | - selected-class="active" | |
13 | - v-if="recommendImages[0] !== null && !isMobile()" | |
14 | - > | |
15 | - <v-tab :value="1">Best Sellers</v-tab> | |
16 | - </v-tabs> | |
17 | - <div id="image-container" v-if="recommendImages[0] !== null && !isMobile()"> | |
18 | - <div class="recommend-left-box"> | |
19 | - <v-img | |
20 | - src="https://m-canrd.oss-cn-shenzhen.aliyuncs.com/crmebimage/public/maintain/2024/09/14/76c987e13a334be481a346c19c2284f3qy4tjnxps7.png" | |
21 | - alt="往左移" | |
22 | - class="recommend-img-left" | |
23 | - @click="toggleRowLeft" | |
24 | - /> | |
25 | - </div> | |
26 | - <div class="image-row" id="row1"> | |
27 | - <div | |
28 | - v-for="(imageObj, index) in recommendImages" | |
29 | - :key="'row1-' + index" | |
30 | - class="imageTotal" | |
31 | - > | |
32 | - <a v-if="imageObj" :href="imageObj[0]?.productUrl" target="_blank"> | |
33 | - <img | |
34 | - :src="imageObj[0]?.url" | |
35 | - :alt="'Image ' + (index + 1)" | |
36 | - class="item-imgHot" | |
37 | - /> | |
38 | - <span class="image-name"> | |
39 | - {{ imageObj[0]?.name }} | |
40 | - </span> | |
41 | - </a> | |
42 | - <div v-else style="width: 200px; height: 200px"></div> | |
43 | - </div> | |
44 | - </div> | |
45 | - <div class="recommend-right-box"> | |
46 | - <v-img | |
47 | - src="https://m-canrd.oss-cn-shenzhen.aliyuncs.com/crmebimage/public/maintain/2024/09/14/b5daa0a8f2f140f5b406e984c730a453iznzlekysg.png" | |
48 | - alt="往右移" | |
49 | - class="recommend-img-right" | |
50 | - @click="toggleRowRight" | |
51 | - /> | |
52 | - </div> | |
53 | - </div> --> | |
54 | 5 | <v-container class=""> |
55 | 6 | <div class="tw-text-center tw-mt-[32px]" v-if="loading"> |
56 | 7 | <v-progress-circular | ... | ... |