Files
electron-egg/electron/apis/example.js
gaoshuaixing df45fe89d6 path
2020-12-24 14:51:19 +08:00

28 lines
548 B
JavaScript

'use strict';
const path = require('path');
const { app, shell } = require('electron');
exports.getPath = function () {
const dir = app.getAppPath();
return dir;
}
exports.openDir = function (dir = '') {
if (!dir) {
return false;
}
dir = getElectronPath(dir);
shell.openItem(dir);
return true;
}
function getElectronPath (filepath) {
//filepath = path.resolve(filepath);
filepath=filepath.replace("resources","");
filepath=filepath.replace("app.asar","");
filepath = path.normalize(filepath);
return filepath;
};