Files
lingxiao865 c5af079d8c first commit
2026-02-10 08:05:03 +08:00

23 lines
952 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export const getObserver = (context, selector) => new Promise((resolve) => {
uni
.createIntersectionObserver(context, {
nativeMode: true,
})
.relativeToViewport()
.observe(selector, (res) => {
resolve(res);
});
});
/**
* 背景:单页模式下, getWindowInfo、getAppBaseInfo、getDeviceInfo 等接口均返回 undefined。
* 复现路径分享到朋友圈再打开单页模式的该页面uni.getWindowInfo() 等接口返回 undefined
* 代码片段https://developers.weixin.qq.com/s/mzvZ8FmH7vVW
*/
export const getWindowInfo = () => (uni.getWindowInfo ? uni.getWindowInfo() || uni.getSystemInfoSync() : uni.getSystemInfoSync());
export const getAppBaseInfo = () => (uni.getAppBaseInfo ? uni.getAppBaseInfo() || uni.getSystemInfoSync() : uni.getSystemInfoSync());
export const getDeviceInfo = () => (uni.getDeviceInfo ? uni.getDeviceInfo() || uni.getSystemInfoSync() : uni.getSystemInfoSync());