askbot-dragon 1.3.33 → 1.3.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/previewDoc.vue +44 -34
package/package.json
CHANGED
|
@@ -21,13 +21,16 @@
|
|
|
21
21
|
<template v-else>
|
|
22
22
|
<iframe class="preview_iframe" :src="previewUrl" style="border:none;"></iframe>
|
|
23
23
|
</template>
|
|
24
|
-
|
|
24
|
+
<div class="onload_btn" @click="downLoad">
|
|
25
25
|
下载
|
|
26
|
-
</div>
|
|
26
|
+
</div>
|
|
27
27
|
</div>
|
|
28
28
|
</template>
|
|
29
29
|
|
|
30
30
|
<script>
|
|
31
|
+
import { Toast } from 'vant';
|
|
32
|
+
import { isMobile } from "../assets/js/common";
|
|
33
|
+
|
|
31
34
|
export default {
|
|
32
35
|
data () {
|
|
33
36
|
return {
|
|
@@ -49,12 +52,19 @@ export default {
|
|
|
49
52
|
previewUrl () {
|
|
50
53
|
let url = process.env.VUE_APP_ENV === 'production' ? 'https://kkfileview.askbot.cn/onlinePreview?url=' : 'https://test.open.askbot.cn/kkfileview/onlinePreview?url='
|
|
51
54
|
if (this.url != '') {
|
|
52
|
-
if (/[\u4E00-\u9FA5]+/g.test(this.url)) {
|
|
55
|
+
// if (/[\u4E00-\u9FA5]+/g.test(this.url)) {
|
|
56
|
+
// url += btoa(encodeURIComponent(this.url))
|
|
57
|
+
// } else {
|
|
58
|
+
// url += btoa(this.url)
|
|
59
|
+
// }
|
|
60
|
+
// url += '&encodeURIComponent=true'
|
|
61
|
+
if(decodeURIComponent(this.url) == this.url) {
|
|
53
62
|
url += btoa(encodeURIComponent(this.url))
|
|
63
|
+
url += '&encodeURIComponent=true'
|
|
54
64
|
} else {
|
|
55
|
-
url += btoa(this.url)
|
|
65
|
+
url += btoa(encodeURIComponent(decodeURIComponent(this.url)))
|
|
66
|
+
url += '&encodeURIComponent=true'
|
|
56
67
|
}
|
|
57
|
-
url += '&encodeURIComponent=true'
|
|
58
68
|
}
|
|
59
69
|
return url
|
|
60
70
|
},
|
|
@@ -89,36 +99,35 @@ export default {
|
|
|
89
99
|
// }
|
|
90
100
|
},
|
|
91
101
|
downLoad () {
|
|
92
|
-
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
this.$message({
|
|
96
|
-
title: '下载地址已复制,请前往Safari浏览器访问下载'
|
|
97
|
-
})
|
|
98
|
-
return
|
|
99
|
-
} else if (/(Android)/i.test(navigator.userAgent)) {
|
|
100
|
-
console.log('isAndroid')
|
|
101
|
-
} else {
|
|
102
|
-
console.log('isPC')
|
|
103
|
-
}
|
|
104
|
-
if (fileType == '.txt') {
|
|
105
|
-
this.$http.get(this.url).then(res =>{
|
|
106
|
-
let elink = document.createElement("a");// 设置下载文件名
|
|
107
|
-
elink.download = this.title + '.txt';
|
|
108
|
-
elink.style.display = "none";
|
|
109
|
-
let blob = new Blob([res.data]);
|
|
110
|
-
elink.href = URL.createObjectURL(blob);
|
|
111
|
-
document.body.appendChild(elink);
|
|
112
|
-
elink.click();
|
|
113
|
-
document.body.removeChild(elink);
|
|
114
|
-
URL.revokeObjectURL(blob); //释放对象
|
|
115
|
-
})
|
|
116
|
-
} else {
|
|
117
|
-
let a = document.createElement('a')
|
|
118
|
-
a.href = this.url
|
|
119
|
-
a.download = (this.title) + fileType
|
|
120
|
-
a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
|
|
102
|
+
let url = this.url
|
|
103
|
+
if (decodeURIComponent(url) != url) {
|
|
104
|
+
url = decodeURIComponent(url)
|
|
121
105
|
}
|
|
106
|
+
const fileType = url.substring(url.lastIndexOf('.'));
|
|
107
|
+
this.$http.post('/knowledge-api/temporary-certificate/or-origin?expired=10', url, {
|
|
108
|
+
headers:{
|
|
109
|
+
"Content-Type": "application/json",
|
|
110
|
+
}
|
|
111
|
+
}).then(res => {
|
|
112
|
+
if (res.data) {
|
|
113
|
+
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
|
|
114
|
+
if(isMobile()) {
|
|
115
|
+
Toast('下载地址已复制,请前往Safari浏览器访问下载');
|
|
116
|
+
} else {
|
|
117
|
+
navigator.clipboard.writeText(res.data)
|
|
118
|
+
this.$message.success({
|
|
119
|
+
message:'下载地址已复制,请前往Safari浏览器访问下载',
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
return
|
|
123
|
+
} else {
|
|
124
|
+
let a = document.createElement('a')
|
|
125
|
+
a.href = res.data
|
|
126
|
+
a.download = (this.title) + fileType
|
|
127
|
+
a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
})
|
|
122
131
|
}
|
|
123
132
|
}
|
|
124
133
|
}
|
|
@@ -161,6 +170,7 @@ export default {
|
|
|
161
170
|
justify-content: center;
|
|
162
171
|
border-radius: 28px;
|
|
163
172
|
cursor: pointer;
|
|
173
|
+
z-index: 9999;
|
|
164
174
|
i{
|
|
165
175
|
margin-right: 8px;
|
|
166
176
|
}
|