oss兼容
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
304ab2bf62
commit
656ebeb3e9
14
src/main.js
14
src/main.js
|
@ -103,12 +103,14 @@ Vue.prototype.selectDictLabel = selectDictLabel
|
||||||
Vue.prototype.handleTree = handleTree
|
Vue.prototype.handleTree = handleTree
|
||||||
|
|
||||||
Vue.prototype.$getObjectName = (url) => {
|
Vue.prototype.$getObjectName = (url) => {
|
||||||
console.log(url)
|
// console.log(url,'url')
|
||||||
var value = url
|
// console.log(Vue.prototype.OSSclientConfig.viewEndpoint,'url')
|
||||||
var str = value.split("//"); //https://进行分割,
|
var value = url;
|
||||||
var index = str[1].indexOf("/") + 1; //indexOf 获取第一个斜杠的索引,
|
let basePath = Vue.prototype.OSSclientConfig.viewEndpoint;
|
||||||
console.log(str[1].substring(index)); //substring 截取,
|
if (Vue.prototype.OSSclientConfig.ObjectStoreUse === 'AliyunOSS') {
|
||||||
return '/' + str[1].substring(index)
|
basePath = Vue.prototype.OSSclientConfig.endPoint.split('https://').length > 1 ? Vue.prototype.OSSclientConfig.endPoint.split('https://')[1] : Vue.prototype.OSSclientConfig.endPoint;
|
||||||
|
}
|
||||||
|
return value.split(basePath)[1];
|
||||||
}
|
}
|
||||||
Vue.prototype.getGuid = (text) => {
|
Vue.prototype.getGuid = (text) => {
|
||||||
text = md5(text)
|
text = md5(text)
|
||||||
|
|
|
@ -19,6 +19,7 @@ function blobToBuffer(blob, fileName) {
|
||||||
async function ossGenerateSTS() {
|
async function ossGenerateSTS() {
|
||||||
let res = await GetObjectStoreToken()
|
let res = await GetObjectStoreToken()
|
||||||
Vue.prototype.OSSclientConfig = { ...res.Result[res.Result.ObjectStoreUse] }
|
Vue.prototype.OSSclientConfig = { ...res.Result[res.Result.ObjectStoreUse] }
|
||||||
|
Vue.prototype.OSSclientConfig.ObjectStoreUse = res.Result.ObjectStoreUse;
|
||||||
Vue.prototype.OSSclientConfig.basePath = Vue.prototype.OSSclientConfig.viewEndpoint
|
Vue.prototype.OSSclientConfig.basePath = Vue.prototype.OSSclientConfig.viewEndpoint
|
||||||
switch (res.Result.ObjectStoreUse) {
|
switch (res.Result.ObjectStoreUse) {
|
||||||
case 'AliyunOSS':
|
case 'AliyunOSS':
|
||||||
|
@ -39,7 +40,7 @@ async function ossGenerateSTS() {
|
||||||
if (res && res.url) {
|
if (res && res.url) {
|
||||||
resolve({
|
resolve({
|
||||||
name: objectName,
|
name: objectName,
|
||||||
url: Vue.prototype.OSSclientConfig.viewEndpoint + objectName
|
url: res.url
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
reject()
|
reject()
|
||||||
|
@ -77,7 +78,7 @@ async function ossGenerateSTS() {
|
||||||
} else {
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
name: objectName,
|
name: objectName,
|
||||||
url: Vue.prototype.OSSclientConfig.viewEndpoint + objectName
|
url: Vue.prototype.OSSclientConfig.viewEndpoint + decodeUtf8(objectName)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -94,6 +95,14 @@ async function ossGenerateSTS() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function decodeUtf8(bytes) {
|
||||||
|
let str = bytes.split('?');
|
||||||
|
let str2 = str[0].split('/');
|
||||||
|
let name = str2[str2.length - 1];
|
||||||
|
name = encodeURIComponent(name);
|
||||||
|
str.shift();
|
||||||
|
str2.pop();
|
||||||
|
return str2.join("/") + '/' + name;
|
||||||
|
}
|
||||||
|
|
||||||
export const OSSclient = ossGenerateSTS
|
export const OSSclient = ossGenerateSTS
|
||||||
|
|
|
@ -977,7 +977,15 @@ const PDFViewerApplication = {
|
||||||
|
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
},
|
},
|
||||||
|
decodeUtf8(bytes) {
|
||||||
|
let str = bytes.split('?');
|
||||||
|
let str2 = str[0].split('/');
|
||||||
|
let name = str2[str2.length-1];
|
||||||
|
name = encodeURIComponent(name);
|
||||||
|
str.shift();
|
||||||
|
str2.pop();
|
||||||
|
return str2.join("/")+'/'+name+'?'+str.join("?");
|
||||||
|
},
|
||||||
async open(file, args) {
|
async open(file, args) {
|
||||||
if (this.pdfLoadingTask) {
|
if (this.pdfLoadingTask) {
|
||||||
await this.close();
|
await this.close();
|
||||||
|
@ -992,6 +1000,7 @@ const PDFViewerApplication = {
|
||||||
const parameters = Object.create(null);
|
const parameters = Object.create(null);
|
||||||
|
|
||||||
if (typeof file === "string") {
|
if (typeof file === "string") {
|
||||||
|
file = this.decodeUtf8(file);
|
||||||
this.setTitleUsingUrl(file, file);
|
this.setTitleUsingUrl(file, file);
|
||||||
parameters.url = file;
|
parameters.url = file;
|
||||||
} else if (file && "byteLength" in file) {
|
} else if (file && "byteLength" in file) {
|
||||||
|
|
Loading…
Reference in New Issue