2022-09-26 01:18:55 +08:00
|
|
|
import path from 'path';
|
|
|
|
|
|
|
|
import { InstallOptions, Plugin } from '@nocobase/server';
|
|
|
|
|
|
|
|
import SnowflakeField from './fields/SnowflakeField';
|
|
|
|
|
|
|
|
export class ShopPlugin extends Plugin {
|
2022-10-27 13:00:16 +08:00
|
|
|
afterAdd() {
|
2022-09-26 01:18:55 +08:00
|
|
|
this.db.registerFieldTypes({
|
2023-01-03 15:17:20 +08:00
|
|
|
snowflake: SnowflakeField,
|
2022-09-26 01:18:55 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeLoad() {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
async load() {
|
|
|
|
await this.db.import({
|
|
|
|
directory: path.resolve(__dirname, 'collections'),
|
|
|
|
});
|
|
|
|
|
|
|
|
this.app.acl.allow('products', '*');
|
|
|
|
this.app.acl.allow('categories', '*');
|
|
|
|
this.app.acl.allow('orders', '*');
|
|
|
|
}
|
|
|
|
|
|
|
|
async install(options: InstallOptions) {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ShopPlugin;
|