gchust b73f170edd
fix: save as template not shown (#6398)
* fix: save as template not shown

* fix: block template settings and route handling

* fix: incorrect l18n
2025-03-10 21:40:51 +08:00

31 lines
1.1 KiB
TypeScript

/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
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;
}
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;
};