增加token
This commit is contained in:
parent
c0ab0af5ec
commit
ec5f3fde4a
|
|
@ -183,7 +183,27 @@
|
|||
</div>
|
||||
</div>
|
||||
</#if>
|
||||
<script type="text/javascript" src="crypto-js-4.0.0/crypto-js.js"></script>
|
||||
<script>
|
||||
function encryptCBC(word){
|
||||
var cbc_key = CryptoJS.enc.Utf8.parse("zhgd@bonus@zhgd@bonus@1234567890");
|
||||
var cbc_iv = CryptoJS.enc.Utf8.parse("1234567812345678");
|
||||
var srcs = CryptoJS.enc.Utf8.parse(word)
|
||||
var encrypted = CryptoJS.AES.encrypt(srcs, cbc_key, {
|
||||
iv: cbc_iv,
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
});
|
||||
return encrypted.toString();
|
||||
}
|
||||
|
||||
function generateToken(){
|
||||
// 获取当前时间戳(以秒为单位)
|
||||
const currentTimeStamp = Math.floor(Date.now());
|
||||
// 将时间戳转换为字符串
|
||||
const timeStampString = currentTimeStamp.toString();
|
||||
return encryptCBC(timeStampString);
|
||||
}
|
||||
<#if deleteCaptcha >
|
||||
$("#deleteCaptchaImg").click(function() {
|
||||
$("#deleteCaptchaImg").attr("src","${baseUrl}deleteFile/captcha?timestamp=" + new Date().getTime());
|
||||
|
|
@ -246,7 +266,7 @@
|
|||
function fileConvert(fileName){
|
||||
showConvertingDiv();
|
||||
$.ajax({
|
||||
url: '${baseUrl}onConvert?url=' + encodeURIComponent(Base64.encode('${baseUrl}' +fileName)),
|
||||
url: '${baseUrl}onConvert?url=' + encodeURIComponent(Base64.encode('${baseUrl}' +fileName))+"&token="+ generateToken(),
|
||||
type: "GET",
|
||||
dataType: "text",
|
||||
success: function (data) {
|
||||
|
|
@ -304,7 +324,7 @@
|
|||
$(data).each(function (index, item) {
|
||||
//href='${baseUrl}onConvert?url=" + encodeURIComponent(Base64.encode('${baseUrl}' + item.fileName)) + "'
|
||||
item.action = "<a class='btn btn-success' target='_blank' onclick='fileConvert(\"" + item.fileName + "\")'>转换</a>" +
|
||||
"<a class='btn btn-success' target='_blank' href='${baseUrl}onlinePreview?url=" + encodeURIComponent(Base64.encode('${baseUrl}' + item.fileName)) + "'>预览</a>" +
|
||||
"<a class='btn btn-success' target='_blank' href='${baseUrl}onlinePreview?url=" + encodeURIComponent(Base64.encode('${baseUrl}' + item.fileName))+"&token="+ generateToken()+" '>预览</a>" +
|
||||
"<a class='btn btn-danger' style='margin-left:10px;' href='javascript:void(0);' onclick='deleteFile(\"" + encodeURIComponent(Base64.encode('${baseUrl}' + item.fileName)) + "\")'>删除</a>";
|
||||
});
|
||||
return data;
|
||||
|
|
@ -325,7 +345,7 @@
|
|||
var b64Encoded = Base64.encode(_url);
|
||||
console.log("_url:" + _url)
|
||||
console.log("encodeURIComponent(b64Encoded(url):"+encodeURIComponent(b64Encoded))
|
||||
window.open('${baseUrl}onlinePreview?url=' + encodeURIComponent(b64Encoded));
|
||||
window.open('${baseUrl}onlinePreview?url=' + encodeURIComponent(b64Encoded) +"&token="+ generateToken());
|
||||
});
|
||||
|
||||
$("#fileUploadBtn").click(function () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue