n20-common-lib 2.1.34 → 2.1.36

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "2.1.34",
3
+ "version": "2.1.36",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -4,7 +4,7 @@
4
4
  :class="{ 'n20-upload-drag': $attrs.drag }"
5
5
  :action="action"
6
6
  :headers="headers | headersF"
7
- :accept="accept"
7
+ :accept="accept | acceptFilter"
8
8
  :multiple="multiple"
9
9
  :file-list="fileList"
10
10
  :show-file-list="multiple ? true : showFileList"
@@ -50,15 +50,18 @@
50
50
 
51
51
  <script>
52
52
  import _axios from 'axios'
53
- import { $lc } from '../../utils/i18n/index'
54
53
  import auth from '../../utils/auth'
55
54
  import axios from '../../utils/axios'
55
+ import { $lc } from '../../utils/i18n/index'
56
56
  import uploadMsg from './uploadMsg.vue'
57
57
  export default {
58
58
  name: 'Upload',
59
59
  filters: {
60
60
  headersF(headers) {
61
61
  return auth.setHeaders(headers)
62
+ },
63
+ acceptFilter(value) {
64
+ return value?.toLowerCase()
62
65
  }
63
66
  },
64
67
  components: {
@@ -214,7 +217,7 @@ export default {
214
217
  let [ftB = '', ftA = ''] = file.type.split('/')
215
218
  ftB = ftB ? ftB + '/*' : ''
216
219
  ftA = file.name.match(/\.[^.]+$/)?.[0] || '.' + ftA
217
- if ((ftB && accept.includes(ftB)) || accept.includes(ftA)) {
220
+ if ((ftB && accept.includes(ftB.toLowerCase())) || accept.includes(ftA.toLowerCase())) {
218
221
  // console.log('文件格式' + ftB + '/' + ftA)
219
222
  } else {
220
223
  this.$message.error(ftA + $lc('格式文件,暂不支持上传!'))
@@ -171,13 +171,16 @@ function verifyDn(dnList, dn) {
171
171
  let checkRes = ''
172
172
  let userDnAttrsArr = dn.split(',').map((c) => c.trim())
173
173
 
174
+ let isIn = false
174
175
  dnList.find((C) => {
175
176
  let dnAttrsArr = C.certDN.split(',').map((c) => c.trim())
176
- if (!dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))) {
177
- checkRes = 'checkRes'
178
- return true
177
+ if (dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))) {
178
+ return (isIn = true)
179
179
  }
180
180
  })
181
+ if (!isIn) {
182
+ checkRes = 'checkRes'
183
+ }
181
184
 
182
185
  return checkRes
183
186
  }
@@ -171,13 +171,16 @@ function verifyDn(dnList, dn) {
171
171
  let checkRes = ''
172
172
  let userDnAttrsArr = dn.split(',').map((c) => c.trim())
173
173
 
174
+ let isIn = false
174
175
  dnList.find((C) => {
175
176
  let dnAttrsArr = C.certDN.split(',').map((c) => c.trim())
176
- if (!dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))) {
177
- checkRes = 'checkRes'
178
- return true
177
+ if (dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))) {
178
+ return (isIn = true)
179
179
  }
180
180
  })
181
+ if (!isIn) {
182
+ checkRes = 'checkRes'
183
+ }
181
184
 
182
185
  return checkRes
183
186
  }
@@ -126,14 +126,16 @@ function verifyDn(dnList, dn) {
126
126
  let checkRes = ''
127
127
  let userDnAttrsArr = dn.split(',').map((c) => c.trim())
128
128
 
129
+ let isIn = false
129
130
  dnList.find((C) => {
130
131
  let dnAttrsArr = C.certDN.split(',').map((c) => c.trim())
131
-
132
- if (!dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))) {
133
- checkRes = 'checkRes'
134
- return true
132
+ if (dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))) {
133
+ return (isIn = true)
135
134
  }
136
135
  })
136
+ if (!isIn) {
137
+ checkRes = 'checkRes'
138
+ }
137
139
 
138
140
  return checkRes
139
141
  }
@@ -5,6 +5,35 @@ import { $lc } from './i18n/index'
5
5
  const _Loading = ElementUI.Loading
6
6
  const _Message = ElementUI.Message
7
7
 
8
+ const fileMap = {
9
+ pdf: 'application/pdf',
10
+ jpeg: 'image/jpeg',
11
+ jpg: 'image/jpeg',
12
+ bmp: 'image/x-ms-bmp',
13
+ png: 'image/png',
14
+ gif: 'image/gif',
15
+ svg: 'image/svg+xml',
16
+ svgz: 'image/svg+xml',
17
+ ico: 'image/x-icon',
18
+ json: 'application/json',
19
+ doc: 'application/msword',
20
+ docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
21
+ xls: 'application/vnd.ms-excel',
22
+ xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
23
+ ppt: 'application/vnd.ms-powerpoint',
24
+ pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
25
+ csv: 'text/plain',
26
+ zip: 'application/zip',
27
+ '7z': 'application/x-7z-compressed',
28
+ rar: 'application/x-rar-compressed',
29
+ mp3: 'audio/mpeg',
30
+ mp4: 'video/mp4',
31
+ avi: 'video/x-msvideo',
32
+ wmv: 'video/x-ms-wmv',
33
+ flv: 'video/x-flv',
34
+ swf: 'application/x-shockwave-flash'
35
+ }
36
+
8
37
  /* 添加msg */
9
38
  function showMsg(msg, single = true) {
10
39
  if (!single || !document.querySelector('.xhr-msg-top')) {
@@ -133,8 +162,26 @@ function request(opt) {
133
162
  .then((res) => {
134
163
  if (opt.responseType === 'blob') {
135
164
  let filename = getFilename(res.headers['content-disposition'])
136
- filename && res.data && (res.data.name = filename.replace(/"/g, ''))
137
- res.data.size === 0 ? reject({ code: 404, msg: opt.url + $lc('请求返回文件大小0KB') }) : resolve(res.data)
165
+ if (filename && res.data) {
166
+ filename = filename.replace(/"/g, '')
167
+ // 调整blob类型
168
+ let I = filename.lastIndexOf('.')
169
+ if (I !== -1) {
170
+ let type = undefined
171
+ let suffix = filename.slice(I + 1)
172
+ type = fileMap[suffix]
173
+ if (type && res.data instanceof Blob && res.data.type !== type) {
174
+ res.data = new Blob([res.data], { type: type })
175
+ }
176
+ }
177
+
178
+ res.data.name = filename
179
+ }
180
+ if (res.data.size === 0) {
181
+ reject({ code: 404, msg: opt.url + $lc('请求返回文件大小0KB') })
182
+ } else {
183
+ resolve(res.data)
184
+ }
138
185
  } else {
139
186
  if (typeof res.data === 'object' && res.data.data === undefined) {
140
187
  res.data.data = {}