mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-14 19:52:10 +08:00
@@ -64,6 +64,17 @@ class ExampleController extends BaseController {
|
||||
|
||||
self.sendData(uploadRes);
|
||||
}
|
||||
|
||||
async getWsUrl() {
|
||||
const self = this;
|
||||
const { service } = this;
|
||||
const data = {};
|
||||
|
||||
const addr = await service.socket.getWsUrl();
|
||||
data.url = addr;
|
||||
|
||||
self.sendSuccess(data);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ExampleController;
|
||||
|
||||
@@ -9,4 +9,6 @@ module.exports = app => {
|
||||
router.post('/api/v1/example/openLocalDir', controller.v1.example.openLocalDir);
|
||||
// upload file
|
||||
router.post('/api/v1/example/uploadFile', controller.v1.example.uploadFile);
|
||||
// get ws url
|
||||
router.post('/api/v1/example/getWsUrl', controller.v1.example.getWsUrl);
|
||||
};
|
||||
@@ -25,6 +25,12 @@ class SocketService extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
async getWsUrl () {
|
||||
const port = this.service.storage.getElectronIPCPort();
|
||||
const url = 'http://localhost:' + port;
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SocketService;
|
||||
|
||||
Reference in New Issue
Block a user