mirror of
https://github.com/nocobase/nocobase.git
synced 2026-09-24 16:02:20 +08:00
* fix(client): fix typo in upload component (#5460) * fix(client): fix typo in upload component * fix(plugin-file-manager): fix rule hook * fix(plugin-file-manager): fix useless log
This commit is contained in:
@@ -203,7 +203,7 @@ const Rules: Record<string, RuleFunction> = {
|
||||
|
||||
type RuleFunction = (file: UploadFile, options: any) => string | null;
|
||||
|
||||
function validate(file, rules: Record<string, any>) {
|
||||
export function validate(file, rules: Record<string, any>) {
|
||||
if (!rules) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -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<any>();
|
||||
const { loading, data } = useRequest<any>(
|
||||
async () => {
|
||||
if (field.pattern !== 'editable') {
|
||||
return null;
|
||||
}
|
||||
return apiClient.request({
|
||||
url: `storages:getRules/${name}`,
|
||||
});
|
||||
const { loading, data, run } = useRequest<any>(
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user