</view>
</template>
<script setup lang="uts">
const webUrl = ref('')
const title = ref('Hello')
const web1 = ref<UniWebViewElement | null>(null)
const showCheckAuth = ref(true)
const statusBarHeight = uni.getWindowInfo().statusBarHeight
const reloading = ref(false)
function reloadWeb() {
if (reloading.value) {
return
} else {
reloading.value = true
uni.showToast({
icon: "loading",
title: '刷新中...',
duration: 2000
});
uni.reLaunch({
url: "/pages/index/index"
})
}
}
function onLoad() {
uni.showToast({
icon: "success",
title: '刷新成功',
duration: 1000
});
setTimeout(function () {
reloading.value = false;
}, 2000);
}
// 页面显示时检查录音权限,已授权则隐藏 checkAuth
onShow(() => {
const setting = uni.getAppAuthorizeSetting()
showCheckAuth.value = setting.microphoneAuthorized !== 'authorized'
setTimeout(function () {
webUrl.value = "https://ask.dcloud.net.cn/";
}, 200);
})
async function checkAuth() {
const setting = uni.getAppAuthorizeSetting()
if (setting.microphoneAuthorized !== 'authorized') {
uni.showModal({
title: '提示',
content: '需要录音权限才能使用,是否前往设置开启?',
confirmText: '去设置',
success: (res) => {
if (res.confirm) {
uni.openAppAuthorizeSetting({
fail: (e) => {
uni.showToast({ title: e.errMsg, icon: 'none' })
}
})
}
}
})
} else {
showCheckAuth.value = false
}
}
</script>
<style>
.container {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
background: none;
}
.checkAuth {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 10;
}
.reloadDiv {
display: flex;
align-items: flex-end;
justify-content: flex-start;
}
.reloadBtn {
display: flex;
flex-direction: row;
margin-right: 10rpx;
margin-bottom: 4rpx;
padding: 0 20rpx;
border-radius: 50%;
border: 1px solid #a0cfff;
align-items: center;
background-color: #ecf5ff;
}
.reloadText {
font-weight: bold;
color: #409eff;
}
.reloadIcon {
font-weight: bold;
font-size: 44rpx;
line-height: 44rpx;
color: #409eff;
}
.mainweb {
flex: 1;
}
.bottomDiv {
height: 20rpx;
background-color: #0D110E;
}
</style>