Emperor_Shun_Reading/electron/controller/example.js

75 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

'use strict';
const { Controller } = require('ee-core');
const Log = require('ee-core/log');
const Services = require('ee-core/services');
const Addon = require('ee-core/addon');
/**
* example
* @class
*/
class ExampleController extends Controller {
constructor(ctx) {
super(ctx);
}
/**
* 所有方法接收两个参数
* @param args 前端传的参数
* @param event - ipc通信时才有值。详情见控制器文档
*/
/**
* test
*/
async test () {
// const result1 = await Services.get('example').test('electron');
// Log.info('service result1:', result1);
// Services.get('framework').test('electron');
return 'hello electron-egg';
}
/**
* test
*/
async testUtils () {
let mid = await Utils.machineIdSync(true);
Log.info('mid 11111111:', mid);
Utils.machineId().then((id) => {
Log.info('mid 222222222:', id);
});
return;
}
/**
* test
*/
async testService () {
const serviceResult2 = await Services.get('example').test('electron');
Log.info('service result2:', serviceResult2);
return;
}
/**
* test
*/
async testAddon () {
const trayResult2 = Addon.get('tray').hello();
Log.info('addon result2:', trayResult2);
return;
}
}
ExampleController.toString = () => '[class ExampleController]';
module.exports = ExampleController;