From 8af19d2489189fc1cc6feb939b81e2a5eb55a542 Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 22 Mar 2022 14:56:43 +0800 Subject: [PATCH] fix: cleanup --- packages/client/src/acl/Configuration/ScopeSelect.tsx | 2 -- .../client/src/acl/Configuration/schemas/scopes.ts | 1 - .../Configuration/AddFieldAction.tsx | 1 - .../src/schema-component/antd/calendar/Calendar.tsx | 2 -- .../src/schema-component/antd/checkbox/Checkbox.tsx | 8 ++------ .../client/src/schema-component/antd/radio/Radio.tsx | 1 - .../src/schema-component/antd/table/Table.Array.tsx | 1 - .../src/schema-component/antd/table/Table.Void.tsx | 2 -- .../client/src/schema-component/antd/tabs/Tabs.tsx | 1 - .../src/schema-component/antd/upload/ReadPretty.tsx | 1 - .../src/schema-component/antd/upload/Upload.tsx | 4 ++-- .../client/src/schema-component/antd/upload/shared.ts | 3 +-- .../src/system-settings/SystemSettingsShortcut.tsx | 11 ++++++++--- packages/client/src/user/SigninPage.tsx | 1 + packages/client/src/user/SignupPage.tsx | 1 + 15 files changed, 15 insertions(+), 25 deletions(-) diff --git a/packages/client/src/acl/Configuration/ScopeSelect.tsx b/packages/client/src/acl/Configuration/ScopeSelect.tsx index bf46c3041f..679bc8636a 100644 --- a/packages/client/src/acl/Configuration/ScopeSelect.tsx +++ b/packages/client/src/acl/Configuration/ScopeSelect.tsx @@ -28,7 +28,6 @@ export const ScopeSelect = (props) => { }), [], ); - console.log('props.value', props.value, form.values); return ( { scope={{ onChange(value) { props?.onChange?.(value); - console.log('onChange', value); }, }} schema={scopesSchema} diff --git a/packages/client/src/acl/Configuration/schemas/scopes.ts b/packages/client/src/acl/Configuration/schemas/scopes.ts index e214d3769d..17fb556351 100644 --- a/packages/client/src/acl/Configuration/schemas/scopes.ts +++ b/packages/client/src/acl/Configuration/schemas/scopes.ts @@ -136,7 +136,6 @@ export const scopesSchema: ISchema = { // }, useDataSource(options) { const record = useRecord(); - console.log('useRecord', record); return useRequest( { resource: 'rolesResourcesScopes', diff --git a/packages/client/src/collection-manager/Configuration/AddFieldAction.tsx b/packages/client/src/collection-manager/Configuration/AddFieldAction.tsx index 7e0a5fa598..63151e0a98 100644 --- a/packages/client/src/collection-manager/Configuration/AddFieldAction.tsx +++ b/packages/client/src/collection-manager/Configuration/AddFieldAction.tsx @@ -25,7 +25,6 @@ const getSchema = (schema: IField): ISchema => { name: `f_${uid()}`, }; initialValue.uiSchema.title = schema.title; - console.log('initialValue', initialValue); return { type: 'object', properties: { diff --git a/packages/client/src/schema-component/antd/calendar/Calendar.tsx b/packages/client/src/schema-component/antd/calendar/Calendar.tsx index cd76306610..86e21fa443 100644 --- a/packages/client/src/schema-component/antd/calendar/Calendar.tsx +++ b/packages/client/src/schema-component/antd/calendar/Calendar.tsx @@ -102,7 +102,6 @@ export const Calendar: any = observer((props: any) => { refreshDeps: [props.dataSource], onSuccess(data) { const events = toEvents(data?.data, fieldNames); - console.log('events', events, data); setDataSource(events); }, }, @@ -114,7 +113,6 @@ export const Calendar: any = observer((props: any) => { } return buf; }, null); - console.log('field', field); return ( diff --git a/packages/client/src/schema-component/antd/checkbox/Checkbox.tsx b/packages/client/src/schema-component/antd/checkbox/Checkbox.tsx index 244c884dbb..9513f6814f 100644 --- a/packages/client/src/schema-component/antd/checkbox/Checkbox.tsx +++ b/packages/client/src/schema-component/antd/checkbox/Checkbox.tsx @@ -1,4 +1,4 @@ -import { CheckOutlined, CloseOutlined } from '@ant-design/icons'; +import { CheckOutlined } from '@ant-design/icons'; import { connect, mapProps, mapReadPretty, useField } from '@formily/react'; import { isValid } from '@formily/shared'; import { Checkbox as AntdCheckbox, Tag } from 'antd'; @@ -29,11 +29,7 @@ export const Checkbox: ComposedCheckbox = connect( if (!isValid(props.value)) { return
; } - return props.value ? ( - - ) : ( - - ); + return props.value ? : null; }), ); diff --git a/packages/client/src/schema-component/antd/radio/Radio.tsx b/packages/client/src/schema-component/antd/radio/Radio.tsx index ed205eea87..ed95502f68 100644 --- a/packages/client/src/schema-component/antd/radio/Radio.tsx +++ b/packages/client/src/schema-component/antd/radio/Radio.tsx @@ -30,7 +30,6 @@ Radio.Group = connect( const { options = [], value } = props; const field = useField(); const dataSource = field.dataSource || []; - console.log({ dataSource }); return (
{dataSource diff --git a/packages/client/src/schema-component/antd/table/Table.Array.tsx b/packages/client/src/schema-component/antd/table/Table.Array.tsx index d9f85193b2..01d09b46e9 100644 --- a/packages/client/src/schema-component/antd/table/Table.Array.tsx +++ b/packages/client/src/schema-component/antd/table/Table.Array.tsx @@ -40,7 +40,6 @@ const useTableColumns = () => { }, } as TableColumnProps; }); - console.log(columns); if (!exists) { return columns; } diff --git a/packages/client/src/schema-component/antd/table/Table.Void.tsx b/packages/client/src/schema-component/antd/table/Table.Void.tsx index b8ec44b9f0..e92be88566 100644 --- a/packages/client/src/schema-component/antd/table/Table.Void.tsx +++ b/packages/client/src/schema-component/antd/table/Table.Void.tsx @@ -18,7 +18,6 @@ type TableVoidProps = TableProps & { }; const usePaginationProps = (props: TableProps & { request?: any }, service): TablePaginationConfig | false => { - console.log('f.componentProps.pagination', props); if (props.pagination === false) { return false; } @@ -97,7 +96,6 @@ export const TableVoid: React.FC = observer((props) => { } field.componentProps.pagination.current = data?.meta?.page || 1; field.componentProps.pagination.pageSize = data?.meta?.pageSize || 10; - console.log('f.componentProps.pagination', field.componentProps.pagination); }, }, props, diff --git a/packages/client/src/schema-component/antd/tabs/Tabs.tsx b/packages/client/src/schema-component/antd/tabs/Tabs.tsx index 09aa4a5e01..fa0be9d4a4 100644 --- a/packages/client/src/schema-component/antd/tabs/Tabs.tsx +++ b/packages/client/src/schema-component/antd/tabs/Tabs.tsx @@ -80,7 +80,6 @@ const designerCss = css` Tabs.TabPane = observer((props: TabPaneProps) => { const Designer = useDesigner(); const field = useField(); - console.log('Designer', Designer); return ( {props.tab || field.title} diff --git a/packages/client/src/schema-component/antd/upload/ReadPretty.tsx b/packages/client/src/schema-component/antd/upload/ReadPretty.tsx index 5fea7add19..0f576813ae 100644 --- a/packages/client/src/schema-component/antd/upload/ReadPretty.tsx +++ b/packages/client/src/schema-component/antd/upload/ReadPretty.tsx @@ -22,7 +22,6 @@ ReadPretty.Attachment = (props: UploadProps) => { const [photoIndex, setPhotoIndex] = useState(0); const [visible, setVisible] = useState(false); const { size } = props; - console.log('field.value', field.value, images); return (
diff --git a/packages/client/src/schema-component/antd/upload/Upload.tsx b/packages/client/src/schema-component/antd/upload/Upload.tsx index 765da72410..32bf720ac4 100644 --- a/packages/client/src/schema-component/antd/upload/Upload.tsx +++ b/packages/client/src/schema-component/antd/upload/Upload.tsx @@ -38,6 +38,7 @@ Upload.Attachment = connect((props: UploadProps) => { setFileList(toFileList(value)); } }, [value, sync]); + const uploadProps = useUploadProps({ ...props }); return (
@@ -126,7 +127,7 @@ Upload.Attachment = connect((props: UploadProps) => { {!disabled && (multiple || toArr(value).length < 1) && (
{ setFileList(info.fileList.map(toItem)); } else { if (info.file.status === 'done') { - console.log('field.value', info.file?.response?.data); // TODO(BUG): object 的联动有问题,不响应,折中的办法先置空再赋值 onChange(null); onChange(info.file?.response?.data); diff --git a/packages/client/src/schema-component/antd/upload/shared.ts b/packages/client/src/schema-component/antd/upload/shared.ts index 8884435b69..d2f56e5282 100644 --- a/packages/client/src/schema-component/antd/upload/shared.ts +++ b/packages/client/src/schema-component/antd/upload/shared.ts @@ -2,10 +2,10 @@ import { Field } from '@formily/core'; import { useField } from '@formily/react'; import { reaction } from '@formily/reactive'; import { isArr, isValid, toArr as toArray } from '@formily/shared'; -import { useAPIClient } from '../../../api-client'; import { UploadChangeParam } from 'antd/lib/upload'; import { UploadFile } from 'antd/lib/upload/interface'; import { useEffect } from 'react'; +import { useAPIClient } from '../../../api-client'; import { UPLOAD_PLACEHOLDER } from './placeholder'; import type { IUploadProps, UploadProps } from './type'; @@ -28,7 +28,6 @@ export const toMap = (fileList: any) => { } list = [fileList]; } - console.log({ list, fileList }); return list.map((item) => { return [item.id || item.uid, toItem(item)]; }); diff --git a/packages/client/src/system-settings/SystemSettingsShortcut.tsx b/packages/client/src/system-settings/SystemSettingsShortcut.tsx index 5fcc613bcc..e08bcca3db 100644 --- a/packages/client/src/system-settings/SystemSettingsShortcut.tsx +++ b/packages/client/src/system-settings/SystemSettingsShortcut.tsx @@ -9,7 +9,6 @@ import { ActionContext, SchemaComponent, useActionContext } from '../schema-comp const useCloseAction = () => { const { setVisible } = useActionContext(); - // const form = useForm(); return { async run() { setVisible(false); @@ -18,23 +17,28 @@ const useCloseAction = () => { }; const useSystemSettingsValues = (options) => { + const { visible } = useActionContext(); const result = useSystemSettings(); return useRequest(() => Promise.resolve(result.data), { ...options, + refreshDeps: [visible], }); }; const useSaveSystemSettingsValues = () => { const { setVisible } = useActionContext(); const form = useForm(); - const { mutate } = useSystemSettings(); + const { mutate, data } = useSystemSettings(); const api = useAPIClient(); return { async run() { await form.submit(); setVisible(false); mutate({ - data: form.values, + data: { + ...data?.data, + ...form.values, + }, }); await api.request({ url: 'systemSettings:update/1', @@ -108,6 +112,7 @@ const schema: ISchema = { 'x-component': 'Action', 'x-component-props': { type: 'primary', + htmlType: 'submit', useAction: '{{ useSaveSystemSettingsValues }}', }, }, diff --git a/packages/client/src/user/SigninPage.tsx b/packages/client/src/user/SigninPage.tsx index 69c5aa7101..018a637db1 100644 --- a/packages/client/src/user/SigninPage.tsx +++ b/packages/client/src/user/SigninPage.tsx @@ -33,6 +33,7 @@ const schema: ISchema = { type: 'void', 'x-component': 'Action', 'x-component-props': { + htmlType: 'submit', block: true, type: 'primary', useAction: '{{ useSignin }}', diff --git a/packages/client/src/user/SignupPage.tsx b/packages/client/src/user/SignupPage.tsx index bdcc0fe587..feae5c6b4a 100644 --- a/packages/client/src/user/SignupPage.tsx +++ b/packages/client/src/user/SignupPage.tsx @@ -63,6 +63,7 @@ const schema: ISchema = { 'x-component-props': { block: true, type: 'primary', + htmlType: 'submit', useAction: '{{ useSignup }}', style: { width: '100%' }, },