9c165db0f7
* feat: init mobile client * feat: add plugin * feat: ready to develop * feat: update pm styels * feat: add mobile center * feat: router ready * feat: support menu block, then menu ready * fix: incorrect path * feat: support TabBar * feat: tabbar, menu support dragging * feat: support page and header * feat: mobile view * fix: optional schema * feat: improve styles * fix: user-scalable * feat: support pc component show in mobile * feat: hidden divider * fix: improve drawer props * feat: support list block * feat: rename to details list * feat: page support tabs * feat: improve designer css * feat: complete enable/disabled header of page * feat: some improve * feat: improve empty data * fix: header info cannot displayed * chore: update deps * fix: incorrect spacing * fix: menu designer * refactor: re implement * feat: support page template * feat: clean code * feat: support i18n * chore: update lock * feat: support GirdCard in mobile * fix: build failed * feat: only render one column in mobile interface * fix: back button should not display in container * fix: switch to padding * fix: fixedBlockDesignRItem shouldn't display in dosen't support block * fix: update font family * fix: remove gridcard title * fix: dragging scope is too wide * fix: add menu cannot direct display * refactor: improve tabbar schema usage * refactor: improve menu schema * feat: should to use simple pagination * feat: the tag should pre-wrap * feat: improve the configuration button * feat: improve name * fix: clear data when modal is closed * fix: the tag is too long * fix: i18n * fix: font incorrect * feat: add map block * fix: some maps error * feat: support global action in page * feat: improve border color * feat: improve performance, the count stop early * style: improve * fix: incorrect font * fix: style conflict * chore: update version * chore: missing dep * feat: support setting block * feat: improve settings block and improve * feat: support onBackPressed * fix: ts error * feat: improve cannot find tab should navigate to mobile * docs: update * chore: update deps * fix: showTitle state is incorrect * feat: improve jsbridge apis * fix: navigate to admin after signout * chore: remove mgrid block * fix: ts error * fix: switch role will reload to root page * fix: update deps * fix: upgrade formily to 2.2.24 --------- Co-authored-by: dream2023 <1098626505@qq.com> Co-authored-by: chenos <chenlinxh@gmail.com>
129 lines
3.3 KiB
TypeScript
129 lines
3.3 KiB
TypeScript
import { Plugin } from '@nocobase/server';
|
|
import _ from 'lodash';
|
|
import path from 'path';
|
|
|
|
export class PresetNocoBase extends Plugin {
|
|
builtInPlugins = [
|
|
'error-handler',
|
|
'collection-manager',
|
|
'ui-schema-storage',
|
|
'ui-routes-storage',
|
|
'file-manager',
|
|
'system-settings',
|
|
'sequence-field',
|
|
'verification',
|
|
'users',
|
|
'acl',
|
|
'china-region',
|
|
'workflow',
|
|
'client',
|
|
'export',
|
|
'import',
|
|
'audit-logs',
|
|
'duplicator',
|
|
'iframe-block',
|
|
'formula-field',
|
|
'charts',
|
|
'auth',
|
|
'sms-auth',
|
|
];
|
|
|
|
localPlugins = [
|
|
'sample-hello',
|
|
'multi-app-manager',
|
|
'multi-app-share-collection',
|
|
'oidc',
|
|
'saml',
|
|
'map',
|
|
'snapshot-field',
|
|
'graph-collection-manager',
|
|
'mobile-client',
|
|
];
|
|
|
|
splitNames(name: string) {
|
|
return (name || '').split(',').filter(Boolean);
|
|
}
|
|
|
|
getBuiltInPlugins() {
|
|
const { PRESET_NOCOBASE_PLUGINS, APPEND_PRESET_BUILT_IN_PLUGINS } = process.env;
|
|
return _.uniq(
|
|
this.splitNames(APPEND_PRESET_BUILT_IN_PLUGINS || PRESET_NOCOBASE_PLUGINS).concat(this.builtInPlugins),
|
|
);
|
|
}
|
|
|
|
getLocalPlugins() {
|
|
const { APPEND_PRESET_LOCAL_PLUGINS } = process.env;
|
|
return _.uniq(this.splitNames(APPEND_PRESET_LOCAL_PLUGINS).concat(this.localPlugins));
|
|
}
|
|
|
|
async addBuiltInPlugins(options?: any) {
|
|
const builtInPlugins = this.getBuiltInPlugins();
|
|
|
|
await this.app.pm.add(builtInPlugins, {
|
|
enabled: true,
|
|
builtIn: true,
|
|
installed: true,
|
|
});
|
|
|
|
const localPlugins = this.getLocalPlugins();
|
|
await this.app.pm.add(localPlugins, {});
|
|
await this.app.reload({ method: options.method });
|
|
}
|
|
|
|
afterAdd() {
|
|
this.app.on('beforeLoad', async (app, options) => {
|
|
if (options?.method !== 'upgrade') {
|
|
return;
|
|
}
|
|
const version = await this.app.version.get();
|
|
console.log(`The version number before upgrade is ${version}`);
|
|
});
|
|
|
|
this.app.on('beforeUpgrade', async () => {
|
|
const result = await this.app.version.satisfies('<0.8.0-alpha.1');
|
|
|
|
if (result) {
|
|
console.log(`Initialize all built-in plugins beforeUpgrade`);
|
|
await this.addBuiltInPlugins({ method: 'upgrade' });
|
|
}
|
|
|
|
const builtInPlugins = this.getBuiltInPlugins();
|
|
const plugins = await this.app.db.getRepository('applicationPlugins').find();
|
|
const pluginNames = plugins.map((p) => p.name);
|
|
await this.app.pm.add(
|
|
builtInPlugins.filter((plugin) => !pluginNames.includes(plugin)),
|
|
{
|
|
enabled: true,
|
|
builtIn: true,
|
|
installed: true,
|
|
},
|
|
);
|
|
const localPlugins = this.getLocalPlugins();
|
|
await this.app.pm.add(
|
|
localPlugins.filter((plugin) => !pluginNames.includes(plugin)),
|
|
{},
|
|
);
|
|
await this.app.reload({ method: 'upgrade' });
|
|
await this.app.db.sync();
|
|
await this.app.db.getRepository<any>('collections').load();
|
|
});
|
|
|
|
this.app.on('beforeInstall', async () => {
|
|
console.log(`Initialize all built-in plugins beforeInstall in ${this.app.name}`);
|
|
await this.addBuiltInPlugins({ method: 'install' });
|
|
});
|
|
}
|
|
|
|
beforeLoad() {
|
|
this.db.addMigrations({
|
|
namespace: this.getName(),
|
|
directory: path.resolve(__dirname, './migrations'),
|
|
context: {
|
|
plugin: this,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
|
|
export default PresetNocoBase;
|