@nocobase/plugin-file-manager 0.9.1-alpha.2 → 0.9.2-alpha.1
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/lib/client/FileStorage.js +3 -49
- package/lib/client/FileStorageShortcut.js +5 -35
- package/lib/client/StorageOptions.js +10 -24
- package/lib/client/hooks/index.d.ts +1 -0
- package/lib/client/hooks/index.js +16 -0
- package/lib/client/hooks/useUploadFiles.d.ts +8 -0
- package/lib/client/hooks/useUploadFiles.js +78 -0
- package/lib/client/index.js +40 -16
- package/lib/client/initializers/UploadActionInitializer.d.ts +1 -0
- package/lib/client/initializers/UploadActionInitializer.js +67 -0
- package/lib/client/initializers/index.d.ts +1 -0
- package/lib/client/initializers/index.js +16 -0
- package/lib/client/locale/index.d.ts +2 -0
- package/lib/client/locale/index.js +29 -0
- package/lib/client/locale/zh-CN.d.ts +10 -0
- package/lib/client/locale/zh-CN.js +17 -0
- package/lib/client/schemas/storage.js +3 -12
- package/lib/client/templates/file.d.ts +2 -0
- package/lib/client/templates/file.js +164 -0
- package/lib/client/templates/index.d.ts +1 -0
- package/lib/client/templates/index.js +16 -0
- package/lib/index.js +0 -2
- package/lib/server/actions/upload.d.ts +2 -1
- package/lib/server/actions/upload.js +91 -125
- package/lib/server/collections/attachments.js +5 -4
- package/lib/server/collections/storages.js +3 -2
- package/lib/server/index.js +0 -4
- package/lib/server/rules/index.js +0 -2
- package/lib/server/rules/mimetype.js +0 -5
- package/lib/server/server.js +13 -38
- package/lib/server/storages/ali-oss.js +0 -6
- package/lib/server/storages/index.js +0 -8
- package/lib/server/storages/local.js +12 -66
- package/lib/server/storages/s3.js +10 -26
- package/lib/server/storages/tx-cos.js +0 -7
- package/lib/server/utils.js +0 -11
- package/package.json +7 -6
|
@@ -4,76 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.FileStoragePane = void 0;
|
|
7
|
-
|
|
8
7
|
function _client() {
|
|
9
8
|
const data = require("@nocobase/client");
|
|
10
|
-
|
|
11
9
|
_client = function _client() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _antd() {
|
|
19
15
|
const data = require("antd");
|
|
20
|
-
|
|
21
16
|
_antd = function _antd() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _react() {
|
|
29
|
-
const data =
|
|
30
|
-
|
|
22
|
+
const data = _interopRequireDefault(require("react"));
|
|
31
23
|
_react = function _react() {
|
|
32
24
|
return data;
|
|
33
25
|
};
|
|
34
|
-
|
|
35
|
-
return data;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function _reactI18next() {
|
|
39
|
-
const data = require("react-i18next");
|
|
40
|
-
|
|
41
|
-
_reactI18next = function _reactI18next() {
|
|
42
|
-
return data;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
26
|
return data;
|
|
46
27
|
}
|
|
47
|
-
|
|
48
|
-
var _storage = require("./schemas/storage");
|
|
49
|
-
|
|
50
28
|
var _StorageOptions = require("./StorageOptions");
|
|
51
|
-
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
55
|
-
|
|
56
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
57
|
-
|
|
58
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
59
|
-
|
|
60
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
61
|
-
|
|
62
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
63
|
-
|
|
64
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
65
|
-
|
|
66
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
67
|
-
|
|
29
|
+
var _storage = require("./schemas/storage");
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
68
31
|
const FileStoragePane = () => {
|
|
69
|
-
const _useState = (0, _react().useState)(false),
|
|
70
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
71
|
-
visible = _useState2[0],
|
|
72
|
-
setVisible = _useState2[1];
|
|
73
|
-
|
|
74
|
-
const _useTranslation = (0, _reactI18next().useTranslation)(),
|
|
75
|
-
t = _useTranslation.t;
|
|
76
|
-
|
|
77
32
|
return _react().default.createElement(_antd().Card, {
|
|
78
33
|
bordered: false
|
|
79
34
|
}, _react().default.createElement(_client().SchemaComponent, {
|
|
@@ -83,5 +38,4 @@ const FileStoragePane = () => {
|
|
|
83
38
|
schema: _storage.storageSchema
|
|
84
39
|
}));
|
|
85
40
|
};
|
|
86
|
-
|
|
87
41
|
exports.FileStoragePane = FileStoragePane;
|
|
@@ -4,77 +4,51 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.FileStorageShortcut = void 0;
|
|
7
|
-
|
|
8
7
|
function _icons() {
|
|
9
8
|
const data = require("@ant-design/icons");
|
|
10
|
-
|
|
11
9
|
_icons = function _icons() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _shared() {
|
|
19
15
|
const data = require("@formily/shared");
|
|
20
|
-
|
|
21
16
|
_shared = function _shared() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _client() {
|
|
29
22
|
const data = require("@nocobase/client");
|
|
30
|
-
|
|
31
23
|
_client = function _client() {
|
|
32
24
|
return data;
|
|
33
25
|
};
|
|
34
|
-
|
|
35
26
|
return data;
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
function _react() {
|
|
39
29
|
const data = _interopRequireWildcard(require("react"));
|
|
40
|
-
|
|
41
30
|
_react = function _react() {
|
|
42
31
|
return data;
|
|
43
32
|
};
|
|
44
|
-
|
|
45
33
|
return data;
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
function _reactI18next() {
|
|
49
36
|
const data = require("react-i18next");
|
|
50
|
-
|
|
51
37
|
_reactI18next = function _reactI18next() {
|
|
52
38
|
return data;
|
|
53
39
|
};
|
|
54
|
-
|
|
55
40
|
return data;
|
|
56
41
|
}
|
|
57
|
-
|
|
58
42
|
var _storage = require("./schemas/storage");
|
|
59
|
-
|
|
60
43
|
var _StorageOptions = require("./StorageOptions");
|
|
61
|
-
|
|
62
44
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
63
|
-
|
|
64
45
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
65
|
-
|
|
66
46
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
67
|
-
|
|
68
47
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
69
|
-
|
|
70
48
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
71
|
-
|
|
72
49
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
73
|
-
|
|
74
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
75
|
-
|
|
50
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
76
51
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
77
|
-
|
|
78
52
|
const schema = {
|
|
79
53
|
type: 'object',
|
|
80
54
|
properties: {
|
|
@@ -88,16 +62,13 @@ const schema = {
|
|
|
88
62
|
}
|
|
89
63
|
}
|
|
90
64
|
};
|
|
91
|
-
|
|
92
65
|
const FileStorageShortcut = () => {
|
|
93
66
|
const _useState = (0, _react().useState)(false),
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
67
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
68
|
+
visible = _useState2[0],
|
|
69
|
+
setVisible = _useState2[1];
|
|
98
70
|
const _useTranslation = (0, _reactI18next().useTranslation)(),
|
|
99
|
-
|
|
100
|
-
|
|
71
|
+
t = _useTranslation.t;
|
|
101
72
|
return _react().default.createElement(_client().ActionContext.Provider, {
|
|
102
73
|
value: {
|
|
103
74
|
visible,
|
|
@@ -117,5 +88,4 @@ const FileStorageShortcut = () => {
|
|
|
117
88
|
schema: schema
|
|
118
89
|
}));
|
|
119
90
|
};
|
|
120
|
-
|
|
121
91
|
exports.FileStorageShortcut = FileStorageShortcut;
|
|
@@ -4,53 +4,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.StorageOptions = void 0;
|
|
7
|
-
|
|
8
7
|
function _antd() {
|
|
9
8
|
const data = require("@formily/antd");
|
|
10
|
-
|
|
11
9
|
_antd = function _antd() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _react() {
|
|
19
15
|
const data = require("@formily/react");
|
|
20
|
-
|
|
21
16
|
_react = function _react() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _react2() {
|
|
29
22
|
const data = _interopRequireWildcard(require("react"));
|
|
30
|
-
|
|
31
23
|
_react2 = function _react2() {
|
|
32
24
|
return data;
|
|
33
25
|
};
|
|
34
|
-
|
|
35
26
|
return data;
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
39
|
-
|
|
40
29
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
41
|
-
|
|
42
30
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
43
|
-
|
|
44
31
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
45
|
-
|
|
46
32
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
47
|
-
|
|
48
33
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
49
|
-
|
|
50
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
51
|
-
|
|
34
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
52
35
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
53
|
-
|
|
54
36
|
const schema = {
|
|
55
37
|
local: {
|
|
56
38
|
properties: {
|
|
@@ -163,6 +145,12 @@ const schema = {
|
|
|
163
145
|
'x-decorator': 'FormItem',
|
|
164
146
|
'x-component': 'Input',
|
|
165
147
|
required: true
|
|
148
|
+
},
|
|
149
|
+
endpoint: {
|
|
150
|
+
title: '{{t("Endpoint")}}',
|
|
151
|
+
type: 'string',
|
|
152
|
+
'x-decorator': 'FormItem',
|
|
153
|
+
'x-component': 'Input'
|
|
166
154
|
}
|
|
167
155
|
}
|
|
168
156
|
}
|
|
@@ -170,12 +158,10 @@ const schema = {
|
|
|
170
158
|
const StorageOptions = (0, _react().observer)(props => {
|
|
171
159
|
const form = (0, _react().useForm)();
|
|
172
160
|
const field = (0, _react().useField)();
|
|
173
|
-
|
|
174
161
|
const _useState = (0, _react2().useState)(new (_react().Schema)({})),
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
162
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
163
|
+
s = _useState2[0],
|
|
164
|
+
setSchema = _useState2[1];
|
|
179
165
|
(0, _react2().useEffect)(() => {
|
|
180
166
|
// form.clearFormGraph('options.*');
|
|
181
167
|
setSchema(new (_react().Schema)(schema[form.values.type] || {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useUploadFiles';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _useUploadFiles = require("./useUploadFiles");
|
|
7
|
+
Object.keys(_useUploadFiles).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _useUploadFiles[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _useUploadFiles[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useUploadFiles = exports.FILE_LIMIT_SIZE = void 0;
|
|
7
|
+
function _client() {
|
|
8
|
+
const data = require("@nocobase/client");
|
|
9
|
+
_client = function _client() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _antd() {
|
|
15
|
+
const data = require("antd");
|
|
16
|
+
_antd = function _antd() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _react() {
|
|
22
|
+
const data = require("react");
|
|
23
|
+
_react = function _react() {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
var _locale = require("../locale");
|
|
29
|
+
// 限制上传文件大小为 10M
|
|
30
|
+
const FILE_LIMIT_SIZE = 10 * 1024 * 1024;
|
|
31
|
+
exports.FILE_LIMIT_SIZE = FILE_LIMIT_SIZE;
|
|
32
|
+
const useUploadFiles = () => {
|
|
33
|
+
const _useBlockRequestConte = (0, _client().useBlockRequestContext)(),
|
|
34
|
+
service = _useBlockRequestConte.service;
|
|
35
|
+
const _useFmTranslation = (0, _locale.useFmTranslation)(),
|
|
36
|
+
t = _useFmTranslation.t;
|
|
37
|
+
const _useActionContext = (0, _client().useActionContext)(),
|
|
38
|
+
setVisible = _useActionContext.setVisible;
|
|
39
|
+
const _ref = (0, _react().useContext)(_client().RecordPickerContext) || {},
|
|
40
|
+
setSelectedRows = _ref.setSelectedRows;
|
|
41
|
+
const uploadingFiles = {};
|
|
42
|
+
let pendingNumber = 0;
|
|
43
|
+
return {
|
|
44
|
+
/**
|
|
45
|
+
* 返回 false 会阻止上传,返回 true 会继续上传
|
|
46
|
+
*/
|
|
47
|
+
beforeUpload(file) {
|
|
48
|
+
if (file.size > FILE_LIMIT_SIZE) {
|
|
49
|
+
_antd().notification.error({
|
|
50
|
+
message: `${t('File size cannot exceed')} ${FILE_LIMIT_SIZE / 1024 / 1024}M`
|
|
51
|
+
});
|
|
52
|
+
file.status = 'error';
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
},
|
|
57
|
+
onChange(fileList) {
|
|
58
|
+
fileList.forEach(file => {
|
|
59
|
+
if (file.status === 'uploading' && !uploadingFiles[file.uid]) {
|
|
60
|
+
pendingNumber++;
|
|
61
|
+
uploadingFiles[file.uid] = true;
|
|
62
|
+
}
|
|
63
|
+
if (file.status !== 'uploading' && uploadingFiles[file.uid]) {
|
|
64
|
+
delete uploadingFiles[file.uid];
|
|
65
|
+
if (--pendingNumber === 0) {
|
|
66
|
+
var _service$refresh;
|
|
67
|
+
service === null || service === void 0 ? void 0 : (_service$refresh = service.refresh) === null || _service$refresh === void 0 ? void 0 : _service$refresh.call(service);
|
|
68
|
+
setSelectedRows === null || setSelectedRows === void 0 ? void 0 : setSelectedRows(preRows => [...preRows, ...fileList.filter(file => file.status === 'done').map(file => file.response.data)]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
if (fileList.every(file => file.status === 'done')) {
|
|
73
|
+
setVisible(false);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
exports.useUploadFiles = useUploadFiles;
|
package/lib/client/index.js
CHANGED
|
@@ -4,42 +4,62 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = _default;
|
|
7
|
-
|
|
8
7
|
function _client() {
|
|
9
8
|
const data = require("@nocobase/client");
|
|
10
|
-
|
|
11
9
|
_client = function _client() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
14
|
+
function _client2() {
|
|
15
|
+
const data = require("@nocobase/utils/client");
|
|
16
|
+
_client2 = function _client2() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
18
21
|
function _react() {
|
|
19
22
|
const data = _interopRequireWildcard(require("react"));
|
|
20
|
-
|
|
21
23
|
_react = function _react() {
|
|
22
24
|
return data;
|
|
23
25
|
};
|
|
24
|
-
|
|
25
26
|
return data;
|
|
26
27
|
}
|
|
27
|
-
|
|
28
28
|
var _FileStorage = require("./FileStorage");
|
|
29
|
-
|
|
30
29
|
var _FileStorageShortcut = require("./FileStorageShortcut");
|
|
31
|
-
|
|
30
|
+
var hooks = _interopRequireWildcard(require("./hooks"));
|
|
31
|
+
var initializers = _interopRequireWildcard(require("./initializers"));
|
|
32
|
+
var templates = _interopRequireWildcard(require("./templates"));
|
|
32
33
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
-
|
|
34
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
|
-
|
|
36
35
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
37
|
-
|
|
38
36
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
37
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
38
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
39
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
40
|
+
// 注册之后就可以在 Crete collection 按钮中选择创建了
|
|
41
|
+
(0, _client2().forEach)(templates, (template, key) => {
|
|
42
|
+
(0, _client().registerTemplate)(key, template);
|
|
43
|
+
});
|
|
42
44
|
function _default(props) {
|
|
45
|
+
const initializes = (0, _react().useContext)(_client().SchemaInitializerContext);
|
|
46
|
+
const hasUploadAction = initializes.TableActionInitializers.items[0].children.some(initialize => initialize.component === 'UploadActionInitializer');
|
|
47
|
+
!hasUploadAction && initializes.TableActionInitializers.items[0].children.push({
|
|
48
|
+
type: 'item',
|
|
49
|
+
title: "{{t('Upload')}}",
|
|
50
|
+
component: 'UploadActionInitializer',
|
|
51
|
+
schema: {
|
|
52
|
+
'x-align': 'right',
|
|
53
|
+
'x-decorator': 'ACLActionProvider',
|
|
54
|
+
'x-acl-action-props': {
|
|
55
|
+
skipScopeCheck: true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
visible: () => {
|
|
59
|
+
const collection = (0, _client().useCollection)();
|
|
60
|
+
return collection.template === 'file';
|
|
61
|
+
}
|
|
62
|
+
});
|
|
43
63
|
const ctx = (0, _react().useContext)(_client().PluginManagerContext);
|
|
44
64
|
return _react().default.createElement(_client().SettingsCenterProvider, {
|
|
45
65
|
settings: {
|
|
@@ -60,5 +80,9 @@ function _default(props) {
|
|
|
60
80
|
FileStorageShortcut: _FileStorageShortcut.FileStorageShortcut
|
|
61
81
|
})
|
|
62
82
|
}
|
|
63
|
-
},
|
|
83
|
+
}, _react().default.createElement(_client().SchemaComponentOptions, {
|
|
84
|
+
scope: hooks
|
|
85
|
+
}, _react().default.createElement(_client().SchemaInitializerProvider, {
|
|
86
|
+
components: initializers
|
|
87
|
+
}, props.children))));
|
|
64
88
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const UploadActionInitializer: (props: any) => JSX.Element;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UploadActionInitializer = void 0;
|
|
7
|
+
function _client() {
|
|
8
|
+
const data = require("@nocobase/client");
|
|
9
|
+
_client = function _client() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _react() {
|
|
15
|
+
const data = _interopRequireDefault(require("react"));
|
|
16
|
+
_react = function _react() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
24
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
26
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
27
|
+
const UploadActionInitializer = props => {
|
|
28
|
+
const collection = (0, _client().useCollection)();
|
|
29
|
+
const schema = {
|
|
30
|
+
type: 'void',
|
|
31
|
+
'x-action': 'create',
|
|
32
|
+
title: "{{t('Upload')}}",
|
|
33
|
+
'x-designer': 'Action.Designer',
|
|
34
|
+
'x-component': 'Action',
|
|
35
|
+
'x-decorator': 'ACLActionProvider',
|
|
36
|
+
'x-component-props': {
|
|
37
|
+
openMode: 'drawer',
|
|
38
|
+
type: 'primary',
|
|
39
|
+
icon: 'UploadOutlined'
|
|
40
|
+
},
|
|
41
|
+
properties: {
|
|
42
|
+
modal: {
|
|
43
|
+
type: 'void',
|
|
44
|
+
title: '{{ t("Upload files") }}',
|
|
45
|
+
'x-component': 'Action.Container',
|
|
46
|
+
properties: {
|
|
47
|
+
upload: {
|
|
48
|
+
type: 'void',
|
|
49
|
+
title: '{{ t("Upload files") }}',
|
|
50
|
+
'x-component': 'Upload.DraggerV2',
|
|
51
|
+
'x-component-props': {
|
|
52
|
+
height: '50vh',
|
|
53
|
+
action: `${collection.name}:create`,
|
|
54
|
+
useProps: '{{useUploadFiles}}',
|
|
55
|
+
multiple: true,
|
|
56
|
+
listType: 'picture'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return _react().default.createElement(_client().ActionInitializer, _objectSpread(_objectSpread({}, props), {}, {
|
|
64
|
+
schema: schema
|
|
65
|
+
}));
|
|
66
|
+
};
|
|
67
|
+
exports.UploadActionInitializer = UploadActionInitializer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './UploadActionInitializer';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _UploadActionInitializer = require("./UploadActionInitializer");
|
|
7
|
+
Object.keys(_UploadActionInitializer).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _UploadActionInitializer[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _UploadActionInitializer[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NAMESPACE = void 0;
|
|
7
|
+
exports.useFmTranslation = useFmTranslation;
|
|
8
|
+
function _client() {
|
|
9
|
+
const data = require("@nocobase/client");
|
|
10
|
+
_client = function _client() {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _reactI18next() {
|
|
16
|
+
const data = require("react-i18next");
|
|
17
|
+
_reactI18next = function _reactI18next() {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
var _zhCN = _interopRequireDefault(require("./zh-CN"));
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
+
const NAMESPACE = 'file-manager';
|
|
25
|
+
exports.NAMESPACE = NAMESPACE;
|
|
26
|
+
_client().i18n.addResources('zh-CN', NAMESPACE, _zhCN.default);
|
|
27
|
+
function useFmTranslation() {
|
|
28
|
+
return (0, _reactI18next().useTranslation)(NAMESPACE);
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const locale = {
|
|
8
|
+
'File collection': '文件数据表',
|
|
9
|
+
'File name': '文件名',
|
|
10
|
+
'Extension name': '扩展名',
|
|
11
|
+
Size: '文件大小',
|
|
12
|
+
'Mime Type': 'Mime 类型',
|
|
13
|
+
URL: 'URL',
|
|
14
|
+
'File storage': '文件存储'
|
|
15
|
+
};
|
|
16
|
+
var _default = locale;
|
|
17
|
+
exports.default = _default;
|