askbot-dragon 88.1.2 → 88.1.4
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 +2 -1
- package/src/assets/js/obsBrowser.js +45 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "askbot-dragon",
|
|
3
|
-
"version": "88.1.
|
|
3
|
+
"version": "88.1.4",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"serve": "vue-cli-service serve",
|
|
6
6
|
"build": "vue-cli-service build",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"@vue/cli-plugin-eslint": "~4.5.0",
|
|
12
12
|
"@vue/cli-service": "~4.5.0",
|
|
13
13
|
"audio-loader": "^1.0.3",
|
|
14
|
+
"axios": "^1.8.4",
|
|
14
15
|
"babel-eslint": "^10.1.0",
|
|
15
16
|
"core-js": "^3.6.5",
|
|
16
17
|
"element-ui": "^2.15.10",
|
|
@@ -1,11 +1,49 @@
|
|
|
1
1
|
// 创建ObsClient实例
|
|
2
2
|
import ObsClient from 'esdk-obs-browserjs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
|
|
5
|
+
let accessKeyId = ""
|
|
6
|
+
let accessKeySecret = ""
|
|
7
|
+
if (localStorage.getItem('VUE_APP_SOURCE' == 'libang_production')) {
|
|
8
|
+
accessKeyId = "XsVgbg1mDU/xiVxPeNsaIwGmhF+jSZ0ep79YuqOjHk8=";
|
|
9
|
+
accessKeySecret = "nBcMSflABN+A5bsaoaeVVI8FeYRaVXkCVZl2m/aC89Q/0uuWEP1f47W/i1jvNXBF";
|
|
10
|
+
} else {
|
|
11
|
+
accessKeyId = "ErivR+YlsAryJl+gJmBKLpQFRW/hRre9JeS+VpbixTY=";
|
|
12
|
+
accessKeySecret = "qAHB0qmrOyTOiaOch8GyweGTmCx06QVtYOupvb1lUL0prxDuGBMt85VHCjg5/aU8";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function getDecryptedKeys() {
|
|
16
|
+
try {
|
|
17
|
+
const response = await axios.post('/knowledge-api/secret/manager/decrypt', {
|
|
18
|
+
accessKeyId: accessKeyId,
|
|
19
|
+
accessKeySecret: accessKeySecret
|
|
20
|
+
});
|
|
21
|
+
if (response.data.code === '0') {
|
|
22
|
+
return response.data.data;
|
|
23
|
+
} else {
|
|
24
|
+
console.error('获取失败,错误码:', response.data.code);
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error('获取出错:', error);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 创建 ObsClient 实例
|
|
34
|
+
async function createObsClient() {
|
|
35
|
+
const keys = await getDecryptedKeys();
|
|
36
|
+
if (!keys) {
|
|
37
|
+
throw new Error('无法获取解密后的密钥');
|
|
38
|
+
}
|
|
39
|
+
return new ObsClient({
|
|
40
|
+
access_key_id: keys.accessKeyId,
|
|
41
|
+
secret_access_key: keys.accessKeySecret,
|
|
42
|
+
server: 'https://obs.cn-east-3.myhuaweicloud.com',
|
|
43
|
+
timeout: 1000
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
9
47
|
let mainId = sessionStorage.getItem('_mainId') ? sessionStorage.getItem('_mainId') : "";
|
|
10
48
|
let IDX = 256, HEX = [], SIZE = 256, BUFFER;
|
|
11
49
|
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
|
|
@@ -40,6 +78,7 @@ async function putObject(file,callback){
|
|
|
40
78
|
let objName = (process.env.VUE_APP_ENV === 'development' ? 'dev_' : 'pro_') + file.name;
|
|
41
79
|
let fileName = "front-oss/" + mainId + '/' + dataFormat("yyyy/MM/dd/hh/mm/") + uid(32) + "/" + objName;
|
|
42
80
|
let bucketName = localStorage.getItem('askObsBucketName') || 'askbot-uat';
|
|
81
|
+
const obsClient = await createObsClient();
|
|
43
82
|
await obsClient.putObject({
|
|
44
83
|
Bucket: bucketName,
|
|
45
84
|
Key : fileName,
|