feat: menu sync & refresh
This commit is contained in:
parent
efc51355dd
commit
ae6ea41c52
@ -26,9 +26,14 @@ export function Details(props: any) {
|
|||||||
const { actions = [], fields = [] } = props.schema;
|
const { actions = [], fields = [] } = props.schema;
|
||||||
return (
|
return (
|
||||||
<Card bordered={false}>
|
<Card bordered={false}>
|
||||||
<Actions {...props} onFinish={() => {
|
<Actions
|
||||||
|
{...props}
|
||||||
|
onFinish={() => {
|
||||||
refresh();
|
refresh();
|
||||||
}} style={{ marginBottom: 14 }} actions={actions}/>
|
}}
|
||||||
|
style={{ marginBottom: 14 }}
|
||||||
|
actions={actions}
|
||||||
|
/>
|
||||||
{loading ? <Spin/> : (
|
{loading ? <Spin/> : (
|
||||||
<Descriptions bordered column={1}>
|
<Descriptions bordered column={1}>
|
||||||
{fields.map((field: any) => {
|
{fields.map((field: any) => {
|
||||||
|
@ -76,6 +76,8 @@ export const DrawerForm = forwardRef((props: any, ref) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
// @ts-ignore
|
||||||
|
window.routesReload && window.routesReload();
|
||||||
onFinish && onFinish(values);
|
onFinish && onFinish(values);
|
||||||
}}>提交</Button>
|
}}>提交</Button>
|
||||||
]}
|
]}
|
||||||
|
@ -77,6 +77,9 @@ export function SimpleTable(props: SimpleTableProps) {
|
|||||||
mode={'update'}
|
mode={'update'}
|
||||||
viewName={rowViewName}
|
viewName={rowViewName}
|
||||||
reference={drawerRef}
|
reference={drawerRef}
|
||||||
|
onFinish={() => {
|
||||||
|
refresh();
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<AntdTable
|
<AntdTable
|
||||||
rowKey={rowKey}
|
rowKey={rowKey}
|
||||||
|
@ -3,6 +3,7 @@ import { TableOptions } from '@nocobase/database';
|
|||||||
export default {
|
export default {
|
||||||
name: 'pages',
|
name: 'pages',
|
||||||
title: '页面配置',
|
title: '页面配置',
|
||||||
|
model: 'BaseModel',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
interface: 'sort',
|
interface: 'sort',
|
||||||
|
@ -18,4 +18,41 @@ export default async function (options = {}) {
|
|||||||
resourcer.registerActionHandler('getView', getView);
|
resourcer.registerActionHandler('getView', getView);
|
||||||
resourcer.registerActionHandler('getPageInfo', getPageInfo);
|
resourcer.registerActionHandler('getPageInfo', getPageInfo);
|
||||||
resourcer.registerActionHandler('pages:getRoutes', getRoutes);
|
resourcer.registerActionHandler('pages:getRoutes', getRoutes);
|
||||||
|
|
||||||
|
const [Collection, Page] = database.getModels(['collections', 'pages']);
|
||||||
|
|
||||||
|
async function createCollectionPage(model) {
|
||||||
|
if (!model.get('showInDataMenu')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const parent = await Page.findOne({
|
||||||
|
where: {
|
||||||
|
path: '/collections',
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let page = await Page.findOne({
|
||||||
|
where: {
|
||||||
|
collection: model.get('name'),
|
||||||
|
path: `/collections/${model.get('name')}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!page) {
|
||||||
|
page = await Page.create({
|
||||||
|
type: 'collection',
|
||||||
|
collection: model.get('name'),
|
||||||
|
path: `/collections/${model.get('name')}`,
|
||||||
|
sort: 100,
|
||||||
|
parent_id: parent.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
page.set({
|
||||||
|
title: model.get('title'),
|
||||||
|
icon: model.get('icon'),
|
||||||
|
showInMenu: model.get('showInDataMenu'),
|
||||||
|
});
|
||||||
|
page.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection.addHook('afterCreate', createCollectionPage);
|
||||||
|
Collection.addHook('afterUpdate', createCollectionPage);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user