example.js 706 Bytes
Newer Older
wuhao's avatar
wuhao committed
1
'use strict';
wuhao's avatar
wuhao committed
2

wuhao's avatar
wuhao committed
3 4 5
const { Controller } = require('ee-core');
const Log = require('ee-core/log');
const Services = require('ee-core/services');
wuhao's avatar
wuhao committed
6 7 8 9 10 11

/**
 * example
 * @class
 */
class ExampleController extends Controller {
wuhao's avatar
wuhao committed
12

wuhao's avatar
wuhao committed
13 14 15 16
  constructor(ctx) {
    super(ctx);
  }

wuhao's avatar
wuhao committed
17

wuhao's avatar
wuhao committed
18 19 20 21 22 23 24 25 26
  /**
   * 所有方法接收两个参数
   * @param args 前端传的参数
   * @param event - ipc通信时才有值。详情见:控制器文档
   */

  /**
   * test
   */
wuhao's avatar
wuhao committed
27 28 29
  async test () {
    const result = await Services.get('example').test('electron');
    Log.info('service result:', result);
wuhao's avatar
wuhao committed
30

wuhao's avatar
wuhao committed
31
    return 'hello electron-egg';
wuhao's avatar
wuhao committed
32 33 34
  }
}

wuhao's avatar
wuhao committed
35 36
ExampleController.toString = () => '[class ExampleController]';
module.exports = ExampleController;