@huyooo/ui 0.4.6 → 0.4.8

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.
@@ -1,128 +0,0 @@
1
- import k from "cos-js-sdk-v5";
2
- import { v6 as w } from "uuid";
3
- import { api as m } from "@huyooo/api";
4
- function D(i, t) {
5
- return m({
6
- url: `${t}/restfulApi/files/create`,
7
- method: "post",
8
- data: i
9
- });
10
- }
11
- function T(i, t) {
12
- return m({
13
- url: `${t}/restfulApi/files/update`,
14
- method: "post",
15
- data: i
16
- });
17
- }
18
- function z(i, t) {
19
- return m({
20
- url: `${t}/restfulApi/files/getKeyAndCredentials`,
21
- method: "post",
22
- data: i
23
- });
24
- }
25
- function F({
26
- appId: i,
27
- bucketId: t,
28
- baseURL: c,
29
- bucket: h,
30
- region: A
31
- }) {
32
- let y, K;
33
- const C = (a, n, f) => {
34
- const s = w(), d = a.split(".").pop(), l = `${n}/${f}/${s}.${d}`;
35
- return console.log(l, "cosKeycosKeycosKeycosKeycosKey"), l;
36
- };
37
- function $({
38
- file: a,
39
- onProgress: n,
40
- onFileFinish: f,
41
- onError: s
42
- }) {
43
- const {
44
- name: d,
45
- size: l,
46
- type: g,
47
- webkitRelativePath: x
48
- } = a, p = C(d, i, t);
49
- console.log(a, "filefilefile");
50
- let r = null;
51
- K = new k({
52
- async getAuthorization(e, u) {
53
- console.log(e, "optionsoptions");
54
- const o = await z({
55
- filename: p,
56
- bucketId: t,
57
- size: l,
58
- type: g
59
- }, c);
60
- if (console.log(o, "filesGetKeyData"), o.data) {
61
- const S = await D({
62
- bucketId: t,
63
- filename: p,
64
- name: d,
65
- size: l,
66
- type: g,
67
- webkitRelativePath: x
68
- }, c);
69
- S.data ? r = S.data.id : s && s({
70
- code: "501",
71
- message: "新建记录失败",
72
- error: "",
73
- url: "/restfulApi/files/create",
74
- method: "post"
75
- }), u({
76
- TmpSecretId: o.data.TmpSecretId,
77
- TmpSecretKey: o.data.TmpSecretKey,
78
- SecurityToken: o.data.SessionToken,
79
- // 建议返回服务器时间作为签名的开始时间,避免客户端本地时间偏差过大导致签名错误
80
- StartTime: o.data.StartTime,
81
- // 时间戳,单位秒,如:1580000000
82
- ExpiredTime: o.data.ExpiredTime,
83
- // 时间戳,单位秒,如:1580000000
84
- ScopeLimit: !0
85
- // 细粒度控制权限需要设为 true,会限制密钥只在相同请求时重复使用
86
- });
87
- }
88
- }
89
- }), console.log(p, "cosKeycosKeycosKey"), K.uploadFile({
90
- Bucket: h,
91
- Region: A,
92
- Key: p,
93
- Body: a,
94
- SliceSize: 1024 * 1024 * 5,
95
- onProgress(e) {
96
- n && n(e);
97
- },
98
- onFileFinish(e, u, o) {
99
- f && f(e, u, o), T({
100
- id: r,
101
- status: "success"
102
- }, c);
103
- },
104
- onTaskReady: (e) => {
105
- y = e, console.log(y);
106
- }
107
- }, (e) => {
108
- e && (console.log("上传失败", e), T({
109
- id: r,
110
- status: "fail"
111
- }, c).catch(() => {
112
- s && s({
113
- code: "501",
114
- message: "更新进度失败",
115
- error: "",
116
- url: "/restfulApi/files/update",
117
- method: "post"
118
- });
119
- }), s && s(e));
120
- });
121
- }
122
- return {
123
- uploadFile: $
124
- };
125
- }
126
- export {
127
- F as u
128
- };