@peng_kai/kit 0.2.48 → 0.2.49
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.
|
@@ -7,7 +7,7 @@ export function createAwsS3Request(awsS3: AwsS3, rootPath?: string) {
|
|
|
7
7
|
return async (options: UploadRequestOption) => {
|
|
8
8
|
if (!(options.file instanceof File))
|
|
9
9
|
throw new Error('options.file 不是 File 对象');
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
const { uploader, fileURL } = await awsS3.upload(options.file, rootPath);
|
|
12
12
|
|
|
13
13
|
uploader.on('httpUploadProgress', (progress) => {
|
|
@@ -74,9 +74,10 @@ function groupingForm(groupName: string, items: Record<string, FormItemProps>) {
|
|
|
74
74
|
* 格式化表单项组
|
|
75
75
|
* @param name - 组名
|
|
76
76
|
* @param items - 包含表单数据
|
|
77
|
+
* @param removeTempKey - 是否移除临时字段(建议删除前克隆 items)
|
|
77
78
|
* @returns 返回一个数组,其元素为分组后的表单项对象,如果没有找到匹配的组名,则返回 undefined
|
|
78
79
|
*/
|
|
79
|
-
function formatGroup(name: string, items: Record<string, any
|
|
80
|
+
function formatGroup(name: string, items: Record<string, any>, removeTempKey = false) {
|
|
80
81
|
const group: any[] = [];
|
|
81
82
|
|
|
82
83
|
for (const k in items) {
|
|
@@ -89,6 +90,14 @@ function formatGroup(name: string, items: Record<string, any>) {
|
|
|
89
90
|
group[params.index][params.fieldName] = items[k];
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
if (removeTempKey) {
|
|
94
|
+
const keyRE = new RegExp(`^${name}${GROUP_SEP}\\d+${GROUP_SEP}`);
|
|
95
|
+
Object.keys(items).forEach((key) => {
|
|
96
|
+
if (keyRE.test(key))
|
|
97
|
+
delete items[key];
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
92
101
|
return group?.length ? group.filter(g => !!g) : undefined;
|
|
93
102
|
}
|
|
94
103
|
|
package/package.json
CHANGED
package/utils/upload/AwsS3.ts
CHANGED
|
@@ -23,7 +23,7 @@ export class AwsS3 {
|
|
|
23
23
|
public async upload(file: File, root?: string) {
|
|
24
24
|
const s3Client = await this.refreshClient();
|
|
25
25
|
const filePath = await this.genFilePath(root || 'unclassified');
|
|
26
|
-
const fileName = await (this.fileHandler?.genFileName(file) ?? this.genFileName(file));
|
|
26
|
+
const fileName = await (this.fileHandler?.genFileName?.(file) ?? this.genFileName(file));
|
|
27
27
|
const fullPath = `${filePath}/${fileName}`;
|
|
28
28
|
|
|
29
29
|
const uploader = new Upload({
|