2023-06-21 11:02:49 +08:00
|
|
|
import { Plugin } from '@nocobase/server';
|
|
|
|
import { resolve } from 'path';
|
2023-06-09 12:23:53 +08:00
|
|
|
import { routes } from './routes';
|
2023-06-08 19:54:00 +08:00
|
|
|
|
|
|
|
export class MobileClientPlugin extends Plugin {
|
|
|
|
afterAdd() {}
|
|
|
|
|
2023-06-21 11:02:49 +08:00
|
|
|
async load() {
|
|
|
|
this.db.addMigrations({
|
|
|
|
namespace: 'client',
|
|
|
|
directory: resolve(__dirname, './migrations'),
|
|
|
|
context: {
|
|
|
|
plugin: this,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2023-06-09 12:23:53 +08:00
|
|
|
|
|
|
|
async install() {
|
2023-06-08 19:54:00 +08:00
|
|
|
const repository = this.app.db.getRepository('uiRoutes');
|
|
|
|
for (const values of routes) {
|
|
|
|
await repository.create({
|
|
|
|
values,
|
|
|
|
});
|
|
|
|
}
|
2023-06-21 11:02:49 +08:00
|
|
|
const uiSchemas = this.db.getRepository<any>('uiSchemas');
|
|
|
|
const systemSettings = this.db.getRepository('systemSettings');
|
|
|
|
const schema = await uiSchemas.insert({
|
|
|
|
type: 'void',
|
|
|
|
'x-component': 'MContainer',
|
|
|
|
'x-designer': 'MContainer.Designer',
|
|
|
|
'x-component-props': {},
|
|
|
|
properties: {
|
|
|
|
page: {
|
|
|
|
type: 'void',
|
|
|
|
'x-component': 'MPage',
|
|
|
|
'x-designer': 'MPage.Designer',
|
|
|
|
'x-component-props': {},
|
|
|
|
properties: {
|
|
|
|
grid: {
|
|
|
|
type: 'void',
|
|
|
|
'x-component': 'Grid',
|
|
|
|
'x-initializer': 'MBlockInitializers',
|
|
|
|
'x-component-props': {
|
|
|
|
showDivider: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const instance = await systemSettings.findOne();
|
|
|
|
instance.set('options.mobileSchemaUid', schema['x-uid']);
|
|
|
|
await instance.save();
|
2023-06-08 19:54:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async afterEnable() {}
|
|
|
|
|
|
|
|
async afterDisable() {}
|
|
|
|
|
|
|
|
async remove() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MobileClientPlugin;
|