diff --git a/electron/controller/example.js b/electron/controller/example.js new file mode 100644 index 0000000..cb0c0f8 --- /dev/null +++ b/electron/controller/example.js @@ -0,0 +1,37 @@ +'use strict'; + +const { Controller } = require('ee-core'); +const Log = require('ee-core/log'); + +/** + * example + * @class + */ +class ExampleController extends Controller { + + constructor(ctx) { + super(ctx); + } + + + /** + * 所有方法接收两个参数 + * @param args 前端传的参数 + * @param event - ipc通信时才有值。详情见:控制器文档 + */ + + /** + * test + */ + async test () { + const result = await this.service.example.test('electron'); + + let tmpDir = Ps.getLogDir(); + Log.info('tmpDir:', tmpDir); + + return result; + } +} + +ExampleController.toString = () => '[class ExampleController]'; +module.exports = ExampleController; \ No newline at end of file diff --git a/electron/service/example.js b/electron/service/example.js new file mode 100644 index 0000000..99a81c3 --- /dev/null +++ b/electron/service/example.js @@ -0,0 +1,29 @@ +'use strict'; + +const { Service } = require('ee-core'); + +/** + * 示例服务(service层为单例) + * @class + */ +class ExampleService extends Service { + + constructor(ctx) { + super(ctx); + } + + /** + * test + */ + async test(args) { + let obj = { + status:'ok', + params: args + } + + return obj; + } +} + +ExampleService.toString = () => '[class ExampleService]'; +module.exports = ExampleService; \ No newline at end of file