mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-15 04:02:10 +08:00
28 lines
548 B
JavaScript
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;
|
|
}; |