utils.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. /**
  8. * example
  9. * @class
  10. */
  11. class UtilsController extends Controller {
  12. constructor(ctx) {
  13. super(ctx);
  14. }
  15. /**
  16. * 所有方法接收两个参数
  17. * @param args 前端传的参数
  18. * @param event - ipc通信时才有值。详情见:控制器文档
  19. */
  20. /**
  21. * upload
  22. */
  23. async openFileFolder (params) {
  24. // const result = await Services.get('example').test('electron');
  25. Log.info(params)
  26. Log.info(decodeURIComponent(params))
  27. shell.openPath(params);
  28. }
  29. async shellFun (params) {
  30. shell[params.action](params.params)
  31. }
  32. async checkUpdate () {
  33. let updaterAddon = new autoUpdater();
  34. updaterAddon.create();
  35. if(updaterAddon.checkUpdate()){
  36. return
  37. }
  38. }
  39. async checkProgress(params){
  40. console.log('checkProgress')
  41. const res = await searchBacthProgress(params)
  42. console.log(res)
  43. if( res.data){
  44. return res.data
  45. }
  46. return false;
  47. }
  48. }
  49. UtilsController.toString = () => '[class ExampleController]';
  50. module.exports = UtilsController;