zen-gitsync 2.0.6 → 2.0.7
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/components/CommitForm.vue +354 -159
- package/src/ui/client/src/components/GitStatus.vue +517 -134
- package/src/ui/client/src/components/LogList.vue +831 -222
- package/src/ui/client/src/stores/gitLogStore.ts +12 -4
- package/src/ui/client/src/stores/gitStore.ts +42 -1
- package/src/ui/client/stats.html +1 -1
- package/src/ui/client/vite.config.ts +2 -0
- package/src/ui/public/assets/index-B1vQ6PC_.js +20 -0
- package/src/ui/public/assets/index-CC5qWyQ-.css +1 -0
- package/src/ui/public/assets/{vendor-BcSuWc8z.js → vendor-BmPvvgTD.js} +7 -7
- package/src/ui/public/index.html +3 -3
- package/src/ui/server/index.js +297 -46
- package/src/ui/public/assets/index-DaPynzAr.js +0 -10
- package/src/ui/public/assets/index-qfIezZmd.css +0 -1
|
@@ -255,12 +255,20 @@ export const useGitLogStore = defineStore('gitLog', () => {
|
|
|
255
255
|
try {
|
|
256
256
|
isLoadingLog.value = true
|
|
257
257
|
console.log('开始加载提交历史...')
|
|
258
|
-
|
|
258
|
+
|
|
259
|
+
// 增加时间戳参数避免缓存,确保获取最新数据
|
|
260
|
+
const timestamp = new Date().getTime()
|
|
261
|
+
const response = await fetch(`/api/log?page=1&_t=${timestamp}`)
|
|
259
262
|
const data = await response.json()
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
|
|
264
|
+
if (data && data.data && Array.isArray(data.data)) {
|
|
265
|
+
// 清空并更新日志数组
|
|
266
|
+
log.value = [...data.data]
|
|
267
|
+
console.log(`提交历史加载完成,共 ${log.value.length} 条记录`)
|
|
268
|
+
} else {
|
|
269
|
+
console.warn('API返回的提交历史格式不正确:', data)
|
|
270
|
+
log.value = [] // 如果数据格式不对,清空日志
|
|
262
271
|
}
|
|
263
|
-
console.log(`提交历史加载完成,共 ${log.value.length} 条记录`)
|
|
264
272
|
|
|
265
273
|
if (showMessage) {
|
|
266
274
|
ElMessage({
|
|
@@ -13,6 +13,12 @@ export const useGitStore = defineStore('git', () => {
|
|
|
13
13
|
const isGitRepo = ref(false) // 当前目录是否是Git仓库
|
|
14
14
|
const lastCheckedTime = ref(0) // 上次检查Git仓库状态的时间戳
|
|
15
15
|
|
|
16
|
+
// 添加分支状态相关变量
|
|
17
|
+
const branchAhead = ref(0) // 当前分支领先远程分支的提交数
|
|
18
|
+
const branchBehind = ref(0) // 当前分支落后远程分支的提交数
|
|
19
|
+
const hasUpstream = ref(false) // 当前分支是否有上游分支
|
|
20
|
+
const upstreamBranch = ref('') // 上游分支名称
|
|
21
|
+
|
|
16
22
|
// 添加重置方法
|
|
17
23
|
function $reset() {
|
|
18
24
|
currentBranch.value = ''
|
|
@@ -23,6 +29,34 @@ export const useGitStore = defineStore('git', () => {
|
|
|
23
29
|
isCreatingBranch.value = false
|
|
24
30
|
isGitRepo.value = false
|
|
25
31
|
lastCheckedTime.value = 0
|
|
32
|
+
branchAhead.value = 0
|
|
33
|
+
branchBehind.value = 0
|
|
34
|
+
hasUpstream.value = false
|
|
35
|
+
upstreamBranch.value = ''
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 获取分支状态(领先/落后远程)
|
|
39
|
+
async function getBranchStatus() {
|
|
40
|
+
if (!isGitRepo.value) return;
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
const response = await fetch('/api/branch-status');
|
|
44
|
+
const data = await response.json();
|
|
45
|
+
|
|
46
|
+
if (data) {
|
|
47
|
+
branchAhead.value = data.ahead || 0;
|
|
48
|
+
branchBehind.value = data.behind || 0;
|
|
49
|
+
hasUpstream.value = data.hasUpstream || false;
|
|
50
|
+
upstreamBranch.value = data.upstreamBranch || '';
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error('获取分支状态失败:', error);
|
|
54
|
+
// 出错时重置状态
|
|
55
|
+
branchAhead.value = 0;
|
|
56
|
+
branchBehind.value = 0;
|
|
57
|
+
hasUpstream.value = false;
|
|
58
|
+
upstreamBranch.value = '';
|
|
59
|
+
}
|
|
26
60
|
}
|
|
27
61
|
|
|
28
62
|
// 检查当前目录是否是Git仓库
|
|
@@ -56,6 +90,8 @@ export const useGitStore = defineStore('git', () => {
|
|
|
56
90
|
const data = await response.json()
|
|
57
91
|
if (data.branch) {
|
|
58
92
|
currentBranch.value = data.branch
|
|
93
|
+
// 获取分支状态信息
|
|
94
|
+
await getBranchStatus();
|
|
59
95
|
}
|
|
60
96
|
} catch (error) {
|
|
61
97
|
console.error('获取分支信息失败:', error)
|
|
@@ -285,6 +321,10 @@ export const useGitStore = defineStore('git', () => {
|
|
|
285
321
|
isCreatingBranch,
|
|
286
322
|
isGitRepo,
|
|
287
323
|
lastCheckedTime,
|
|
324
|
+
branchAhead,
|
|
325
|
+
branchBehind,
|
|
326
|
+
hasUpstream,
|
|
327
|
+
upstreamBranch,
|
|
288
328
|
|
|
289
329
|
// 方法
|
|
290
330
|
$reset,
|
|
@@ -296,6 +336,7 @@ export const useGitStore = defineStore('git', () => {
|
|
|
296
336
|
createBranch,
|
|
297
337
|
loadInitialData,
|
|
298
338
|
clearUserConfig,
|
|
299
|
-
restoreUserConfig
|
|
339
|
+
restoreUserConfig,
|
|
340
|
+
getBranchStatus
|
|
300
341
|
}
|
|
301
342
|
})
|