fix kkFile预览提出公共方法,加水印
This commit is contained in:
@@ -28,6 +28,7 @@ import { ACCESS_TOKEN } from '../store/mutation-types.js'
|
||||
import { downloadFile, getFileAccessHttpUrl } from '../api/manage.js'
|
||||
import { previewPdf } from '../utils/previewPdf.js'
|
||||
import { Base64 } from 'js-base64'
|
||||
import { kkFilePreview } from '../utils/kkFilePreview'
|
||||
|
||||
// 支持预览的文件类型
|
||||
const CAN_PREVIEW_FILE_TYPE = ['pdf', 'image']
|
||||
@@ -120,8 +121,7 @@ export default {
|
||||
return
|
||||
}
|
||||
// 其余可预览文件仍使用KKFile进行预览
|
||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
||||
window.open(url)
|
||||
kkFilePreview(fileFullUrl)
|
||||
},
|
||||
/**
|
||||
* 单个文件的下载功能
|
||||
|
||||
@@ -54,6 +54,7 @@ import { downloadFile, getFileAccessHttpUrl } from '@/api/manage'
|
||||
import { getFileInfo } from '@/api/api'
|
||||
import { previewPdf } from '@/utils/previewPdf'
|
||||
import Vue from 'vue'
|
||||
import { kkFilePreview } from '../utils/kkFilePreview'
|
||||
|
||||
const FILE_TYPE_ALL = 'all'
|
||||
const FILE_TYPE_IMG = 'image'
|
||||
@@ -327,8 +328,7 @@ export default {
|
||||
return
|
||||
}
|
||||
// 其余可预览文件仍使用KKFile进行预览
|
||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
||||
window.open(url)
|
||||
kkFilePreview(fileFullUrl)
|
||||
},
|
||||
handleDownload (file) {
|
||||
// 下载文件
|
||||
|
||||
@@ -48,6 +48,7 @@ import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||
import { getFileAccessHttpUrl, downloadFile } from '@/api/manage'
|
||||
import { getFileInfo } from '@/api/api'
|
||||
import { previewPdf } from '../../utils/previewPdf'
|
||||
import { kkFilePreview } from '../../utils/kkFilePreview'
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
// const Base64 = require('js-base64').Base64
|
||||
@@ -459,8 +460,7 @@ export default {
|
||||
return
|
||||
}
|
||||
// 其余可预览文件仍使用KKFile进行预览
|
||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
||||
window.open(url)
|
||||
kkFilePreview(fileFullUrl)
|
||||
},
|
||||
getFileUrl (fileId) {
|
||||
return `${window._CONFIG.domianURL}/sys/common/download/${fileId}`
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import Vue from 'vue'
|
||||
import { USER_INFO } from '../store/mutation-types'
|
||||
import { Base64 } from 'js-base64'
|
||||
|
||||
const md5 = require('md5')
|
||||
|
||||
/**
|
||||
* kkFile预览文件并添加水印
|
||||
* @param fileUrl
|
||||
*/
|
||||
export const kkFilePreview = (fileUrl) => {
|
||||
const userInfo = Vue.ls.get(USER_INFO)
|
||||
// 水印内容
|
||||
const watermarkTxt = `${userInfo.username} ${userInfo.realname}`
|
||||
// 客户环境预览需要加的加密参数
|
||||
const watermarkSign = md5(watermarkTxt, 'cnhtc')
|
||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileUrl))}&watermarkTxt=${encodeURIComponent(watermarkTxt)}&watermarkSign=${watermarkSign}`
|
||||
window.open(url)
|
||||
}
|
||||
@@ -95,6 +95,7 @@ import { ACCESS_TOKEN } from '../../../../store/mutation-types'
|
||||
import { downloadFile, getFileAccessHttpUrl } from '../../../../api/manage'
|
||||
import { previewPdf } from '../../../../utils/previewPdf'
|
||||
import { Base64 } from 'js-base64'
|
||||
import { kkFilePreview } from '../../../../utils/kkFilePreview'
|
||||
|
||||
export default {
|
||||
name: 'BasisDescriptionModal',
|
||||
@@ -217,8 +218,7 @@ export default {
|
||||
}
|
||||
// word用KKfile预览
|
||||
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
|
||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
||||
window.open(url)
|
||||
kkFilePreview(fileFullUrl)
|
||||
return
|
||||
}
|
||||
// 如果都不能预览就下载
|
||||
|
||||
@@ -139,6 +139,7 @@ import { ACCESS_TOKEN } from '../../../store/mutation-types.js'
|
||||
import { downloadFile, getFileAccessHttpUrl } from '../../../api/manage.js'
|
||||
import { previewPdf } from '../../../utils/previewPdf.js'
|
||||
import { Base64 } from 'js-base64'
|
||||
import { kkFilePreview } from '../../../utils/kkFilePreview'
|
||||
|
||||
// 国内标准权限
|
||||
const DomesticStandardPermission = {
|
||||
@@ -396,8 +397,7 @@ export default {
|
||||
return
|
||||
}
|
||||
// 其余可预览文件仍使用KKFile进行预览
|
||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
||||
window.open(url)
|
||||
kkFilePreview(fileFullUrl)
|
||||
},
|
||||
/**
|
||||
* 无水印下载
|
||||
|
||||
Reference in New Issue
Block a user