完善录音时长功能
This commit is contained in:
@@ -5,11 +5,48 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// 获取系统信息的辅助函数,优先使用新 API
|
||||
function getSystemInfo() {
|
||||
// #ifdef MP-WEIXIN
|
||||
// 微信小程序:优先使用新的 API
|
||||
if (typeof wx !== 'undefined' && wx.getWindowInfo) {
|
||||
try {
|
||||
const windowInfo = wx.getWindowInfo();
|
||||
return {
|
||||
statusBarHeight: windowInfo.statusBarHeight || 20,
|
||||
windowWidth: windowInfo.windowWidth,
|
||||
windowHeight: windowInfo.windowHeight
|
||||
};
|
||||
} catch (e) {
|
||||
console.warn('[UniStatusBar] Failed to use wx.getWindowInfo, fallback to getSystemInfoSync:', e);
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
|
||||
// 回退到旧的 API 或使用 uni-app 的 API
|
||||
try {
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
return {
|
||||
statusBarHeight: systemInfo.statusBarHeight || 20,
|
||||
windowWidth: systemInfo.windowWidth,
|
||||
windowHeight: systemInfo.windowHeight
|
||||
};
|
||||
} catch (e) {
|
||||
console.error('[UniStatusBar] Failed to get system info:', e);
|
||||
return {
|
||||
statusBarHeight: 20,
|
||||
windowWidth: 375,
|
||||
windowHeight: 667
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'UniStatusBar',
|
||||
data() {
|
||||
const systemInfo = getSystemInfo();
|
||||
return {
|
||||
statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px'
|
||||
statusBarHeight: systemInfo.statusBarHeight + 'px'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user