@nocobase/plugin-file-manager 2.1.0-beta.32 → 2.1.0-beta.33
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-v2/450.f590b4c220108742.js +10 -0
- package/dist/client-v2/index.d.ts +1 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +10 -12
- package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
- package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -1
- package/dist/node_modules/ali-oss/package.json +1 -1
- package/dist/node_modules/cos-nodejs-sdk-v5/.github/workflows/auto-changelog.yml +55 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/.prettierrc +10 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/.travis.yml +16 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/LICENSE +21 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/demo/crc64.js +9 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/demo/demo-sts-scope.js +75 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/demo/demo-sts.js +65 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/demo/demo.js +4542 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/demo/util.js +135 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/index.d.ts +2610 -0
- package/dist/node_modules/{multer-cos → cos-nodejs-sdk-v5}/index.js +2 -2
- package/dist/node_modules/cos-nodejs-sdk-v5/package.json +1 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/sdk/advance.js +1659 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/sdk/async.js +59 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/sdk/base.js +4404 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/sdk/cos.js +137 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/sdk/event.js +34 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/sdk/select-stream.js +181 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/sdk/session.js +126 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/sdk/task.js +255 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/sdk/util.js +776 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/test/csp.js +1302 -0
- package/dist/node_modules/cos-nodejs-sdk-v5/test/test.js +6119 -0
- package/dist/node_modules/mime-match/package.json +1 -1
- package/dist/node_modules/mime-types/package.json +1 -1
- package/dist/node_modules/mkdirp/package.json +1 -1
- package/dist/node_modules/url-join/package.json +1 -1
- package/dist/server/storages/tx-cos.d.ts +16 -1
- package/dist/server/storages/tx-cos.js +111 -10
- package/package.json +2 -3
- package/dist/client/StorageOptions.d.ts +0 -10
- package/dist/client-v2/450.24143827c94b9dca.js +0 -10
- package/dist/client-v2/501.37bff0473d880acd.js +0 -10
- package/dist/client-v2/885.b832814bff4497c8.js +0 -10
- package/dist/node_modules/multer-cos/LICENSE +0 -24
- package/dist/node_modules/multer-cos/demo/index.js +0 -39
- package/dist/node_modules/multer-cos/demo/myMulter.js +0 -88
- package/dist/node_modules/multer-cos/package.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mime-match","version":"1.0.2","description":"A simple function to check whether a mimetype matches the specified mimetype (with wildcard support)","main":"index.js","scripts":{"test":"node test.js","gendocs":"gendocs > README.md"},"repository":{"type":"git","url":"https://github.com/DamonOehlman/mime-match.git"},"keywords":["mime","wildcard"],"author":"Damon Oehlman <damon.oehlman@gmail.com>","license":"ISC","bugs":{"url":"https://github.com/DamonOehlman/mime-match/issues"},"homepage":"https://github.com/DamonOehlman/mime-match","dependencies":{"wildcard":"^1.1.0"},"devDependencies":{"tape":"^4.5.1"},"_lastModified":"2026-05-
|
|
1
|
+
{"name":"mime-match","version":"1.0.2","description":"A simple function to check whether a mimetype matches the specified mimetype (with wildcard support)","main":"index.js","scripts":{"test":"node test.js","gendocs":"gendocs > README.md"},"repository":{"type":"git","url":"https://github.com/DamonOehlman/mime-match.git"},"keywords":["mime","wildcard"],"author":"Damon Oehlman <damon.oehlman@gmail.com>","license":"ISC","bugs":{"url":"https://github.com/DamonOehlman/mime-match/issues"},"homepage":"https://github.com/DamonOehlman/mime-match","dependencies":{"wildcard":"^1.1.0"},"devDependencies":{"tape":"^4.5.1"},"_lastModified":"2026-05-15T15:54:17.432Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mime-types","description":"The ultimate javascript content-type utility.","version":"3.0.1","contributors":["Douglas Christopher Wilson <doug@somethingdoug.com>","Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)","Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"],"license":"MIT","keywords":["mime","types"],"repository":"jshttp/mime-types","dependencies":{"mime-db":"^1.54.0"},"devDependencies":{"eslint":"8.33.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.27.5","eslint-plugin-markdown":"3.0.0","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"6.1.1","eslint-plugin-standard":"4.1.0","mocha":"10.2.0","nyc":"15.1.0"},"files":["HISTORY.md","LICENSE","index.js","mimeScore.js"],"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_lastModified":"2026-05-
|
|
1
|
+
{"name":"mime-types","description":"The ultimate javascript content-type utility.","version":"3.0.1","contributors":["Douglas Christopher Wilson <doug@somethingdoug.com>","Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)","Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"],"license":"MIT","keywords":["mime","types"],"repository":"jshttp/mime-types","dependencies":{"mime-db":"^1.54.0"},"devDependencies":{"eslint":"8.33.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.27.5","eslint-plugin-markdown":"3.0.0","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"6.1.1","eslint-plugin-standard":"4.1.0","mocha":"10.2.0","nyc":"15.1.0"},"files":["HISTORY.md","LICENSE","index.js","mimeScore.js"],"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_lastModified":"2026-05-15T15:54:17.723Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"0.5.6","publishConfig":{"tag":"legacy"},"author":"James Halliday <mail@substack.net> (http://substack.net)","main":"index.js","keywords":["mkdir","directory"],"repository":{"type":"git","url":"https://github.com/substack/node-mkdirp.git"},"scripts":{"test":"tap test/*.js"},"dependencies":{"minimist":"^1.2.6"},"devDependencies":{"tap":"^16.0.1"},"bin":"bin/cmd.js","license":"MIT","files":["bin","index.js"],"_lastModified":"2026-05-
|
|
1
|
+
{"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"0.5.6","publishConfig":{"tag":"legacy"},"author":"James Halliday <mail@substack.net> (http://substack.net)","main":"index.js","keywords":["mkdir","directory"],"repository":{"type":"git","url":"https://github.com/substack/node-mkdirp.git"},"scripts":{"test":"tap test/*.js"},"dependencies":{"minimist":"^1.2.6"},"devDependencies":{"tap":"^16.0.1"},"bin":"bin/cmd.js","license":"MIT","files":["bin","index.js"],"_lastModified":"2026-05-15T15:54:21.862Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"url-join","version":"4.0.1","description":"Join urls and normalize as in path.join.","main":"lib/url-join.js","scripts":{"test":"mocha --require should"},"repository":{"type":"git","url":"git://github.com/jfromaniello/url-join.git"},"keywords":["url","join"],"author":"José F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)","license":"MIT","devDependencies":{"conventional-changelog":"^1.1.10","mocha":"^3.2.0","should":"~1.2.1"},"_lastModified":"2026-05-
|
|
1
|
+
{"name":"url-join","version":"4.0.1","description":"Join urls and normalize as in path.join.","main":"lib/url-join.js","scripts":{"test":"mocha --require should"},"repository":{"type":"git","url":"git://github.com/jfromaniello/url-join.git"},"keywords":["url","join"],"author":"José F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)","license":"MIT","devDependencies":{"conventional-changelog":"^1.1.10","mocha":"^3.2.0","should":"~1.2.1"},"_lastModified":"2026-05-15T15:54:17.533Z"}
|
|
@@ -7,6 +7,20 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { AttachmentModel, StorageType } from '.';
|
|
10
|
+
declare class TxCosStorage {
|
|
11
|
+
cos: any;
|
|
12
|
+
getFilename: Function;
|
|
13
|
+
baseUrl: string;
|
|
14
|
+
options: Record<string, any>;
|
|
15
|
+
constructor({ config, baseUrl, filename }: {
|
|
16
|
+
config: any;
|
|
17
|
+
baseUrl: any;
|
|
18
|
+
filename: any;
|
|
19
|
+
});
|
|
20
|
+
getUploadedFileURL(key: string, location?: string): any;
|
|
21
|
+
_handleFile(req: any, file: any, cb: any): any;
|
|
22
|
+
_removeFile(req: any, file: any, cb: any): any;
|
|
23
|
+
}
|
|
10
24
|
export default class extends StorageType {
|
|
11
25
|
static defaults(): {
|
|
12
26
|
title: string;
|
|
@@ -21,6 +35,7 @@ export default class extends StorageType {
|
|
|
21
35
|
};
|
|
22
36
|
};
|
|
23
37
|
static filenameKey: string;
|
|
24
|
-
make():
|
|
38
|
+
make(): TxCosStorage;
|
|
25
39
|
delete(records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
|
|
26
40
|
}
|
|
41
|
+
export {};
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
var __create = Object.create;
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
13
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
16
|
var __export = (target, all) => {
|
|
15
17
|
for (var name in all)
|
|
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
25
|
}
|
|
24
26
|
return to;
|
|
25
27
|
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
26
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
37
|
var tx_cos_exports = {};
|
|
28
38
|
__export(tx_cos_exports, {
|
|
@@ -30,9 +40,103 @@ __export(tx_cos_exports, {
|
|
|
30
40
|
});
|
|
31
41
|
module.exports = __toCommonJS(tx_cos_exports);
|
|
32
42
|
var import_util = require("util");
|
|
43
|
+
var import_stream = require("stream");
|
|
44
|
+
var import_url_join = __toESM(require("url-join"));
|
|
33
45
|
var import__ = require(".");
|
|
34
46
|
var import_constants = require("../../constants");
|
|
35
|
-
var
|
|
47
|
+
var import_utils = require("../utils");
|
|
48
|
+
const ERROR_NO_CLIENT = new Error("cos client undefined");
|
|
49
|
+
class CountingStream extends import_stream.Transform {
|
|
50
|
+
size = 0;
|
|
51
|
+
_transform(chunk, encoding, callback) {
|
|
52
|
+
this.size += chunk.length;
|
|
53
|
+
callback(null, chunk);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
class TxCosStorage {
|
|
57
|
+
cos;
|
|
58
|
+
getFilename;
|
|
59
|
+
baseUrl;
|
|
60
|
+
options;
|
|
61
|
+
constructor({ config, baseUrl, filename }) {
|
|
62
|
+
const COS = require("cos-nodejs-sdk-v5");
|
|
63
|
+
this.cos = new COS({
|
|
64
|
+
SecretId: config.SecretId,
|
|
65
|
+
SecretKey: config.SecretKey,
|
|
66
|
+
SecurityToken: config.SecurityToken,
|
|
67
|
+
XCosSecurityToken: config.XCosSecurityToken,
|
|
68
|
+
FileParallelLimit: config.FileParallelLimit,
|
|
69
|
+
ChunkParallelLimit: config.ChunkParallelLimit,
|
|
70
|
+
ChunkSize: config.ChunkSize,
|
|
71
|
+
Domain: config.Domain,
|
|
72
|
+
Protocol: config.Protocol,
|
|
73
|
+
Timeout: config.Timeout,
|
|
74
|
+
KeepAlive: config.KeepAlive,
|
|
75
|
+
ForcePathStyle: config.ForcePathStyle,
|
|
76
|
+
CompatibilityMode: config.CompatibilityMode,
|
|
77
|
+
UseAccelerate: config.UseAccelerate
|
|
78
|
+
});
|
|
79
|
+
this.getFilename = filename;
|
|
80
|
+
this.baseUrl = baseUrl;
|
|
81
|
+
this.options = config;
|
|
82
|
+
}
|
|
83
|
+
getUploadedFileURL(key, location) {
|
|
84
|
+
if (this.baseUrl) {
|
|
85
|
+
return (0, import_url_join.default)(this.baseUrl, key);
|
|
86
|
+
}
|
|
87
|
+
if (!location) {
|
|
88
|
+
return key;
|
|
89
|
+
}
|
|
90
|
+
if (/^https?:\/\//.test(location)) {
|
|
91
|
+
return location;
|
|
92
|
+
}
|
|
93
|
+
return `https://${location}`;
|
|
94
|
+
}
|
|
95
|
+
_handleFile(req, file, cb) {
|
|
96
|
+
if (!this.cos) {
|
|
97
|
+
return cb(ERROR_NO_CLIENT);
|
|
98
|
+
}
|
|
99
|
+
const getFilename = (0, import_util.promisify)(this.getFilename);
|
|
100
|
+
Promise.resolve().then(async () => {
|
|
101
|
+
const key = await getFilename(req, file);
|
|
102
|
+
const counter = new CountingStream();
|
|
103
|
+
const body = file.stream.pipe(counter);
|
|
104
|
+
const params = {
|
|
105
|
+
Bucket: this.options.Bucket,
|
|
106
|
+
Region: this.options.Region,
|
|
107
|
+
Key: key,
|
|
108
|
+
Body: body
|
|
109
|
+
};
|
|
110
|
+
if (file.mimetype === "text/plain") {
|
|
111
|
+
params.ContentType = "text/plain; charset=utf-8";
|
|
112
|
+
} else if (file.mimetype) {
|
|
113
|
+
params.ContentType = file.mimetype;
|
|
114
|
+
}
|
|
115
|
+
const result = await (0, import_util.promisify)(this.cos.putObject).call(this.cos, params);
|
|
116
|
+
cb(null, {
|
|
117
|
+
key,
|
|
118
|
+
size: counter.size,
|
|
119
|
+
url: this.getUploadedFileURL(key, result == null ? void 0 : result.Location)
|
|
120
|
+
});
|
|
121
|
+
}).catch(cb);
|
|
122
|
+
}
|
|
123
|
+
_removeFile(req, file, cb) {
|
|
124
|
+
if (!this.cos) {
|
|
125
|
+
return cb(ERROR_NO_CLIENT);
|
|
126
|
+
}
|
|
127
|
+
if (!file.key) {
|
|
128
|
+
return cb(null);
|
|
129
|
+
}
|
|
130
|
+
this.cos.deleteObject(
|
|
131
|
+
{
|
|
132
|
+
Bucket: this.options.Bucket,
|
|
133
|
+
Region: this.options.Region,
|
|
134
|
+
Key: file.key
|
|
135
|
+
},
|
|
136
|
+
cb
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
36
140
|
class tx_cos_default extends import__.StorageType {
|
|
37
141
|
static defaults() {
|
|
38
142
|
return {
|
|
@@ -50,13 +154,10 @@ class tx_cos_default extends import__.StorageType {
|
|
|
50
154
|
}
|
|
51
155
|
static filenameKey = "url";
|
|
52
156
|
make() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
dir: (this.storage.path ?? "").replace(/\/+$/, "")
|
|
58
|
-
},
|
|
59
|
-
filename: (0, import_utils2.diskFilenameGetter)(this.storage)
|
|
157
|
+
return new TxCosStorage({
|
|
158
|
+
config: this.storage.options,
|
|
159
|
+
baseUrl: this.storage.baseUrl,
|
|
160
|
+
filename: (0, import_utils.cloudFilenameGetter)(this.storage)
|
|
60
161
|
});
|
|
61
162
|
}
|
|
62
163
|
async delete(records) {
|
|
@@ -64,8 +165,8 @@ class tx_cos_default extends import__.StorageType {
|
|
|
64
165
|
const { Deleted } = await (0, import_util.promisify)(cos.deleteMultipleObject).call(cos, {
|
|
65
166
|
Region: this.storage.options.Region,
|
|
66
167
|
Bucket: this.storage.options.Bucket,
|
|
67
|
-
Objects: records.map((record) => ({ Key: (0,
|
|
168
|
+
Objects: records.map((record) => ({ Key: (0, import_utils.getFileKey)(record) }))
|
|
68
169
|
});
|
|
69
|
-
return [Deleted.length, records.filter((record) => !Deleted.find((item) => item.Key === (0,
|
|
170
|
+
return [Deleted.length, records.filter((record) => !Deleted.find((item) => item.Key === (0, import_utils.getFileKey)(record)))];
|
|
70
171
|
}
|
|
71
172
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-file-manager",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.33",
|
|
4
4
|
"displayName": "File manager",
|
|
5
5
|
"displayName.ru-RU": "Менеджер файлов",
|
|
6
6
|
"displayName.zh-CN": "文件管理器",
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"mime-types": "^3.0.1",
|
|
33
33
|
"mkdirp": "~0.5.4",
|
|
34
34
|
"multer": "^1.4.5-lts.2",
|
|
35
|
-
"multer-cos": "^1.0.3",
|
|
36
35
|
"multer-s3": "^3.0.1",
|
|
37
36
|
"multistream": "^4.1.0",
|
|
38
37
|
"react": "^18.2.0",
|
|
@@ -59,5 +58,5 @@
|
|
|
59
58
|
"Collections",
|
|
60
59
|
"Collection fields"
|
|
61
60
|
],
|
|
62
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "4815c394e80a264fa8ed619246280923c47aeb72"
|
|
63
62
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
export declare const StorageOptions: React.MemoExoticComponent<import("@formily/react").ReactFC<unknown>>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
(self.webpackChunk_nocobase_plugin_file_manager_client_v2=self.webpackChunk_nocobase_plugin_file_manager_client_v2||[]).push([["450"],{484:function(e,t,n){var r=n(986),o=/[\/\+\.]/;e.exports=function(e,t){function n(t){var n=r(t,e,o);return n&&n.length>=2}return t?n(t.split(";")[0]):n}},986:function(e){"use strict";function t(e,t){this.text=e=e||"",this.hasWild=~e.indexOf("*"),this.separator=t,this.parts=e.split(t)}t.prototype.match=function(e){var t,n,r=!0,o=this.parts,i=o.length;if("string"==typeof e||e instanceof String)if(this.hasWild||this.text==e){for(t=0,n=(e||"").split(this.separator);r&&t<i;t++)if("*"===o[t])continue;else r=t<n.length&&o[t]===n[t];r=r&&n}else r=!1;else if("function"==typeof e.splice)for(r=[],t=e.length;t--;)this.match(e[t])&&(r[r.length]=e[t]);else if("object"==typeof e)for(var l in r={},e)this.match(l)&&(r[l]=e[l]);return r},e.exports=function(e,n,r){var o=new t(e,r||/[\/\.]/);return void 0!==n?o.match(n):o}},177:function(e,t,n){"use strict";n.r(t),n.d(t,{UploadActionModel:function(){return z},useBeforeUpload:function(){return A},useStorageCfg:function(){return B},useStorageUploadProps:function(){return _},useStorage:function(){return C},validate:function(){return I}});var r=n(375),o=n(485),i=n(694),l=n(625),a=n(59);let u="bits",c="bytes",s="jedec",p={iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},f={iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]};var d=n(484),b=n.n(d),y=n(155),g=n.n(y),h=n(953);function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,o,i,l){try{var a=e[i](l),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function w(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(e,t,n){return(O="u">typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=x(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n||e):o.value}})(e,t,n||e)}function x(e){return(x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){w(e,t,n[t])})}return e}function k(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,a=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){a=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(a)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return v(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return v(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(P=function(){return!!e})()}var T=function(e){var t,n,r=(0,i.useFlowContext)(),o=(0,y.useMemo)(function(){var t="".concat(e.context.collection.name,":create");if(null==(o=r.view)||null==(n=o.inputArgs)?void 0:n.sourceId){var n,o,i,l=S(e.context.blockModel.association.resourceName.split("."),2),a=l[0],u=l[1];t="".concat(a,"/").concat(null==(i=r.view)?void 0:i.inputArgs.sourceId,"/").concat(u,":create")}return t},[e.context.collection.name,null==(n=r.view)||null==(t=n.inputArgs)?void 0:t.sourceId]),l={},a=0,u={action:o,onChange:function(t){var n=t.fileList;n.forEach(function(t){if("uploading"!==t.status||l[t.uid]||(a++,l[t.uid]=!0),"uploading"!==t.status&&l[t.uid]&&(delete l[t.uid],0==--a)){var n,r;null==(n=(r=e.context.blockModel.resource).refresh)||n.call(r)}}),n.every(function(e){return"done"===e.status})&&r.view.close()}},c=_(u,e);return j({},u,c)};function C(e){var t=null!=e?e:"",n="storages:getBasicInfo/".concat(t),r=(0,i.useFlowContext)(),o=(0,l.useRequest)(function(){var e;return(e=function(){var e;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:u(0)}),a(l,"throw",{value:u(1)}),a(l,"return",{value:u(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function u(a){return function(u){var c=[a,u];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:return[4,r.api.request({url:n,skipNotify:!0})];case 1:return[2,null==(e=t.sent())?void 0:e.data]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){m(i,r,o,l,a,"next",e)}function a(e){m(i,r,o,l,a,"throw",e)}l(void 0)})})()},{manual:!0,refreshDeps:[t],cacheKey:n}),a=o.loading,u=o.data,c=o.run;return(0,y.useEffect)(function(){c()},[c]),!a&&(null==u?void 0:u.data)||null}function B(e){var t,n=(0,i.useFlowContext)(),r=n.collectionField,o=null==(t=n.collectionField)?void 0:t.targetCollection,l=n.app.pm.get("@nocobase/plugin-file-manager"),a=e.context.blockModel.collection,u=C((null==r?void 0:r.storage)||a.storage||o.storage),c=l.getStorageType(null==u?void 0:u.type);return{storage:u,storageType:c}}function _(e,t){var n=B(t),r=n.storage,o=n.storageType,i=null==o?void 0:o.useUploadProps,l=(null==i?void 0:i(j({storage:r,rules:r.rules},e)))||{};return j({rules:null==r?void 0:r.rules},l)}var M={size:function(e,t){var n=null!=t?t:0x1400000;return 0===n||e.size<=n?null:"File size exceeds the limit"},mimetype:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*",n=t.toString().trim();return n&&"*"!==n?n.split(",").filter(Boolean).some(b()(e.type))?null:"File type is not allowed":null}};function I(e,t){if(!t)return null;var n=Object.keys(t);if(!n.length)return null;var r=!0,o=!1,i=void 0;try{for(var l,a=n[Symbol.iterator]();!(r=(l=a.next()).done);r=!0){var u=l.value,c=M[u](e,t[u]);if(c)return c}}catch(e){o=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return null}function A(e){var t=(0,h.useTranslation)().t;return(0,y.useCallback)(function(n,r){var o=I(n,e);return o?(n.status="error",n.response=t(o)):"error"===n.status&&(delete n.status,delete n.response),!o&&Promise.resolve(n)},[e])}function U(e){var t,n,o,l,d,b,v=e.model,m=(0,i.useFlowContext)(),w=T(v),O=w.rules,x=null!=O?O:{},E=x.size;x.mimetype;var P=(t=null!=E?E:0x1400000,o=(n=(0,h.useTranslation)()).t,l=function(e,{bits:t=!1,pad:n=!1,base:r=-1,round:o=2,locale:i="",localeOptions:l={},separator:a="",spacer:d=" ",symbols:b={},standard:y="",output:g="string",fullform:h=!1,fullforms:v=[],exponent:m=-1,roundingMethod:w="round",precision:O=0}={}){let x=m,j=Number(e),k=[],E=0,S="";"si"===y?(r=10,y=s):"iec"===y||y===s?r=2:2===r?y="iec":(r=10,y=s);let P=10===r?1e3:1024,T=j<0,C=Math[w];if("bigint"!=typeof e&&isNaN(e))throw TypeError("Invalid number");if("function"!=typeof C)throw TypeError("Invalid rounding method");if(T&&(j=-j),(-1===x||isNaN(x))&&(x=Math.floor(Math.log(j)/Math.log(P)))<0&&(x=0),x>8&&(O>0&&(O+=8-x),x=8),"exponent"===g)return x;if(0===j)k[0]=0,S=k[1]=p[y][t?u:c][x];else{E=j/(2===r?Math.pow(2,10*x):Math.pow(1e3,x)),t&&(E*=8)>=P&&x<8&&(E/=P,x++);let e=Math.pow(10,x>0?o:0);k[0]=C(E*e)/e,k[0]===P&&x<8&&-1===m&&(k[0]=1,x++),S=k[1]=10===r&&1===x?t?"kbit":"kB":p[y][t?u:c][x]}if(T&&(k[0]=-k[0]),O>0&&(k[0]=k[0].toPrecision(O)),k[1]=b[k[1]]||k[1],!0===i?k[0]=k[0].toLocaleString():i.length>0?k[0]=k[0].toLocaleString(i,l):a.length>0&&(k[0]=k[0].toString().replace(".",a)),n&&o>0){let e=k[0].toString(),t=a||(e.match(/(\D)/g)||[]).pop()||".",n=e.toString().split(t),r=n[1]||"",i=r.length;k[0]=`${n[0]}${t}${r.padEnd(i+(o-i),"0")}`}return!0===h&&(k[1]=v[x]?v[x]:f[y][x]+(t?"bit":"byte")+(1===k[0]?"":"s")),"array"===g?k:"object"===g?{value:k[0],symbol:k[1],exponent:x,unit:S}:k.join(d)}(t,{base:2,standard:"jedec",locale:n.i18n.language}),0!==t?o("File size should not exceed {{size}}.",{size:l}):""),C=S((0,y.useState)(!1),2),B=C[0],_=C[1],M=(0,y.useCallback)(function(e){e.fileList.some(function(e){return"uploading"===e.status})?_(!0):_(!1)},[]),I=m.view.Header,U=A(O);return g().createElement("div",null,g().createElement(I,{title:m.t("Upload file")}),g().createElement("div",{style:{height:"50vh"},onClick:function(e){return e.stopPropagation()}},g().createElement(a.Upload.Dragger,j({multiple:!0,listType:"picture"},(d=k(j({},w),{handleChange:M,beforeUpload:U}),b=(0,i.useFlowContext)(),j({customRequest:function(e){var t=e.action,n=e.data,r=e.file,o=e.filename,i=e.headers,l=e.onError,a=e.onProgress,u=e.onSuccess,c=e.withCredentials,s=new FormData;return n&&Object.keys(n).forEach(function(e){s.append(e,n[e])}),s.append(o,r),b.api.axios.post(t,s,{withCredentials:c,headers:i,onUploadProgress:function(e){var t=e.total;a({percent:Math.round(e.loaded/t*100).toFixed(2)},r)}}).then(function(e){u(e.data,r)}).catch(l).finally(function(){}),{abort:function(){console.log("upload progress is aborted.")}}}},d))),g().createElement("p",{className:"ant-upload-drag-icon"},B?g().createElement(r.LoadingOutlined,{style:{fontSize:36},spin:!0}):g().createElement(r.InboxOutlined,null)),g().createElement("p",{className:"ant-upload-text"},m.t("Click or drag file to this area to upload")),g().createElement("ul",{style:{listStyleType:"none"}},g().createElement("li",{className:"ant-upload-hint"},m.t("Support for a single or bulk upload.")),g().createElement("li",{className:"ant-upload-hint"},P)))))}var z=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=x(t),w(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,P()?Reflect.construct(t,r||[],x(this).constructor):t.apply(this,r)),"defaultProps",{type:"primary",title:(0,i.escapeT)("Upload"),icon:"UploadOutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&E(n,e),t=[{key:"getAclActionName",value:function(){return"create"}},{key:"onInit",value:function(e){var t=this;O(x(n.prototype),"onInit",this).call(this,e),this.onUploadClick=function(e){t.dispatchEvent("openView",{event:e})}}},{key:"onUploadClick",set:function(e){this.setProps({onUploadClick:e})}},{key:"render",value:function(){var e=this.props,t=e.icon?g().createElement(o.Icon,{type:e.icon}):void 0;return g().createElement(a.Button,k(j({},e),{onClick:this.props.onUploadClick,icon:t}),e.children||e.title)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(o.ActionModel);w(z,"scene",o.ActionSceneEnum.collection),z.define({label:(0,i.escapeT)("Upload"),hide:function(e){var t;return(null==(t=e.collection)?void 0:t.template)!=="file"}}),z.registerFlow({key:"selectExitRecordSettings",title:(0,i.escapeT)("Selector setting"),on:{eventName:"openView"},steps:{openView:{title:(0,i.escapeT)("Edit popup"),uiSchema:function(e){return{mode:{type:"string",title:(0,i.escapeT)("Open mode"),enum:[{label:(0,i.escapeT)("Drawer"),value:"drawer"},{label:(0,i.escapeT)("Dialog"),value:"dialog"}],"x-decorator":"FormItem","x-component":"Radio.Group"},size:{type:"string",title:(0,i.escapeT)("Popup size"),enum:[{label:(0,i.escapeT)("Small"),value:"small"},{label:(0,i.escapeT)("Medium"),value:"medium"},{label:(0,i.escapeT)("Large"),value:"large"}],"x-decorator":"FormItem","x-component":"Radio.Group"}}},defaultParams:{mode:"drawer",size:"medium"},handler:function(e,t){var n,r=e.inputArgs.mode||t.mode||"drawer",o=e.inputArgs.size||t.size||"medium";e.viewer.open({type:r,width:{drawer:{small:"30%",medium:"50%",large:"70%"},dialog:{small:"40%",medium:"50%",large:"80%"},embed:{}}[r][o],inheritContext:!1,target:e.layoutContentElement,inputArgs:{sourceId:null==(n=e.resource)?void 0:n.getSourceId()},content:function(){return g().createElement(U,{model:e.model})},styles:{content:j({padding:0,backgroundColor:e.model.flowEngine.context.themeToken.colorBgLayout},"embed"===r?{position:"absolute",top:0,left:0,right:0,bottom:0}:{})}})}}}})}}]);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_file_manager_client_v2=self.webpackChunk_nocobase_plugin_file_manager_client_v2||[]).push([["501"],{76:function(e,t,n){n.r(t),n.d(t,{UploadFieldModel:function(){return M},CardUpload:function(){return I}});var r=n(375),o=n(477),l=n(59),i=n(773),a=n(953),u=n(694),c=n(155),s=n.n(c),p=n(230),d=n(485),f=n(348);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var y=function(e,t){var n,r,o,l,i=null==e?void 0:e.response,a=null!=(n=null==e?void 0:e.id)?n:null==i?void 0:i.id,u=null!=(r=null==e?void 0:e.url)?r:null==i?void 0:i.url,c=null!=(o=null==e?void 0:e.filename)?o:null==i?void 0:i.filename,s=null!=(l=null==e?void 0:e.name)?l:null==i?void 0:i.name;return null!=a?"id:".concat(String(a)):null!=u?"url:".concat(u):null!=c?"filename:".concat(c,":").concat(t):null!=s?"name:".concat(s,":").concat(t):(null==e?void 0:e.uid)?"uid:".concat(e.uid):"index:".concat(t)},v=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=new Map(t.map(function(e,t){return[y(e,t),e.uid]}).filter(function(e){return!!(function(e){if(Array.isArray(e))return e}(e)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],l=!0,i=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(i)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return m(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return m(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[1]}));return e.map(function(e,t){var r,o,l,i=y(e,t);return r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),o=o={uid:e.uid||n.get(i)||i,thumbUrl:null!=(l=e.thumbUrl)?l:(0,f.qk)(e)},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r})},b=function(e,t){var n=e.findIndex(function(e){return e.uid===(null==t?void 0:t.uid)});return n>=0?n:0};function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t,n,r,o,l,i){try{var a=e[l](i),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function w(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function i(e){h(l,r,o,i,a,"next",e)}function a(e){h(l,r,o,i,a,"throw",e)}i(void 0)})}}function O(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function S(e,t,n){return(S="u">typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=E(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n||e):o.value}})(e,t,n||e)}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){O(e,t,n[t])})}return e}function P(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function j(e,t){return(j=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],i=!0,a=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw r}}return l}}(e,t)||F(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||F(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}}function C(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(C=function(){return!!e})()}function A(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(i,"next",{value:u(0)}),a(i,"throw",{value:u(1)}),a(i,"return",{value:u(2)}),"function"==typeof Symbol&&a(i,Symbol.iterator,{value:function(){return this}}),i;function u(a){return function(u){var c=[a,u];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function U(){var e,t,n=(e=["\n .ant-upload-list-picture-card {\n margin-bottom: 10px;\n .ant-upload-list-item-container {\n margin: ",";\n }\n }\n .ant-upload-select {\n margin: ",";\n }\n ","\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return U=function(){return n},n}var I=function(e){var t,n=e.allowSelectExistingRecord,u=e.multiple,d=e.value,m=e.disabled,y=e.onSelectExitRecordClick,g=e.quickUpload,h=e.showFileName,O=k((0,c.useState)(function(){return v((0,i.castArray)(d||[]))}),2),S=O[0],E=O[1],j=k((0,c.useState)(!1),2),R=j[0],F=j[1],C=k((0,c.useState)(null),2),I=C[0],M=C[1],T=k((0,c.useState)(0),2),_=T[0],D=T[1],q=(0,a.useTranslation)().t;(0,c.useLayoutEffect)(function(){E(function(e){return v((0,i.castArray)(d||[]),e)})},[d]);var N=(t=S.length,!!u||0===t);return s().createElement(p.FieldContext.Provider,{value:{value:S}},s().createElement("div",{style:{display:"flex"},className:(0,o.css)(U(),h?"8px 0px":"0px",h?"8px 0px":"0px",u?"":"\n .ant-upload-list-item-container.ant-upload-animate-inline-appear,\n .ant-upload-list-item-container.ant-upload-animate-inline-appear-active,\n .ant-upload-list-item-container.ant-upload-animate-inline-enter,\n .ant-upload-list-item-container.ant-upload-animate-inline-enter-active {\n animation: none !important;\n transition: none !important;\n transform: none !important;\n opacity: 1 !important;\n }\n\n .ant-upload.ant-upload-animate-inline-leave,\n .ant-upload.ant-upload-animate-inline-leave-active {\n animation: none !important;\n transition: none !important;\n }\n ")},s().createElement(l.Upload,P(x({onPreview:function(e){return w(function(){var t;return A(this,function(n){switch(n.label){case 0:var r;if(t=b(S,e),!(!e.url&&!e.preview))return[3,2];return[4,(r=e.originFileObj,new Promise(function(e,t){var n=new FileReader;n.readAsDataURL(r),n.onload=function(){return e(n.result)},n.onerror=function(e){return t(e)}}))];case 1:e.preview=n.sent(),n.label=2;case 2:return M(e),D(t),F(!0),[2]}})})()}},e),{listType:"picture-card",fileList:S,onChange:function(t){var n=t.fileList;E(function(e){return v(n,e)});var r=n.filter(function(e){return"done"===e.status||e.id});if(n.every(function(e){return"done"===e.status||e.id}))if(1===e.maxCount){var o=r[0];e.onChange(o?o.response:null)}else e.onChange(r.map(function(e){return e.response||e}).filter(Boolean))},itemRender:function(e,t){return s().createElement(s().Fragment,null,e,h&&s().createElement("div",{style:{fontSize:12,whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden"},title:t.filename},t.filename))}}),(void 0===g||g)&&N?s().createElement(r.UploadOutlined,{style:{fontSize:20}}):null),I&&s().createElement(f.Mo,{open:R,file:I,list:S,index:_,onOpenChange:F,onClose:function(){return M(null)},onSwitchIndex:function(e){e<0||e>=S.length||(D(e),M(S[e]))},onDownload:function(e){var t=e||I;if(t){var n=t.url||t.preview;if(n){var r=(0,f.ub)(t,n);fetch(n).then(function(e){return e.blob()}).then(function(e){var t=URL.createObjectURL(new Blob([e])),n=document.createElement("a");n.href=t,n.download=r,document.body.appendChild(n),n.click(),URL.revokeObjectURL(t),n.remove()})}}}}),n&&N?s().createElement("div",{style:{marginLeft:5}},s().createElement(l.Upload,{disabled:m,multiple:u,listType:"picture-card",showUploadList:!1},s().createElement("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},onClick:function(e){m||(e.stopPropagation(),e.preventDefault(),y())}},s().createElement(r.PlusOutlined,null),q("Select")))):null))},M=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=E(t),O(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,C()?Reflect.construct(t,r||[],E(this).constructor):t.apply(this,r)),"selectedRows",u.observable.ref([])),O(e,"_closeView",void 0),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&j(n,e),t=[{key:"customRequest",set:function(e){this.setProps({customRequest:e})}},{key:"onInit",value:function(e){var t=this;S(E(n.prototype),"onInit",this).call(this,e),this.onSelectExitRecordClick=function(e){t.dispatchEvent("openView",{event:e})}}},{key:"onSelectExitRecordClick",set:function(e){this.setProps({onSelectExitRecordClick:e})}},{key:"change",value:function(){this.props.onChange(this.selectedRows.value)}},{key:"render",value:function(){return s().createElement(I,this.props)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(d.FieldModel);(M=function(e,t,n,r){var o,l=arguments.length,i=l<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(l<3?o(i):l>3?o(t,n,i):o(t,n))||i);return l>3&&i&&Object.defineProperty(t,n,i),i}([(0,u.largeField)()],M)).registerFlow({key:"uploadSettings",title:(0,u.tExpr)("Upload file settings"),steps:{quickUpload:{title:(0,u.tExpr)("Quick upload"),uiMode:{type:"switch",key:"quickUpload"},hideInSettings:function(e){return!e.collectionField.isAssociationField()||!e.collectionField.targetCollection},defaultParams:function(e){return{quickUpload:!0}},handler:function(e,t){e.model.setProps({quickUpload:t.quickUpload})}},allowMultiple:{title:(0,u.tExpr)("Allow multiple"),uiMode:{type:"switch",key:"multiple"},hideInSettings:function(e){return!e.collectionField||!["belongsToMany","hasMany","belongsToArray"].includes(e.collectionField.type)},defaultParams:function(e){return{multiple:e.collectionField&&["belongsToMany","hasMany","belongsToArray"].includes(e.model.context.collectionField.type)}},handler:function(e,t){e.model.setProps({multiple:null==t?void 0:t.multiple,maxCount:(null==t?void 0:t.multiple)?null:1})}},showFileName:{title:(0,u.tExpr)("Show file name"),uiMode:{type:"switch",key:"showFileName"},defaultParams:{showFileName:!1},handler:function(e,t){e.model.setProps("showFileName",t.showFileName)}},allowSelectExistingRecord:{title:(0,u.tExpr)("Allow selection of existing file"),uiMode:{type:"switch",key:"allowSelectExistingRecord"},hideInSettings:function(e){return!e.collectionField.isAssociationField()||!e.collectionField.targetCollection},defaultParams:function(e){return{allowSelectExistingRecord:e.collectionField.targetCollection&&e.collectionField.isAssociationField()}},handler:function(e,t){e.model.setProps({allowSelectExistingRecord:t.allowSelectExistingRecord})}}}}),M.registerFlow({key:"eventSettings",sort:300,steps:{bindEvent:{handler:function(e,t){e.model.customRequest=function(t){e.model.dispatchEvent("customRequest",{apiClient:e.app.apiClient,fileData:t})}}}}}),M.registerFlow({key:"customRequestSettings",on:"customRequest",steps:{step1:{handler:function(e,t){return w(function(){var t,n,r,o,l,i,a,u,c,s,p,d,f,m,y,v,b,g,h,w,O,S,E,j,k,R,F,C;return A(this,function(A){switch(A.label){case 0:if(n=(t=e.inputArgs.fileData).file,r=t.onSuccess,o=t.onError,l=t.onProgress,i=e.app.pm.get("@nocobase/plugin-file-manager"),a=e.model.props.target,u=e.collectionField,!i)return[2,r(n)];A.label=1;case 1:return A.trys.push([1,6,,7]),[4,e.api.resource("storages").check({fileCollectionName:a,storageName:u.options.storage})];case 2:if(!(null==(h=A.sent().data)||null==(c=h.data)?void 0:c.isSupportToUploadFiles))return O=e.t('The current storage "{{storageName}}" does not support file uploads.',{storageName:null==(w=h.data.storage)?void 0:w.title}).replaceAll(">",">"),null==o||o(Error(O)),[2];if(S=i.getStorageType(null==h||null==(p=h.data)||null==(s=p.storage)?void 0:s.type)||{},E=null==h||null==(d=h.data)?void 0:d.storage,!S.createUploadCustomRequest||"function"!=typeof(j=S.createUploadCustomRequest(P(x({},e.model.props),{api:e.api,action:"".concat(a,":create?attachmentField=").concat(u.collectionName,".").concat(u.name),storage:E}))))return[3,4];return[4,j({file:n,onProgress:l,onSuccess:r,onError:o})];case 3:return A.sent(),[2];case 4:return[4,i.uploadFile({file:n,fileCollectionName:a,storageId:null==h||null==(m=h.data)||null==(f=m.storage)?void 0:f.id,storageType:null==h||null==(v=h.data)||null==(y=v.storage)?void 0:y.type,storageRules:null==h||null==(g=h.data)||null==(b=g.storage)?void 0:b.rules,onProgress:function(e){null==l||l({percent:e})},query:{attachmentField:"".concat(u.collectionName,".").concat(u.name)}})];case 5:if(R=(k=A.sent()).data,F=k.errorMessage)return null==o||o(Error(F)),[2];if(!R)return null==o||o(Error("上传成功但响应数据为空")),[2];return r(R),[3,7];case 6:return C=A.sent(),null==o||o(C),[3,7];case 7:return[2]}})})()}}}}),M.registerFlow({key:"selectExitRecordSettings",title:(0,u.tExpr)("Selector setting"),on:{eventName:"openView"},steps:{openView:{title:(0,u.tExpr)("Edit popup"),hideInSettings:function(e){var t,n,r;return!1===(null==(n=(r=e.model).getStepParams)||null==(t=n.call(r,"uploadSettings","allowSelectExistingRecord"))?void 0:t.allowSelectExistingRecord)},uiSchema:function(e){return{mode:{type:"string",title:(0,u.tExpr)("Open mode"),enum:[{label:(0,u.tExpr)("Drawer"),value:"drawer"},{label:(0,u.tExpr)("Dialog"),value:"dialog"}],"x-decorator":"FormItem","x-component":"Radio.Group"},size:{type:"string",title:(0,u.tExpr)("Popup size"),enum:[{label:(0,u.tExpr)("Small"),value:"small"},{label:(0,u.tExpr)("Medium"),value:"medium"},{label:(0,u.tExpr)("Large"),value:"large"}],"x-decorator":"FormItem","x-component":"Radio.Group"}}},defaultParams:{mode:"drawer",size:"medium"},handler:function(e,t){var n,r,o,l,i,a=["belongsTo","hasOne"].includes(e.collectionField.type),u=e.isMobileLayout?"embed":e.inputArgs.mode||t.mode||"drawer",c=e.inputArgs.size||t.size||"medium",p=(null==(n=e.model.props)?void 0:n.sourceFieldModelUid)||e.model.uid,f=(null==(r=e.model.parent)?void 0:r.use)==="QuickEditFormModel"?null==(o=e.model.parent)?void 0:o.viewContainer:null;null==f||null==(l=f.update)||l.call(f,{preventClose:!0}),e.viewer.open({type:u,width:{drawer:{small:"30%",medium:"50%",large:"70%"},dialog:{small:"40%",medium:"50%",large:"80%"},embed:{}}[u][c],inheritContext:!1,target:e.layoutContentElement,onClose:function(){setTimeout(function(){var e;null==f||null==(e=f.update)||e.call(f,{preventClose:!1})},0)},inputArgs:{parentId:p,scene:"select",dataSourceKey:e.collection.dataSourceKey,collectionName:null==(i=e.collectionField)?void 0:i.target,collectionField:e.collectionField,rowSelectionProps:{type:a?"radio":"checkbox",defaultSelectedRows:function(){return e.model.props.value},renderCell:void 0,selectedRowKeys:void 0,onChange:function(t,n){if(a){var r,o;e.model.selectedRows.value=null==n?void 0:n[0],e.model.change(),null==(r=(o=e.model)._closeView)||r.call(o)}else{var l=R(e.model.props.value||[]).concat(R(n)).filter(function(t,n,r){return n===r.findIndex(function(n){return n[e.collection.filterTargetKey]===t[e.collection.filterTargetKey]})});e.model.selectedRows.value=l}}}},content:function(){return s().createElement(d.RecordPickerContent,{model:e.model})},styles:{content:x({padding:0,backgroundColor:e.model.flowEngine.context.themeToken.colorBgLayout},"embed"===u?{position:"absolute",top:0,left:0,right:0,bottom:0}:{}),body:{padding:0}}})}}}}),M.define({label:(0,u.tExpr)("File picker")}),u.EditableItemModel.bindModelToInterface("UploadFieldModel",["attachment","m2m","m2o","o2o","o2m","oho","obo","updatedBy","createdBy","mbm"],{isDefault:!0,order:30,when:function(e,t){return!t.targetCollection||"file"===t.targetCollection.template}})}}]);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
(self.webpackChunk_nocobase_plugin_file_manager_client_v2=self.webpackChunk_nocobase_plugin_file_manager_client_v2||[]).push([["885"],{484:function(e,n,t){var o=t(986),r=/[\/\+\.]/;e.exports=function(e,n){function t(n){var t=o(n,e,r);return t&&t.length>=2}return n?t(n.split(";")[0]):t}},986:function(e){"use strict";function n(e,n){this.text=e=e||"",this.hasWild=~e.indexOf("*"),this.separator=n,this.parts=e.split(n)}n.prototype.match=function(e){var n,t,o=!0,r=this.parts,i=r.length;if("string"==typeof e||e instanceof String)if(this.hasWild||this.text==e){for(n=0,t=(e||"").split(this.separator);o&&n<i;n++)if("*"===r[n])continue;else o=n<t.length&&r[n]===t[n];o=o&&t}else o=!1;else if("function"==typeof e.splice)for(o=[],n=e.length;n--;)this.match(e[n])&&(o[o.length]=e[n]);else if("object"==typeof e)for(var l in o={},e)this.match(l)&&(o[l]=e[l]);return o},e.exports=function(e,t,o){var r=new n(e,o||/[\/\.]/);return void 0!==t?r.match(t):r}},348:function(e,n,t){"use strict";t.d(n,{Mo:function(){return T},WP:function(){return C},_H:function(){return s},_Y:function(){return S},q:function(){return m},qk:function(){return _},ub:function(){return P}});var o=t(155),r=t.n(o),i=t(375),l=t(59),a=t(484),c=t.n(a),u=t(953),p=t(301);function f(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var d=new(function(){var e;function n(){if(!(this instanceof n))throw TypeError("Cannot call a class as a function");f(this,"types",[])}return e=[{key:"add",value:function(e){this.types.unshift(e)}},{key:"getTypeByFile",value:function(e){var n=s(e);return this.types.find(function(e){return e.match(n)})}}],function(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,e),n}());function s(e){return e&&"string"==typeof e?{url:e}:e}function m(e){return e?"string"==typeof e?e:e.preview||e.url||"":""}function v(e){return e?"string"==typeof e?e:e.url||e.preview||"":""}var g={pdf:"/file-placeholder/pdf-200-200.png",mp4:"/file-placeholder/video-200-200.png",mov:"/file-placeholder/video-200-200.png",avi:"/file-placeholder/video-200-200.png",wmv:"/file-placeholder/video-200-200.png",flv:"/file-placeholder/video-200-200.png",mkv:"/file-placeholder/video-200-200.png",mp3:"/file-placeholder/audio-200-200.png",wav:"/file-placeholder/audio-200-200.png",aac:"/file-placeholder/audio-200-200.png",ogg:"/file-placeholder/audio-200-200.png",doc:"/file-placeholder/docx-200-200.png",docx:"/file-placeholder/docx-200-200.png",odt:"/file-placeholder/docx-200-200.png",xls:"/file-placeholder/xlsx-200-200.png",xlsx:"/file-placeholder/xlsx-200-200.png",csv:"/file-placeholder/xlsx-200-200.png",ppt:"/file-placeholder/pptx-200-200.png",pptx:"/file-placeholder/pptx-200-200.png",jpg:"/file-placeholder/jpeg-200-200.png",jpeg:"/file-placeholder/jpeg-200-200.png",png:"/file-placeholder/png-200-200.png",gif:"/file-placeholder/gif-200-200.png",webp:"/file-placeholder/png-200-200.png",bmp:"/file-placeholder/png-200-200.png",svg:"/file-placeholder/svg-200-200.png",default:"/file-placeholder/unknown-200-200.png"},h=new Set(["application/xhtml+xml","image/svg+xml","text/html"]),y=new Set(["htm","html","svg","svgz","xhtml"]),w=function(e){return e.split("?")[0].split("#")[0]},b=function(e){if(!e)return"";var n=w(e),t=n.lastIndexOf(".");return -1!==t?n.slice(t+1).toLowerCase():""},x={aac:"audio/aac",avi:"video/x-msvideo",bmp:"image/bmp",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",flv:"video/x-flv",gif:"image/gif",jpeg:"image/jpeg",jpg:"image/jpeg",json:"application/json",mkv:"video/x-matroska",mov:"video/quicktime",mp3:"audio/mpeg",mp4:"video/mp4",odt:"application/vnd.oasis.opendocument.text",ogg:"audio/ogg",pdf:"application/pdf",png:"image/png",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",svg:"image/svg+xml",txt:"text/plain",wav:"audio/wav",webp:"image/webp",wmv:"video/x-ms-wmv",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};function O(e,n){return!!e&&(e.originFileObj?c()(e.type,n):e.mimetype?c()(e.mimetype,n):!!e.url&&c()(x[b(e.url)]||"",n))}var E=function(e){if(!e)return"";var n=w(e),t=n.lastIndexOf("/");return -1!==t?n.slice(t+1):n},j=function(e,n){if(e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"){if(e.extname)return String(e.extname).replace(/^\./,"").toLowerCase();var t=b(e.name||e.filename||e.title);if(t)return t}return b(n)},k=function(e,n){var t=(null==e?void 0:e.mimetype)||(null==e?void 0:e.type);if("string"==typeof t&&h.has(t.toLowerCase()))return!0;var o=j(e,n);return y.has(o)},C=function(e,n){var t=E(n);return e&&"string"!=typeof e&&(e.name||e.filename||e.title)||t},P=function(e,n){var t=n||v(e),o=C(e,t),r=j(e,t);return o&&r&&!o.toLowerCase().endsWith(".".concat(r))&&(o="".concat(o,".").concat(r)),"".concat(Date.now(),"_").concat(o||"file")},S=function(e,n){return g[j(e,n)]||g.default},_=function(e){var n,t=s(e),o=m(t);if(k(t,o))return S(t,o);var r=(null!=(n=d.getTypeByFile(t))?n:{}).getThumbnailURL,i=null==r?void 0:r(t);return i||(O(t,"image/*")?"":S(t,o))},D=function(e){var n=e.index,t=e.list,o=e.onSwitchIndex,a=e.onDownload,c=e.file,u="number"==typeof n&&!!o&&n>0,p="number"==typeof n&&!!o&&n<t.length-1;return r().createElement(l.Space,{size:14,style:{fontSize:"20px"}},r().createElement(i.LeftOutlined,{style:{cursor:u?"pointer":"not-allowed"},disabled:!u,onClick:function(){return u&&(null==o?void 0:o(n-1))}}),r().createElement(i.RightOutlined,{style:{cursor:p?"pointer":"not-allowed"},disabled:!p,onClick:function(){return p&&(null==o?void 0:o(n+1))}}),r().createElement(i.DownloadOutlined,{onClick:function(){return a(c)}}))},R=function(e){return function(n){var t=n.open,o=n.onOpenChange,i=n.onClose,a=n.file;if("boolean"!=typeof t)return r().createElement(e,n);var c=C(a,v(a));return r().createElement(l.Modal,{open:t,title:c,onCancel:function(){null==o||o(!1),null==i||i()},footer:D(n),width:"90vw",centered:!0},r().createElement("div",{style:{maxWidth:"100%",maxHeight:"calc(100vh - 256px)",height:"80vh",width:"100%",background:"white",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",overflowY:"auto"}},r().createElement(e,n)))}},L=function(e){(0,u.useTranslation)().t;var n=e.file;return r().createElement(l.Alert,{type:"warning",description:r().createElement(u.Trans,{ns:p.C},"File type is not supported for previewing, please ",e.onDownload?r().createElement("a",{onClick:function(){var t;return null==(t=e.onDownload)?void 0:t.call(e,n)},style:{textDecoration:"underline",cursor:"pointer"}},"download it to preview"):r().createElement("span",null,"download it to preview")),showIcon:!0})};d.add({match:function(){return!0},Previewer:R(L)}),d.add({match:function(e){return O(e,"image/*")},getThumbnailURL:function(e){return m(e)},Previewer:function(e){var n=e.file,t=e.list,o=e.index,a=e.open,c=e.onOpenChange,u=e.onSwitchIndex,p=e.onClose,f=e.onDownload;if("boolean"!=typeof a)return null;var d=v(n);if(!d)return null;var s="number"==typeof o&&o>0,m="number"==typeof o&&o<t.length-1;return r().createElement(l.Image,{wrapperStyle:{display:"none"},preview:{visible:a,onVisibleChange:function(e){return null==c?void 0:c(e)},afterOpenChange:function(e){e||null==p||p()},toolbarRender:function(e,t){var a=t.transform.scale,c=t.actions,p=c.onFlipY,d=c.onFlipX,v=c.onRotateLeft,g=c.onRotateRight,h=c.onZoomOut,y=c.onZoomIn,w=c.onReset;return r().createElement(l.Space,{size:14,className:"toolbar-wrapper",style:{fontSize:"20px"}},r().createElement(i.LeftOutlined,{style:{cursor:s?"pointer":"not-allowed"},disabled:!s,onClick:function(){return s&&(null==u?void 0:u(o-1))}}),r().createElement(i.RightOutlined,{style:{cursor:m?"pointer":"not-allowed"},disabled:!m,onClick:function(){return m&&(null==u?void 0:u(o+1))}}),f?r().createElement(i.DownloadOutlined,{onClick:function(){return f(n)}}):null,r().createElement(i.SwapOutlined,{rotate:90,onClick:p}),r().createElement(i.SwapOutlined,{onClick:d}),r().createElement(i.RotateLeftOutlined,{onClick:v}),r().createElement(i.RotateRightOutlined,{onClick:g}),r().createElement(i.ZoomOutOutlined,{disabled:1===a,onClick:h}),r().createElement(i.ZoomInOutlined,{disabled:50===a,onClick:y}),r().createElement(i.UndoOutlined,{onClick:w}))}},src:d})}}),d.add({match:function(e){return["text/plain","application/pdf","application/json"].some(function(n){return O(e,n)})},Previewer:R(function(e){var n=v(e.file);return n?r().createElement("iframe",{src:n,width:"100%",height:"100%",style:{border:"none"}}):null})}),d.add({match:function(e){return O(e,"audio/*")},Previewer:R(function(e){var n=e.file,t=(0,u.useTranslation)().t,o=v(n);return o?r().createElement("audio",{controls:!0},r().createElement("source",{src:o,type:(null==n?void 0:n.type)||(null==n?void 0:n.mimetype)}),t("Your browser does not support the audio tag.")):null})}),d.add({match:function(e){return O(e,"video/*")},Previewer:R(function(e){var n=e.file,t=(0,u.useTranslation)().t,o=v(n);return o?r().createElement("video",{controls:!0,width:"100%",height:"100%"},r().createElement("source",{src:o,type:(null==n?void 0:n.type)||(null==n?void 0:n.mimetype)}),t("Your browser does not support the video tag.")):null})}),d.add({match:function(e){return k(e,v(e))},Previewer:R(L)});var T=function(e){var n,t,o,i=s(e.file);if(!i)return null;var l=(null!=(o=d.getTypeByFile(i))?o:{}).Previewer;return l?r().createElement(l,(n=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.forEach(function(n){f(e,n,t[n])})}return e}({},e),t=t={file:i},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):(function(e){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n.push.apply(n,t)}return n})(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))}),n)):null}}}]);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
(The MIT License)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2009-2014 TJ Holowaychuk <tj@vision-media.ca>
|
|
4
|
-
Copyright (c) 2013-2014 Roman Shtylman <shtylman+expressjs@gmail.com>
|
|
5
|
-
Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
8
|
-
a copy of this software and associated documentation files (the
|
|
9
|
-
'Software'), to deal in the Software without restriction, including
|
|
10
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
12
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
13
|
-
the following conditions:
|
|
14
|
-
|
|
15
|
-
The above copyright notice and this permission notice shall be
|
|
16
|
-
included in all copies or substantial portions of the Software.
|
|
17
|
-
|
|
18
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
21
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
22
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
24
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
let express= require('express');
|
|
2
|
-
let myMulter = require('./myMulter');
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let app = express();
|
|
6
|
-
let server = require('http').Server(app);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//文件上传服务
|
|
10
|
-
app.post('/upload', function (req, res, next) {
|
|
11
|
-
|
|
12
|
-
let responseData; //响应的数据
|
|
13
|
-
|
|
14
|
-
var upload=myMulter('file',1);
|
|
15
|
-
|
|
16
|
-
upload(req, res, function (err) {
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
if (err) throw err;
|
|
20
|
-
if(req.files.length==0) throw new Error("不能上传空文件");
|
|
21
|
-
|
|
22
|
-
responseData={msg:"上传成功",code:2000};
|
|
23
|
-
responseData.url=req.files[0].url;
|
|
24
|
-
res.json(responseData);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
responseData={msg:"上传失败",code:4000};;
|
|
30
|
-
responseData.error=err.message;
|
|
31
|
-
res.status(500).json(responseData);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
server.listen(3000);
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
let path=require('path');
|
|
2
|
-
let multer = require('multer');
|
|
3
|
-
let multerCOS = require('multer-COS');
|
|
4
|
-
require( 'dotenv' ).config();
|
|
5
|
-
/**
|
|
6
|
-
* multer
|
|
7
|
-
* https://github.com/expressjs/multer/blob/master/doc/README-zh-cn.md
|
|
8
|
-
* cos
|
|
9
|
-
* https://cloud.tencent.com/document/product/436/12264#options-object
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
//定义临时文件
|
|
14
|
-
let dir=path.resolve(__dirname,'./tmp');
|
|
15
|
-
|
|
16
|
-
//定义mimes-type
|
|
17
|
-
const mimes = {
|
|
18
|
-
'.png': 'image/png',
|
|
19
|
-
'.gif': 'image/gif',
|
|
20
|
-
'.jpg': 'image/jpeg',
|
|
21
|
-
'.jpeg': 'image/jpeg',
|
|
22
|
-
'.zip':'application/zip',
|
|
23
|
-
'.txt':'text/plain'
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const cosConfig={
|
|
28
|
-
//id和key是必须
|
|
29
|
-
|
|
30
|
-
//SecretId: AKIXXXXXXXXXXX,
|
|
31
|
-
//SecretKey:XXXXXXXXXXXXXX,
|
|
32
|
-
//Bucket:test-bucket-125XXXXXXXXX
|
|
33
|
-
//Region=ap-shanghai
|
|
34
|
-
// 可选参数
|
|
35
|
-
FileParallelLimit: 3, // 控制文件上传并发数
|
|
36
|
-
ChunkParallelLimit: 3, // 控制单个文件下分片上传并发数
|
|
37
|
-
ChunkSize: 1024 * 1024, // 控制分片大小,单位 B
|
|
38
|
-
domain:'static.dorodoro-lab.com', //cos域名
|
|
39
|
-
dir:'upload', //cos文件路径
|
|
40
|
-
onProgress:function(progressData){//进度回调函数,回调是一个对象,包含进度信息
|
|
41
|
-
//console.log(progressData);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
//定义仓库
|
|
48
|
-
const storage = multerCOS({
|
|
49
|
-
cos:cosConfig,
|
|
50
|
-
//Note:如果你传递的是一个函数,你负责创建文件夹,如果你传递的是一个字符串,multer会自动创建 如果什么都不传 系统自己会生成tmp目录
|
|
51
|
-
destination: function (req, file, cb) {
|
|
52
|
-
cb(null, dir);
|
|
53
|
-
},
|
|
54
|
-
//自己会生成个随机16字母的文件名和后缀
|
|
55
|
-
filename:'auto'
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
//测试cos
|
|
59
|
-
//storage.test();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
//定义过滤器
|
|
63
|
-
const fileFilter =function (req, file, cb) {
|
|
64
|
-
|
|
65
|
-
// 指示是否应接受该文件
|
|
66
|
-
let test = Object.values(mimes).filter(type=>type===file.mimetype);
|
|
67
|
-
|
|
68
|
-
// 接受这个文件,使用`true`,像这样:
|
|
69
|
-
if(test.length>0){
|
|
70
|
-
cb(null, true);
|
|
71
|
-
}else{ // 拒绝这个文件,使用`false`,像这样:
|
|
72
|
-
cb(new Error('file mimes not allow!'), false);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
//定义限制
|
|
77
|
-
const limits={
|
|
78
|
-
fileSize:1024 * 1024 * 30
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
module.exports=function(opt) {
|
|
83
|
-
return multer({
|
|
84
|
-
storage: storage,
|
|
85
|
-
fileFilter:fileFilter,
|
|
86
|
-
limits: limits,
|
|
87
|
-
}).array(opt);
|
|
88
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"_from":"multer-cos","_id":"multer-cos@1.0.2","_inBundle":false,"_integrity":"sha512-4F8P1VTCSNhiem+BFJFLe3Ixco6cIuAQ6j7U+PBRvdbBJRZgq5Q+vaDMMBWJ1HmPGOOP3AyKS5yk2f0nbFoqqA==","_location":"/multer-cos","_phantomChildren":{},"_requested":{"type":"tag","registry":true,"raw":"multer-cos","name":"multer-cos","escapedName":"multer-cos","rawSpec":"","saveSpec":null,"fetchSpec":"latest"},"_requiredBy":["#USER","/"],"_resolved":"https://registry.npmjs.org/multer-cos/-/multer-cos-1.0.2.tgz","_shasum":"95c7c06cdee1b9311675a895481f9d946de6dcf3","_spec":"multer-cos","_where":"/Users/lanbo/workplace/websocket","author":{"name":"lanbosm"},"bugs":{"url":"https://github.com/lanbosm/multer-COS/issues"},"bundleDependencies":false,"deprecated":false,"description":"Streaming multer storage engine for QCloud COS","devDependencies":{"cos-nodejs-sdk-v5":"^2.2.6","dotenv":"^5.0.1","multer":"^1.3.0"},"engines":{"node":">= 6.10.0"},"homepage":"https://github.com/lanbosm/multer-COS#readme","keywords":["express","multer","COS"],"license":"MIT","main":"index.js","name":"multer-cos","repository":{"type":"git","url":"git+ssh://git@github.com/lanbosm/multer-COS.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"version":"1.0.3","_lastModified":"2026-05-13T05:25:20.347Z"}
|