Merge pull request #6 from zhouqunan/master

get ws addr
This commit is contained in:
Wallace Gao
2021-01-07 18:40:38 +08:00
committed by GitHub
3 changed files with 19 additions and 0 deletions

View File

@@ -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;

View File

@@ -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);
};

View File

@@ -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;