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 { downloadFile, getFileAccessHttpUrl } from '../api/manage.js'
|
||||||
import { previewPdf } from '../utils/previewPdf.js'
|
import { previewPdf } from '../utils/previewPdf.js'
|
||||||
import { Base64 } from 'js-base64'
|
import { Base64 } from 'js-base64'
|
||||||
|
import { kkFilePreview } from '../utils/kkFilePreview'
|
||||||
|
|
||||||
// 支持预览的文件类型
|
// 支持预览的文件类型
|
||||||
const CAN_PREVIEW_FILE_TYPE = ['pdf', 'image']
|
const CAN_PREVIEW_FILE_TYPE = ['pdf', 'image']
|
||||||
@@ -120,8 +121,7 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 其余可预览文件仍使用KKFile进行预览
|
// 其余可预览文件仍使用KKFile进行预览
|
||||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
kkFilePreview(fileFullUrl)
|
||||||
window.open(url)
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 单个文件的下载功能
|
* 单个文件的下载功能
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import { downloadFile, getFileAccessHttpUrl } from '@/api/manage'
|
|||||||
import { getFileInfo } from '@/api/api'
|
import { getFileInfo } from '@/api/api'
|
||||||
import { previewPdf } from '@/utils/previewPdf'
|
import { previewPdf } from '@/utils/previewPdf'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
import { kkFilePreview } from '../utils/kkFilePreview'
|
||||||
|
|
||||||
const FILE_TYPE_ALL = 'all'
|
const FILE_TYPE_ALL = 'all'
|
||||||
const FILE_TYPE_IMG = 'image'
|
const FILE_TYPE_IMG = 'image'
|
||||||
@@ -327,8 +328,7 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 其余可预览文件仍使用KKFile进行预览
|
// 其余可预览文件仍使用KKFile进行预览
|
||||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
kkFilePreview(fileFullUrl)
|
||||||
window.open(url)
|
|
||||||
},
|
},
|
||||||
handleDownload (file) {
|
handleDownload (file) {
|
||||||
// 下载文件
|
// 下载文件
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import { ACCESS_TOKEN } from '@/store/mutation-types'
|
|||||||
import { getFileAccessHttpUrl, downloadFile } from '@/api/manage'
|
import { getFileAccessHttpUrl, downloadFile } from '@/api/manage'
|
||||||
import { getFileInfo } from '@/api/api'
|
import { getFileInfo } from '@/api/api'
|
||||||
import { previewPdf } from '../../utils/previewPdf'
|
import { previewPdf } from '../../utils/previewPdf'
|
||||||
|
import { kkFilePreview } from '../../utils/kkFilePreview'
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
// const Base64 = require('js-base64').Base64
|
// const Base64 = require('js-base64').Base64
|
||||||
@@ -459,8 +460,7 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 其余可预览文件仍使用KKFile进行预览
|
// 其余可预览文件仍使用KKFile进行预览
|
||||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
kkFilePreview(fileFullUrl)
|
||||||
window.open(url)
|
|
||||||
},
|
},
|
||||||
getFileUrl (fileId) {
|
getFileUrl (fileId) {
|
||||||
return `${window._CONFIG.domianURL}/sys/common/download/${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 { downloadFile, getFileAccessHttpUrl } from '../../../../api/manage'
|
||||||
import { previewPdf } from '../../../../utils/previewPdf'
|
import { previewPdf } from '../../../../utils/previewPdf'
|
||||||
import { Base64 } from 'js-base64'
|
import { Base64 } from 'js-base64'
|
||||||
|
import { kkFilePreview } from '../../../../utils/kkFilePreview'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'BasisDescriptionModal',
|
name: 'BasisDescriptionModal',
|
||||||
@@ -217,8 +218,7 @@ export default {
|
|||||||
}
|
}
|
||||||
// word用KKfile预览
|
// word用KKfile预览
|
||||||
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
|
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
|
||||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
kkFilePreview(fileFullUrl)
|
||||||
window.open(url)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 如果都不能预览就下载
|
// 如果都不能预览就下载
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ import { ACCESS_TOKEN } from '../../../store/mutation-types.js'
|
|||||||
import { downloadFile, getFileAccessHttpUrl } from '../../../api/manage.js'
|
import { downloadFile, getFileAccessHttpUrl } from '../../../api/manage.js'
|
||||||
import { previewPdf } from '../../../utils/previewPdf.js'
|
import { previewPdf } from '../../../utils/previewPdf.js'
|
||||||
import { Base64 } from 'js-base64'
|
import { Base64 } from 'js-base64'
|
||||||
|
import { kkFilePreview } from '../../../utils/kkFilePreview'
|
||||||
|
|
||||||
// 国内标准权限
|
// 国内标准权限
|
||||||
const DomesticStandardPermission = {
|
const DomesticStandardPermission = {
|
||||||
@@ -396,8 +397,7 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 其余可预览文件仍使用KKFile进行预览
|
// 其余可预览文件仍使用KKFile进行预览
|
||||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
kkFilePreview(fileFullUrl)
|
||||||
window.open(url)
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 无水印下载
|
* 无水印下载
|
||||||
|
|||||||
Reference in New Issue
Block a user