zen-gitsync 2.0.4 → 2.0.5
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 +1 -1
- package/src/ui/client/components.d.ts +1 -0
- package/src/ui/client/src/App.vue +214 -68
- package/src/ui/client/src/components/CommitForm.vue +399 -365
- package/src/ui/client/src/components/GitStatus.vue +46 -65
- package/src/ui/client/src/components/LogList.vue +42 -0
- package/src/ui/client/src/stores/gitLogStore.ts +126 -126
- package/src/ui/client/src/stores/gitStore.ts +86 -1
- package/src/ui/client/stats.html +1 -1
- package/src/ui/public/assets/index-CALk9kKc.js +9 -0
- package/src/ui/public/assets/index-D3zIiSNw.css +1 -0
- package/src/ui/public/assets/vendor-BfXVsoKv.js +45 -0
- package/src/ui/public/index.html +3 -3
- package/src/ui/server/index.js +88 -4
- package/src/ui/public/assets/index-D5irnfho.css +0 -1
- package/src/ui/public/assets/index-DBck3u67.js +0 -8
- package/src/ui/public/assets/vendor-CdJ34PvS.js +0 -45
|
@@ -13,6 +13,18 @@ export const useGitStore = defineStore('git', () => {
|
|
|
13
13
|
const isGitRepo = ref(false) // 当前目录是否是Git仓库
|
|
14
14
|
const lastCheckedTime = ref(0) // 上次检查Git仓库状态的时间戳
|
|
15
15
|
|
|
16
|
+
// 添加重置方法
|
|
17
|
+
function $reset() {
|
|
18
|
+
currentBranch.value = ''
|
|
19
|
+
allBranches.value = []
|
|
20
|
+
userName.value = ''
|
|
21
|
+
userEmail.value = ''
|
|
22
|
+
isChangingBranch.value = false
|
|
23
|
+
isCreatingBranch.value = false
|
|
24
|
+
isGitRepo.value = false
|
|
25
|
+
lastCheckedTime.value = 0
|
|
26
|
+
}
|
|
27
|
+
|
|
16
28
|
// 检查当前目录是否是Git仓库
|
|
17
29
|
async function checkGitRepo() {
|
|
18
30
|
// 如果距离上次检查不到1秒,直接返回缓存的结果
|
|
@@ -193,6 +205,76 @@ export const useGitStore = defineStore('git', () => {
|
|
|
193
205
|
}
|
|
194
206
|
}
|
|
195
207
|
|
|
208
|
+
// 清除Git用户配置
|
|
209
|
+
async function clearUserConfig() {
|
|
210
|
+
try {
|
|
211
|
+
const response = await fetch('/api/clear-user-config', {
|
|
212
|
+
method: 'POST'
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
const result = await response.json();
|
|
216
|
+
if (result.success) {
|
|
217
|
+
// 清空本地状态
|
|
218
|
+
userName.value = '';
|
|
219
|
+
userEmail.value = '';
|
|
220
|
+
ElMessage({
|
|
221
|
+
message: '已清除Git用户配置',
|
|
222
|
+
type: 'success'
|
|
223
|
+
});
|
|
224
|
+
return true;
|
|
225
|
+
} else {
|
|
226
|
+
ElMessage({
|
|
227
|
+
message: `清除配置失败: ${result.error}`,
|
|
228
|
+
type: 'error'
|
|
229
|
+
});
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
} catch (error) {
|
|
233
|
+
ElMessage({
|
|
234
|
+
message: `清除配置失败: ${(error as Error).message}`,
|
|
235
|
+
type: 'error'
|
|
236
|
+
});
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// 恢复Git用户配置
|
|
242
|
+
async function restoreUserConfig(name: string, email: string) {
|
|
243
|
+
try {
|
|
244
|
+
const response = await fetch('/api/restore-user-config', {
|
|
245
|
+
method: 'POST',
|
|
246
|
+
headers: {
|
|
247
|
+
'Content-Type': 'application/json'
|
|
248
|
+
},
|
|
249
|
+
body: JSON.stringify({ name, email })
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
const result = await response.json();
|
|
253
|
+
if (result.success) {
|
|
254
|
+
// 更新本地状态
|
|
255
|
+
userName.value = name;
|
|
256
|
+
userEmail.value = email;
|
|
257
|
+
ElMessage({
|
|
258
|
+
message: '已恢复Git用户配置',
|
|
259
|
+
type: 'success'
|
|
260
|
+
});
|
|
261
|
+
return true;
|
|
262
|
+
} else {
|
|
263
|
+
ElMessage({
|
|
264
|
+
message: `恢复配置失败: ${result.error}`,
|
|
265
|
+
type: 'error'
|
|
266
|
+
});
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
} catch (error) {
|
|
270
|
+
ElMessage({
|
|
271
|
+
message: `恢复配置失败: ${(error as Error).message}`,
|
|
272
|
+
type: 'error'
|
|
273
|
+
});
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
196
278
|
return {
|
|
197
279
|
// 状态
|
|
198
280
|
currentBranch,
|
|
@@ -205,12 +287,15 @@ export const useGitStore = defineStore('git', () => {
|
|
|
205
287
|
lastCheckedTime,
|
|
206
288
|
|
|
207
289
|
// 方法
|
|
290
|
+
$reset,
|
|
208
291
|
checkGitRepo,
|
|
209
292
|
getCurrentBranch,
|
|
210
293
|
getAllBranches,
|
|
211
294
|
changeBranch,
|
|
212
295
|
getUserInfo,
|
|
213
296
|
createBranch,
|
|
214
|
-
loadInitialData
|
|
297
|
+
loadInitialData,
|
|
298
|
+
clearUserConfig,
|
|
299
|
+
restoreUserConfig
|
|
215
300
|
}
|
|
216
301
|
})
|