mixin.js 951 B

12345678910111213141516171819202122232425262728293031323334
  1. const OS = require('os');
  2. const { exec } = require('child_process');
  3. const Msg = Editor.require('packages://hot-update-tools/panel/msg.js');
  4. const Fs = require('fs');
  5. const Electron = require('electron');
  6. module.exports = {
  7. methods: {
  8. log (str) {
  9. this.$root.$emit(Msg.Log, str);
  10. },
  11. openDir (path) {
  12. if (!Fs.existsSync(path)) {
  13. return;
  14. }
  15. let cmd = '';
  16. switch (OS.platform()) {
  17. case 'win32': {
  18. cmd = `start "" "${path}"`;
  19. break;
  20. }
  21. case 'darwin': {
  22. cmd = `open "${path}"`;
  23. break;
  24. }
  25. }
  26. if (cmd) {
  27. exec(cmd);
  28. } else {
  29. Electron.remote.shell.showItemInFolder(path);
  30. }
  31. Electron.remote.shell.beep();
  32. },
  33. },
  34. };