@scx-js/scx-ui 0.0.1 → 0.0.3

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,177 +1,177 @@
1
- class UploadInfo {
2
-
3
- /**
4
- * a
5
- * @type {string}
6
- */
7
- fileName = "";
8
-
9
- /**
10
- * a
11
- * @type {string}
12
- */
13
- previewURL = null;
14
-
15
- /**
16
- *
17
- * @type {string}
18
- */
19
- downloadURL = null;
20
-
21
- /**
22
- *
23
- * @type {number}
24
- */
25
- progressValue = 0;
26
-
27
- /**
28
- * a
29
- * @type {string}
30
- */
31
- progressState = "";
32
-
33
- /**
34
- * a
35
- * @type {boolean}
36
- */
37
- progressVisible = false;
38
-
39
- /**
40
- *
41
- * @type {File}
42
- */
43
- file = null;
44
-
45
- /**
46
- * a
47
- * @type {string}
48
- */
49
- fileID = "";
50
-
51
- /**
52
- * 上传时间
53
- * @type {null}
54
- */
55
- uploadTime = null;
56
-
57
- /**
58
- * 文件大小
59
- * @type {null}
60
- */
61
- fileSizeDisplay = null;
62
-
63
- /**
64
- * 文件实际大小
65
- * @type {null}
66
- */
67
- fileSize = null;
68
-
69
- /**
70
- * 文件 fssObjectID
71
- * @type {null}
72
- */
73
- fssObjectID = null;
74
-
75
- reset() {
76
- this.fileName = null;
77
- this.previewURL = null;
78
- this.downloadURL = null;
79
- this.uploadTime = null;
80
- this.fileSizeDisplay = null;
81
- this.fileSize = null;
82
- this.fssObjectID = null;
83
- return this;
84
- }
85
-
86
- fill(rawOptions) {
87
- const {
88
- fileName,
89
- previewURL,
90
- downloadURL,
91
- uploadTime,
92
- fileSizeDisplay,
93
- fileSize,
94
- fssObjectID,
95
- } = rawOptions;
96
- this.fileName = fileName;
97
- this.previewURL = previewURL;
98
- this.downloadURL = downloadURL;
99
- this.uploadTime = uploadTime;
100
- this.fileSizeDisplay = fileSizeDisplay;
101
- this.fileSize = fileSize;
102
- this.fssObjectID = fssObjectID;
103
- return this;
104
- }
105
-
106
- copy() {
107
- return new UploadInfo().fill(this);
108
- }
109
-
110
- }
111
-
112
- class ScxFSSHelper {
113
-
114
- /**
115
- * @type ScxFSS
116
- */
117
- scxFSS;
118
-
119
- constructor(scxFSS) {
120
- this.scxFSS = scxFSS;
121
- }
122
-
123
- /**
124
- * 默认的 scx-fss 的 fileInfoHandler
125
- *
126
- * @param fileID
127
- * @returns {Promise<{fileName: string}|{[p: string]: *}>}
128
- */
129
- fileInfoHandler(fileID) {
130
- const previewURL = this.scxFSS.joinImageURL(fileID, {
131
- w: 150,
132
- h: 150,
133
- });
134
- const downloadURL = this.scxFSS.joinDownloadURL(fileID);
135
- return new Promise((resolve, reject) => {
136
- this.scxFSS.info(fileID).then(item => {
137
- if (item) {
138
- resolve({
139
- ...item,
140
- previewURL,
141
- downloadURL,
142
- });
143
- } else {
144
- resolve({fileName: "文件无法读取 !!! id : " + fileID});
145
- }
146
- }).catch(e => reject(e));
147
- });
148
- }
149
-
150
- /**
151
- * 默认的 scx-fss 的上传 handler
152
- * @param needUploadFile
153
- * @param progress
154
- * @returns {Promise<unknown>}
155
- */
156
- uploadHandler(needUploadFile, progress) {
157
- const onProgress = (state, value) => {
158
- // todo 这里没有使用 ScxFSS.CHECKING() 而是直接引入字符串的原因
159
- // todo 请参照 https://github.com/vitejs/vite/issues/7775
160
- //前 50% 是校验 md5 后 50% 才是真正的文件上传
161
- if (state === "checking") {
162
- progress(value * 0.5, "校验中");
163
- } else if (state === "uploading") {
164
- progress(50 + value * 0.5, "上传中");
165
- }
166
- };
167
- return new Promise((resolve, reject) => {
168
- this.scxFSS.upload(needUploadFile, onProgress).then(d => {
169
- resolve(d.item.fssObjectID);
170
- }).catch(e => reject(e));
171
- });
172
- }
173
-
174
- }
175
-
176
- export {UploadInfo, ScxFSSHelper};
177
-
1
+ class UploadInfo {
2
+
3
+ /**
4
+ * a
5
+ * @type {string}
6
+ */
7
+ fileName = "";
8
+
9
+ /**
10
+ * a
11
+ * @type {string}
12
+ */
13
+ previewURL = null;
14
+
15
+ /**
16
+ *
17
+ * @type {string}
18
+ */
19
+ downloadURL = null;
20
+
21
+ /**
22
+ *
23
+ * @type {number}
24
+ */
25
+ progressValue = 0;
26
+
27
+ /**
28
+ * a
29
+ * @type {string}
30
+ */
31
+ progressState = "";
32
+
33
+ /**
34
+ * a
35
+ * @type {boolean}
36
+ */
37
+ progressVisible = false;
38
+
39
+ /**
40
+ *
41
+ * @type {File}
42
+ */
43
+ file = null;
44
+
45
+ /**
46
+ * a
47
+ * @type {string}
48
+ */
49
+ fileID = "";
50
+
51
+ /**
52
+ * 上传时间
53
+ * @type {null}
54
+ */
55
+ uploadTime = null;
56
+
57
+ /**
58
+ * 文件大小
59
+ * @type {null}
60
+ */
61
+ fileSizeDisplay = null;
62
+
63
+ /**
64
+ * 文件实际大小
65
+ * @type {null}
66
+ */
67
+ fileSize = null;
68
+
69
+ /**
70
+ * 文件 fssObjectID
71
+ * @type {null}
72
+ */
73
+ fssObjectID = null;
74
+
75
+ reset() {
76
+ this.fileName = null;
77
+ this.previewURL = null;
78
+ this.downloadURL = null;
79
+ this.uploadTime = null;
80
+ this.fileSizeDisplay = null;
81
+ this.fileSize = null;
82
+ this.fssObjectID = null;
83
+ return this;
84
+ }
85
+
86
+ fill(rawOptions) {
87
+ const {
88
+ fileName,
89
+ previewURL,
90
+ downloadURL,
91
+ uploadTime,
92
+ fileSizeDisplay,
93
+ fileSize,
94
+ fssObjectID,
95
+ } = rawOptions;
96
+ this.fileName = fileName;
97
+ this.previewURL = previewURL;
98
+ this.downloadURL = downloadURL;
99
+ this.uploadTime = uploadTime;
100
+ this.fileSizeDisplay = fileSizeDisplay;
101
+ this.fileSize = fileSize;
102
+ this.fssObjectID = fssObjectID;
103
+ return this;
104
+ }
105
+
106
+ copy() {
107
+ return new UploadInfo().fill(this);
108
+ }
109
+
110
+ }
111
+
112
+ class ScxFSSHelper {
113
+
114
+ /**
115
+ * @type ScxFSS
116
+ */
117
+ scxFSS;
118
+
119
+ constructor(scxFSS) {
120
+ this.scxFSS = scxFSS;
121
+ }
122
+
123
+ /**
124
+ * 默认的 scx-fss 的 fileInfoHandler
125
+ *
126
+ * @param fileID
127
+ * @returns {Promise<{fileName: string}|{[p: string]: *}>}
128
+ */
129
+ fileInfoHandler(fileID) {
130
+ const previewURL = this.scxFSS.joinImageURL(fileID, {
131
+ w: 150,
132
+ h: 150,
133
+ });
134
+ const downloadURL = this.scxFSS.joinDownloadURL(fileID);
135
+ return new Promise((resolve, reject) => {
136
+ this.scxFSS.info(fileID).then(item => {
137
+ if (item) {
138
+ resolve({
139
+ ...item,
140
+ previewURL,
141
+ downloadURL,
142
+ });
143
+ } else {
144
+ resolve({fileName: "文件无法读取 !!! id : " + fileID});
145
+ }
146
+ }).catch(e => reject(e));
147
+ });
148
+ }
149
+
150
+ /**
151
+ * 默认的 scx-fss 的上传 handler
152
+ * @param needUploadFile
153
+ * @param progress
154
+ * @returns {Promise<unknown>}
155
+ */
156
+ uploadHandler(needUploadFile, progress) {
157
+ const onProgress = (state, value) => {
158
+ // todo 这里没有使用 ScxFSS.CHECKING() 而是直接引入字符串的原因
159
+ // todo 请参照 https://github.com/vitejs/vite/issues/7775
160
+ //前 50% 是校验 md5 后 50% 才是真正的文件上传
161
+ if (state === "checking") {
162
+ progress(value * 0.5, "校验中");
163
+ } else if (state === "uploading") {
164
+ progress(50 + value * 0.5, "上传中");
165
+ }
166
+ };
167
+ return new Promise((resolve, reject) => {
168
+ this.scxFSS.upload(needUploadFile, onProgress).then(d => {
169
+ resolve(d.item.fssObjectID);
170
+ }).catch(e => reject(e));
171
+ });
172
+ }
173
+
174
+ }
175
+
176
+ export {UploadInfo, ScxFSSHelper};
177
+