2022-02-11 23:59:03 +08:00
|
|
|
import { skip } from '@nocobase/acl';
|
2022-02-11 15:16:00 +08:00
|
|
|
import { MagicAttributeModel } from '@nocobase/database';
|
|
|
|
import { Plugin } from '@nocobase/server';
|
|
|
|
import { resolve } from 'path';
|
|
|
|
import { getAccessible } from './actions/getAccessible';
|
|
|
|
|
|
|
|
export class UiRoutesStoragePlugin extends Plugin {
|
|
|
|
beforeLoad() {
|
|
|
|
this.app.on('installing', async () => {
|
|
|
|
const repository = this.app.db.getRepository('uiRoutes');
|
|
|
|
const routes = [
|
|
|
|
{
|
|
|
|
type: 'redirect',
|
|
|
|
from: '/',
|
|
|
|
to: '/admin',
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'route',
|
|
|
|
uiSchema: {
|
|
|
|
type: 'void',
|
|
|
|
'x-component': 'Menu',
|
|
|
|
'x-component-props': {
|
|
|
|
mode: 'mix',
|
|
|
|
theme: 'dark',
|
|
|
|
// defaultSelectedUid: 'u8',
|
|
|
|
onSelect: '{{ onSelect }}',
|
|
|
|
sideMenuRefScopeKey: 'sideMenuRef',
|
|
|
|
},
|
|
|
|
properties: {
|
|
|
|
item3: {
|
|
|
|
type: 'void',
|
|
|
|
title: 'SubMenu u3',
|
|
|
|
'x-component': 'Menu.SubMenu',
|
|
|
|
'x-component-props': {},
|
|
|
|
properties: {
|
|
|
|
item6: {
|
|
|
|
type: 'void',
|
|
|
|
title: 'SubMenu u6',
|
|
|
|
'x-component': 'Menu.SubMenu',
|
|
|
|
'x-component-props': {},
|
|
|
|
properties: {
|
|
|
|
item7: {
|
|
|
|
type: 'void',
|
|
|
|
title: 'Menu Item u7',
|
|
|
|
'x-component': 'Menu.Item',
|
|
|
|
'x-component-props': {},
|
2022-02-13 11:23:40 +08:00
|
|
|
properties: {
|
|
|
|
page1: {
|
|
|
|
type: 'void',
|
|
|
|
'x-component': 'Page',
|
|
|
|
'x-async': true,
|
|
|
|
properties: {
|
|
|
|
grid1: {
|
|
|
|
type: 'void',
|
|
|
|
'x-component': 'Grid',
|
|
|
|
'x-item-initializer': 'Grid.AddBlockItem',
|
|
|
|
properties: {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2022-02-11 15:16:00 +08:00
|
|
|
},
|
|
|
|
item8: {
|
|
|
|
type: 'void',
|
|
|
|
title: 'Menu Item u8',
|
|
|
|
'x-component': 'Menu.Item',
|
|
|
|
'x-component-props': {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
item4: {
|
|
|
|
type: 'void',
|
|
|
|
title: 'Menu Item u4',
|
|
|
|
'x-component': 'Menu.Item',
|
|
|
|
'x-component-props': {},
|
|
|
|
},
|
|
|
|
item5: {
|
|
|
|
type: 'void',
|
|
|
|
title: 'Menu Item u5',
|
|
|
|
'x-component': 'Menu.Item',
|
|
|
|
'x-component-props': {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
item1: {
|
|
|
|
type: 'void',
|
|
|
|
title: 'Menu Item u1',
|
|
|
|
'x-component': 'Menu.Item',
|
|
|
|
'x-component-props': {},
|
|
|
|
},
|
|
|
|
item2: {
|
|
|
|
type: 'void',
|
|
|
|
title: 'Menu Item u2',
|
|
|
|
'x-component': 'Menu.Item',
|
|
|
|
'x-component-props': {},
|
|
|
|
},
|
|
|
|
item9: {
|
|
|
|
type: 'void',
|
|
|
|
title: 'SubMenu u9',
|
|
|
|
'x-component': 'Menu.SubMenu',
|
|
|
|
'x-component-props': {},
|
|
|
|
properties: {
|
|
|
|
item10: {
|
|
|
|
type: 'void',
|
|
|
|
title: 'Menu Item u10',
|
|
|
|
'x-component': 'Menu.Item',
|
|
|
|
'x-component-props': {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
path: '/admin/:name(.+)?',
|
|
|
|
component: 'AdminLayout',
|
|
|
|
title: 'NocoBase Admin',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'route',
|
|
|
|
component: 'AuthLayout',
|
|
|
|
routes: [
|
|
|
|
{
|
|
|
|
type: 'route',
|
|
|
|
path: '/signin',
|
|
|
|
component: 'SigninPage',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'route',
|
|
|
|
path: '/signup',
|
|
|
|
component: 'SignupPage',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
for (const values of routes) {
|
|
|
|
await repository.create({
|
|
|
|
values,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async load() {
|
|
|
|
this.app.resourcer.registerActionHandler('uiRoutes:getAccessible', getAccessible);
|
|
|
|
this.app.db.registerModels({ MagicAttributeModel });
|
|
|
|
this.app.db.import({
|
|
|
|
directory: resolve(__dirname, 'collections'),
|
|
|
|
});
|
2022-02-11 23:59:03 +08:00
|
|
|
this.app.acl.use(
|
|
|
|
skip({
|
|
|
|
resourceName: 'uiRoutes',
|
|
|
|
actionName: 'getAccessible',
|
|
|
|
}),
|
|
|
|
);
|
2022-02-11 15:16:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default UiRoutesStoragePlugin;
|