diff --git a/packages/core/client/src/schema-component/antd/upload/Upload.tsx b/packages/core/client/src/schema-component/antd/upload/Upload.tsx
index 44f989fa68..84a905031f 100644
--- a/packages/core/client/src/schema-component/antd/upload/Upload.tsx
+++ b/packages/core/client/src/schema-component/antd/upload/Upload.tsx
@@ -250,7 +250,7 @@ function AttachmentListItem(props) {
{item}
) : (
- {item}3
+ {item}
);
const content = (
@@ -358,6 +358,7 @@ export function Uploader({ rules, ...props }: UploadProps) {
const uploadProps = useUploadProps(props);
const beforeUpload = useBeforeUpload(rules);
+ console.log('----------', pendingList);
useEffect(() => {
if (pendingList.length) {
diff --git a/packages/core/client/src/schema-component/antd/upload/shared.ts b/packages/core/client/src/schema-component/antd/upload/shared.ts
index f334502859..c95605396d 100644
--- a/packages/core/client/src/schema-component/antd/upload/shared.ts
+++ b/packages/core/client/src/schema-component/antd/upload/shared.ts
@@ -59,8 +59,11 @@ export class AttachmentFileTypes {
*/
export const attachmentFileTypes = new AttachmentFileTypes();
-export function matchMimetype(file: FileModel, type: string) {
- if (file.mimetype) {
+export function matchMimetype(file: FileModel | UploadFile, type: string) {
+ if ('originFileObj' in file) {
+ return match(file.type, type);
+ }
+ if ('mimetype' in file) {
return match(file.mimetype, type);
}
if (file.url) {
@@ -223,7 +226,7 @@ const Rules: Record = {
type RuleFunction = (file: UploadFile, options: any) => string | null;
-function validate(file, rules: Record) {
+export function validate(file, rules: Record) {
if (!rules) {
return null;
}
diff --git a/packages/plugins/@nocobase/plugin-file-manager/src/client/hooks/useStorageRules.ts b/packages/plugins/@nocobase/plugin-file-manager/src/client/hooks/useStorageRules.ts
index 942f5b812b..e40f1cb927 100644
--- a/packages/plugins/@nocobase/plugin-file-manager/src/client/hooks/useStorageRules.ts
+++ b/packages/plugins/@nocobase/plugin-file-manager/src/client/hooks/useStorageRules.ts
@@ -7,6 +7,7 @@
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
+import { useEffect } from 'react';
import { useField } from '@formily/react';
import { useAPIClient, useCollectionField, useCollectionManager, useRequest } from '@nocobase/client';
@@ -14,20 +15,22 @@ export function useStorageRules(storage) {
const name = storage ?? '';
const apiClient = useAPIClient();
const field = useField();
- const { loading, data } = useRequest(
- async () => {
- if (field.pattern !== 'editable') {
- return null;
- }
- return apiClient.request({
- url: `storages:getRules/${name}`,
- });
+ const { loading, data, run } = useRequest(
+ {
+ url: `storages:getRules/${name}`,
},
{
+ manual: true,
refreshDeps: [name],
cacheKey: name,
},
);
+ useEffect(() => {
+ if (field.pattern !== 'editable') {
+ return;
+ }
+ run();
+ }, [field.pattern, run]);
return (!loading && data?.data) || null;
}