js文件,可适用于移动端和pc端。
主要功能:复制粘贴、切屏、中断、摄像拍照功能。
import axios from 'axios'
let cheatInfo = {
hideTime: 0,
showTime: 0,
leaveTimes: 0,
breakTimes: 0
}
let captureImageTimer = null
let isUploading = false
let stopCaptureFlag = false
// 上传拍照、切屏、中断记录
const _uploadRecord = (url, data, config) => {
axios.post(url, data, {
withCredentials: true }).finally(() => {
isUploading = false
if (config && config.request.interval && !stopCaptureFlag) {
captureImageTimer = setTimeout(() => {
startCaptureImage(config)
}, config.request.interval)
}
})
}
// 获取相机列表
const getCamera = () => {
return new Promise((resolve, reject) => {
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
console.log('浏览器不支持摄像头 enumerateDevices() 方法,请更换浏览器')
reject('浏览器不支持摄像头功能~')
}
navigator.mediaDevices.enumerateDevices().then((devices) => {
const videoInputList = []
devices.forEach((device) => {
if (device.kind === 'videoinput') {
videoInputList.push({
label: device.label || 'Default Camera',
id: device.deviceId
})
}
})
resolve(videoInputList)
}).catch((err) => {
reject(err)
版权声明:本文为qq_46620208原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。