Files
mini-yu/uni_modules/tdesign-uniapp/components/common/wechat.js

23 lines
952 B
JavaScript
Raw Normal View History

2026-02-10 08:05:03 +08:00
export const getObserver = (context, selector) => new Promise((resolve) => {
uni
.createIntersectionObserver(context, {
nativeMode: true,
})
.relativeToViewport()
.observe(selector, (res) => {
resolve(res);
});
});
/**
* 背景单页模式下, getWindowInfogetAppBaseInfogetDeviceInfo 等接口均返回 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());