@smart100/spu-web-plugin 0.0.9 → 0.0.13
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/README.md +9 -0
- package/dist/index.d.ts +12 -19
- package/dist/spu-web-plugin.mjs +44406 -6
- package/package.json +1 -5
- package/src/axios.ts +1 -1
- package/src/components/common/index.ts +19 -0
- package/src/components/expandexp/icons/icon_csv.png +0 -0
- package/src/components/expandexp/icons/icon_excel.png +0 -0
- package/src/components/expandexp/icons/icon_pdf.png +0 -0
- package/src/components/expandexp/icons/icon_zip.png +0 -0
- package/src/components/expandexp/index.ts +707 -0
- package/src/components/expandexp/step.ts +46 -0
- package/src/components/expandexp/template.ts +343 -0
- package/src/components/expandexp/util.ts +91 -0
- package/src/components/index.ts +7 -0
- package/src/components/loadding/index.ts +152 -0
- package/src/core.js +471 -0
- package/src/index.ts +8 -4
- package/src/install.ts +38 -12
- package/src/login.ts +27 -10
- package/src/oss/downloadService.ts +72 -9
- package/src/package/ali-oss/aliyun-oss-sdk.js +25121 -25121
- package/src/package/ali-oss/aliyun-oss-sdk.min.js +14 -14
- package/src/package/ali-oss/package.json +162 -162
- package/src/test.ts +23 -0
- package/src/types/global.d.ts +1 -1
- package/src/types/shims-lib.d.ts +2 -2
- /package/src/{loadding → components/loadding-vue3}/img/loading.gif +0 -0
- /package/src/{loadding → components/loadding-vue3}/index.ts +0 -0
- /package/src/{loadding → components/loadding-vue3}/index.vue +0 -0
|
@@ -58,18 +58,18 @@ const getContentType = (suffix: string) => {
|
|
|
58
58
|
// }
|
|
59
59
|
// }
|
|
60
60
|
|
|
61
|
-
|
|
62
61
|
type Cope = { width?: number, height?: number } | string | boolean
|
|
62
|
+
|
|
63
63
|
interface IDownload {
|
|
64
64
|
type?: 'att' | 'img',
|
|
65
65
|
source: string,
|
|
66
66
|
datetime: string | number,
|
|
67
67
|
storagetype?: StorageType,
|
|
68
|
-
cope?: Cope
|
|
68
|
+
cope?: Cope,
|
|
69
|
+
filename?: string, // 下载文件名
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
|
|
72
|
-
|
|
73
73
|
const getNormalizeAliOssCope = (cope?: Cope) => {
|
|
74
74
|
let copeObj = ''
|
|
75
75
|
if (cope) {
|
|
@@ -91,13 +91,11 @@ const getNormalizeAliOssCope = (cope?: Cope) => {
|
|
|
91
91
|
return copeObj
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
94
|
// 根据文件信息最后生成一个云文件服务可以用的链接http://xxxxx.xxx.jpg
|
|
98
95
|
const getUrl = async ({
|
|
99
96
|
type = 'img',
|
|
100
97
|
source = '',
|
|
98
|
+
filename = '',
|
|
101
99
|
datetime = '',
|
|
102
100
|
storagetype = 'storage',
|
|
103
101
|
cope = ''
|
|
@@ -110,8 +108,12 @@ const getUrl = async ({
|
|
|
110
108
|
const isAliYun = CloudServ.isAliyun(storagetype)
|
|
111
109
|
const isHuawei = CloudServ.isHuawei(storagetype)
|
|
112
110
|
const tenantCode = login.getUser('tenantcode')
|
|
111
|
+
|
|
112
|
+
if (!filename) {
|
|
113
|
+
filename = source
|
|
114
|
+
}
|
|
113
115
|
const isAbsoluteUrl = !!source.match(/\/att\//) || !!source.match(/\/img\//) || !!source.match(/att\//) || !!source.match(/img\//)
|
|
114
|
-
const suffix =
|
|
116
|
+
const suffix = filename.slice(filename.lastIndexOf('.'))
|
|
115
117
|
const date = dayjs(+datetime).format('YYYYMMDD')
|
|
116
118
|
let objectKey = isAbsoluteUrl ? source : `${source.slice(0, 3)}/${type}/${date}/${tenantCode}/${source}`
|
|
117
119
|
const copeObj = getNormalizeAliOssCope(cope)
|
|
@@ -131,7 +133,7 @@ const getUrl = async ({
|
|
|
131
133
|
// TODO 这两个请求头不能改顺序,不知道什么情况!!改了顺序会报错
|
|
132
134
|
const responseHeader: IAny = {
|
|
133
135
|
// 'content-type': contentType || undefined,
|
|
134
|
-
'content-disposition': 'attachment; filename=' + (
|
|
136
|
+
'content-disposition': 'attachment; filename=' + (filename && encodeURIComponent(filename)) // 阿里云提供的下载名字
|
|
135
137
|
}
|
|
136
138
|
if (contentType) {
|
|
137
139
|
responseHeader['content-type'] = contentType
|
|
@@ -190,6 +192,67 @@ const getUrl = async ({
|
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
194
|
|
|
195
|
+
|
|
196
|
+
const callDownloadManager = (url: string, filename: string) => {
|
|
197
|
+
let aElm = document.createElement('a')
|
|
198
|
+
aElm.innerHTML = filename + ''
|
|
199
|
+
aElm.download = filename
|
|
200
|
+
let href = url
|
|
201
|
+
aElm.href = href
|
|
202
|
+
document.body.appendChild(aElm)
|
|
203
|
+
aElm.target = '_blank'
|
|
204
|
+
let evt = document.createEvent('MouseEvents')
|
|
205
|
+
evt.initEvent('click', false, false)
|
|
206
|
+
aElm.dispatchEvent(evt)
|
|
207
|
+
document.body.removeChild(aElm)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const deal = (response: any, filename: string) => {
|
|
211
|
+
let aElm = document.createElement('a')
|
|
212
|
+
aElm.innerHTML = filename + ''
|
|
213
|
+
aElm.download = filename
|
|
214
|
+
aElm.target = '_blank'
|
|
215
|
+
let href = window.URL.createObjectURL(response.bodyBlob)
|
|
216
|
+
aElm.href = href
|
|
217
|
+
document.body.appendChild(aElm)
|
|
218
|
+
let evt = document.createEvent('MouseEvents')
|
|
219
|
+
evt.initEvent('click', false, false)
|
|
220
|
+
aElm.dispatchEvent(evt)
|
|
221
|
+
document.body.removeChild(aElm)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const downloadFile = async ({
|
|
225
|
+
type = 'img',
|
|
226
|
+
source = '',
|
|
227
|
+
datetime = '',
|
|
228
|
+
storagetype = 'storage',
|
|
229
|
+
cope = '',
|
|
230
|
+
filename = ''
|
|
231
|
+
}: IDownload) => {
|
|
232
|
+
|
|
233
|
+
if (!filename) {
|
|
234
|
+
filename = source
|
|
235
|
+
}
|
|
236
|
+
const suffix = filename.slice(filename.lastIndexOf('.'))
|
|
237
|
+
filename = filename.replace(suffix, '') + dayjs(+datetime).format('_YYYYMMDDHHmmssS') + String(Math.floor(Math.random() * 9000) + 1000) + suffix
|
|
238
|
+
|
|
239
|
+
// console.log(filename)
|
|
240
|
+
|
|
241
|
+
const url = await getUrl({
|
|
242
|
+
type,
|
|
243
|
+
source,
|
|
244
|
+
datetime,
|
|
245
|
+
storagetype,
|
|
246
|
+
filename,
|
|
247
|
+
cope
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
// console.log(url)
|
|
251
|
+
|
|
252
|
+
callDownloadManager(url, filename)
|
|
253
|
+
}
|
|
254
|
+
|
|
193
255
|
export default {
|
|
194
|
-
getUrl
|
|
256
|
+
getUrl,
|
|
257
|
+
downloadFile
|
|
195
258
|
}
|