@nocobase/plugin-file-manager 0.13.0-alpha.3 → 0.13.0-alpha.5
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/dist/client/index.js +1 -975
- package/dist/index.js +37 -16
- package/dist/locale/en-US.js +22 -4
- package/dist/locale/fr-FR.js +22 -4
- package/dist/locale/ja-JP.js +22 -4
- package/dist/locale/ru-RU.js +22 -4
- package/dist/locale/tr-TR.js +22 -4
- package/dist/locale/zh-CN.js +22 -4
- package/dist/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +3 -3
- package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
- package/dist/node_modules/mime-match/index.js +1 -1
- package/dist/node_modules/mime-match/package.json +1 -1
- package/dist/node_modules/mkdirp/index.js +1 -1
- package/dist/node_modules/mkdirp/package.json +1 -1
- package/dist/node_modules/multer-aliyun-oss/index.js +22 -22
- package/dist/node_modules/multer-aliyun-oss/package.json +1 -1
- package/dist/node_modules/multer-cos/index.js +15 -15
- package/dist/node_modules/multer-cos/package.json +1 -1
- package/dist/node_modules/multer-s3/index.js +5 -5
- package/dist/node_modules/multer-s3/package.json +1 -1
- package/dist/server/actions/attachments.js +54 -45
- package/dist/server/actions/index.js +37 -14
- package/dist/server/collections/attachments.js +22 -4
- package/dist/server/collections/storages.js +22 -4
- package/dist/server/constants.js +38 -10
- package/dist/server/index.js +37 -21
- package/dist/server/migrations/20230831160742-fix-attachment-field.d.ts +4 -0
- package/dist/server/migrations/20230831160742-fix-attachment-field.js +60 -0
- package/dist/server/rules/index.js +36 -13
- package/dist/server/rules/mimetype.js +34 -11
- package/dist/server/server.js +53 -24
- package/dist/server/storages/ali-oss.js +26 -9
- package/dist/server/storages/index.js +48 -26
- package/dist/server/storages/local.js +45 -25
- package/dist/server/storages/s3.js +26 -9
- package/dist/server/storages/tx-cos.js +28 -11
- package/dist/server/utils.js +42 -15
- package/dist/swagger/index.json +81 -0
- package/package.json +2 -2
- package/dist/swagger/index.js +0 -95
package/dist/client/index.js
CHANGED
|
@@ -1,975 +1 @@
|
|
|
1
|
-
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@nocobase/client"), require("react"), require("@nocobase/utils/client"), require("antd"), require("@formily/antd-v5"), require("@formily/react"), require("react-i18next"), require("@formily/shared")) : typeof define === "function" && define.amd ? define(["exports", "@nocobase/client", "react", "@nocobase/utils/client", "antd", "@formily/antd-v5", "@formily/react", "react-i18next", "@formily/shared"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@nocobase/plugin-file-manager"] = {}, global["@nocobase/client"], global.react, global["@nocobase/utils"], global.antd, global["@formily/antd-v5"], global["@formily/react"], global["react-i18next"], global["@formily/shared"]));
|
|
3
|
-
})(this, function(exports2, client, require$$0, client$1, antd, antdV5, react, reactI18next, shared) {
|
|
4
|
-
"use strict";
|
|
5
|
-
var jsxRuntime = { exports: {} };
|
|
6
|
-
var reactJsxRuntime_production_min = {};
|
|
7
|
-
/**
|
|
8
|
-
* @license React
|
|
9
|
-
* react-jsx-runtime.production.min.js
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
12
|
-
*
|
|
13
|
-
* This source code is licensed under the MIT license found in the
|
|
14
|
-
* LICENSE file in the root directory of this source tree.
|
|
15
|
-
*/
|
|
16
|
-
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
|
|
17
|
-
function q(c, a, g) {
|
|
18
|
-
var b, d = {}, e = null, h = null;
|
|
19
|
-
void 0 !== g && (e = "" + g);
|
|
20
|
-
void 0 !== a.key && (e = "" + a.key);
|
|
21
|
-
void 0 !== a.ref && (h = a.ref);
|
|
22
|
-
for (b in a)
|
|
23
|
-
m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
24
|
-
if (c && c.defaultProps)
|
|
25
|
-
for (b in a = c.defaultProps, a)
|
|
26
|
-
void 0 === d[b] && (d[b] = a[b]);
|
|
27
|
-
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
28
|
-
}
|
|
29
|
-
reactJsxRuntime_production_min.Fragment = l;
|
|
30
|
-
reactJsxRuntime_production_min.jsx = q;
|
|
31
|
-
reactJsxRuntime_production_min.jsxs = q;
|
|
32
|
-
{
|
|
33
|
-
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
34
|
-
}
|
|
35
|
-
var jsxRuntimeExports = jsxRuntime.exports;
|
|
36
|
-
const NAMESPACE = "file-manager";
|
|
37
|
-
function useFmTranslation() {
|
|
38
|
-
return reactI18next.useTranslation(NAMESPACE);
|
|
39
|
-
}
|
|
40
|
-
const schema = {
|
|
41
|
-
local: {
|
|
42
|
-
properties: {
|
|
43
|
-
documentRoot: {
|
|
44
|
-
title: `{{t("Destination", { ns: "${NAMESPACE}" })}}`,
|
|
45
|
-
type: "string",
|
|
46
|
-
"x-decorator": "FormItem",
|
|
47
|
-
"x-component": "Input",
|
|
48
|
-
default: "storage/uploads"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"ali-oss": {
|
|
53
|
-
properties: {
|
|
54
|
-
region: {
|
|
55
|
-
title: `{{t("Region", { ns: "${NAMESPACE}" })}}`,
|
|
56
|
-
type: "string",
|
|
57
|
-
"x-decorator": "FormItem",
|
|
58
|
-
"x-component": "Input",
|
|
59
|
-
required: true
|
|
60
|
-
},
|
|
61
|
-
accessKeyId: {
|
|
62
|
-
title: `{{t("AccessKey ID", { ns: "${NAMESPACE}" })}}`,
|
|
63
|
-
type: "string",
|
|
64
|
-
"x-decorator": "FormItem",
|
|
65
|
-
"x-component": "Input",
|
|
66
|
-
required: true
|
|
67
|
-
},
|
|
68
|
-
accessKeySecret: {
|
|
69
|
-
title: `{{t("AccessKey Secret", { ns: "${NAMESPACE}" })}}`,
|
|
70
|
-
type: "string",
|
|
71
|
-
"x-decorator": "FormItem",
|
|
72
|
-
"x-component": "Password",
|
|
73
|
-
required: true
|
|
74
|
-
},
|
|
75
|
-
bucket: {
|
|
76
|
-
title: `{{t("Bucket", { ns: "${NAMESPACE}" })}}`,
|
|
77
|
-
type: "string",
|
|
78
|
-
"x-decorator": "FormItem",
|
|
79
|
-
"x-component": "Input",
|
|
80
|
-
required: true
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
"tx-cos": {
|
|
85
|
-
properties: {
|
|
86
|
-
Region: {
|
|
87
|
-
title: `{{t("Region", { ns: "${NAMESPACE}" })}}`,
|
|
88
|
-
type: "string",
|
|
89
|
-
"x-decorator": "FormItem",
|
|
90
|
-
"x-component": "Input",
|
|
91
|
-
required: true
|
|
92
|
-
},
|
|
93
|
-
SecretId: {
|
|
94
|
-
title: `{{t("SecretId", { ns: "${NAMESPACE}" })}}`,
|
|
95
|
-
type: "string",
|
|
96
|
-
"x-decorator": "FormItem",
|
|
97
|
-
"x-component": "Input",
|
|
98
|
-
required: true
|
|
99
|
-
},
|
|
100
|
-
SecretKey: {
|
|
101
|
-
title: `{{t("SecretKey", { ns: "${NAMESPACE}" })}}`,
|
|
102
|
-
type: "string",
|
|
103
|
-
"x-decorator": "FormItem",
|
|
104
|
-
"x-component": "Password",
|
|
105
|
-
required: true
|
|
106
|
-
},
|
|
107
|
-
Bucket: {
|
|
108
|
-
title: `{{t("Bucket", { ns: "${NAMESPACE}" })}}`,
|
|
109
|
-
type: "string",
|
|
110
|
-
"x-decorator": "FormItem",
|
|
111
|
-
"x-component": "Input",
|
|
112
|
-
required: true
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
s3: {
|
|
117
|
-
properties: {
|
|
118
|
-
region: {
|
|
119
|
-
title: `{{t("Region", { ns: "${NAMESPACE}" })}}`,
|
|
120
|
-
type: "string",
|
|
121
|
-
"x-decorator": "FormItem",
|
|
122
|
-
"x-component": "Input",
|
|
123
|
-
required: true
|
|
124
|
-
},
|
|
125
|
-
accessKeyId: {
|
|
126
|
-
title: `{{t("AccessKey ID", { ns: "${NAMESPACE}" })}}`,
|
|
127
|
-
type: "string",
|
|
128
|
-
"x-decorator": "FormItem",
|
|
129
|
-
"x-component": "Input",
|
|
130
|
-
required: true
|
|
131
|
-
},
|
|
132
|
-
secretAccessKey: {
|
|
133
|
-
title: `{{t("AccessKey Secret", { ns: "${NAMESPACE}" })}}`,
|
|
134
|
-
type: "string",
|
|
135
|
-
"x-decorator": "FormItem",
|
|
136
|
-
"x-component": "Password",
|
|
137
|
-
required: true
|
|
138
|
-
},
|
|
139
|
-
bucket: {
|
|
140
|
-
title: `{{t("Bucket", { ns: "${NAMESPACE}" })}}`,
|
|
141
|
-
type: "string",
|
|
142
|
-
"x-decorator": "FormItem",
|
|
143
|
-
"x-component": "Input",
|
|
144
|
-
required: true
|
|
145
|
-
},
|
|
146
|
-
endpoint: {
|
|
147
|
-
title: `{{t("Endpoint", { ns: "${NAMESPACE}" })}}`,
|
|
148
|
-
type: "string",
|
|
149
|
-
"x-decorator": "FormItem",
|
|
150
|
-
"x-component": "Input"
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
const StorageOptions = react.observer(
|
|
156
|
-
(props) => {
|
|
157
|
-
const form = react.useForm();
|
|
158
|
-
const field = react.useField();
|
|
159
|
-
const [s, setSchema] = require$$0.useState(new react.Schema({}));
|
|
160
|
-
require$$0.useEffect(() => {
|
|
161
|
-
setSchema(new react.Schema(schema[form.values.type] || {}));
|
|
162
|
-
}, [form.values.type]);
|
|
163
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(antdV5.FormLayout, { layout: "vertical", children: /* @__PURE__ */ jsxRuntimeExports.jsx(react.RecursionField, { basePath: field.address, onlyRenderProperties: true, schema: s }, form.values.type || "local") });
|
|
164
|
-
},
|
|
165
|
-
{ displayName: "StorageOptions" }
|
|
166
|
-
);
|
|
167
|
-
const collection = {
|
|
168
|
-
name: "storages",
|
|
169
|
-
fields: [
|
|
170
|
-
{
|
|
171
|
-
type: "integer",
|
|
172
|
-
name: "title",
|
|
173
|
-
interface: "input",
|
|
174
|
-
uiSchema: {
|
|
175
|
-
title: '{{t("Title")}}',
|
|
176
|
-
type: "string",
|
|
177
|
-
"x-component": "Input",
|
|
178
|
-
required: true
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
type: "string",
|
|
183
|
-
name: "name",
|
|
184
|
-
interface: "input",
|
|
185
|
-
uiSchema: {
|
|
186
|
-
title: `{{t("Storage name", { ns: "${NAMESPACE}" })}}`,
|
|
187
|
-
descriptions: `{{t("Will be used for API", { ns: "${NAMESPACE}" })}}`,
|
|
188
|
-
type: "string",
|
|
189
|
-
"x-component": "Input"
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
type: "string",
|
|
194
|
-
name: "type",
|
|
195
|
-
interface: "select",
|
|
196
|
-
uiSchema: {
|
|
197
|
-
title: `{{t("Storage type", { ns: "${NAMESPACE}" })}}`,
|
|
198
|
-
type: "string",
|
|
199
|
-
"x-component": "Select",
|
|
200
|
-
required: true,
|
|
201
|
-
enum: [
|
|
202
|
-
{ label: `{{t("Local storage", { ns: "${NAMESPACE}" })}}`, value: "local" },
|
|
203
|
-
{ label: `{{t("Aliyun OSS", { ns: "${NAMESPACE}" })}}`, value: "ali-oss" },
|
|
204
|
-
{ label: `{{t("Amazon S3", { ns: "${NAMESPACE}" })}}`, value: "s3" },
|
|
205
|
-
{ label: `{{t("Tencent COS", { ns: "${NAMESPACE}" })}}`, value: "tx-cos" }
|
|
206
|
-
]
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
type: "string",
|
|
211
|
-
name: "baseUrl",
|
|
212
|
-
interface: "input",
|
|
213
|
-
uiSchema: {
|
|
214
|
-
title: `{{t("Storage base URL", { ns: "${NAMESPACE}" })}}`,
|
|
215
|
-
type: "string",
|
|
216
|
-
"x-component": "Input",
|
|
217
|
-
required: true
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
type: "string",
|
|
222
|
-
name: "path",
|
|
223
|
-
interface: "input",
|
|
224
|
-
uiSchema: {
|
|
225
|
-
title: `{{t("Path", { ns: "${NAMESPACE}" })}}`,
|
|
226
|
-
type: "string",
|
|
227
|
-
"x-component": "Input"
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
type: "boolean",
|
|
232
|
-
name: "default",
|
|
233
|
-
interface: "boolean",
|
|
234
|
-
uiSchema: {
|
|
235
|
-
title: `{{t("Default storage", { ns: "${NAMESPACE}" })}}`,
|
|
236
|
-
type: "boolean",
|
|
237
|
-
"x-component": "Checkbox"
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
type: "boolean",
|
|
242
|
-
name: "paranoid",
|
|
243
|
-
interface: "boolean",
|
|
244
|
-
uiSchema: {
|
|
245
|
-
title: `{{t("Keep file in storage when destroy record", { ns: "${NAMESPACE}" })}}`,
|
|
246
|
-
type: "boolean",
|
|
247
|
-
"x-component": "Checkbox"
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
]
|
|
251
|
-
};
|
|
252
|
-
const storageSchema = {
|
|
253
|
-
type: "object",
|
|
254
|
-
properties: {
|
|
255
|
-
[shared.uid()]: {
|
|
256
|
-
type: "void",
|
|
257
|
-
"x-decorator": "ResourceActionProvider",
|
|
258
|
-
"x-decorator-props": {
|
|
259
|
-
collection,
|
|
260
|
-
resourceName: "storages",
|
|
261
|
-
request: {
|
|
262
|
-
resource: "storages",
|
|
263
|
-
action: "list",
|
|
264
|
-
params: {
|
|
265
|
-
pageSize: 50,
|
|
266
|
-
sort: ["id"],
|
|
267
|
-
appends: []
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
"x-component": "CollectionProvider",
|
|
272
|
-
"x-component-props": {
|
|
273
|
-
collection
|
|
274
|
-
},
|
|
275
|
-
properties: {
|
|
276
|
-
actions: {
|
|
277
|
-
type: "void",
|
|
278
|
-
"x-component": "ActionBar",
|
|
279
|
-
"x-component-props": {
|
|
280
|
-
style: {
|
|
281
|
-
marginBottom: 16
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
properties: {
|
|
285
|
-
delete: {
|
|
286
|
-
type: "void",
|
|
287
|
-
title: '{{ t("Delete") }}',
|
|
288
|
-
"x-component": "Action",
|
|
289
|
-
"x-component-props": {
|
|
290
|
-
useAction: "{{ cm.useBulkDestroyAction }}",
|
|
291
|
-
confirm: {
|
|
292
|
-
title: "{{t('Delete')}}",
|
|
293
|
-
content: "{{t('Are you sure you want to delete it?')}}"
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
create: {
|
|
298
|
-
type: "void",
|
|
299
|
-
title: '{{t("Add new")}}',
|
|
300
|
-
"x-component": "Action",
|
|
301
|
-
"x-component-props": {
|
|
302
|
-
type: "primary"
|
|
303
|
-
},
|
|
304
|
-
properties: {
|
|
305
|
-
drawer: {
|
|
306
|
-
type: "void",
|
|
307
|
-
"x-component": "Action.Drawer",
|
|
308
|
-
"x-decorator": "Form",
|
|
309
|
-
"x-decorator-props": {
|
|
310
|
-
useValues(options) {
|
|
311
|
-
const ctx = client.useActionContext();
|
|
312
|
-
return client.useRequest(
|
|
313
|
-
() => Promise.resolve({
|
|
314
|
-
data: {
|
|
315
|
-
name: `s_${shared.uid()}`
|
|
316
|
-
}
|
|
317
|
-
}),
|
|
318
|
-
{ ...options, refreshDeps: [ctx.visible] }
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
title: '{{t("Add new")}}',
|
|
323
|
-
properties: {
|
|
324
|
-
title: {
|
|
325
|
-
"x-component": "CollectionField",
|
|
326
|
-
"x-decorator": "FormItem"
|
|
327
|
-
},
|
|
328
|
-
name: {
|
|
329
|
-
"x-component": "CollectionField",
|
|
330
|
-
"x-decorator": "FormItem",
|
|
331
|
-
description: '{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'
|
|
332
|
-
},
|
|
333
|
-
baseUrl: {
|
|
334
|
-
"x-component": "CollectionField",
|
|
335
|
-
"x-decorator": "FormItem"
|
|
336
|
-
},
|
|
337
|
-
type: {
|
|
338
|
-
"x-component": "CollectionField",
|
|
339
|
-
"x-decorator": "FormItem"
|
|
340
|
-
},
|
|
341
|
-
options: {
|
|
342
|
-
type: "object",
|
|
343
|
-
"x-component": "StorageOptions"
|
|
344
|
-
},
|
|
345
|
-
path: {
|
|
346
|
-
"x-component": "CollectionField",
|
|
347
|
-
"x-decorator": "FormItem"
|
|
348
|
-
},
|
|
349
|
-
default: {
|
|
350
|
-
"x-component": "CollectionField",
|
|
351
|
-
"x-decorator": "FormItem",
|
|
352
|
-
title: "",
|
|
353
|
-
"x-content": `{{t("Default storage", { ns: "${NAMESPACE}" })}}`
|
|
354
|
-
},
|
|
355
|
-
paranoid: {
|
|
356
|
-
title: "",
|
|
357
|
-
"x-component": "CollectionField",
|
|
358
|
-
"x-decorator": "FormItem",
|
|
359
|
-
"x-content": `{{t("Keep file in storage when destroy record", { ns: "${NAMESPACE}" })}}`
|
|
360
|
-
},
|
|
361
|
-
footer: {
|
|
362
|
-
type: "void",
|
|
363
|
-
"x-component": "Action.Drawer.Footer",
|
|
364
|
-
properties: {
|
|
365
|
-
cancel: {
|
|
366
|
-
title: '{{t("Cancel")}}',
|
|
367
|
-
"x-component": "Action",
|
|
368
|
-
"x-component-props": {
|
|
369
|
-
useAction: "{{ cm.useCancelAction }}"
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
submit: {
|
|
373
|
-
title: '{{t("Submit")}}',
|
|
374
|
-
"x-component": "Action",
|
|
375
|
-
"x-component-props": {
|
|
376
|
-
type: "primary",
|
|
377
|
-
useAction: "{{ cm.useCreateAction }}"
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
},
|
|
388
|
-
table: {
|
|
389
|
-
type: "void",
|
|
390
|
-
"x-uid": "input",
|
|
391
|
-
"x-component": "Table.Void",
|
|
392
|
-
"x-component-props": {
|
|
393
|
-
rowKey: "id",
|
|
394
|
-
rowSelection: {
|
|
395
|
-
type: "checkbox"
|
|
396
|
-
},
|
|
397
|
-
useDataSource: "{{ cm.useDataSourceFromRAC }}"
|
|
398
|
-
},
|
|
399
|
-
properties: {
|
|
400
|
-
title: {
|
|
401
|
-
type: "void",
|
|
402
|
-
"x-decorator": "Table.Column.Decorator",
|
|
403
|
-
"x-component": "Table.Column",
|
|
404
|
-
properties: {
|
|
405
|
-
title: {
|
|
406
|
-
type: "number",
|
|
407
|
-
"x-component": "CollectionField",
|
|
408
|
-
"x-read-pretty": true
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
},
|
|
412
|
-
name: {
|
|
413
|
-
type: "void",
|
|
414
|
-
"x-decorator": "Table.Column.Decorator",
|
|
415
|
-
"x-component": "Table.Column",
|
|
416
|
-
properties: {
|
|
417
|
-
name: {
|
|
418
|
-
type: "string",
|
|
419
|
-
"x-component": "CollectionField",
|
|
420
|
-
"x-read-pretty": true
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
},
|
|
424
|
-
default: {
|
|
425
|
-
type: "void",
|
|
426
|
-
"x-decorator": "Table.Column.Decorator",
|
|
427
|
-
"x-component": "Table.Column",
|
|
428
|
-
properties: {
|
|
429
|
-
default: {
|
|
430
|
-
type: "string",
|
|
431
|
-
"x-component": "CollectionField",
|
|
432
|
-
"x-read-pretty": true
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
},
|
|
436
|
-
actions: {
|
|
437
|
-
type: "void",
|
|
438
|
-
title: '{{t("Actions")}}',
|
|
439
|
-
"x-component": "Table.Column",
|
|
440
|
-
properties: {
|
|
441
|
-
actions: {
|
|
442
|
-
type: "void",
|
|
443
|
-
"x-component": "Space",
|
|
444
|
-
"x-component-props": {
|
|
445
|
-
split: "|"
|
|
446
|
-
},
|
|
447
|
-
properties: {
|
|
448
|
-
update: {
|
|
449
|
-
type: "void",
|
|
450
|
-
title: '{{t("Edit")}}',
|
|
451
|
-
"x-component": "Action.Link",
|
|
452
|
-
"x-component-props": {
|
|
453
|
-
type: "primary"
|
|
454
|
-
},
|
|
455
|
-
properties: {
|
|
456
|
-
drawer: {
|
|
457
|
-
type: "void",
|
|
458
|
-
"x-component": "Action.Drawer",
|
|
459
|
-
"x-decorator": "Form",
|
|
460
|
-
"x-decorator-props": {
|
|
461
|
-
useValues: "{{ cm.useValuesFromRecord }}"
|
|
462
|
-
},
|
|
463
|
-
title: '{{t("Edit")}}',
|
|
464
|
-
properties: {
|
|
465
|
-
title: {
|
|
466
|
-
"x-component": "CollectionField",
|
|
467
|
-
"x-decorator": "FormItem"
|
|
468
|
-
},
|
|
469
|
-
name: {
|
|
470
|
-
"x-component": "CollectionField",
|
|
471
|
-
"x-decorator": "FormItem",
|
|
472
|
-
"x-disabled": true
|
|
473
|
-
},
|
|
474
|
-
baseUrl: {
|
|
475
|
-
"x-component": "CollectionField",
|
|
476
|
-
"x-decorator": "FormItem"
|
|
477
|
-
},
|
|
478
|
-
type: {
|
|
479
|
-
"x-component": "CollectionField",
|
|
480
|
-
"x-decorator": "FormItem",
|
|
481
|
-
"x-disabled": true
|
|
482
|
-
},
|
|
483
|
-
options: {
|
|
484
|
-
type: "object",
|
|
485
|
-
"x-component": "StorageOptions"
|
|
486
|
-
},
|
|
487
|
-
path: {
|
|
488
|
-
"x-component": "CollectionField",
|
|
489
|
-
"x-decorator": "FormItem"
|
|
490
|
-
},
|
|
491
|
-
default: {
|
|
492
|
-
title: "",
|
|
493
|
-
"x-component": "CollectionField",
|
|
494
|
-
"x-decorator": "FormItem",
|
|
495
|
-
"x-content": `{{t("Default storage", { ns: "${NAMESPACE}" })}}`
|
|
496
|
-
},
|
|
497
|
-
paranoid: {
|
|
498
|
-
title: "",
|
|
499
|
-
"x-component": "CollectionField",
|
|
500
|
-
"x-decorator": "FormItem",
|
|
501
|
-
"x-content": `{{t("Keep file in storage when destroy record", { ns: "${NAMESPACE}" })}}`
|
|
502
|
-
},
|
|
503
|
-
footer: {
|
|
504
|
-
type: "void",
|
|
505
|
-
"x-component": "Action.Drawer.Footer",
|
|
506
|
-
properties: {
|
|
507
|
-
cancel: {
|
|
508
|
-
title: '{{t("Cancel")}}',
|
|
509
|
-
"x-component": "Action",
|
|
510
|
-
"x-component-props": {
|
|
511
|
-
useAction: "{{ cm.useCancelAction }}"
|
|
512
|
-
}
|
|
513
|
-
},
|
|
514
|
-
submit: {
|
|
515
|
-
title: '{{t("Submit")}}',
|
|
516
|
-
"x-component": "Action",
|
|
517
|
-
"x-component-props": {
|
|
518
|
-
type: "primary",
|
|
519
|
-
useAction: "{{ cm.useUpdateAction }}"
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
},
|
|
528
|
-
delete: {
|
|
529
|
-
type: "void",
|
|
530
|
-
title: '{{ t("Delete") }}',
|
|
531
|
-
"x-component": "Action.Link",
|
|
532
|
-
"x-component-props": {
|
|
533
|
-
confirm: {
|
|
534
|
-
title: '{{t("Delete")}}',
|
|
535
|
-
content: '{{t("Are you sure you want to delete it?")}}'
|
|
536
|
-
},
|
|
537
|
-
useAction: "{{cm.useDestroyAction}}"
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
|
-
const FileStoragePane = () => {
|
|
551
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Card, { bordered: false, children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.SchemaComponent, { components: { StorageOptions }, schema: storageSchema }) });
|
|
552
|
-
};
|
|
553
|
-
const FILE_LIMIT_SIZE = 1024 * 1024 * 1024;
|
|
554
|
-
const useUploadFiles = () => {
|
|
555
|
-
const { service } = client.useBlockRequestContext();
|
|
556
|
-
const { t } = useFmTranslation();
|
|
557
|
-
const { setVisible } = client.useActionContext();
|
|
558
|
-
const { setSelectedRows } = require$$0.useContext(client.RecordPickerContext) || {};
|
|
559
|
-
const uploadingFiles = {};
|
|
560
|
-
let pendingNumber = 0;
|
|
561
|
-
return {
|
|
562
|
-
/**
|
|
563
|
-
* 返回 false 会阻止上传,返回 true 会继续上传
|
|
564
|
-
*/
|
|
565
|
-
beforeUpload(file2) {
|
|
566
|
-
if (file2.size > FILE_LIMIT_SIZE) {
|
|
567
|
-
antd.notification.error({
|
|
568
|
-
message: `${t("File size cannot exceed")} ${FILE_LIMIT_SIZE / 1024 / 1024}M`
|
|
569
|
-
});
|
|
570
|
-
file2.status = "error";
|
|
571
|
-
return false;
|
|
572
|
-
}
|
|
573
|
-
return true;
|
|
574
|
-
},
|
|
575
|
-
onChange(fileList) {
|
|
576
|
-
fileList.forEach((file2) => {
|
|
577
|
-
var _a;
|
|
578
|
-
if (file2.status === "uploading" && !uploadingFiles[file2.uid]) {
|
|
579
|
-
pendingNumber++;
|
|
580
|
-
uploadingFiles[file2.uid] = true;
|
|
581
|
-
}
|
|
582
|
-
if (file2.status !== "uploading" && uploadingFiles[file2.uid]) {
|
|
583
|
-
delete uploadingFiles[file2.uid];
|
|
584
|
-
if (--pendingNumber === 0) {
|
|
585
|
-
(_a = service == null ? void 0 : service.refresh) == null ? void 0 : _a.call(service);
|
|
586
|
-
setSelectedRows == null ? void 0 : setSelectedRows((preRows) => [
|
|
587
|
-
...preRows,
|
|
588
|
-
...fileList.filter((file22) => file22.status === "done").map((file22) => file22.response.data)
|
|
589
|
-
]);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
if (fileList.every((file2) => file2.status === "done")) {
|
|
594
|
-
setVisible(false);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
};
|
|
599
|
-
const hooks = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
600
|
-
__proto__: null,
|
|
601
|
-
FILE_LIMIT_SIZE,
|
|
602
|
-
useUploadFiles
|
|
603
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
604
|
-
const UploadActionInitializer = (props) => {
|
|
605
|
-
const collection2 = client.useCollection();
|
|
606
|
-
const schema2 = {
|
|
607
|
-
type: "void",
|
|
608
|
-
"x-action": "create",
|
|
609
|
-
title: "{{t('Upload')}}",
|
|
610
|
-
"x-designer": "Action.Designer",
|
|
611
|
-
"x-component": "Action",
|
|
612
|
-
"x-decorator": "ACLActionProvider",
|
|
613
|
-
"x-component-props": {
|
|
614
|
-
openMode: "drawer",
|
|
615
|
-
type: "primary",
|
|
616
|
-
icon: "UploadOutlined"
|
|
617
|
-
},
|
|
618
|
-
properties: {
|
|
619
|
-
drawer: {
|
|
620
|
-
type: "void",
|
|
621
|
-
title: '{{ t("Upload files") }}',
|
|
622
|
-
"x-component": "Action.Container",
|
|
623
|
-
properties: {
|
|
624
|
-
upload: {
|
|
625
|
-
type: "void",
|
|
626
|
-
title: '{{ t("Upload files") }}',
|
|
627
|
-
"x-component": "Upload.DraggerV2",
|
|
628
|
-
"x-component-props": {
|
|
629
|
-
height: "50vh",
|
|
630
|
-
action: `${collection2.name}:create`,
|
|
631
|
-
useProps: "{{useUploadFiles}}",
|
|
632
|
-
multiple: true,
|
|
633
|
-
listType: "picture"
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
};
|
|
640
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(client.ActionInitializer, { ...props, schema: schema2 });
|
|
641
|
-
};
|
|
642
|
-
const initializers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
643
|
-
__proto__: null,
|
|
644
|
-
UploadActionInitializer
|
|
645
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
646
|
-
const attachment = {
|
|
647
|
-
name: "attachment",
|
|
648
|
-
type: "object",
|
|
649
|
-
group: "media",
|
|
650
|
-
title: `{{t("Attachment", { ns: "${NAMESPACE}" })}}`,
|
|
651
|
-
isAssociation: true,
|
|
652
|
-
default: {
|
|
653
|
-
type: "belongsToMany",
|
|
654
|
-
target: "attachments",
|
|
655
|
-
// name,
|
|
656
|
-
uiSchema: {
|
|
657
|
-
type: "array",
|
|
658
|
-
// title,
|
|
659
|
-
"x-component": "Upload.Attachment",
|
|
660
|
-
"x-component-props": {}
|
|
661
|
-
}
|
|
662
|
-
},
|
|
663
|
-
availableTypes: ["belongsToMany"],
|
|
664
|
-
schemaInitialize(schema2, { block, field }) {
|
|
665
|
-
if (["Table", "Kanban"].includes(block)) {
|
|
666
|
-
schema2["x-component-props"] = schema2["x-component-props"] || {};
|
|
667
|
-
schema2["x-component-props"]["size"] = "small";
|
|
668
|
-
}
|
|
669
|
-
if (!schema2["x-component-props"]) {
|
|
670
|
-
schema2["x-component-props"] = {};
|
|
671
|
-
}
|
|
672
|
-
schema2["x-component-props"]["action"] = `${field.target}:create${field.storage ? `?attachementField=${field.collectionName}.${field.name}` : ""}`;
|
|
673
|
-
},
|
|
674
|
-
initialize: (values) => {
|
|
675
|
-
if (!values.through) {
|
|
676
|
-
values.through = `t_${shared.uid()}`;
|
|
677
|
-
}
|
|
678
|
-
if (!values.foreignKey) {
|
|
679
|
-
values.foreignKey = `f_${shared.uid()}`;
|
|
680
|
-
}
|
|
681
|
-
if (!values.otherKey) {
|
|
682
|
-
values.otherKey = `f_${shared.uid()}`;
|
|
683
|
-
}
|
|
684
|
-
if (!values.sourceKey) {
|
|
685
|
-
values.sourceKey = "id";
|
|
686
|
-
}
|
|
687
|
-
if (!values.targetKey) {
|
|
688
|
-
values.targetKey = "id";
|
|
689
|
-
}
|
|
690
|
-
},
|
|
691
|
-
properties: {
|
|
692
|
-
...client.interfacesProperties.defaultProps,
|
|
693
|
-
"uiSchema.x-component-props.accept": {
|
|
694
|
-
type: "string",
|
|
695
|
-
title: `{{t("MIME type", { ns: "${NAMESPACE}" })}}`,
|
|
696
|
-
"x-component": "Input",
|
|
697
|
-
"x-decorator": "FormItem",
|
|
698
|
-
description: "Example: image/png",
|
|
699
|
-
default: "image/*"
|
|
700
|
-
},
|
|
701
|
-
"uiSchema.x-component-props.multiple": {
|
|
702
|
-
type: "boolean",
|
|
703
|
-
"x-content": `{{t('Allow uploading multiple files', { ns: "${NAMESPACE}" })}}`,
|
|
704
|
-
"x-decorator": "FormItem",
|
|
705
|
-
"x-component": "Checkbox",
|
|
706
|
-
default: true
|
|
707
|
-
},
|
|
708
|
-
storage: {
|
|
709
|
-
type: "string",
|
|
710
|
-
title: `{{t("Storage", { ns: "${NAMESPACE}" })}}`,
|
|
711
|
-
description: `{{t('Default storage will be used when not selected', { ns: "${NAMESPACE}" })}}`,
|
|
712
|
-
"x-decorator": "FormItem",
|
|
713
|
-
"x-component": "RemoteSelect",
|
|
714
|
-
"x-component-props": {
|
|
715
|
-
service: {
|
|
716
|
-
resource: "storages",
|
|
717
|
-
params: {
|
|
718
|
-
// pageSize: -1
|
|
719
|
-
}
|
|
720
|
-
},
|
|
721
|
-
manual: false,
|
|
722
|
-
fieldNames: {
|
|
723
|
-
label: "title",
|
|
724
|
-
value: "name"
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
},
|
|
729
|
-
filterable: {
|
|
730
|
-
children: [
|
|
731
|
-
{
|
|
732
|
-
name: "id",
|
|
733
|
-
title: '{{t("Exists")}}',
|
|
734
|
-
operators: [
|
|
735
|
-
{ label: '{{t("exists")}}', value: "$exists", noValue: true },
|
|
736
|
-
{ label: '{{t("not exists")}}', value: "$notExists", noValue: true }
|
|
737
|
-
],
|
|
738
|
-
schema: {
|
|
739
|
-
title: '{{t("Exists")}}',
|
|
740
|
-
type: "string",
|
|
741
|
-
"x-component": "Input"
|
|
742
|
-
}
|
|
743
|
-
},
|
|
744
|
-
{
|
|
745
|
-
name: "filename",
|
|
746
|
-
title: `{{t("Filename", { ns: "${NAMESPACE}" })}}`,
|
|
747
|
-
operators: client.interfacesProperties.operators.string,
|
|
748
|
-
schema: {
|
|
749
|
-
title: `{{t("Filename", { ns: "${NAMESPACE}" })}}`,
|
|
750
|
-
type: "string",
|
|
751
|
-
"x-component": "Input"
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
]
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
const file = {
|
|
758
|
-
name: "file",
|
|
759
|
-
title: `{{t("File collection", { ns: "${NAMESPACE}" })}}`,
|
|
760
|
-
order: 3,
|
|
761
|
-
color: "blue",
|
|
762
|
-
default: {
|
|
763
|
-
createdBy: true,
|
|
764
|
-
updatedBy: true,
|
|
765
|
-
fields: [
|
|
766
|
-
{
|
|
767
|
-
interface: "input",
|
|
768
|
-
type: "string",
|
|
769
|
-
name: "title",
|
|
770
|
-
deletable: false,
|
|
771
|
-
uiSchema: {
|
|
772
|
-
type: "string",
|
|
773
|
-
title: `{{t("Title")}}`,
|
|
774
|
-
"x-component": "Input"
|
|
775
|
-
}
|
|
776
|
-
},
|
|
777
|
-
// '系统文件名(含扩展名)',
|
|
778
|
-
{
|
|
779
|
-
interface: "input",
|
|
780
|
-
type: "string",
|
|
781
|
-
name: "filename",
|
|
782
|
-
deletable: false,
|
|
783
|
-
uiSchema: {
|
|
784
|
-
type: "string",
|
|
785
|
-
title: `{{t("File name", { ns: "${NAMESPACE}" })}}`,
|
|
786
|
-
"x-component": "Input",
|
|
787
|
-
"x-read-pretty": true
|
|
788
|
-
}
|
|
789
|
-
},
|
|
790
|
-
// '扩展名(含“.”)',
|
|
791
|
-
{
|
|
792
|
-
interface: "input",
|
|
793
|
-
type: "string",
|
|
794
|
-
name: "extname",
|
|
795
|
-
deletable: false,
|
|
796
|
-
uiSchema: {
|
|
797
|
-
type: "string",
|
|
798
|
-
title: `{{t("Extension name", { ns: "${NAMESPACE}" })}}`,
|
|
799
|
-
"x-component": "Input",
|
|
800
|
-
"x-read-pretty": true
|
|
801
|
-
}
|
|
802
|
-
},
|
|
803
|
-
// '文件体积(字节)',
|
|
804
|
-
{
|
|
805
|
-
interface: "integer",
|
|
806
|
-
type: "integer",
|
|
807
|
-
name: "size",
|
|
808
|
-
deletable: false,
|
|
809
|
-
uiSchema: {
|
|
810
|
-
type: "number",
|
|
811
|
-
title: `{{t("Size", { ns: "${NAMESPACE}" })}}`,
|
|
812
|
-
"x-component": "InputNumber",
|
|
813
|
-
"x-read-pretty": true,
|
|
814
|
-
"x-component-props": {
|
|
815
|
-
stringMode: true,
|
|
816
|
-
step: "0"
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
},
|
|
820
|
-
{
|
|
821
|
-
interface: "input",
|
|
822
|
-
type: "string",
|
|
823
|
-
name: "mimetype",
|
|
824
|
-
deletable: false,
|
|
825
|
-
uiSchema: {
|
|
826
|
-
type: "string",
|
|
827
|
-
title: `{{t("MIME type", { ns: "${NAMESPACE}" })}}`,
|
|
828
|
-
"x-component": "Input",
|
|
829
|
-
"x-read-pretty": true
|
|
830
|
-
}
|
|
831
|
-
},
|
|
832
|
-
// '相对路径(含“/”前缀)',
|
|
833
|
-
{
|
|
834
|
-
interface: "input",
|
|
835
|
-
type: "string",
|
|
836
|
-
name: "path",
|
|
837
|
-
deletable: false,
|
|
838
|
-
uiSchema: {
|
|
839
|
-
type: "string",
|
|
840
|
-
title: `{{t("Path")}}`,
|
|
841
|
-
"x-component": "Input",
|
|
842
|
-
"x-read-pretty": true
|
|
843
|
-
}
|
|
844
|
-
},
|
|
845
|
-
// 文件的可访问地址
|
|
846
|
-
{
|
|
847
|
-
interface: "input",
|
|
848
|
-
type: "string",
|
|
849
|
-
name: "url",
|
|
850
|
-
deletable: false,
|
|
851
|
-
uiSchema: {
|
|
852
|
-
type: "string",
|
|
853
|
-
title: `{{t("URL")}}`,
|
|
854
|
-
"x-component": "Input.URL",
|
|
855
|
-
"x-read-pretty": true
|
|
856
|
-
}
|
|
857
|
-
},
|
|
858
|
-
// 用于预览
|
|
859
|
-
{
|
|
860
|
-
interface: "url",
|
|
861
|
-
type: "string",
|
|
862
|
-
name: "preview",
|
|
863
|
-
field: "url",
|
|
864
|
-
// 直接引用 url 字段
|
|
865
|
-
deletable: false,
|
|
866
|
-
uiSchema: {
|
|
867
|
-
type: "string",
|
|
868
|
-
title: `{{t("Preview")}}`,
|
|
869
|
-
"x-component": "Preview",
|
|
870
|
-
"x-read-pretty": true
|
|
871
|
-
}
|
|
872
|
-
},
|
|
873
|
-
{
|
|
874
|
-
comment: "存储引擎",
|
|
875
|
-
type: "belongsTo",
|
|
876
|
-
name: "storage",
|
|
877
|
-
target: "storages",
|
|
878
|
-
foreignKey: "storageId",
|
|
879
|
-
deletable: false
|
|
880
|
-
},
|
|
881
|
-
// '其他文件信息(如图片的宽高)',
|
|
882
|
-
{
|
|
883
|
-
type: "jsonb",
|
|
884
|
-
name: "meta",
|
|
885
|
-
deletable: false,
|
|
886
|
-
defaultValue: {}
|
|
887
|
-
}
|
|
888
|
-
]
|
|
889
|
-
},
|
|
890
|
-
configurableProperties: {
|
|
891
|
-
...client.getConfigurableProperties("title", "name"),
|
|
892
|
-
inherits: {
|
|
893
|
-
...client.getConfigurableProperties("inherits").inherits,
|
|
894
|
-
"x-reactions": ["{{useAsyncDataSource(loadCollections)}}"]
|
|
895
|
-
},
|
|
896
|
-
...client.getConfigurableProperties("category"),
|
|
897
|
-
storage: {
|
|
898
|
-
title: `{{t("File storage", { ns: "${NAMESPACE}" })}}`,
|
|
899
|
-
type: "hasOne",
|
|
900
|
-
name: "storage",
|
|
901
|
-
required: true,
|
|
902
|
-
"x-decorator": "FormItem",
|
|
903
|
-
"x-component": "Select",
|
|
904
|
-
"x-reactions": ["{{useAsyncDataSource(loadStorages)}}"]
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
};
|
|
908
|
-
const templates = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
909
|
-
__proto__: null,
|
|
910
|
-
file
|
|
911
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
912
|
-
client$1.forEach(templates, (template, key) => {
|
|
913
|
-
client.registerTemplate(key, template);
|
|
914
|
-
});
|
|
915
|
-
client.registerField(attachment.group, "attachment", attachment);
|
|
916
|
-
const FileManagerProvider = (props) => {
|
|
917
|
-
const initializes = require$$0.useContext(client.SchemaInitializerContext);
|
|
918
|
-
const hasUploadAction = initializes.TableActionInitializers.items[0].children.some(
|
|
919
|
-
(initialize) => initialize.component === "UploadActionInitializer"
|
|
920
|
-
);
|
|
921
|
-
!hasUploadAction && initializes.TableActionInitializers.items[0].children.push({
|
|
922
|
-
type: "item",
|
|
923
|
-
title: "{{t('Upload')}}",
|
|
924
|
-
component: "UploadActionInitializer",
|
|
925
|
-
schema: {
|
|
926
|
-
"x-align": "right",
|
|
927
|
-
"x-decorator": "ACLActionProvider",
|
|
928
|
-
"x-acl-action-props": {
|
|
929
|
-
skipScopeCheck: true
|
|
930
|
-
}
|
|
931
|
-
},
|
|
932
|
-
visible: () => {
|
|
933
|
-
const collection2 = client.useCollection();
|
|
934
|
-
return collection2.template === "file";
|
|
935
|
-
}
|
|
936
|
-
});
|
|
937
|
-
const ctx = require$$0.useContext(client.PluginManagerContext);
|
|
938
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
939
|
-
client.SettingsCenterProvider,
|
|
940
|
-
{
|
|
941
|
-
settings: {
|
|
942
|
-
"file-manager": {
|
|
943
|
-
title: `{{t("File manager", { ns: "${NAMESPACE}" })}}`,
|
|
944
|
-
icon: "FileOutlined",
|
|
945
|
-
tabs: {
|
|
946
|
-
storages: {
|
|
947
|
-
title: `{{t("File storage", { ns: "${NAMESPACE}" })}}`,
|
|
948
|
-
component: FileStoragePane
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
},
|
|
953
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
954
|
-
client.PluginManagerContext.Provider,
|
|
955
|
-
{
|
|
956
|
-
value: {
|
|
957
|
-
components: {
|
|
958
|
-
...ctx == null ? void 0 : ctx.components
|
|
959
|
-
}
|
|
960
|
-
},
|
|
961
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.CollectionManagerProvider, { interfaces: { attachment }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.SchemaComponentOptions, { scope: hooks, children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.SchemaInitializerProvider, { components: initializers, children: props.children }) }) })
|
|
962
|
-
}
|
|
963
|
-
)
|
|
964
|
-
}
|
|
965
|
-
);
|
|
966
|
-
};
|
|
967
|
-
class FileManagerPlugin extends client.Plugin {
|
|
968
|
-
async load() {
|
|
969
|
-
this.app.use(FileManagerProvider);
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
exports2.FileManagerPlugin = FileManagerPlugin;
|
|
973
|
-
exports2.default = FileManagerPlugin;
|
|
974
|
-
Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
975
|
-
});
|
|
1
|
+
(function(n,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@nocobase/utils/client"),require("react"),require("antd"),require("@formily/antd-v5"),require("@formily/react"),require("react-i18next"),require("@formily/shared")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@nocobase/utils/client","react","antd","@formily/antd-v5","@formily/react","react-i18next","@formily/shared"],t):(n=typeof globalThis!="undefined"?globalThis:n||self,t(n["@nocobase/plugin-file-manager"]={},n["@nocobase/client"],n.jsxRuntime,n["@nocobase/utils"],n.react,n.antd,n["@formily/antd-v5"],n["@formily/react"],n["react-i18next"],n["@formily/shared"]))})(this,function(n,t,r,b,u,f,h,s,p,c){"use strict";var B=Object.defineProperty,L=Object.defineProperties;var R=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var V=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var T=(n,t,r)=>t in n?B(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,x=(n,t)=>{for(var r in t||(t={}))V.call(t,r)&&T(n,r,t[r]);if(P)for(var r of P(t))N.call(t,r)&&T(n,r,t[r]);return n},y=(n,t)=>L(n,R(t));var q=(n,t,r)=>new Promise((b,u)=>{var f=p=>{try{s(r.next(p))}catch(c){u(c)}},h=p=>{try{s(r.throw(p))}catch(c){u(c)}},s=p=>p.done?b(p.value):Promise.resolve(p.value).then(f,h);s((r=r.apply(n,t)).next())});const e="file-manager";function w(){return p.useTranslation(e)}const D={local:{properties:{documentRoot:{title:`{{t("Destination", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input",default:"storage/uploads"}}},"ali-oss":{properties:{region:{title:`{{t("Region", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input",required:!0},accessKeyId:{title:`{{t("AccessKey ID", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input",required:!0},accessKeySecret:{title:`{{t("AccessKey Secret", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Password",required:!0},bucket:{title:`{{t("Bucket", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input",required:!0}}},"tx-cos":{properties:{Region:{title:`{{t("Region", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input",required:!0},SecretId:{title:`{{t("SecretId", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input",required:!0},SecretKey:{title:`{{t("SecretKey", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Password",required:!0},Bucket:{title:`{{t("Bucket", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input",required:!0}}},s3:{properties:{region:{title:`{{t("Region", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input",required:!0},accessKeyId:{title:`{{t("AccessKey ID", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input",required:!0},secretAccessKey:{title:`{{t("AccessKey Secret", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Password",required:!0},bucket:{title:`{{t("Bucket", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input",required:!0},endpoint:{title:`{{t("Endpoint", { ns: "${e}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"}}}},K=s.observer(o=>{const i=s.useForm(),a=s.useField(),[l,m]=u.useState(new s.Schema({}));return u.useEffect(()=>{m(new s.Schema(D[i.values.type]||{}))},[i.values.type]),r.jsx(h.FormLayout,{layout:"vertical",children:r.jsx(s.RecursionField,{basePath:a.address,onlyRenderProperties:!0,schema:l},i.values.type||"local")})},{displayName:"StorageOptions"}),A={name:"storages",fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{t("Title")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:`{{t("Storage name", { ns: "${e}" })}}`,descriptions:`{{t("Will be used for API", { ns: "${e}" })}}`,type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Storage type", { ns: "${e}" })}}`,type:"string","x-component":"Select",required:!0,enum:[{label:`{{t("Local storage", { ns: "${e}" })}}`,value:"local"},{label:`{{t("Aliyun OSS", { ns: "${e}" })}}`,value:"ali-oss"},{label:`{{t("Amazon S3", { ns: "${e}" })}}`,value:"s3"},{label:`{{t("Tencent COS", { ns: "${e}" })}}`,value:"tx-cos"}]}},{type:"string",name:"baseUrl",interface:"input",uiSchema:{title:`{{t("Storage base URL", { ns: "${e}" })}}`,type:"string","x-component":"Input",required:!0}},{type:"string",name:"path",interface:"input",uiSchema:{title:`{{t("Path", { ns: "${e}" })}}`,type:"string","x-component":"Input"}},{type:"boolean",name:"default",interface:"boolean",uiSchema:{title:`{{t("Default storage", { ns: "${e}" })}}`,type:"boolean","x-component":"Checkbox"}},{type:"boolean",name:"paranoid",interface:"boolean",uiSchema:{title:`{{t("Keep file in storage when destroy record", { ns: "${e}" })}}`,type:"boolean","x-component":"Checkbox"}}]},U={type:"object",properties:{[c.uid()]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:A,resourceName:"storages",request:{resource:"storages",action:"list",params:{pageSize:50,sort:["id"],appends:[]}}},"x-component":"CollectionProvider","x-component-props":{collection:A},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(o){const i=t.useActionContext();return t.useRequest(()=>Promise.resolve({data:{name:`s_${c.uid()}`}}),y(x({},o),{refreshDeps:[i.visible]}))}},title:'{{t("Add new")}}',properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'},baseUrl:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"StorageOptions"},path:{"x-component":"CollectionField","x-decorator":"FormItem"},default:{"x-component":"CollectionField","x-decorator":"FormItem",title:"","x-content":`{{t("Default storage", { ns: "${e}" })}}`},paranoid:{title:"","x-component":"CollectionField","x-decorator":"FormItem","x-content":`{{t("Keep file in storage when destroy record", { ns: "${e}" })}}`},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},default:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{default:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Edit")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Edit")}}',properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},baseUrl:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},options:{type:"object","x-component":"StorageOptions"},path:{"x-component":"CollectionField","x-decorator":"FormItem"},default:{title:"","x-component":"CollectionField","x-decorator":"FormItem","x-content":`{{t("Default storage", { ns: "${e}" })}}`},paranoid:{title:"","x-component":"CollectionField","x-decorator":"FormItem","x-content":`{{t("Keep file in storage when destroy record", { ns: "${e}" })}}`},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:'{{t("Delete")}}',content:'{{t("Are you sure you want to delete it?")}}'},useAction:"{{cm.useDestroyAction}}"}}}}}}}}}}}},z=()=>r.jsx(f.Card,{bordered:!1,children:r.jsx(t.SchemaComponent,{components:{StorageOptions:K},schema:U})}),I=1024*1024*1024,M=Object.freeze(Object.defineProperty({__proto__:null,FILE_LIMIT_SIZE:I,useUploadFiles:()=>{const{service:o}=t.useBlockRequestContext(),{t:i}=w(),{setVisible:a}=t.useActionContext(),{setSelectedRows:l}=u.useContext(t.RecordPickerContext)||{},m={};let $=0;return{beforeUpload(g){return g.size>I?(f.notification.error({message:`${i("File size cannot exceed")} ${I/1024/1024}M`}),g.status="error",!1):!0},onChange(g){g.forEach(d=>{var v;d.status==="uploading"&&!m[d.uid]&&($++,m[d.uid]=!0),d.status!=="uploading"&&m[d.uid]&&(delete m[d.uid],--$===0&&((v=o==null?void 0:o.refresh)==null||v.call(o),l==null||l(O=>[...O,...g.filter(S=>S.status==="done").map(S=>S.response.data)])))}),g.every(d=>d.status==="done")&&a(!1)}}}},Symbol.toStringTag,{value:"Module"})),_=Object.freeze(Object.defineProperty({__proto__:null,UploadActionInitializer:o=>{const i=t.useCollection(),a={type:"void","x-action":"create",title:"{{t('Upload')}}","x-designer":"Action.Designer","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",icon:"UploadOutlined"},properties:{drawer:{type:"void",title:'{{ t("Upload files") }}',"x-component":"Action.Container",properties:{upload:{type:"void",title:'{{ t("Upload files") }}',"x-component":"Upload.DraggerV2","x-component-props":{height:"50vh",action:`${i.name}:create`,useProps:"{{useUploadFiles}}",multiple:!0,listType:"picture"}}}}}};return r.jsx(t.ActionInitializer,y(x({},o),{schema:a}))}},Symbol.toStringTag,{value:"Module"})),F={name:"attachment",type:"object",group:"media",title:`{{t("Attachment", { ns: "${e}" })}}`,isAssociation:!0,default:{type:"belongsToMany",target:"attachments",uiSchema:{type:"array","x-component":"Upload.Attachment","x-component-props":{}}},availableTypes:["belongsToMany"],schemaInitialize(o,{block:i,field:a}){["Table","Kanban"].includes(i)&&(o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].size="small"),o["x-component-props"]||(o["x-component-props"]={}),o["x-component-props"].action=`${a.target}:create${a.storage?`?attachmentField=${a.collectionName}.${a.name}`:""}`},initialize:o=>{o.through||(o.through=`t_${c.uid()}`),o.foreignKey||(o.foreignKey=`f_${c.uid()}`),o.otherKey||(o.otherKey=`f_${c.uid()}`),o.sourceKey||(o.sourceKey="id"),o.targetKey||(o.targetKey="id")},properties:y(x({},t.interfacesProperties.defaultProps),{"uiSchema.x-component-props.accept":{type:"string",title:`{{t("MIME type", { ns: "${e}" })}}`,"x-component":"Input","x-decorator":"FormItem",description:"Example: image/png",default:"image/*"},"uiSchema.x-component-props.multiple":{type:"boolean","x-content":`{{t('Allow uploading multiple files', { ns: "${e}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox",default:!0},storage:{type:"string",title:`{{t("Storage", { ns: "${e}" })}}`,description:`{{t('Default storage will be used when not selected', { ns: "${e}" })}}`,"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{service:{resource:"storages",params:{}},manual:!1,fieldNames:{label:"title",value:"name"}}}}),filterable:{children:[{name:"id",title:'{{t("Exists")}}',operators:[{label:'{{t("exists")}}',value:"$exists",noValue:!0},{label:'{{t("not exists")}}',value:"$notExists",noValue:!0}],schema:{title:'{{t("Exists")}}',type:"string","x-component":"Input"}},{name:"filename",title:`{{t("Filename", { ns: "${e}" })}}`,operators:t.interfacesProperties.operators.string,schema:{title:`{{t("Filename", { ns: "${e}" })}}`,type:"string","x-component":"Input"}}]}},k={name:"file",title:`{{t("File collection", { ns: "${e}" })}}`,order:3,color:"blue",default:{createdBy:!0,updatedBy:!0,fields:[{interface:"input",type:"string",name:"title",deletable:!1,uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"input",type:"string",name:"filename",deletable:!1,uiSchema:{type:"string",title:`{{t("File name", { ns: "${e}" })}}`,"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"string",name:"extname",deletable:!1,uiSchema:{type:"string",title:`{{t("Extension name", { ns: "${e}" })}}`,"x-component":"Input","x-read-pretty":!0}},{interface:"integer",type:"integer",name:"size",deletable:!1,uiSchema:{type:"number",title:`{{t("Size", { ns: "${e}" })}}`,"x-component":"InputNumber","x-read-pretty":!0,"x-component-props":{stringMode:!0,step:"0"}}},{interface:"input",type:"string",name:"mimetype",deletable:!1,uiSchema:{type:"string",title:`{{t("MIME type", { ns: "${e}" })}}`,"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"string",name:"path",deletable:!1,uiSchema:{type:"string",title:'{{t("Path")}}',"x-component":"Input","x-read-pretty":!0}},{interface:"input",type:"string",name:"url",deletable:!1,uiSchema:{type:"string",title:'{{t("URL")}}',"x-component":"Input.URL","x-read-pretty":!0}},{interface:"url",type:"string",name:"preview",field:"url",deletable:!1,uiSchema:{type:"string",title:'{{t("Preview")}}',"x-component":"Preview","x-read-pretty":!0}},{comment:"存储引擎",type:"belongsTo",name:"storage",target:"storages",foreignKey:"storageId",deletable:!1},{type:"jsonb",name:"meta",deletable:!1,defaultValue:{}}]},configurableProperties:y(x(y(x({},t.getConfigurableProperties("title","name")),{inherits:y(x({},t.getConfigurableProperties("inherits").inherits),{"x-reactions":["{{useAsyncDataSource(loadCollections)}}"]})}),t.getConfigurableProperties("category","description")),{storage:{title:`{{t("File storage", { ns: "${e}" })}}`,type:"hasOne",name:"storage",required:!0,"x-decorator":"FormItem","x-component":"Select","x-reactions":["{{useAsyncDataSource(loadStorages)}}"]}})},j=Object.freeze(Object.defineProperty({__proto__:null,file:k},Symbol.toStringTag,{value:"Module"}));b.forEach(j,(o,i)=>{t.registerTemplate(i,o)}),t.registerField(F.group,"attachment",F);const E=o=>{const i=u.useContext(t.SchemaInitializerContext);!i.TableActionInitializers.items[0].children.some(m=>m.component==="UploadActionInitializer")&&i.TableActionInitializers.items[0].children.push({type:"item",title:"{{t('Upload')}}",component:"UploadActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},visible:()=>t.useCollection().template==="file"});const l=u.useContext(t.PluginManagerContext);return r.jsx(t.SettingsCenterProvider,{settings:{"file-manager":{title:`{{t("File manager", { ns: "${e}" })}}`,icon:"FileOutlined",tabs:{storages:{title:`{{t("File storage", { ns: "${e}" })}}`,component:z}}}},children:r.jsx(t.PluginManagerContext.Provider,{value:{components:x({},l==null?void 0:l.components)},children:r.jsx(t.CollectionManagerProvider,{interfaces:{attachment:F},children:r.jsx(t.SchemaComponentOptions,{scope:M,children:r.jsx(t.SchemaInitializerProvider,{components:_,children:o.children})})})})})};class C extends t.Plugin{load(){return q(this,null,function*(){this.app.use(E)})}}n.FileManagerPlugin=C,n.default=C,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|