fix kkFile预览水印加时间
This commit is contained in:
@@ -3,14 +3,33 @@ import { USER_INFO } from '../store/mutation-types'
|
||||
import { Base64 } from 'js-base64'
|
||||
import md5 from 'md5'
|
||||
|
||||
function fillZero (str) {
|
||||
let realNum
|
||||
if (str < 10) {
|
||||
realNum = '0' + str
|
||||
} else {
|
||||
realNum = str
|
||||
}
|
||||
return realNum
|
||||
}
|
||||
|
||||
/**
|
||||
* kkFile预览文件并添加水印
|
||||
* @param fileUrl
|
||||
*/
|
||||
export const kkFilePreview = (fileUrl) => {
|
||||
const userInfo = Vue.ls.get(USER_INFO)
|
||||
// 获取当前时间
|
||||
const date = new Date()
|
||||
const year = date.getFullYear()
|
||||
const month = date.getMonth() + 1
|
||||
const day = date.getDate()
|
||||
const hour = date.getHours()
|
||||
const minute = date.getMinutes()
|
||||
const second = date.getSeconds()
|
||||
const time = `${year}${fillZero(month)}${fillZero(day)}${fillZero(hour)}${fillZero(minute)}${fillZero(second)}`
|
||||
// 水印内容
|
||||
const watermarkTxt = `${userInfo.username} ${userInfo.realname}`
|
||||
const watermarkTxt = `${userInfo.username} ${userInfo.realname} ${time}`
|
||||
// 客户环境预览需要加的加密参数
|
||||
const watermarkSign = md5(watermarkTxt + 'cnhtc')
|
||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileUrl))}&watermarkTxt=${encodeURIComponent(watermarkTxt)}&watermarkSign=${watermarkSign}`
|
||||
|
||||
Reference in New Issue
Block a user