diff --git a/packages/core/client/src/pm/index.tsx b/packages/core/client/src/pm/index.tsx index 0ee4017f49..6ea78f24cf 100644 --- a/packages/core/client/src/pm/index.tsx +++ b/packages/core/client/src/pm/index.tsx @@ -29,12 +29,13 @@ export class PMPlugin extends Plugin { } addSettings() { - this.app.pluginSettingsManager.add('ui-schema-storage', { - title: '{{t("Block templates")}}', - icon: 'LayoutOutlined', - Component: BlockTemplatesPane, - aclSnippet: 'pm.ui-schema-storage.block-templates', - }); + // hide old block template settings page + // this.app.pluginSettingsManager.add('ui-schema-storage', { + // title: '{{t("Block templates")}}', + // icon: 'LayoutOutlined', + // Component: BlockTemplatesPane, + // aclSnippet: 'pm.ui-schema-storage.block-templates', + // }); this.app.pluginSettingsManager.add('system-settings', { icon: 'SettingOutlined', title: '{{t("System settings")}}', diff --git a/packages/core/client/src/schema-initializer/components/DeprecatedTemplateTitle.tsx b/packages/core/client/src/schema-initializer/components/DeprecatedTemplateTitle.tsx index 23a63de6a4..b2f644e107 100644 --- a/packages/core/client/src/schema-initializer/components/DeprecatedTemplateTitle.tsx +++ b/packages/core/client/src/schema-initializer/components/DeprecatedTemplateTitle.tsx @@ -18,7 +18,7 @@ export const DeprecatedTemplateTitle = () => { {t('Deprecated')} diff --git a/packages/plugins/@nocobase/plugin-block-template/src/client/hooks/useIsPageBlock.ts b/packages/plugins/@nocobase/plugin-block-template/src/client/hooks/useIsPageBlock.ts index bdc7c8d09b..1c44bb2c35 100644 --- a/packages/plugins/@nocobase/plugin-block-template/src/client/hooks/useIsPageBlock.ts +++ b/packages/plugins/@nocobase/plugin-block-template/src/client/hooks/useIsPageBlock.ts @@ -8,27 +8,23 @@ */ import { useMemo } from 'react'; +import { useLocation } from 'react-router-dom'; import { useFieldSchema } from '@formily/react'; export const useIsPageBlock = () => { + const location = useLocation(); const fieldSchema = useFieldSchema(); + const isPageBlock = useMemo(() => { if (!fieldSchema || fieldSchema['x-template-uid']) { return false; } - - let schema = fieldSchema.parent; - while (schema) { - if (['Page', 'MobilePage'].includes(schema['x-component'])) { - return true; - } - if (!['Grid', 'Grid.Row', 'Grid.Col'].includes(schema['x-component'])) { - return false; - } - schema = schema.parent; - } - return false; - }, [fieldSchema]); + const isPage = location.pathname.includes('/admin/') || location.pathname.includes('/m/'); + const notInPopup = !location.pathname.includes('/popups/'); + const notInSetting = !location.pathname.includes('/admin/settings/'); + const notInBlockTemplate = !location.pathname.includes('/m/block-templates/'); + return isPage && notInPopup && notInSetting && notInBlockTemplate; + }, [location.pathname, fieldSchema]); return isPageBlock; };