imageMatting.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. const { Controller } = require('ee-core');
  3. const Log = require('ee-core/log');
  4. const { dialog } = require('electron');
  5. const { checkSelectImages } = require('../api/imageMatting')
  6. /**
  7. * example
  8. * @class
  9. */
  10. class ExampleController extends Controller {
  11. constructor(ctx) {
  12. super(ctx);
  13. }
  14. /**
  15. * 所有方法接收两个参数
  16. * @param args 前端传的参数
  17. * @param event - ipc通信时才有值。详情见:控制器文档
  18. */
  19. /**
  20. * upload
  21. */
  22. async upload (param) {
  23. // const result = await Services.get('example').test('electron');
  24. let dialogParams = {}
  25. if(param === 'file'){
  26. dialogParams = {
  27. title:"选择图片",
  28. properties: ['openFile'], filters: [
  29. { name: '支持JPG', extensions: ['jpg'] },
  30. ]
  31. }
  32. }else{
  33. dialogParams = {
  34. title:"选择文件夹",
  35. properties: ['openDirectory']
  36. }
  37. }
  38. const filePaths = dialog.showOpenDialogSync(dialogParams);
  39. Log.info(filePaths);
  40. const res = await checkSelectImages({
  41. path_type:1,
  42. path:filePaths[0],
  43. })
  44. Log.info(res);
  45. return 'hello upload';
  46. }
  47. }
  48. ExampleController.toString = () => '[class ExampleController]';
  49. module.exports = ExampleController;