chore(组件): components-diy 必须使用easyncom系统,不然在微信上无法渲染

This commit is contained in:
2026-01-05 09:29:19 +08:00
parent 311efe1ecd
commit b24f77be1a
49 changed files with 1462 additions and 1547 deletions

View File

@@ -251,6 +251,11 @@
<diy-icon :value="item"></diy-icon>
</template>
<template v-if="item.componentName == 'Group'">
<!-- 组件组 -->
<diy-group :diyData="item"></diy-group>
</template>
<!-- 自定义扩展组件 -->
<diy-comp-extend :value="item"></diy-comp-extend>
</view>
@@ -261,20 +266,24 @@
// 组件组展示
import DiyMinx from './minx.js'
export default {
components: {},
name: 'DiyGroup',
mixins: [DiyMinx],
props: {
diyData: {
type: Object
type: Object,
default: () => ({})
},
scrollTop: {
type: [String, Number],
default: '0'
},
haveTopCategory: {
type: Boolean
type: Boolean,
default: false
},
followOfficialAccount: {
type: Object
type: Object,
default: () => ({})
},
},
mixins: [DiyMinx],
@@ -284,25 +293,28 @@ export default {
};
},
created() {
this.diyGlobalData = JSON.parse(JSON.stringify(this.diyData));
this.diyGlobalData = JSON.parse(JSON.stringify(this.diyData || {}));
},
computed: {
topNavColor() {
var color = '';
if (this.diyData.global.topNavBg) {
if (this.diyData.global && this.diyData.global.topNavBg) {
color = 'transparent';
if (this.scrollTop > 20) {
if (this.scrollTop > 20 && this.diyData.global.topNavColor) {
color = this.diyData.global.topNavColor;
} else {
color = 'transparent';
}
} else {
} else if (this.diyData.global && this.diyData.global.topNavColor) {
color = this.diyData.global.topNavColor;
}
return color;
},
// 修改属性样式
setPagestyle() {
if (!this.diyGlobalData || !this.diyGlobalData.value || !Array.isArray(this.diyGlobalData.value)) {
return [];
}
this.diyGlobalData.value.forEach((item, index) => {
item.pageStyle = '';
// 给每个组件增加位置属性,用于定位,搜索、分类导航等定位
@@ -314,12 +326,12 @@ export default {
return false;
}
item.pageStyle += 'background-color:' + item.pageBgColor + ';';
item.pageStyle += 'background-color:' + (item.pageBgColor || '') + ';';
if (item.margin) {
item.pageStyle += 'padding-top:' + item.margin.top * 2 + 'rpx' + ';';
item.pageStyle += 'padding-bottom:' + item.margin.bottom * 2 + 'rpx' + ';';
item.pageStyle += 'padding-right:' + item.margin.both * 2 + 'rpx' + ';';
item.pageStyle += 'padding-left:' + item.margin.both * 2 + 'rpx' + ';';
item.pageStyle += 'padding-top:' + (item.margin.top || 0) * 2 + 'rpx' + ';';
item.pageStyle += 'padding-bottom:' + (item.margin.bottom || 0) * 2 + 'rpx' + ';';
item.pageStyle += 'padding-right:' + (item.margin.both || 0) * 2 + 'rpx' + ';';
item.pageStyle += 'padding-left:' + (item.margin.both || 0) * 2 + 'rpx' + ';';
}
});
@@ -327,20 +339,35 @@ export default {
},
// 过滤组件的渲染
diyDataArray() {
let data = [],
showModuleData = this.$store.state.diyGroupShowModule ? JSON.parse(this.$store.state
.diyGroupShowModule) : '';
let data = [];
let showModuleData = [];
// 安全获取store中的模块显示数据
try {
if (this.$store && this.$store.state && this.$store.state.diyGroupShowModule) {
showModuleData = JSON.parse(this.$store.state.diyGroupShowModule);
// 确保showModuleData是数组
if (!Array.isArray(showModuleData)) {
showModuleData = [];
}
}
} catch (e) {
showModuleData = [];
}
const diyDataArr = this.setPagestyle;
if (showModuleData.length) {
if (showModuleData.includes('null')) return [];
let diyDataArr = this.setPagestyle;
diyDataArr.forEach((item, index) => {
if (showModuleData.includes(item.componentName)) {
if (item && item.componentName && showModuleData.includes(item.componentName)) {
data.push(item);
}
});
} else data = this.setPagestyle;
} else {
data = diyDataArr;
}
return data;
}
},