Files
electron-egg/electron/controller/cross.js
gaoshuaixing 068b740088 go demo
2023-11-27 17:31:16 +08:00

46 lines
940 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use strict';
const { Controller } = require('ee-core');
const Cross = require('ee-core/cross');
const HttpClient = require('ee-core/httpclient');
/**
* Cross
* @class
*/
class CrossController extends Controller {
constructor(ctx) {
super(ctx);
}
/**
* 所有方法接收两个参数
* @param args 前端传的参数
* @param event - ipc通信时才有值。详情见控制器文档
*/
/**
* Access the api for the go service
*/
async requestGoApi() {
const hc = new HttpClient();
const goUrl = Cross.getUrl('go');
console.log('goUrl:', goUrl);
const apiHello = goUrl + '/api/hello'
const options = {
method: 'GET',
data: {},
dataType: 'json',
timeout: 1000,
};
const result = await hc.request(apiHello, options);
return result.data;
}
}
CrossController.toString = () => '[class CrossController]';
module.exports = CrossController;