From c503f0952974018ff714153870602ff89a8107fc Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 15 Jan 2022 16:28:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E2=80=9C=E4=BE=BF=E6=90=BA?= =?UTF-8?q?=E2=80=9D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 1 + src/main/index.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/publish/changeLog.md b/publish/changeLog.md index 1ee62647..243caf63 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,5 +1,6 @@ ### 新增 +- 新增“便携”功能,在Windows平台下,若程序目录下存在 portable 目录,则自动使用此目录作为数据存储目录 - 新增 Scheme URL 支持,同时发布lx-music-script项目配合使用(一个油猴脚本,可以在浏览器中的官方平台网页直接调用LX Music),Scheme URL的调用说明看Readme.md文档的Scheme URL支持部分 - 新增启动参数`-proxy-server`与`-proxy-bypass-list`,详细介绍看Readme.md文档的启动参数部分 diff --git a/src/main/index.js b/src/main/index.js index 60fc4056..9da5bba4 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -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)