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;
|
||||
return (
|
||||
<Card bordered={false}>
|
||||
<Actions {...props} onFinish={() => {
|
||||
refresh();
|
||||
}} style={{ marginBottom: 14 }} actions={actions}/>
|
||||
<Actions
|
||||
{...props}
|
||||
onFinish={() => {
|
||||
refresh();
|
||||
}}
|
||||
style={{ marginBottom: 14 }}
|
||||
actions={actions}
|
||||
/>
|
||||
{loading ? <Spin/> : (
|
||||
<Descriptions bordered column={1}>
|
||||
{fields.map((field: any) => {
|
||||
|
@ -76,6 +76,8 @@ export const DrawerForm = forwardRef((props: any, ref) => {
|
||||
});
|
||||
}
|
||||
setVisible(false);
|
||||
// @ts-ignore
|
||||
window.routesReload && window.routesReload();
|
||||
onFinish && onFinish(values);
|
||||
}}>提交</Button>
|
||||
]}
|
||||
|
@ -77,6 +77,9 @@ export function SimpleTable(props: SimpleTableProps) {
|
||||
mode={'update'}
|
||||
viewName={rowViewName}
|
||||
reference={drawerRef}
|
||||
onFinish={() => {
|
||||
refresh();
|
||||
}}
|
||||
/>
|
||||
<AntdTable
|
||||
rowKey={rowKey}
|
||||
|
@ -3,6 +3,7 @@ import { TableOptions } from '@nocobase/database';
|
||||
export default {
|
||||
name: 'pages',
|
||||
title: '页面配置',
|
||||
model: 'BaseModel',
|
||||
fields: [
|
||||
{
|
||||
interface: 'sort',
|
||||
|
@ -18,4 +18,41 @@ export default async function (options = {}) {
|
||||
resourcer.registerActionHandler('getView', getView);
|
||||
resourcer.registerActionHandler('getPageInfo', getPageInfo);
|
||||
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