From cc833719bc9c6ebe3a0f12378886551366fc7b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Tue, 3 Sep 2024 14:55:32 +0800 Subject: [PATCH] =?UTF-8?q?optimize:=20=E5=85=BC=E5=AE=B9=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20`1.7.3`=20=E5=8F=8A=E4=BB=A5=E4=B8=8B=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=20(#339)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/config.js | 12 ++++++++++-- packages/core/src/config/index.js | 4 ++-- packages/gui/src/bridge/api/backend.js | 10 +++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/core/src/config.js b/packages/core/src/config.js index c164777..d32dba3 100644 --- a/packages/core/src/config.js +++ b/packages/core/src/config.js @@ -23,15 +23,23 @@ function _getRemoteSavePath (suffix = '') { if (!fs.existsSync(dir)) { fs.mkdirSync(dir) } - return path.join(dir, `remote_config${suffix}.json5`) + return path.join(dir, `/remote_config${suffix}.json5`) } function _getConfigPath () { const dir = getDefaultConfigBasePath() if (!fs.existsSync(dir)) { fs.mkdirSync(dir) + } else { + // 兼容1.7.3及以下版本的配置文件处理逻辑 + const newFilePath = path.join(dir, '/config.json') + const oldFilePath = path.join(dir, '/config.json5') + if (!fs.existsSync(newFilePath) && fs.existsSync(oldFilePath)) { + return oldFilePath // 如果新文件不存在,且旧文件存在,则返回旧文件路径 + } + return newFilePath } - return path.join(dir, 'config.json') + return path.join(dir, '/config.json') } let timer diff --git a/packages/core/src/config/index.js b/packages/core/src/config/index.js index 2a4f6ad..9a8758d 100644 --- a/packages/core/src/config/index.js +++ b/packages/core/src/config/index.js @@ -6,11 +6,11 @@ function getUserBasePath () { } function getRootCaCertPath () { - return getUserBasePath() + '/dev-sidecar.ca.crt' + return path.join(getUserBasePath(), '/dev-sidecar.ca.crt') } function getRootCaKeyPath () { - return getUserBasePath() + '/dev-sidecar.ca.key.pem' + return path.join(getUserBasePath(), '/dev-sidecar.ca.key.pem') } module.exports = { diff --git a/packages/gui/src/bridge/api/backend.js b/packages/gui/src/bridge/api/backend.js index ccd513b..97e1a45 100644 --- a/packages/gui/src/bridge/api/backend.js +++ b/packages/gui/src/bridge/api/backend.js @@ -138,8 +138,16 @@ function _getSettingsPath () { const dir = getDefaultConfigBasePath() if (!fs.existsSync(dir)) { fs.mkdirSync(dir) + } else { + // 兼容1.7.3及以下版本的配置文件处理逻辑 + const newFilePath = path.join(dir, '/setting.json') + const oldFilePath = path.join(dir, '/setting.json5') + if (!fs.existsSync(newFilePath) && fs.existsSync(oldFilePath)) { + return oldFilePath // 如果新文件不存在,且旧文件存在,则返回旧文件路径 + } + return newFilePath } - return dir + '/setting.json' + return path.join(dir, '/setting.json') } function invoke (api, param) {