79 lines
2.0 KiB
Vue
79 lines
2.0 KiB
Vue
<template>
|
|
<view class="content">
|
|
<view class="btn" @click="onAntiScreenshot"><text>开启防截屏</text></view>
|
|
<view class="btn" @click="onAntiScreenshot2"><text>开启防截屏</text></view>
|
|
<view class="btn" @click="offAntiScreenshot"><text>关闭防截屏</text></view>
|
|
<view class="btn" @click="offAntiScreenshot2"><text>关闭防截屏</text></view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
|
|
}
|
|
},
|
|
methods: {
|
|
onAntiScreenshot() {
|
|
console.log('点击了开启按钮')
|
|
// screenshot.onAntiScreenshot()
|
|
// screenGuard.onAntiScreenshot()
|
|
uni.setUserCaptureScreen({
|
|
enable: false,
|
|
success() {
|
|
console.log('截屏录屏功能已禁用');
|
|
},
|
|
fail(err) {
|
|
console.error('禁用截屏录屏功能失败', err);
|
|
}
|
|
});
|
|
},
|
|
offAntiScreenshot() {
|
|
console.log('点击了关闭按钮')
|
|
// screenshot.offAntiScreenshot()
|
|
// screenGuard.offAntiScreenshot()
|
|
uni.setUserCaptureScreen({
|
|
enable: true,
|
|
success() {
|
|
console.log('截屏录屏功能已启用');
|
|
},
|
|
fail(err) {
|
|
console.error('启用截屏录屏功能失败', err);
|
|
}
|
|
})
|
|
},
|
|
onAntiScreenshot2() {
|
|
console.log('点击了开启按钮')
|
|
// screenshot.onAntiScreenshot()
|
|
screenGuard.onAntiScreenshot()
|
|
},
|
|
offAntiScreenshot2() {
|
|
console.log('点击了关闭按钮')
|
|
// screenshot.offAntiScreenshot()
|
|
|
|
screenGuard.offAntiScreenshot()
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.content {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.btn {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background-color: antiquewhite;
|
|
border-radius: 8rpx;
|
|
width: 690rpx;
|
|
height: 80rpx;
|
|
margin-top: 40rpx;
|
|
}
|
|
</style> |