example.js 546 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. const path = require('path');
  3. const { app, shell } = require('electron');
  4. exports.getPath = function () {
  5. const dir = app.getAppPath();
  6. return dir;
  7. }
  8. exports.openDir = function (dir = '') {
  9. if (!dir) {
  10. return false;
  11. }
  12. dir = getElectronPath(dir);
  13. shell.openItem(dir);
  14. return true;
  15. }
  16. function getElectronPath (filepath) {
  17. filepath = path.resolve(filepath);
  18. filepath=filepath.replace("resources","");
  19. filepath=filepath.replace("app.asar","");
  20. filepath = path.normalize(filepath);
  21. return filepath;
  22. };