haiwei-module-common 1.0.2 → 1.0.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": 1,
|
|
3
3
|
"name": "haiwei-module-common",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"code": "common",
|
|
6
6
|
"title": "通用模块",
|
|
7
7
|
"description": "通用模块",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"pub": "cd ./script && npm_publish.bat"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"haiwei-module-admin": "^1.2.
|
|
22
|
-
"haiwei-ui": "^1.
|
|
21
|
+
"haiwei-module-admin": "^1.2.2",
|
|
22
|
+
"haiwei-ui": "^1.5.1"
|
|
23
23
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import module from '../../module'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 附件上传、下载、预览
|
|
5
|
+
*
|
|
6
|
+
* 历史:该接口原为 Common 模块自己的 `common/attachment/Upload`、`common/attachment/Download/{id}`,
|
|
7
|
+
* 于 1.0.1 版随后端一起移除,文件上传统一下沉到框架 Admin 模块的 file 接口。
|
|
8
|
+
* 但本模块 index.js 的 callback 与文档(haiwei.Docs 01_Common.md)都还依赖
|
|
9
|
+
* `$api.common.attachment` 这个入口,缺失会直接导致前端启动时抛
|
|
10
|
+
* "Cannot read properties of undefined (reading 'getUploadUrl')",故在此保留入口、
|
|
11
|
+
* 内部转发到 `$api.admin.file`。
|
|
12
|
+
*
|
|
13
|
+
* 注意:下载与预览的入参已由「附件 ID」变为「文件路径(fullPath)」
|
|
14
|
+
*/
|
|
15
|
+
export default () => {
|
|
16
|
+
// 上传地址
|
|
17
|
+
const getUploadUrl = () => {
|
|
18
|
+
return $api.admin.file.getUploadUrl()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 上传:moduleCode 固定为当前模块
|
|
22
|
+
const upload = (file, group, accessMode = 0, accounts = '') => {
|
|
23
|
+
return $api.admin.file.upload(file, module.code, group, accessMode, accounts)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 下载
|
|
27
|
+
const download = fullPath => {
|
|
28
|
+
return $api.admin.file.download(fullPath)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 预览
|
|
32
|
+
const preview = fullPath => {
|
|
33
|
+
return $api.admin.file.preview(fullPath)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
getUploadUrl,
|
|
38
|
+
upload,
|
|
39
|
+
download,
|
|
40
|
+
preview
|
|
41
|
+
}
|
|
42
|
+
}
|