diff --git a/packages/core/client/src/route-switch/antd/admin-layout/index.tsx b/packages/core/client/src/route-switch/antd/admin-layout/index.tsx index e03f681bd..ab2532df7 100644 --- a/packages/core/client/src/route-switch/antd/admin-layout/index.tsx +++ b/packages/core/client/src/route-switch/antd/admin-layout/index.tsx @@ -1,13 +1,11 @@ import { css } from '@emotion/css'; +import { useMutationObserver } from 'ahooks'; import { Layout, Spin } from 'antd'; import React, { createContext, useContext, useMemo, useRef, useState } from 'react'; import { useHistory, useRouteMatch } from 'react-router-dom'; import { - ACLRolesCheckProvider, - CurrentUser, - CurrentUserProvider, - CurrentAppInfoProvider, - findByUid, + ACLRolesCheckProvider, CurrentAppInfoProvider, CurrentUser, + CurrentUserProvider, findByUid, findMenuItem, RemoteCollectionManagerProvider, RemotePluginManagerToolbar, @@ -17,11 +15,9 @@ import { useDocumentTitle, useRequest, useRoute, - useSystemSettings, + useSystemSettings } from '../../../'; import { useCollectionManager } from '../../../collection-manager'; -import { PoweredBy } from '../../../powered-by'; -import { useMutationObserver } from 'ahooks'; const filterByACL = (schema, options) => { const { allowAll, allowMenuItemIds = [] } = options; @@ -209,8 +205,8 @@ export const InternalAdminLayout = (props: any) => { max-width: var(--side-menu-width); min-width: var(--side-menu-width); pointer-events: none; - transition: background-color 0.3s ease 0s, min-width 0.3s ease 0s, - max-width 0.3s cubic-bezier(0.645, 0.045, 0.355, 1) 0s; + /* transition: background-color 0.3s ease 0s, min-width 0.3s ease 0s, + max-width 0.3s cubic-bezier(0.645, 0.045, 0.355, 1) 0s; */ `} > { {...others} footer={ enablePageTabs && ( - { - setLoading(true); - setActiveKey(activeKey); - window.history.pushState({}, '', location.pathname + `?tab=` + activeKey); - setTimeout(() => { - setLoading(false); - }, 50); - }} - tabBarExtraContent={ - dn.designable && ( - - ) - } - > - {fieldSchema.mapProperties((schema) => { - return ( - - {schema['x-icon'] && } - {schema.title || t('Unnamed')} - - - } - key={schema.name} - /> - ); - })} - + }} + /> + + + ); + }).open({ + initialValues: {}, + }); + const { title, icon } = values; + dn.insertBeforeEnd({ + type: 'void', + title, + 'x-icon': icon, + 'x-component': 'Grid', + 'x-initializer': 'BlockInitializers', + properties: {}, + }); + }} + > + Add tab + + ) + } + > + {fieldSchema.mapProperties((schema) => { + return ( + + {schema['x-icon'] && } + {schema.title || t('Unnamed')} + + + } + key={schema.name} + /> + ); + })} + + ) } /> diff --git a/packages/core/client/src/schema-component/antd/page/PageTabDesigner.tsx b/packages/core/client/src/schema-component/antd/page/PageTabDesigner.tsx index 4f49d8fa3..621d02268 100644 --- a/packages/core/client/src/schema-component/antd/page/PageTabDesigner.tsx +++ b/packages/core/client/src/schema-component/antd/page/PageTabDesigner.tsx @@ -1,9 +1,9 @@ -import { MenuOutlined } from '@ant-design/icons'; +import { DragOutlined, MenuOutlined } from '@ant-design/icons'; import { ISchema, useField, useFieldSchema } from '@formily/react'; import { Modal, Space } from 'antd'; import React from 'react'; import { useTranslation } from 'react-i18next'; -import { useDesignable } from '../..'; +import { DragHandler, useDesignable } from '../..'; import { SchemaSettings } from '../../../schema-settings'; export const PageDesigner = ({ title }) => { @@ -120,6 +120,9 @@ export const PageTabDesigner = ({ schema }) => {
+ + + }> { ); }; -export const SortableItem: React.FC = observer((props) => { +const useSortableItemProps = (props) => { + const id = useSortableItemId(props); + if (props.schema) { + return { ...props, id }; + } + const schema = useFieldSchema(); + return { ...props, id, schema }; +}; + +const useSortableItemId = (props) => { + if (props.id) { + return props.id; + } const field = useField(); - const fieldSchema = useFieldSchema(); + return field.address.toString(); +}; + +export const SortableItem: React.FC = observer((props) => { + const { schema, id, ...others } = useSortableItemProps(props); return ( - - {props.children} + + {props.children} ); });