Config
Modules can individually provide their own Config configuration.
Initialize code skeleton
1. Cli command
bash
$ zova :init:config demo-student2. Menu command
TIP
Context Menu - [Module Path]: Zova Init/Config
Define Config
Taking the module demo-student as an example, define the Config configuration of the module:
src/module/demo-student/src/config/config.ts
diff
export const config = (_sys: ZovaSys) => {
return {
+ title: 'Hello World',
};
};Just define the required configuration fields directly, and the system will automatically extract the type information of config.
Use Config
The Config configuration of the module can be obtained through the Scope instance.
diff
class ControllerTest {
async test() {
+ console.log(this.scope.config.title);
}
}Use Config cross-module
diff
+ import { ScopeModuleDemoStudent } from 'zova-module-demo-student';
class ControllerOther {
+ @UseScope()
+ $$scopeDemoStudent: ScopeModuleDemoStudent;
async test() {
+ console.log(this.$$scopeDemoStudent.config.title);
}
}Override Config
You can use project-level Config to override module-level Config.
src/front/config/config/config.ts
diff
// modules
config.modules = {
'demo-student': {
+ title: 'Hello World!!',
},
};