Commit f11f3bbf121ded4b4b5c7661b0fb324e2b2421cf
1 parent
e621b58f
fix: prod2-43/44
Showing
2 changed files
with
30 additions
and
6 deletions
components/MobileProductDetail.vue
... | ... | @@ -226,22 +226,22 @@ |
226 | 226 | <div v-if="info.physicalproperty" class="tw-mb-[24px]"> |
227 | 227 | <div class="py-2 pl-2 text-h6">Physical Property</div> |
228 | 228 | <v-divider class="tw-mb-[12px]"></v-divider> |
229 | - <div v-html="info.physicalproperty"></div> | |
229 | + <div v-html="clearSpanStyle(info.physicalproperty)"></div> | |
230 | 230 | </div> |
231 | 231 | <div v-if="info.storage" class="tw-mb-[24px]"> |
232 | 232 | <div class="py-2 pl-2 text-h6">Storage</div> |
233 | 233 | <v-divider class="tw-mb-[12px]"></v-divider> |
234 | - <div v-html="info.storage"></div> | |
234 | + <div v-html="clearSpanStyle(info.storage)"></div> | |
235 | 235 | </div> |
236 | 236 | <div v-if="info.introduction" class="tw-mb-[24px]"> |
237 | 237 | <div class="py-2 pl-2 text-h6">Introduction</div> |
238 | 238 | <v-divider class="tw-mb-[12px]"></v-divider> |
239 | - <div v-html="info.introduction"></div> | |
239 | + <div v-html="clearSpanStyle(info.introduction)"></div> | |
240 | 240 | </div> |
241 | 241 | <div v-if="info.description" class="tw-mb-[24px]"> |
242 | 242 | <div class="py-2 pl-2 text-h6">Description</div> |
243 | 243 | <v-divider class="tw-mb-[12px]"></v-divider> |
244 | - <div v-html="info.description"></div> | |
244 | + <div v-html="clearSpanStyle(info.description)"></div> | |
245 | 245 | </div> |
246 | 246 | </v-window-item> |
247 | 247 | <v-window-item key="2" :value="2"> |
... | ... | @@ -505,6 +505,30 @@ const hotTotal = ref(10); |
505 | 505 | const isOrNotMobile = isMobile(); |
506 | 506 | const hoveredItem = ref(null); |
507 | 507 | |
508 | +const clearSpanStyle = (htmlContent) => { | |
509 | + if (!htmlContent) return ""; // 检查是否为空 | |
510 | + // 创建一个 DOM 解析器 | |
511 | + const parser = new DOMParser(); | |
512 | + const doc = parser.parseFromString(htmlContent, "text/html"); | |
513 | + | |
514 | + // 清理 span 的 style 属性 | |
515 | + const spans = doc.querySelectorAll("span"); | |
516 | + spans.forEach((span) => { | |
517 | + span.removeAttribute("style"); // 清空 style 属性 | |
518 | + }); | |
519 | + | |
520 | + // 修改 img 的 style 属性,追加 width: 100% | |
521 | + const imgs = doc.querySelectorAll("img"); | |
522 | + imgs.forEach((img) => { | |
523 | + const style = img.getAttribute("style") || ""; // 获取现有 style | |
524 | + if (!style.includes("width: 100%")) { | |
525 | + img.setAttribute("style", `${style} width: 100%;`.trim()); // 添加 width: 100% | |
526 | + } | |
527 | + }); | |
528 | + | |
529 | + // 返回处理后的 HTML | |
530 | + return doc.body.innerHTML; | |
531 | +}; | |
508 | 532 | const navigateToUrl = (url) => { |
509 | 533 | window.open(url); // 在新标签页中打开链接 |
510 | 534 | }; | ... | ... |
deploy/prod2.sh