https://github.com/zhangmingfeng/egg-dict
egg data dictionary plugins
https://github.com/zhangmingfeng/egg-dict
dictionary egg-dict egg-plugin
Last synced: 2 months ago
JSON representation
egg data dictionary plugins
- Host: GitHub
- URL: https://github.com/zhangmingfeng/egg-dict
- Owner: zhangmingfeng
- License: mit
- Created: 2018-09-10T07:40:50.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-12T03:31:16.000Z (over 6 years ago)
- Last Synced: 2025-03-05T16:12:13.751Z (3 months ago)
- Topics: dictionary, egg-dict, egg-plugin
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Install
```bash
$ npm i --save egg-dict
```## Usage & configuration
- `config.default.js`
```js
// 相对app目录的路径,默认值dict
exports.dict = {
path: 'dict'
};
```- `config/plugin.js`
``` js
exports.dict = {
enable: true,
package: 'egg-dict'
}
```### example
```js
// app/dict/demo/demo.js
module.exports = {
status: {
error: '错误',
success: '成功'
}
}
```
```js
// controller.js or service.js
console.log(this.ctx.dict.demo.demo.status);//print: {error: "错误", success: "成功"}
``````js
// app/dict/demo/demo.js
// 只为了说明可以使用app
module.exports = (app)=>{
return {
statusWithApp: {
appPath: app.baseDir
}
}
}
```
```js
// controller.js or service.js
console.log(this.ctx.dict.demo.demo.statusWithApp.appPath);//print: /path/to/app-basedir
```