xs-common-plugins 1.4.5 → 1.4.7
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/.idea/codeStyles/Project.xml +3 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/prettier.xml +6 -0
- package/package.json +2 -3
- package/src/common/common.js +5 -1
- package/src/styles/table.scss +4 -0
- package/src/utils/ossService.js +69 -55
- package/webpack.config.js +12 -0
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
<option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
|
|
30
30
|
<option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
|
|
31
31
|
</VueCodeStyleSettings>
|
|
32
|
+
<editorconfig>
|
|
33
|
+
<option name="ENABLED" value="false" />
|
|
34
|
+
</editorconfig>
|
|
32
35
|
<codeStyleSettings language="HTML">
|
|
33
36
|
<option name="SOFT_MARGINS" value="400" />
|
|
34
37
|
<indentOptions>
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xs-common-plugins",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"private": false,
|
|
3
|
+
"version": "1.4.7",
|
|
5
4
|
"description": "向上公共代码部分",
|
|
6
5
|
"author": "祝玲云 <1902733517@qq.com>",
|
|
7
6
|
"main": "index.js",
|
|
@@ -13,4 +12,4 @@
|
|
|
13
12
|
"type": "git",
|
|
14
13
|
"url": "https://gitlab.365xs.cn/web/npm/xs-common-plugins.git"
|
|
15
14
|
}
|
|
16
|
-
}
|
|
15
|
+
}
|
package/src/common/common.js
CHANGED
|
@@ -293,6 +293,10 @@ common.popup = (options) => {
|
|
|
293
293
|
type: Function,
|
|
294
294
|
default: null,
|
|
295
295
|
},
|
|
296
|
+
closeOnPressEscape:{
|
|
297
|
+
type: Boolean,
|
|
298
|
+
default: false,
|
|
299
|
+
}
|
|
296
300
|
},
|
|
297
301
|
data() {
|
|
298
302
|
return {
|
|
@@ -324,7 +328,7 @@ common.popup = (options) => {
|
|
|
324
328
|
},
|
|
325
329
|
template: `
|
|
326
330
|
<div>
|
|
327
|
-
<el-dialog :title="title" v-el-drag-dialog :visible.sync="visible" :width="width" :before-close="beforeClose" v-bind="dialogCfg" append-to-body>
|
|
331
|
+
<el-dialog :title="title" :close-on-click-modal="closeOnPressEscape" :close-on-press-escape="closeOnPressEscape" v-el-drag-dialog :visible.sync="visible" :width="width" :before-close="beforeClose" v-bind="dialogCfg" append-to-body>
|
|
328
332
|
<child ref="child" :srcData="srcData" v-bind="props" @close="close" @cancel="cancel"/>
|
|
329
333
|
<div v-if="showButton" style="text-align: right;margin-top: 10px">
|
|
330
334
|
<el-button size="medium" type="primary" @click="confirm" v-loading="loading">确认</el-button>
|
package/src/styles/table.scss
CHANGED
package/src/utils/ossService.js
CHANGED
|
@@ -1,55 +1,69 @@
|
|
|
1
|
-
import OSS from 'ali-oss'
|
|
2
|
-
import { requestApi as axios} from 'xs-request'
|
|
3
|
-
import store from '../store/index'
|
|
4
|
-
import { getLocalStorage } from
|
|
5
|
-
import {getConfig} from '@/utils/global-config'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
import OSS from 'ali-oss'
|
|
2
|
+
import { requestApi as axios } from 'xs-request'
|
|
3
|
+
import store from '../store/index'
|
|
4
|
+
import { getLocalStorage } from '@/utils/localStorage'
|
|
5
|
+
import { getConfig } from '@/utils/global-config'
|
|
6
|
+
|
|
7
|
+
let ossCfg = {}
|
|
8
|
+
|
|
9
|
+
// 去哪个服务下 获取 token 信息
|
|
10
|
+
function getOssToken() {
|
|
11
|
+
return axios
|
|
12
|
+
.get('@commng/UserCur/Oss/Config/' + getConfig('CLIENT_ID'))
|
|
13
|
+
.then(({ data }) => {
|
|
14
|
+
let timestamp = new Date().getTime()
|
|
15
|
+
ossCfg.region = data.ossEndpoint
|
|
16
|
+
ossCfg.bucket = data.bucketName
|
|
17
|
+
ossCfg.accessKeyId = data.stsAccessKeyId
|
|
18
|
+
ossCfg.accessKeySecret = data.stsAccessKeySecret
|
|
19
|
+
ossCfg.stsToken = data.stsSecurityToken
|
|
20
|
+
ossCfg.baseDir = data.baseDir
|
|
21
|
+
ossCfg.timeout = timestamp + data.durationSeconds * 1000
|
|
22
|
+
store.commit('oss/SET_OSS', ossCfg)
|
|
23
|
+
return ossCfg
|
|
24
|
+
})
|
|
25
|
+
.catch(err => {
|
|
26
|
+
console.log('获取Token错误', err)
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//自动刷新token
|
|
31
|
+
const initOssToken = function (time) {
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
getOssToken()
|
|
34
|
+
}, time)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 从 vuex 中 获取初始化值
|
|
38
|
+
const initToken = async function () {
|
|
39
|
+
ossCfg = store.getters.ossCfg
|
|
40
|
+
let timestamp = new Date().getTime()
|
|
41
|
+
// 有效期内不发送获取token 请求
|
|
42
|
+
let endTime = ossCfg.timeout - timestamp - 1000 * 60 // 提前1分钟刷新
|
|
43
|
+
initOssToken(endTime)
|
|
44
|
+
if (ossCfg.region && ossCfg.timeout > timestamp) {
|
|
45
|
+
return Promise.resolve(ossCfg)
|
|
46
|
+
}
|
|
47
|
+
return getOssToken()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const newFileName = function (id = getConfig('CLIENT_ID'), userid = getLocalStorage('userProfile').id) {
|
|
51
|
+
let dt = new Date()
|
|
52
|
+
let y = dt.getFullYear()
|
|
53
|
+
let m = dt.getMonth() + 1 < 10 ? '0' + (dt.getMonth() + 1) : dt.getMonth() + 1
|
|
54
|
+
let d = dt.getDate() < 10 ? '0' + dt.getDate() : dt.getDate()
|
|
55
|
+
return `${ossCfg.baseDir}/${userid}/${y}${m}${d}/${id}_${dt.getTime()}` // 定义唯一的文件名
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const ossService = {
|
|
59
|
+
token: ossCfg,
|
|
60
|
+
initToken,
|
|
61
|
+
newFileName,
|
|
62
|
+
_ossClient: null,
|
|
63
|
+
getOssClient() {
|
|
64
|
+
this._ossClient = new OSS(ossCfg)
|
|
65
|
+
return this._ossClient
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default ossService
|