新增“便携”功能

This commit is contained in:
lyswhut
2022-01-15 16:28:16 +08:00
parent f5bb9189af
commit c503f09529
2 changed files with 13 additions and 0 deletions
+12
View File
@@ -31,6 +31,18 @@ app.on('second-instance', (event, argv, cwd) => {
}
})
// windows平台下如果应用目录下存在 portable 文件夹则将数据存在此文件下
if (process.platform === 'win32') {
const fs = require('fs')
const portablePath = path.join(path.dirname(app.getPath('exe')), '/portable')
if (fs.existsSync(portablePath)) {
app.setPath('appData', portablePath)
const appDataPath = path.join(portablePath, '/userData')
if (!fs.existsSync(appDataPath)) fs.mkdirSync(appDataPath)
app.setPath('userData', appDataPath)
}
}
const isDev = global.isDev = process.env.NODE_ENV !== 'production'
require('./env')
// console.log(global.envParams.cmdParams)