zen-gitsync 2.10.22 → 2.10.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-gitsync",
3
- "version": "2.10.22",
3
+ "version": "2.10.24",
4
4
  "description": "一个 git 提交的工具",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/config.js CHANGED
@@ -31,7 +31,10 @@ const defaultConfig = {
31
31
  type: 'command',
32
32
  refId: ''
33
33
  },
34
- currentDirectory: ''
34
+ currentDirectory: '',
35
+ // 通用设置
36
+ theme: 'light', // 主题: light | dark | auto
37
+ locale: 'zh-CN' // 语言: zh-CN | en-US
35
38
  };
36
39
 
37
40
  // 规范化项目路径作为配置键
@@ -109,9 +112,15 @@ async function loadConfig() {
109
112
  return { ...defaultConfig, ...raw };
110
113
  }
111
114
 
112
- // 新版结构:{ projects: { [key]: projectConfig }, global?: {...} }
115
+ // 新版结构:{ projects: { [key]: projectConfig }, theme?, locale?, recentDirectories? }
113
116
  const projectConfig = raw?.projects?.[key];
114
- return { ...defaultConfig, ...(projectConfig || {}) };
117
+ // 合并:默认配置 + 项目配置 + 全局通用设置(theme, locale)
118
+ return {
119
+ ...defaultConfig,
120
+ ...(projectConfig || {}),
121
+ theme: raw?.theme ?? defaultConfig.theme,
122
+ locale: raw?.locale ?? defaultConfig.locale
123
+ };
115
124
  }
116
125
 
117
126
  // 异步保存配置
@@ -141,9 +150,20 @@ async function saveConfig(config) {
141
150
  raw.projects = {};
142
151
  }
143
152
 
153
+ // 分离全局设置和项目设置
154
+ const { theme, locale, ...projectConfig } = config;
155
+
156
+ // 保存全局设置到根级别
157
+ if (theme !== undefined) {
158
+ raw.theme = theme;
159
+ }
160
+ if (locale !== undefined) {
161
+ raw.locale = locale;
162
+ }
163
+
144
164
  // 写入当前项目配置(在 defaultConfig 基础上合并,但不清空顶层其它键)
145
165
  const existingProjectConfig = (raw.projects[key] && typeof raw.projects[key] === 'object') ? raw.projects[key] : {};
146
- raw.projects[key] = { ...defaultConfig, ...existingProjectConfig, ...config };
166
+ raw.projects[key] = { ...defaultConfig, ...existingProjectConfig, ...projectConfig };
147
167
  await backupConfigFileIfExists();
148
168
  await writeRawConfigFile(raw);
149
169
  }
@@ -263,5 +283,7 @@ export default {
263
283
  listLockedFiles,
264
284
  getLockedFiles,
265
285
  getRecentDirectories,
266
- saveRecentDirectory
286
+ saveRecentDirectory,
287
+ readRawConfigFile,
288
+ writeRawConfigFile
267
289
  };