fix: save as template not shown (#6398)

* fix: save as template not shown

* fix: block template settings and route handling

* fix: incorrect l18n
This commit is contained in:
gchust 2025-03-10 21:40:51 +08:00 committed by GitHub
parent f70ff6da80
commit b73f170edd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 20 deletions

View File

@ -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")}}',

View File

@ -18,7 +18,7 @@ export const DeprecatedTemplateTitle = () => {
<Space>
{t('Deprecated')}
<Tooltip
title={t('The following old template features have been deprecated and will be removed in next versions.')}
title={t('The following old template features have been deprecated and will be removed in next version.')}
>
<QuestionCircleOutlined />
</Tooltip>

View File

@ -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;
};