完善录音时长功能

This commit is contained in:
zhonghua.li
2026-02-07 19:51:03 +08:00
parent 33950f41fd
commit 3944fa6969
52 changed files with 2013 additions and 886 deletions

View File

@@ -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'
}
}
}