example.js 597 B

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