From 31749c43626633db569c042a8593cbcdc9b942c7 Mon Sep 17 00:00:00 2001 From: jry Date: Mon, 30 Dec 2024 20:52:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1getS?= =?UTF-8?q?ystemInfoSync=E6=8E=A5=E5=8F=A3=E5=BA=9F=E5=BC=83=E8=AD=A6?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/u-dropdown/u-dropdown.vue | 6 ++-- .../components/u-index-list/u-index-list.vue | 15 +++++---- .../components/u-list-item/u-list-item.vue | 4 +-- .../uview-plus/components/u-list/u-list.vue | 4 +-- .../components/u-navbar/u-navbar.vue | 6 ++-- .../components/u-no-network/u-no-network.vue | 4 +-- .../components/u-parse/node/node.vue | 2 +- .../uview-plus/components/u-parse/parser.js | 8 +++-- .../uview-plus/components/u-popup/u-popup.vue | 4 +-- .../u-safe-bottom/u-safe-bottom.vue | 4 +-- .../components/u-status-bar/u-status-bar.vue | 4 +-- .../components/u-sticky/u-sticky.vue | 4 +-- .../uview-plus/components/u-tabs/u-tabs.vue | 4 +-- .../uview-plus/components/u-toast/u-toast.vue | 4 +-- .../components/u-tooltip/u-tooltip.vue | 4 +-- .../uview-plus/libs/function/index.js | 32 +++++++++++++++++-- .../uview-plus/types/comps/actionSheet.d.ts | 2 +- 17 files changed, 71 insertions(+), 40 deletions(-) diff --git a/src/uni_modules/uview-plus/components/u-dropdown/u-dropdown.vue b/src/uni_modules/uview-plus/components/u-dropdown/u-dropdown.vue index 02964bcb8..55fa086be 100644 --- a/src/uni_modules/uview-plus/components/u-dropdown/u-dropdown.vue +++ b/src/uni_modules/uview-plus/components/u-dropdown/u-dropdown.vue @@ -37,7 +37,7 @@ import { props } from './props'; import { mpMixin } from '../../libs/mixin/mpMixin'; import { mixin } from '../../libs/mixin/mixin'; - import { addUnit, sys} from '../../libs/function/index'; + import { addUnit, getWindowInfo} from '../../libs/function/index'; /** * dropdown 下拉菜单 * @description 该组件一般用于向下展开菜单,同时可切换多个选项卡的场景 @@ -166,8 +166,8 @@ getContentHeight() { // 这里的原理为,因为dropdown组件是相对定位的,它的下拉出来的内容,必须给定一个高度 // 才能让遮罩占满菜单一下,直到屏幕底部的高度 - // sys()为uview-plus封装的获取设备信息的方法 - let windowHeight = sys().windowHeight; + // getWindowInfo()为uview-plus封装的获取设备信息的方法 + let windowHeight = getWindowInfo().windowHeight; this.$uGetRect('.u-dropdown__menu').then(res => { // 这里获取的是dropdown的尺寸,在H5上,uniapp获取尺寸是有bug的(以前提出修复过,后来又出现了此bug,目前hx2.8.11版本) // H5端bug表现为元素尺寸的top值为导航栏底部到到元素的上边沿的距离,但是元素的bottom值确是导航栏顶部到元素底部的距离 diff --git a/src/uni_modules/uview-plus/components/u-index-list/u-index-list.vue b/src/uni_modules/uview-plus/components/u-index-list/u-index-list.vue index c345413a4..eb29ec007 100644 --- a/src/uni_modules/uview-plus/components/u-index-list/u-index-list.vue +++ b/src/uni_modules/uview-plus/components/u-index-list/u-index-list.vue @@ -105,7 +105,7 @@ import { props } from './props'; import { mpMixin } from '../../libs/mixin/mpMixin'; import { mixin } from '../../libs/mixin/mixin'; - import { addUnit, sys, sleep, getPx } from '../../libs/function/index'; + import { addUnit, getWindowInfo, sleep, getPx } from '../../libs/function/index'; // #ifdef APP-NVUE // 由于weex为阿里的KPI业绩考核的产物,所以不支持百分比单位,这里需要通过dom查询组件的宽度 @@ -152,7 +152,7 @@ // scroll-view的高度 scrollViewHeight: 0, // 系统信息 - sys: sys(), + sys: {}, scrolling: false, scrollIntoView: '', pageY: 0, @@ -188,6 +188,7 @@ created() { this.children = [] this.anchors = [] + this.sys = getWindowInfo() }, mounted() { this.init() @@ -320,7 +321,7 @@ const { height } = size - const sysData = sys() + const sysData = getWindowInfo() const windowHeight = sysData.windowHeight let customNavHeight = 0 // 消除各端导航栏非原生和原生导致的差异,让索引列表字母对屏幕垂直居中 @@ -358,7 +359,7 @@ let index = this.currentIndex; // 对H5的pageY进行修正,这是由于uni-app自作多情在H5中将触摸点的坐标跟H5的导航栏结合导致的问题 // #ifdef H5 - // pageY += sys().windowTop + // pageY += getWindowInfo().windowTop // #endif // 对第一和最后一个字母做边界处理,因为用户可能在字母列表上触摸到两端的尽头后依然继续滑动 // console.log('top1', top) @@ -476,8 +477,8 @@ let children = this.children // #ifdef APP-NVUE // nvue下获取的滚动条偏移为负数,需要转为正数 - let sys = uni.getSystemInfoSync() - scrollTop = Math.abs(e.contentOffset.y) / 10 + let sys = getWindowInfo() + scrollTop = Math.abs(e.contentOffset.y) / 10 // console.log('native', e) // #endif @@ -515,7 +516,7 @@ if (scrollTop <= children[0].top || scrollTop >= children[len - 1].top + children[len - 1].height) { this.activeIndex = -1 break - } else if (!nextItem) { + } else if (!nextItem) { // 当不存在下一个item时,意味着历遍到了最后一个 this.activeIndex = len - 1 break diff --git a/src/uni_modules/uview-plus/components/u-list-item/u-list-item.vue b/src/uni_modules/uview-plus/components/u-list-item/u-list-item.vue index ae30b0801..eeaccdcfb 100644 --- a/src/uni_modules/uview-plus/components/u-list-item/u-list-item.vue +++ b/src/uni_modules/uview-plus/components/u-list-item/u-list-item.vue @@ -19,7 +19,7 @@ import { props } from './props'; import { mpMixin } from '../../libs/mixin/mpMixin'; import { mixin } from '../../libs/mixin/mixin'; - import { sys } from '../../libs/function/index'; + import { getWindowInfo } from '../../libs/function/index'; // #ifdef APP-NVUE const dom = uni.requireNativePlugin('dom') // #endif @@ -39,7 +39,7 @@ rect: {}, index: 0, show: true, - sys: sys() + sys: getWindowInfo() } }, computed: { diff --git a/src/uni_modules/uview-plus/components/u-list/u-list.vue b/src/uni_modules/uview-plus/components/u-list/u-list.vue index af95ff1df..41de94780 100644 --- a/src/uni_modules/uview-plus/components/u-list/u-list.vue +++ b/src/uni_modules/uview-plus/components/u-list/u-list.vue @@ -50,7 +50,7 @@ import { props } from './props'; import { mpMixin } from '../../libs/mixin/mpMixin'; import { mixin } from '../../libs/mixin/mixin'; - import { addUnit, addStyle, deepMerge, sleep, sys } from '../../libs/function/index'; + import { addUnit, addStyle, deepMerge, sleep, getWindowInfo } from '../../libs/function/index'; // #ifdef APP-NVUE const dom = uni.requireNativePlugin('dom') // #endif @@ -90,7 +90,7 @@ innerScrollTop: 0, // vue下,scroll-view在上拉加载时的偏移值 offset: 0, - sys: sys() + sys: getWindowInfo() } }, computed: { diff --git a/src/uni_modules/uview-plus/components/u-navbar/u-navbar.vue b/src/uni_modules/uview-plus/components/u-navbar/u-navbar.vue index 4e5b4e4f7..ca86634d9 100644 --- a/src/uni_modules/uview-plus/components/u-navbar/u-navbar.vue +++ b/src/uni_modules/uview-plus/components/u-navbar/u-navbar.vue @@ -4,7 +4,7 @@ class="u-navbar__placeholder" v-if="fixed && placeholder" :style="{ - height: addUnit(getPx(height) + sys().statusBarHeight,'px'), + height: addUnit(getPx(height) + getWindowInfo().statusBarHeight,'px'), }" > @@ -77,7 +77,7 @@ import { props } from './props'; import { mpMixin } from '../../libs/mixin/mpMixin'; import { mixin } from '../../libs/mixin/mixin'; - import { addUnit, addStyle, getPx, sys } from '../../libs/function/index'; + import { addUnit, addStyle, getPx, getWindowInfo } from '../../libs/function/index'; /** * Navbar 自定义导航栏 * @description 此组件一般用于在特殊情况下,需要自定义导航栏的时候用到,一般建议使用uni-app带的导航栏。 @@ -114,7 +114,7 @@ methods: { addStyle, addUnit, - sys, + getWindowInfo, getPx, // 点击左侧区域 leftClick() { diff --git a/src/uni_modules/uview-plus/components/u-no-network/u-no-network.vue b/src/uni_modules/uview-plus/components/u-no-network/u-no-network.vue index 54539a528..62f85ffb8 100644 --- a/src/uni_modules/uview-plus/components/u-no-network/u-no-network.vue +++ b/src/uni_modules/uview-plus/components/u-no-network/u-no-network.vue @@ -46,7 +46,7 @@ import { props } from './props'; import { mpMixin } from '../../libs/mixin/mpMixin'; import { mixin } from '../../libs/mixin/mixin'; - import { toast } from '../../libs/function/index'; + import { toast, getDeviceInfo } from '../../libs/function/index'; /** * noNetwork 无网络提示 * @description 该组件无需任何配置,引入即可,内部自动处理所有功能和事件。 @@ -67,7 +67,7 @@ } }, mounted() { - this.isIOS = (uni.getSystemInfoSync().platform === 'ios') + this.isIOS = (getDeviceInfo().platform === 'ios') uni.onNetworkStatusChange((res) => { this.isConnected = res.isConnected this.networkType = res.networkType diff --git a/src/uni_modules/uview-plus/components/u-parse/node/node.vue b/src/uni_modules/uview-plus/components/u-parse/node/node.vue index 70a4b05fe..a6a4fe25d 100644 --- a/src/uni_modules/uview-plus/components/u-parse/node/node.vue +++ b/src/uni_modules/uview-plus/components/u-parse/node/node.vue @@ -122,7 +122,7 @@ export default { return { ctrl: {}, // #ifdef MP-WEIXIN - isiOS: uni.getSystemInfoSync().system.includes('iOS') + isiOS: uni.getDeviceInfo().system.includes('iOS') // #endif } }, diff --git a/src/uni_modules/uview-plus/components/u-parse/parser.js b/src/uni_modules/uview-plus/components/u-parse/parser.js index c251cbff3..dc93c9d97 100644 --- a/src/uni_modules/uview-plus/components/u-parse/parser.js +++ b/src/uni_modules/uview-plus/components/u-parse/parser.js @@ -75,12 +75,16 @@ const config = { } } const tagSelector={} +// #ifdef APP || H5 || MP-WEIXIN +const { windowWidth } = uni.getWindowInfo() +const { system } = uni.getDeviceInfo() +// #endif +// #ifndef APP || H5 || MP-WEIXIN const { windowWidth, - // #ifdef MP-WEIXIN system - // #endif } = uni.getSystemInfoSync() +// #endif const blankChar = makeMap(' ,\r,\n,\t,\f') let idIndex = 0 diff --git a/src/uni_modules/uview-plus/components/u-popup/u-popup.vue b/src/uni_modules/uview-plus/components/u-popup/u-popup.vue index bd5fa32e6..caf24fad8 100644 --- a/src/uni_modules/uview-plus/components/u-popup/u-popup.vue +++ b/src/uni_modules/uview-plus/components/u-popup/u-popup.vue @@ -51,7 +51,7 @@ import { props } from './props'; import { mpMixin } from '../../libs/mixin/mpMixin'; import { mixin } from '../../libs/mixin/mixin'; - import { addUnit, addStyle, deepMerge, sleep, sys } from '../../libs/function/index'; + import { addUnit, addStyle, deepMerge, sleep, getWindowInfo } from '../../libs/function/index'; /** * popup 弹窗 * @description 弹出层容器,用于展示弹窗、信息提示等内容,支持上、下、左、右和中部弹出。组件只提供容器,内部内容由用户自定义 @@ -139,7 +139,7 @@ // 不使用css方案,是因为nvue不支持css的iPhoneX安全区查询属性 const { safeAreaInsets - } = sys() + } = getWindowInfo() if (this.mode !== 'center') { style.flex = 1 } diff --git a/src/uni_modules/uview-plus/components/u-safe-bottom/u-safe-bottom.vue b/src/uni_modules/uview-plus/components/u-safe-bottom/u-safe-bottom.vue index db8475d16..70c381bc9 100644 --- a/src/uni_modules/uview-plus/components/u-safe-bottom/u-safe-bottom.vue +++ b/src/uni_modules/uview-plus/components/u-safe-bottom/u-safe-bottom.vue @@ -11,7 +11,7 @@ import { props } from "./props.js"; import { mpMixin } from '../../libs/mixin/mpMixin'; import { mixin } from '../../libs/mixin/mixin'; - import { addStyle, deepMerge, addUnit, sys } from '../../libs/function/index'; + import { addStyle, deepMerge, addUnit, getWindowInfo } from '../../libs/function/index'; /** * SafeBottom 底部安全区 * @description 这个适配,主要是针对IPhone X等一些底部带指示条的机型,指示条的操作区域与页面底部存在重合,容易导致用户误操作,因此我们需要针对这些机型进行底部安全区适配。 @@ -36,7 +36,7 @@ const style = {}; // #ifdef APP-NVUE || MP-TOUTIAO // nvue下,高度使用js计算填充 - style.height = addUnit(sys().safeAreaInsets.bottom, 'px'); + style.height = addUnit(getWindowInfo().safeAreaInsets.bottom, 'px'); // #endif return deepMerge(style, addStyle(this.customStyle)); }, diff --git a/src/uni_modules/uview-plus/components/u-status-bar/u-status-bar.vue b/src/uni_modules/uview-plus/components/u-status-bar/u-status-bar.vue index f7d35ab88..e962f9155 100644 --- a/src/uni_modules/uview-plus/components/u-status-bar/u-status-bar.vue +++ b/src/uni_modules/uview-plus/components/u-status-bar/u-status-bar.vue @@ -12,7 +12,7 @@ import { props } from './props'; import { mpMixin } from '../../libs/mixin/mpMixin'; import { mixin } from '../../libs/mixin/mixin'; - import { addUnit, addStyle, deepMerge, sys } from '../../libs/function/index'; + import { addUnit, addStyle, deepMerge, getWindowInfo } from '../../libs/function/index'; /** * StatbusBar 状态栏占位 * @description 本组件主要用于状态填充,比如在自定导航栏的时候,它会自动适配一个恰当的状态栏高度。 @@ -38,7 +38,7 @@ style() { const style = {} // 状态栏高度,由于某些安卓和微信开发工具无法识别css的顶部状态栏变量,所以使用js获取的方式 - style.height = addUnit(sys().statusBarHeight, 'px') + style.height = addUnit(getWindowInfo().statusBarHeight, 'px') style.backgroundColor = this.bgColor return deepMerge(style, addStyle(this.customStyle)) } diff --git a/src/uni_modules/uview-plus/components/u-sticky/u-sticky.vue b/src/uni_modules/uview-plus/components/u-sticky/u-sticky.vue index 7c3eb5ef9..4cc483d51 100644 --- a/src/uni_modules/uview-plus/components/u-sticky/u-sticky.vue +++ b/src/uni_modules/uview-plus/components/u-sticky/u-sticky.vue @@ -17,7 +17,7 @@ import { props } from './props'; import { mpMixin } from '../../libs/mixin/mpMixin'; import { mixin } from '../../libs/mixin/mixin'; - import { addUnit, addStyle, deepMerge, getPx, guid, sys, os } from '../../libs/function/index'; + import { addUnit, addStyle, deepMerge, getPx, guid, getDeviceInfo, os } from '../../libs/function/index'; import zIndex from '../../libs/config/zIndex'; /** * sticky 吸顶 @@ -150,7 +150,7 @@ // #endif // 如果安卓版本高于8.0,依然认为是支持css sticky的(因为安卓7在某些机型,可能不支持sticky) - if (os() === 'android' && Number(sys().system) > 8) { + if (os() === 'android' && Number(getDeviceInfo().system) > 8) { this.cssSticky = true } diff --git a/src/uni_modules/uview-plus/components/u-tabs/u-tabs.vue b/src/uni_modules/uview-plus/components/u-tabs/u-tabs.vue index 87dfcec26..1fb1d54a3 100644 --- a/src/uni_modules/uview-plus/components/u-tabs/u-tabs.vue +++ b/src/uni_modules/uview-plus/components/u-tabs/u-tabs.vue @@ -95,7 +95,7 @@ import { mpMixin } from '../../libs/mixin/mpMixin'; import { mixin } from '../../libs/mixin/mixin'; import defProps from '../../libs/config/props.js' - import { addUnit, addStyle, deepMerge, getPx, sleep, sys } from '../../libs/function/index'; + import { addUnit, addStyle, deepMerge, getPx, sleep, getWindowInfo } from '../../libs/function/index'; /** * Tabs 标签 * @description tabs标签组件,在标签多的时候,可以配置为左右滑动,标签少的时候,可以禁止滑动。 该组件的一个特点是配置为滚动模式时,激活的tab会自动移动到组件的中间位置。 @@ -253,7 +253,7 @@ return total + curr.rect.width }, 0) // 此处为屏幕宽度 - const windowWidth = sys().windowWidth + const windowWidth = getWindowInfo().windowWidth // 将活动的tabs-item移动到屏幕正中间,实际上是对scroll-view的移动 let scrollLeft = offsetLeft - (this.tabsRect.width - tabRect.rect.width) / 2 - (windowWidth - this.tabsRect .right) / 2 + this.tabsRect.left / 2 diff --git a/src/uni_modules/uview-plus/components/u-toast/u-toast.vue b/src/uni_modules/uview-plus/components/u-toast/u-toast.vue index b03e1d361..dd1b94236 100644 --- a/src/uni_modules/uview-plus/components/u-toast/u-toast.vue +++ b/src/uni_modules/uview-plus/components/u-toast/u-toast.vue @@ -42,7 +42,7 @@