diff --git a/common/js/common/common.js b/common/js/common/common.js index dede6101..a8da3fbb 100644 --- a/common/js/common/common.js +++ b/common/js/common/common.js @@ -629,4 +629,25 @@ export function get_math() { export const percentage_count = (num, container_size) => { const marks = (num / container_size) * 100; return marks.toFixed(4) + '%'; +}; + +/** + * 计算当前偏移量 + * + * @param size 当前的组件的大小宽或者高。 + * @param location 容器的位置的偏移量。 + * @param container_size 对应位置的容器的大小 + * @returns 偏移量 + */ +export const location_compute = (size, location, container_size) => { + if (size + location >= container_size) { + const deviation = container_size - size; + if (deviation >= 0) { + return deviation; + } else { + return 0; + } + } else { + return location; + } }; \ No newline at end of file diff --git a/components/diy/custom.vue b/components/diy/custom.vue index ad8ea57d..07f04b40 100644 --- a/components/diy/custom.vue +++ b/components/diy/custom.vue @@ -10,7 +10,7 @@ - + @@ -23,7 +23,7 @@ - + @@ -44,7 +44,7 @@ @@ -52,14 +52,14 @@ diff --git a/components/diy/data-magic.vue b/components/diy/data-magic.vue index df66dee4..46bd15cc 100644 --- a/components/diy/data-magic.vue +++ b/components/diy/data-magic.vue @@ -203,8 +203,8 @@ const new_style = this.propValue.style; const container_height = !isEmpty(new_form.container_height) ? new_form.container_height : sys_width; const density = !isEmpty(new_form.magic_cube_density) ? new_form.magic_cube_density : 4; - const { margin_left, margin_right, padding_left, padding_right } = new_style.common_style; - const width = sys_width - margin_left - margin_right - padding_left - padding_right - border_width(new_style.common_style) - this.propOuterContainerPadding; + const { margin_left, margin_right } = new_style.common_style; + const width = sys_width - margin_left - margin_right - border_width(new_style.common_style) - this.propOuterContainerPadding; this.setData({ form: new_form, new_style: new_style, diff --git a/components/diy/diy.vue b/components/diy/diy.vue index b0e1a4ea..14c6cc8d 100644 --- a/components/diy/diy.vue +++ b/components/diy/diy.vue @@ -10,7 +10,7 @@ @@ -26,9 +26,9 @@ - - - + + + @@ -290,44 +290,67 @@ } }, get_diy_prop_top() { - // 不开启沉浸模式时的处理 - if (!this.is_immersion_model) { - return this.temp_sticky_top + this.tabs_height; - } else { - // 开启沉浸模式且开启选项卡置顶时 - if (this.is_tabs_data_topped) { - return this.tabs_height; + return (item) => { + // 不开启沉浸模式时的处理 + if (!this.is_immersion_model) { + return this.temp_sticky_top + this.tabs_height; } else { - // 开启安全距离 - if (this.is_the_safe_distance_enabled) { - return this.is_header_top ? this.temp_sticky_top : 0; + // 开启沉浸模式且开启选项卡置顶时 + if (this.is_tabs_data_topped) { + return this.tabs_height; } else { - return 0; + // 开启安全距离 + let is_general_safe_distance_num = this.temp_sticky_top; + // #ifdef H5 || MP-TOUTIAO + is_general_safe_distance_num = this.is_header_top ? this.temp_sticky_top : 0 + // #endif + if (this.is_the_safe_distance_enabled) { + return is_general_safe_distance_num; + } else { + if (item?.content?.is_general_safe_distance == '1') { + return is_general_safe_distance_num; + } else { + return 0; + } + } } } - } + } }, get_diy_custom_nav_height() { - // 不开启沉浸模式时的处理 - if (!this.is_immersion_model) { + return (item) => { let header_height = (this.is_search_alone_row ? 66 + this.data_alone_row_space : 33); // #ifdef H5 || MP-TOUTIAO header_height = this.is_header_top ? header_height : 0; // #endif - return header_height; - } else { - // 开启沉浸模式且开启选项卡置顶时 - if (this.is_tabs_data_topped) { - return 0; + // 不开启沉浸模式时的处理 + if (!this.is_immersion_model) { + return header_height; } else { - // 开启沉浸模式时并且开启安全距离 - if (this.is_the_safe_distance_enabled) { - return this.is_search_alone_row ? 66 + this.data_alone_row_space : 33; + // 开启沉浸模式且开启选项卡置顶时 + if (this.is_tabs_data_topped) { + return 0; } else { - return 0 - } - } + // 开启沉浸模式时并且开启安全距离 + if (this.is_the_safe_distance_enabled) { + return this.is_search_alone_row ? 66 + this.data_alone_row_space : 33; + } else { + if (item?.content?.is_general_safe_distance == '1') { + return header_height; + } else { + return 0; + } + } + } + } } + }, + getPropIsTabsUseSafeDistance() { + let is_tabs_use_safe_distance = this.is_immersion_model; + // #ifdef H5 || MP-TOUTIAO + is_tabs_use_safe_distance = this.is_immersion_model && this.is_header_top; + // #endif + return is_tabs_use_safe_distance || !this.is_immersion_model; } }, watch: { diff --git a/components/diy/img-magic.vue b/components/diy/img-magic.vue index dd900472..3d2433a1 100644 --- a/components/diy/img-magic.vue +++ b/components/diy/img-magic.vue @@ -143,8 +143,9 @@ const container_height = !isEmpty(new_content.container_height) ? new_content.container_height : sys_width; const density = !isEmpty(new_content.magic_cube_density) ? new_content.magic_cube_density : 4; - const { margin_left, margin_right, padding_left, padding_right } = new_style.common_style; - const width = sys_width - margin_left - margin_right - padding_left - padding_right - border_width(new_style.common_style) - this.propOuterContainerPadding; + const { margin_left, margin_right } = new_style.common_style; + const width = sys_width - margin_left - margin_right - border_width(new_style.common_style) - this.propOuterContainerPadding; + const scale = width / 390; this.setData({ form: this.propValue.content, new_style: this.propValue.style, @@ -155,7 +156,7 @@ style_img_container: common_img_computer(new_style.common_style, this.propIndex) + 'box-sizing: border-box;', img_fit: fit, div_width: sys_width, - container_size: container_height * (width / 390) + 'px', + container_size: container_height * scale + 'px', cube_cell: sys_width / density, content_img_container: common_styles_computer(new_style) + margin_computer(new_style?.margin || old_margin) + 'box-sizing: border-box;', content_img_style_container: common_img_computer(new_style) + padding_computer(new_style?.padding || old_padding) + 'box-sizing: border-box;', diff --git a/components/diy/modules/custom/data-group-rendering.vue b/components/diy/modules/custom/data-group-rendering.vue index 42441f4a..e5a9e423 100644 --- a/components/diy/modules/custom/data-group-rendering.vue +++ b/components/diy/modules/custom/data-group-rendering.vue @@ -1,6 +1,6 @@