Files
console-dev/app/components/ProductCategoryNotice.vue

94 lines
3.1 KiB
Vue

<script>
/** 分类订购说明:兼容被 HTML 实体编码的文本,清理富文本后仅在存在可见内容时展示。 */
import "~/assets/styles/ProductCategoryNotice.CwaR3eXN.css";
import { normalizeClass } from "vue";
import { createCommentVNode } from "vue";
import { computed } from "vue";
import { createElementBlock } from "vue";
import { createElementVNode } from "vue";
import { unref } from "vue";
import { defineComponent } from "vue";
import { openBlock } from "vue";
import { t as _plugin_vue_export_helper_t } from "~/lib/_plugin-vue_export-helper.js";
import { n as sanitize_n } from "~/lib/sanitize.js";
var u = {
key: 0,
class: `category-notice`,
"aria-label": `分类订购提示`,
"aria-live": `polite`,
"aria-atomic": `true`,
},
d = [`innerHTML`],
f = Object.assign(
_plugin_vue_export_helper_t(
defineComponent({
__name: `ProductCategoryNotice`,
props: {
description: {},
},
setup(o) {
let c = o,
f = computed(() => {
// 最多解码两轮纯文本包装,随后统一消毒;图片也算有效内容,空白占位不显示。
let e = typeof c.description == `string` ? c.description : ``;
for (let t = 0; t < 2; t++) {
let t = new DOMParser().parseFromString(e, `text/html`);
if (t.body.childElementCount || t.head.childElementCount) break;
let n = t.body.textContent ?? e;
if (n === e) break;
e = n;
}
let t = sanitize_n(e),
n = new DOMParser().parseFromString(t, `text/html`);
return {
html:
n.body.textContent
?.replace(/[\u200b-\u200d\ufeff]/g, ``)
.trim() || n.body.querySelector(`img[src]`)
? t
: ``,
plain: n.body.childElementCount === 0,
};
});
return (n, o) =>
unref(f).html
? (openBlock(),
createElementBlock(`aside`, u, [
(o[0] ||= createElementVNode(
`i`,
{
class: `pi pi-info-circle category-notice-icon`,
"aria-hidden": `true`,
},
null,
-1,
)),
createElementVNode(
`div`,
{
class: normalizeClass([
`category-notice-content`,
{
"category-notice-plain": unref(f).plain,
},
]),
innerHTML: unref(f).html,
},
null,
10,
d,
),
]))
: createCommentVNode(``, !0);
},
}),
[[`__scopeId`, `data-v-faa6a7a3`]],
),
{
__name: `ProductCategoryNotice`,
},
);
export {};
export default f;
</script>