refactor(diy-group): simplify topNavColor and setPagestyle logic

remove redundant null checks for diyData and diyGlobalData, streamline the conditional branches for better readability
This commit is contained in:
2026-06-04 13:47:33 +08:00
parent 23b5e91d11
commit 0f9647e7c5

View File

@@ -300,21 +300,20 @@ export default {
computed: { computed: {
topNavColor() { topNavColor() {
var color = ''; var color = '';
if (this.diyData && this.diyData.global && this.diyData.global.topNavBg) { if (this.diyData.global.topNavBg) {
color = 'transparent'; color = 'transparent';
if (this.scrollTop > 20) { if (this.scrollTop > 20) {
color = this.diyData.global.topNavColor; color = this.diyData.global.topNavColor;
} else { } else {
color = 'transparent'; color = 'transparent';
} }
} else if (this.diyData && this.diyData.global) { } else {
color = this.diyData.global.topNavColor; color = this.diyData.global.topNavColor;
} }
return color; return color;
}, },
// 修改属性样式 // 修改属性样式
setPagestyle() { setPagestyle() {
if (!this.diyGlobalData || !this.diyGlobalData.value) return [];
this.diyGlobalData.value.forEach((item, index) => { this.diyGlobalData.value.forEach((item, index) => {
item.pageStyle = ''; item.pageStyle = '';
// 给每个组件增加位置属性,用于定位,搜索、分类导航等定位 // 给每个组件增加位置属性,用于定位,搜索、分类导航等定位