// 对俯仰角度进行设置
|
export function setPitchAngle(pitch) {
|
let pitchment = Number(pitch) || 0
|
let result = ''
|
if (pitchment == 0) {
|
result = '正前'
|
} else if (pitchment > -90 && pitchment < 0) {
|
result = '斜下'
|
} else if (pitchment == -90) {
|
result = '正下'
|
} else if (pitchment > 0 && pitchment < 90) {
|
result = '斜上'
|
} else if (pitchment == 90) {
|
result = '正上'
|
}
|
return result
|
}
|
|
// 对云台偏航角度进行设置
|
export function setYawAngle(Yaw) {
|
let adjustment = Number(Yaw) || 0
|
let result = ''
|
if (adjustment > 0 && adjustment <= 45) {
|
result = '北偏东'
|
} else if (adjustment > 45 && adjustment < 90) {
|
result = '东偏北'
|
} else if (adjustment == 90) {
|
result = '正东'
|
} else if (adjustment > 90 && adjustment <= 135) {
|
result = '东偏南'
|
} else if (adjustment > 135 && adjustment < 180) {
|
result = '南偏东'
|
} else if (adjustment == 180) {
|
result = '正南'
|
} else if (adjustment < 0 && adjustment >= -45) {
|
result = '北偏西'
|
} else if (adjustment < -45 && adjustment > -90) {
|
result = '西偏北'
|
} else if (adjustment == -90) {
|
result = '正西'
|
} else if (adjustment < -90 && adjustment >= -135) {
|
result = '西偏南'
|
} else if (adjustment < -135 && adjustment > -180) {
|
result = '南偏西'
|
} else {
|
result = '正北'
|
}
|
return result
|
}
|
|
// 文件格式后缀获取
|
export function getFileType(ext) {
|
// 获取类型结果
|
let result = ''
|
// fileName无后缀返回 false
|
if (!ext) {
|
return -1
|
}
|
ext = ext.toLocaleLowerCase()
|
// 图片格式
|
const imglist = ['png', 'jpg', 'jpeg', 'bmp', 'gif']
|
// 进行图片匹配
|
result = imglist.find(item => item === ext)
|
if (result) {
|
return 'image'
|
}
|
// 匹配txt
|
const txtlist = ['txt']
|
result = txtlist.find(item => item === ext)
|
if (result) {
|
return 'txt'
|
}
|
// 匹配 excel
|
const excelist = ['xls', 'xlsx']
|
result = excelist.find(item => item === ext)
|
if (result) {
|
return 'excel'
|
}
|
// 匹配 word
|
const wordlist = ['doc', 'docx']
|
result = wordlist.find(item => item === ext)
|
if (result) {
|
return 'word'
|
}
|
// 匹配 pdf
|
const pdflist = ['pdf']
|
result = pdflist.find(item => item === ext)
|
if (result) {
|
return 'pdf'
|
}
|
// 匹配 ppt
|
const pptlist = ['ppt', 'pptx']
|
result = pptlist.find(item => item === ext)
|
if (result) {
|
return 'ppt'
|
}
|
// 匹配 视频
|
const videolist = ['mp4', 'm2v', 'mkv', 'rmvb', 'wmv', 'avi', 'flv', 'mov', 'm4v', 'ogv']
|
result = videolist.find(item => item === ext)
|
if (result) {
|
return 'video'
|
}
|
// 匹配 音频
|
const radiolist = ['mp3', 'wav', 'wmv']
|
result = radiolist.find(item => item === ext)
|
if (result) {
|
return 'radio'
|
}
|
// 其他 文件类型
|
return 'other'
|
}
|
|
// 获取视频首帧
|
export function getVideoFirstCover(url) {
|
return new Promise(resolve => {
|
const video = document.createElement('video')
|
video.src = url
|
video.muted = true
|
video.setAttribute('crossorigin', 'anonymous')
|
|
video.addEventListener('loadedmetadata', function () {
|
const canvas = document.createElement('canvas')
|
canvas.width = video.videoWidth
|
canvas.height = video.videoHeight
|
|
const context = canvas.getContext('2d')
|
context.drawImage(video, 0, 0, canvas.width, canvas.height)
|
|
// 输出首帧图像
|
const firstFrameDataUrl = canvas.toDataURL('image/png')
|
resolve(firstFrameDataUrl)
|
})
|
})
|
}
|