utils.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. 'use strict';
  2. const { Controller } = require('ee-core');
  3. const { shell } = require('electron');
  4. const Log = require('ee-core/log');
  5. const autoUpdater = require('../addon/autoUpdater');
  6. const { searchBacthProgress } = require('../api/imageMatting')
  7. const errData = {
  8. msg :'请求失败,请联系管理员',
  9. code:999
  10. }
  11. /**
  12. * example
  13. * @class
  14. */
  15. class UtilsController extends Controller {
  16. constructor(ctx) {
  17. super(ctx);
  18. }
  19. /**
  20. * 所有方法接收两个参数
  21. * @param args 前端传的参数
  22. * @param event - ipc通信时才有值。详情见:控制器文档
  23. */
  24. /**
  25. * upload
  26. */
  27. async openFileFolder (params) {
  28. // const result = await Services.get('example').test('electron');
  29. Log.info(params)
  30. Log.info(decodeURIComponent(params))
  31. shell.openPath(params);
  32. }
  33. async shellFun (params) {
  34. shell[params.action](params.params)
  35. }
  36. async checkUpdate () {
  37. let updaterAddon = new autoUpdater();
  38. updaterAddon.create();
  39. if(updaterAddon.checkUpdate()){
  40. return
  41. }
  42. }
  43. async checkProgress(params){
  44. console.log('checkProgress')
  45. let error = false
  46. const res = await searchBacthProgress(params).catch(e=>{
  47. Log.info(e);
  48. error = errData
  49. return error;
  50. })
  51. console.log(res)
  52. if(res.data){
  53. return res.data
  54. }
  55. return error;
  56. }
  57. }
  58. UtilsController.toString = () => '[class ExampleController]';
  59. module.exports = UtilsController;