zen-gitsync 2.1.2 → 2.1.6

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.
Files changed (38) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +96 -96
  3. package/index.js +2 -2
  4. package/package.json +69 -66
  5. package/src/config.js +51 -51
  6. package/src/gitCommit.js +261 -261
  7. package/src/ui/public/assets/index-8gQo1ABk.js +20 -0
  8. package/src/ui/public/assets/index-IcGOG2Ja.css +1 -0
  9. package/src/ui/public/assets/{vendor-Dy1zosHw.js → vendor-Bm8yNvvz.js} +1 -1
  10. package/src/ui/public/favicon.svg +26 -26
  11. package/src/ui/public/index.html +3 -3
  12. package/src/ui/public/logo.svg +26 -26
  13. package/src/ui/server/index.js +141 -51
  14. package/src/ui/client/README.md +0 -5
  15. package/src/ui/client/auto-imports.d.ts +0 -10
  16. package/src/ui/client/components.d.ts +0 -33
  17. package/src/ui/client/index.html +0 -13
  18. package/src/ui/client/package.json +0 -28
  19. package/src/ui/client/public/favicon.svg +0 -27
  20. package/src/ui/client/public/logo.svg +0 -27
  21. package/src/ui/client/public/vite.svg +0 -1
  22. package/src/ui/client/src/App.vue +0 -984
  23. package/src/ui/client/src/assets/logo.svg +0 -27
  24. package/src/ui/client/src/components/CommitForm.vue +0 -2167
  25. package/src/ui/client/src/components/GitStatus.vue +0 -1621
  26. package/src/ui/client/src/components/LogList.vue +0 -1937
  27. package/src/ui/client/src/main.ts +0 -7
  28. package/src/ui/client/src/stores/configStore.ts +0 -212
  29. package/src/ui/client/src/stores/gitLogStore.ts +0 -790
  30. package/src/ui/client/src/stores/gitStore.ts +0 -443
  31. package/src/ui/client/src/vite-env.d.ts +0 -1
  32. package/src/ui/client/stats.html +0 -4949
  33. package/src/ui/client/tsconfig.app.json +0 -14
  34. package/src/ui/client/tsconfig.json +0 -7
  35. package/src/ui/client/tsconfig.node.json +0 -24
  36. package/src/ui/client/vite.config.ts +0 -50
  37. package/src/ui/public/assets/index-C0FIVyIy.css +0 -1
  38. package/src/ui/public/assets/index-FuuBZ-mS.js +0 -20
@@ -1,1937 +0,0 @@
1
- <script setup lang="ts">
2
- import { ref, onMounted, computed, watch, onBeforeUnmount, nextTick } from 'vue'
3
- import {
4
- ElTable,
5
- ElTableColumn,
6
- ElTag,
7
- ElButton,
8
- ElSlider,
9
- ElDialog,
10
- ElSelect,
11
- ElOption,
12
- ElDatePicker,
13
- ElInput,
14
- ElBadge,
15
- ElMessage,
16
- ElMessageBox
17
- } from 'element-plus'
18
- import { RefreshRight, ZoomIn, ZoomOut, Filter, Document, TrendCharts, List, More } from '@element-plus/icons-vue'
19
- import 'element-plus/dist/index.css'
20
- import { createGitgraph } from '@gitgraph/js'
21
- import { useGitLogStore } from '../stores/gitLogStore'
22
- import { useGitStore } from '../stores/gitStore'
23
-
24
- interface LogItem {
25
- hash: string
26
- date: string
27
- author: string
28
- email: string
29
- message: string
30
- branch?: string
31
- parents?: string[]
32
- }
33
-
34
- // 使用Git状态和日志Store
35
- const gitLogStore = useGitLogStore()
36
- const gitStore = useGitStore()
37
-
38
- // 获取日志数据
39
- let logsData: LogItem[] = []
40
- const logs = ref<LogItem[]>(logsData)
41
- const errorMessage = ref('')
42
- // 定义本地加载状态,而不是依赖于computed
43
- const localLoading = ref(false)
44
- const isLoading = computed(() => gitLogStore.isLoadingLog || localLoading.value)
45
- const showAllCommits = ref(false)
46
- const totalCommits = ref(0)
47
- const showGraphView = ref(false)
48
- const graphContainer = ref<HTMLElement | null>(null)
49
-
50
- // 添加分页相关变量
51
- const currentPage = ref(1)
52
- const hasMoreData = ref(true)
53
- const isLoadingMore = ref(false)
54
- const loadTimerInterval = ref<number | null>(null)
55
-
56
- // 添加提交详情弹窗相关变量
57
- const commitDetailVisible = ref(false)
58
- const selectedCommit = ref<LogItem | null>(null)
59
- const commitFiles = ref<string[]>([])
60
- const commitDiff = ref('')
61
- const isLoadingCommitDetail = ref(false)
62
- const selectedCommitFile = ref('')
63
-
64
- // 添加图表缩放控制
65
- const graphScale = ref(1)
66
- const minScale = 0.5
67
- const maxScale = 1.5
68
- const scaleStep = 0.1
69
-
70
- // 添加日志被刷新的提示状态
71
- const logRefreshed = ref(false)
72
-
73
- // 添加筛选相关变量
74
- const filterVisible = ref(false)
75
- const authorFilter = ref<string[]>([])
76
- const messageFilter = ref('')
77
- const dateRangeFilter = ref<any>(null)
78
- const availableAuthors = ref<string[]>([])
79
- // 添加分支筛选
80
- const branchFilter = ref<string[]>([])
81
- const availableBranches = ref<string[]>([])
82
-
83
- // 添加右键菜单相关变量
84
- const contextMenuVisible = ref(false)
85
- const contextMenuTop = ref(0)
86
- const contextMenuLeft = ref(0)
87
- const selectedContextCommit = ref<LogItem | null>(null)
88
-
89
- // 应用筛选后的日志
90
- const filteredLogs = computed(() => {
91
- // 不再在前端进行筛选,直接使用加载的日志
92
- return logs.value;
93
- })
94
-
95
- // 加载提交历史
96
- async function loadLog(all = false, page = 1) {
97
- // 从gitStore获取仓库状态
98
- const gitStore = useGitStore()
99
-
100
- // 检查是否是Git仓库
101
- if (!gitStore.isGitRepo) {
102
- errorMessage.value = '当前目录不是Git仓库'
103
- return
104
- }
105
-
106
- try {
107
- // 设置加载状态
108
- if (page > 1) {
109
- isLoadingMore.value = true
110
- } else {
111
- localLoading.value = true
112
- }
113
-
114
- console.log(`加载提交历史: page=${page}, all=${all}`)
115
-
116
- // 构建查询参数
117
- const queryParams = new URLSearchParams()
118
- queryParams.append('page', page.toString())
119
- queryParams.append('all', all.toString())
120
-
121
- // 添加筛选参数
122
- if (authorFilter.value.length > 0) {
123
- queryParams.append('author', authorFilter.value.join(','))
124
- }
125
-
126
- // 添加分支筛选参数
127
- if (branchFilter.value.length > 0) {
128
- queryParams.append('branch', branchFilter.value.join(','))
129
- }
130
-
131
- if (messageFilter.value) {
132
- queryParams.append('message', messageFilter.value)
133
- }
134
-
135
- if (dateRangeFilter.value && Array.isArray(dateRangeFilter.value) && dateRangeFilter.value.length === 2) {
136
- queryParams.append('dateFrom', dateRangeFilter.value[0])
137
- queryParams.append('dateTo', dateRangeFilter.value[1])
138
- }
139
-
140
- // 添加时间戳防止缓存
141
- queryParams.append('_t', Date.now().toString())
142
-
143
- const response = await fetch(`/api/log?${queryParams.toString()}`)
144
- const result = await response.json()
145
-
146
- // 确保result有正确的数据结构
147
- if (!result || !result.data || !Array.isArray(result.data)) {
148
- console.error('API返回的数据格式不正确:', result)
149
- errorMessage.value = '加载提交历史失败: 服务器返回数据格式不正确'
150
- return
151
- }
152
-
153
- const isLoadMore = page > 1
154
-
155
- // 处理结果
156
- // 如果是加载更多,追加数据,否则替换数据
157
- if (isLoadMore) {
158
- result.data.forEach((item: LogItem) => logsData.push(item))
159
- } else {
160
- logsData.length = 0
161
- result.data.forEach((item: LogItem) => logsData.push(item))
162
- }
163
-
164
- // 强制重新渲染列表
165
- logs.value = [...logsData]
166
-
167
- // 更新当前页码
168
- currentPage.value = page
169
-
170
- // 更新总数和分页标记
171
- totalCommits.value = result.total || logsData.length
172
- hasMoreData.value = result.hasMore === true
173
-
174
- if (!hasMoreData.value) {
175
- console.log('已加载所有提交记录')
176
- }
177
-
178
- // 设置刷新提示状态(仅在初次加载时)
179
- if (!isLoadMore) {
180
- logRefreshed.value = true
181
- // 2秒后隐藏提示
182
- setTimeout(() => { logRefreshed.value = false }, 2000)
183
- }
184
-
185
- // 加载完数据后渲染图表(仅在初次加载时)
186
- if (!isLoadMore && showGraphView.value) {
187
- setTimeout(renderGraph, 0)
188
- }
189
-
190
- errorMessage.value = ''
191
- } catch (error) {
192
- errorMessage.value = '加载提交历史失败: ' + (error instanceof Error ? error.message : String(error))
193
- console.error('加载日志失败:', error)
194
-
195
- // 如果加载更多失败,标记没有更多数据
196
- if (page > 1) {
197
- hasMoreData.value = false
198
- }
199
- } finally {
200
- // 重置加载状态
201
- if (page > 1) {
202
- isLoadingMore.value = false
203
- } else {
204
- localLoading.value = false
205
- }
206
- }
207
- }
208
-
209
- // 渲染Git图表
210
- async function renderGraph() {
211
- console.log(`开始渲染图表...数据长度: ${logsData.length}`)
212
-
213
- if (!graphContainer.value) {
214
- console.error('图表容器未找到')
215
- return
216
- }
217
-
218
- if (logsData.length === 0) {
219
- console.error('没有日志数据可渲染')
220
- return
221
- }
222
-
223
- try {
224
- // 清空容器
225
- graphContainer.value.innerHTML = ''
226
-
227
- console.log(`创建gitgraph实例,分支: ${gitStore.currentBranch || 'main'}`)
228
-
229
- // 创建gitgraph实例
230
- const gitgraph = createGitgraph(graphContainer.value, {
231
- // 自定义选项
232
- orientation: 'vertical-reverse' as any, // 使用类型断言解决类型错误
233
- template: 'metro' as any, // 使用类型断言解决类型错误
234
- author: '提交者 <committer@example.com>'
235
- })
236
-
237
- // 处理分支和提交数据
238
- const branches: Record<string, any> = {}
239
- const mainBranch = gitgraph.branch(gitStore.currentBranch || 'main')
240
- branches[gitStore.currentBranch || 'main'] = mainBranch
241
-
242
- console.log(`开始创建提交图...共${logsData.length}条提交`)
243
-
244
- // 简化示例 - 实际实现需要根据API返回的数据结构调整
245
- logsData.forEach((commit, index) => {
246
- // 这里需要根据实际数据结构构建分支图
247
- let currentBranch = mainBranch
248
-
249
- // 如果有分支信息,使用对应的分支
250
- if (commit.branch) {
251
- const branchName = formatBranchName(commit.branch.split(',')[0])
252
- if (!branches[branchName]) {
253
- branches[branchName] = gitgraph.branch(branchName)
254
- }
255
- currentBranch = branches[branchName]
256
- }
257
-
258
- // 创建提交,添加邮箱信息
259
- currentBranch.commit({
260
- hash: commit.hash,
261
- subject: commit.message,
262
- author: `${commit.author} <${commit.email}>`
263
- })
264
-
265
- if (index % 10 === 0) {
266
- console.log(`已渲染 ${index + 1}/${logsData.length} 个提交`)
267
- }
268
- })
269
-
270
- console.log('图表渲染完成')
271
-
272
- // 确保渲染完成后调用自适应缩放
273
- setTimeout(() => {
274
- fitGraphToContainer()
275
- }, 100)
276
- } catch (error) {
277
- console.error('渲染图表失败:', error)
278
- errorMessage.value = '渲染图表失败: ' + (error instanceof Error ? error.message : String(error))
279
- }
280
- }
281
-
282
- // 切换视图模式
283
- function toggleViewMode() {
284
- showGraphView.value = !showGraphView.value
285
- if (showGraphView.value && logsData.length > 0) {
286
- // 延迟执行以确保DOM已更新
287
- setTimeout(renderGraph, 0)
288
- }
289
- }
290
-
291
- // 切换显示所有提交
292
- function toggleAllCommits() {
293
- loadLog(!showAllCommits.value)
294
- }
295
-
296
- // 格式化分支名(实现该函数,因为在模板中调用了)
297
- function formatBranchName(ref: string) {
298
- // 处理HEAD、远程分支等情况
299
- if (ref.includes('HEAD -> ')) {
300
- return ref.replace('HEAD -> ', '')
301
- }
302
- if (ref.includes('origin/')) {
303
- return ref
304
- }
305
- return ref.trim()
306
- }
307
-
308
- // 获取分支标签类型(实现该函数,因为在模板中调用了)
309
- function getBranchTagType(ref: string) {
310
- if (ref.includes('HEAD')) return 'success'
311
- if (ref.includes('origin/')) return 'warning'
312
- return 'info'
313
- }
314
-
315
- // 添加对表格实例的引用
316
- const tableRef = ref<InstanceType<typeof ElTable> | null>(null)
317
- const tableBodyWrapper = ref<HTMLElement | null>(null)
318
-
319
- // 监听表格滚动事件的处理函数
320
- function handleTableScroll(event: Event) {
321
- if (showGraphView.value || !hasMoreData.value || isLoadingMore.value || isLoading.value) {
322
- return
323
- }
324
-
325
- const target = event.target as HTMLElement
326
- const { scrollTop, scrollHeight, clientHeight } = target
327
- const scrollDistance = scrollHeight - scrollTop - clientHeight
328
-
329
- // 调试信息
330
- console.log('表格滚动:', {
331
- scrollTop,
332
- scrollHeight,
333
- clientHeight,
334
- scrollDistance
335
- })
336
-
337
- // 当滚动到距离底部20px时触发加载
338
- if (scrollDistance <= 20) {
339
- console.log('已滚动到底部,加载更多数据')
340
- loadMoreLogs()
341
- }
342
- }
343
-
344
- // 设置表格滚动监听
345
- function setupTableScrollListener() {
346
- if (!tableRef.value) return
347
-
348
- // 获取表格的body-wrapper
349
- tableBodyWrapper.value = tableRef.value.$el.querySelector('.el-table__body-wrapper')
350
-
351
- if (tableBodyWrapper.value) {
352
- console.log('添加表格滚动监听')
353
- tableBodyWrapper.value.addEventListener('scroll', handleTableScroll, true)
354
- } else {
355
- console.error('未找到表格的body-wrapper元素')
356
- }
357
- }
358
-
359
- // 移除表格滚动监听
360
- function removeTableScrollListener() {
361
- if (tableBodyWrapper.value) {
362
- console.log('移除表格滚动监听')
363
- tableBodyWrapper.value.removeEventListener('scroll', handleTableScroll, true)
364
- tableBodyWrapper.value = null
365
- }
366
- }
367
-
368
- onMounted(() => {
369
- // 检查gitLogStore中是否已有数据
370
- if (gitStore.isGitRepo) {
371
- if (gitLogStore.log.length > 0) {
372
- // 如果已经有数据,直接使用现有数据
373
- console.log('使用已加载的日志数据')
374
-
375
- // 清空并填充logsData
376
- logsData.length = 0
377
- gitLogStore.log.forEach(item => logsData.push(item))
378
-
379
- // 由于TypeScript类型错误,我们直接设置totalCommits而不是使用logs.value.length
380
- totalCommits.value = gitLogStore.log.length
381
-
382
- // 确保视图被渲染
383
- if (showGraphView.value) {
384
- setTimeout(() => {
385
- console.log(`准备渲染图表,数据长度: ${logsData.length}`)
386
- renderGraph()
387
- }, 100)
388
- }
389
- } else {
390
- // 否则加载数据
391
- console.log('初始加载日志数据')
392
- loadLog()
393
- }
394
-
395
- // 加载所有可能的作者列表
396
- fetchAllAuthors()
397
-
398
- // 不再在这里直接设置 availableBranches,改为通过 watch 监听 gitStore.allBranches 的变化
399
- } else {
400
- errorMessage.value = '当前目录不是Git仓库'
401
- }
402
-
403
- // 在下一个tick中设置表格滚动监听
404
- nextTick(() => {
405
- setTimeout(() => {
406
- setupTableScrollListener()
407
- }, 500) // 给表格足够的时间来渲染
408
- })
409
- })
410
-
411
- // 添加对 gitStore.allBranches 的监听
412
- watch(() => gitStore.allBranches, (newBranches) => {
413
- if (newBranches && newBranches.length > 0) {
414
- availableBranches.value = [...newBranches].sort()
415
- console.log(`分支数据更新,共 ${availableBranches.value.length} 个分支`)
416
- } else {
417
- availableBranches.value = []
418
- console.warn('gitStore 中没有分支数据')
419
- }
420
- }, { immediate: true }) // immediate: true 确保组件创建时立即执行一次
421
-
422
- onBeforeUnmount(() => {
423
- // 清除表格滚动监听
424
- removeTableScrollListener()
425
-
426
- // 清除定时器
427
- if (loadTimerInterval.value !== null) {
428
- window.clearInterval(loadTimerInterval.value)
429
- loadTimerInterval.value = null
430
- }
431
- })
432
-
433
- // 简化刷新函数,只需调用loadLog即可
434
- const refreshLog = () => {
435
- if (!gitStore.isGitRepo) {
436
- errorMessage.value = '当前目录不是Git仓库'
437
- return
438
- }
439
- // 重置页码,重新加载第一页
440
- currentPage.value = 1
441
- hasMoreData.value = true
442
- loadLog(showAllCommits.value, 1)
443
- }
444
-
445
- // 监听store中的日志变化
446
- watch(() => gitLogStore.log, (newLogs) => {
447
- console.log('监听到gitLogStore.log变化,更新图表数据')
448
-
449
- try {
450
- // 清空logsData
451
- logsData.length = 0
452
-
453
- // 重新填充数据,使用类型断言
454
- if (Array.isArray(newLogs)) {
455
- // @ts-ignore - 忽略类型校验
456
- newLogs.forEach(item => item && logsData.push(item))
457
- }
458
-
459
- // 更新计数器
460
- totalCommits.value = logsData.length
461
-
462
- // 重置当前页为第1页
463
- currentPage.value = 1
464
-
465
- // 确保引用更新,触发UI重渲染
466
- // @ts-ignore - 忽略类型校验
467
- logs.value = [...logsData]
468
-
469
- // 设置刷新提示
470
- logRefreshed.value = true
471
- setTimeout(() => { logRefreshed.value = false }, 2000)
472
-
473
- console.log(`数据更新完成,共${logs.value.length}条记录,准备渲染图表`)
474
-
475
- if (showGraphView.value && logsData.length > 0) {
476
- setTimeout(renderGraph, 0)
477
- }
478
- } catch (error) {
479
- console.error('更新日志数据失败:', error)
480
- }
481
- }, { immediate: true })
482
-
483
- // 暴露方法给父组件
484
- defineExpose({
485
- refreshLog
486
- })
487
-
488
- // 增加/减少缩放比例
489
- function zoomIn() {
490
- if (graphScale.value < maxScale) {
491
- graphScale.value = Math.min(maxScale, graphScale.value + scaleStep)
492
- applyScale()
493
- }
494
- }
495
-
496
- function zoomOut() {
497
- if (graphScale.value > minScale) {
498
- graphScale.value = Math.max(minScale, graphScale.value - scaleStep)
499
- applyScale()
500
- }
501
- }
502
-
503
- // 应用缩放比例
504
- function applyScale() {
505
- if (!graphContainer.value) return
506
-
507
- const svgElement = graphContainer.value.querySelector('svg')
508
- if (svgElement) {
509
- svgElement.style.transform = `scale(${graphScale.value})`
510
- svgElement.style.transformOrigin = 'top left'
511
- }
512
- }
513
-
514
- // 自适应图表大小
515
- function fitGraphToContainer() {
516
- if (!graphContainer.value) return
517
-
518
- const svgElement = graphContainer.value.querySelector('svg')
519
- if (!svgElement) return
520
-
521
- // 获取SVG和容器的宽度
522
- const svgWidth = svgElement.getBoundingClientRect().width / graphScale.value
523
- const containerWidth = graphContainer.value.clientWidth
524
-
525
- // 计算合适的缩放比例
526
- if (svgWidth > containerWidth) {
527
- // 如果SVG宽度大于容器,需要缩小
528
- graphScale.value = Math.max(minScale, containerWidth / svgWidth)
529
- } else {
530
- // 否则恢复到默认比例
531
- graphScale.value = 1
532
- }
533
-
534
- applyScale()
535
- }
536
-
537
- // 查看提交详情
538
- async function viewCommitDetail(commit: LogItem | null) {
539
- if (!commit) return
540
-
541
- selectedCommit.value = commit
542
- commitDetailVisible.value = true
543
- isLoadingCommitDetail.value = true
544
- commitFiles.value = []
545
- commitDiff.value = ''
546
- selectedCommitFile.value = ''
547
-
548
- // 调试输出当前提交对象的所有属性
549
- console.log('提交详情对象:', JSON.stringify(commit, null, 2))
550
- console.log('哈希值类型和长度:', typeof commit.hash, commit.hash ? commit.hash.length : 0)
551
- console.log('提交信息类型和长度:', typeof commit.message, commit.message ? commit.message.length : 0)
552
- console.log('提交分支:', commit.branch)
553
-
554
- try {
555
- console.log(`获取提交详情: ${commit.hash}`)
556
-
557
- // 确保哈希值有效
558
- if (!commit.hash || commit.hash.length < 7) {
559
- console.error('无效的提交哈希值:', commit.hash)
560
- commitDiff.value = '无效的提交哈希值'
561
- isLoadingCommitDetail.value = false
562
- return
563
- }
564
-
565
- // 获取提交的变更文件列表
566
- const filesResponse = await fetch(`/api/commit-files?hash=${commit.hash}`)
567
- console.log('API响应状态: ', filesResponse.status)
568
- const filesData = await filesResponse.json()
569
- console.log('文件列表数据: ', filesData)
570
-
571
- if (filesData.success && Array.isArray(filesData.files)) {
572
- commitFiles.value = filesData.files
573
-
574
- // 如果有文件,自动加载第一个文件的差异
575
- if (commitFiles.value.length > 0) {
576
- await getCommitFileDiff(commit.hash, commitFiles.value[0])
577
- } else {
578
- console.log('没有找到变更文件')
579
- commitDiff.value = '该提交没有变更文件'
580
- }
581
- } else {
582
- console.error('获取提交文件列表失败:', filesData.error || '未知错误')
583
- commitDiff.value = `获取文件列表失败: ${filesData.error || '未知错误'}`
584
- }
585
- } catch (error) {
586
- console.error('获取提交详情失败:', error)
587
- commitDiff.value = `获取提交详情失败: ${(error as Error).message}`
588
- } finally {
589
- isLoadingCommitDetail.value = false
590
- }
591
- }
592
-
593
- // 获取提交中特定文件的差异
594
- async function getCommitFileDiff(hash: string, filePath: string) {
595
- isLoadingCommitDetail.value = true
596
- selectedCommitFile.value = filePath
597
-
598
- try {
599
- console.log(`获取文件差异: hash=${hash}, file=${filePath}`)
600
- const diffResponse = await fetch(`/api/commit-file-diff?hash=${hash}&file=${encodeURIComponent(filePath)}`)
601
- console.log('差异API响应状态: ', diffResponse.status)
602
- const diffData = await diffResponse.json()
603
- console.log('差异数据: ', diffData.success, typeof diffData.diff)
604
-
605
- if (diffData.success) {
606
- commitDiff.value = diffData.diff || '没有变更内容'
607
- } else {
608
- console.error('获取差异失败: ', diffData.error)
609
- commitDiff.value = `获取差异失败: ${diffData.error || '未知错误'}`
610
- }
611
- } catch (error) {
612
- console.error('获取文件差异失败:', error)
613
- commitDiff.value = `获取差异失败: ${(error as Error).message}`
614
- } finally {
615
- isLoadingCommitDetail.value = false
616
- }
617
- }
618
-
619
- // 格式化差异内容,添加颜色
620
- function formatDiff(diffText: string) {
621
- if (!diffText) return '';
622
-
623
- // 将差异内容按行分割
624
- const lines = diffText.split('\n');
625
-
626
- // 转义 HTML 标签的函数
627
- function escapeHtml(text: string) {
628
- return text
629
- .replace(/&/g, '&amp;')
630
- .replace(/</g, '&lt;')
631
- .replace(/>/g, '&gt;')
632
- .replace(/"/g, '&quot;')
633
- .replace(/'/g, '&#039;');
634
- }
635
-
636
- // 为每行添加适当的 CSS 类
637
- return lines.map(line => {
638
- // 先转义 HTML 标签,再添加样式
639
- const escapedLine = escapeHtml(line);
640
-
641
- if (line.startsWith('diff --git')) {
642
- return `<div class="diff-header">${escapedLine}</div>`;
643
- } else if (line.startsWith('---')) {
644
- return `<div class="diff-old-file">${escapedLine}</div>`;
645
- } else if (line.startsWith('+++')) {
646
- return `<div class="diff-new-file">${escapedLine}</div>`;
647
- } else if (line.startsWith('@@')) {
648
- return `<div class="diff-hunk-header">${escapedLine}</div>`;
649
- } else if (line.startsWith('+')) {
650
- return `<div class="diff-added">${escapedLine}</div>`;
651
- } else if (line.startsWith('-')) {
652
- return `<div class="diff-removed">${escapedLine}</div>`;
653
- } else {
654
- return `<div class="diff-context">${escapedLine}</div>`;
655
- }
656
- }).join('');
657
- }
658
-
659
- // 格式化提交信息,支持多行显示
660
- function formatCommitMessage(message: string) {
661
- if (!message) return '(无提交信息)';
662
-
663
- // 调试输出
664
- console.log('格式化前的提交信息:', message)
665
- console.log('提交信息中的换行符数量:', (message.match(/\n/g) || []).length)
666
-
667
- // 返回格式化后的提交信息,保留换行符
668
- return message.trim();
669
- }
670
-
671
- // 加载更多日志
672
- function loadMoreLogs() {
673
- if (!hasMoreData.value || isLoadingMore.value || isLoading.value) return
674
-
675
- console.log(`加载更多日志,页码: ${currentPage.value + 1}`)
676
- loadLog(showAllCommits.value, currentPage.value + 1)
677
- }
678
-
679
- // 重置筛选条件并重新加载数据
680
- function resetFilters() {
681
- authorFilter.value = []
682
- branchFilter.value = []
683
- messageFilter.value = ''
684
- dateRangeFilter.value = null
685
-
686
- // 重置筛选后重新加载数据
687
- currentPage.value = 1
688
- loadLog(showAllCommits.value, 1)
689
- }
690
-
691
- // 应用筛选条件
692
- function applyFilters() {
693
- // 应用筛选时重置到第一页
694
- currentPage.value = 1
695
- loadLog(showAllCommits.value, 1)
696
- }
697
-
698
- // 添加获取所有作者的函数
699
- async function fetchAllAuthors() {
700
- try {
701
- console.log('获取所有可用作者...')
702
- const response = await fetch('/api/authors')
703
- const result = await response.json()
704
-
705
- if (result.success && Array.isArray(result.authors)) {
706
- // 更新可用作者列表
707
- availableAuthors.value = result.authors.sort()
708
- console.log(`获取到${availableAuthors.value.length}位作者`)
709
- } else {
710
- // 如果获取作者列表失败,但正常获取了日志
711
- // 从当前加载的日志中提取作者列表作为备选
712
- console.warn('从API获取作者列表失败,将从现有日志中提取作者列表')
713
- extractAuthorsFromLogs()
714
- }
715
- } catch (error) {
716
- console.error('获取作者列表失败:', error)
717
- // 从当前加载的日志中提取作者列表作为备选
718
- extractAuthorsFromLogs()
719
- }
720
- }
721
-
722
- // 从已加载的日志中提取作者列表
723
- function extractAuthorsFromLogs() {
724
- const authors = new Set<string>()
725
- logs.value.forEach(log => {
726
- if (log.author) {
727
- authors.add(log.author)
728
- }
729
- })
730
- availableAuthors.value = Array.from(authors).sort()
731
- console.log(`从现有日志中提取了${availableAuthors.value.length}位作者`)
732
- }
733
-
734
- // // 添加获取所有分支的函数
735
- // async function fetchAllBranches() {
736
- // try {
737
- // console.log('获取所有可用分支...')
738
-
739
- // // 直接调用 gitStore 中的方法获取分支列表
740
- // await gitStore.getAllBranches()
741
-
742
- // // 从 gitStore 中获取分支列表
743
- // if (gitStore.allBranches.length > 0) {
744
- // // 更新可用分支列表
745
- // availableBranches.value = [...gitStore.allBranches].sort()
746
- // console.log(`获取到${availableBranches.value.length}个分支`)
747
- // } else {
748
- // console.warn('gitStore中没有分支数据')
749
- // }
750
- // } catch (error) {
751
- // console.error('获取分支列表失败:', error)
752
- // extractBranchesFromLogs()
753
- // }
754
- // }
755
-
756
-
757
-
758
- // 处理右键菜单事件
759
- function handleContextMenu(row: LogItem, column: any, event: MouseEvent) {
760
- console.log('handleContextMenu', row, column, event)
761
- // 阻止默认右键菜单
762
- event.preventDefault()
763
-
764
- // 设置右键菜单位置
765
- contextMenuTop.value = event.clientY
766
- contextMenuLeft.value = event.clientX
767
-
768
- // 设置选中的提交
769
- selectedContextCommit.value = row
770
-
771
- // 显示右键菜单
772
- contextMenuVisible.value = true
773
-
774
- // 点击其他地方时隐藏菜单
775
- const hideContextMenu = () => {
776
- contextMenuVisible.value = false
777
- document.removeEventListener('click', hideContextMenu)
778
- }
779
-
780
- // 添加点击监听器
781
- setTimeout(() => {
782
- document.addEventListener('click', hideContextMenu)
783
- }, 0)
784
- }
785
-
786
- // 撤销提交 (Revert)
787
- async function revertCommit(commit: LogItem | null) {
788
- if (!commit) return
789
-
790
- try {
791
- // 询问确认
792
- await ElMessageBox.confirm(
793
- `确定要撤销提交 ${commit.hash.substring(0, 7)} 吗?这将创建一个新的提交来撤销这次提交的更改。`,
794
- '撤销提交确认',
795
- {
796
- confirmButtonText: '确认',
797
- cancelButtonText: '取消',
798
- type: 'warning'
799
- }
800
- )
801
-
802
- // 发送请求
803
- const response = await fetch('/api/revert-commit', {
804
- method: 'POST',
805
- headers: {
806
- 'Content-Type': 'application/json'
807
- },
808
- body: JSON.stringify({ hash: commit.hash })
809
- })
810
-
811
- const result = await response.json()
812
-
813
- if (result.success) {
814
- ElMessage.success(result.message || '已成功撤销提交')
815
- // 刷新日志
816
- refreshLog()
817
- // 刷新Git状态
818
- gitLogStore.fetchStatus()
819
- // 添加: 刷新分支状态
820
- gitStore.getBranchStatus()
821
- } else {
822
- ElMessage.error(result.error || '撤销提交失败')
823
- }
824
- } catch (error: any) {
825
- if (error !== 'cancel') {
826
- console.error('撤销提交出错:', error)
827
- ElMessage.error('撤销提交失败: ' + (error.message || error))
828
- }
829
- }
830
- }
831
-
832
- // Cherry-pick提交
833
- async function cherryPickCommit(commit: LogItem | null) {
834
- if (!commit) return
835
-
836
- try {
837
- // 询问确认
838
- await ElMessageBox.confirm(
839
- `确定要将提交 ${commit.hash.substring(0, 7)} Cherry-Pick 到当前分支吗?`,
840
- 'Cherry-Pick确认',
841
- {
842
- confirmButtonText: '确认',
843
- cancelButtonText: '取消',
844
- type: 'warning'
845
- }
846
- )
847
-
848
- // 发送请求
849
- const response = await fetch('/api/cherry-pick-commit', {
850
- method: 'POST',
851
- headers: {
852
- 'Content-Type': 'application/json'
853
- },
854
- body: JSON.stringify({ hash: commit.hash })
855
- })
856
-
857
- const result = await response.json()
858
-
859
- if (result.success) {
860
- ElMessage.success(result.message || '已成功Cherry-Pick提交')
861
- // 刷新日志
862
- refreshLog()
863
- // 刷新Git状态
864
- gitLogStore.fetchStatus()
865
- // 添加: 刷新分支状态
866
- gitStore.getBranchStatus()
867
- } else {
868
- ElMessage.error(result.error || 'Cherry-Pick提交失败')
869
- }
870
- } catch (error: any) {
871
- if (error !== 'cancel') {
872
- console.error('Cherry-Pick提交出错:', error)
873
- ElMessage.error('Cherry-Pick提交失败: ' + (error.message || error))
874
- }
875
- }
876
- }
877
- </script>
878
-
879
- <template>
880
- <div class="card">
881
- <!-- 添加刷新提示,移到最外层 -->
882
- <div v-if="logRefreshed" class="refresh-notification">
883
- 提交历史已刷新
884
- </div>
885
-
886
- <!-- 固定头部区域 -->
887
- <div class="log-header">
888
- <div class="header-left">
889
- <h2>提交历史</h2>
890
- <!-- <el-tag type="info" effect="plain" size="small" class="record-count" v-if="!showGraphView">
891
- <template #icon>
892
- <el-icon><Document /></el-icon>
893
- </template>
894
- {{ filteredLogs.length }}/{{ logs.length }}
895
- <el-tag v-if="!showAllCommits" type="warning" size="small" effect="plain" style="margin-left: 5px">
896
- 分页加载 (每页100条)
897
- </el-tag>
898
- <el-tag v-else type="success" size="small" effect="plain" style="margin-left: 5px">
899
- 全部
900
- </el-tag>
901
- </el-tag> -->
902
- </div>
903
-
904
- <div class="log-actions">
905
- <!-- 筛选按钮移到这里 -->
906
- <el-button
907
- v-if="!showGraphView"
908
- :type="filterVisible ? 'primary' : 'default'"
909
- size="small"
910
- @click="filterVisible = !filterVisible"
911
- >
912
- <template #icon>
913
- <el-icon><Filter /></el-icon>
914
- </template>
915
- 筛选
916
- <el-badge v-if="filteredLogs.length !== logs.length" :value="filteredLogs.length" class="filter-badge" />
917
- </el-button>
918
-
919
- <!-- 原有的按钮 -->
920
- <el-button
921
- type="primary"
922
- size="small"
923
- @click="toggleViewMode"
924
- >
925
- <template #icon>
926
- <el-icon><component :is="showGraphView ? Document : TrendCharts" /></el-icon>
927
- </template>
928
- {{ showGraphView ? '表格视图' : '图表视图' }}
929
- </el-button>
930
- <el-button
931
- type="primary"
932
- size="small"
933
- @click="toggleAllCommits"
934
- :loading="isLoading"
935
- >
936
- <template #icon>
937
- <el-icon><component :is="showAllCommits ? List : More" /></el-icon>
938
- </template>
939
- {{ showAllCommits ? '显示分页加载 (每页100条)' : '显示所有提交' }}
940
- </el-button>
941
- <el-button
942
- circle
943
- size="small"
944
- @click="refreshLog()"
945
- :loading="isLoading"
946
- :class="{ 'refresh-button-animated': logRefreshed }"
947
- >
948
- <el-icon><RefreshRight /></el-icon>
949
- </el-button>
950
- </div>
951
- </div>
952
-
953
- <!-- 筛选面板放在头部下方,但在内容区域之前 -->
954
- <div v-if="filterVisible && !showGraphView" class="filter-panel-header">
955
- <div class="filter-form">
956
- <div class="filter-item">
957
- <div class="filter-label">作者:</div>
958
- <el-select
959
- v-model="authorFilter"
960
- placeholder="选择作者"
961
- multiple
962
- clearable
963
- filterable
964
- class="filter-input"
965
- size="small"
966
- >
967
- <el-option
968
- v-for="author in availableAuthors"
969
- :key="author"
970
- :label="author"
971
- :value="author"
972
- />
973
- </el-select>
974
- </div>
975
-
976
- <div class="filter-item">
977
- <div class="filter-label">分支:</div>
978
- <el-select
979
- v-model="branchFilter"
980
- placeholder="选择分支"
981
- multiple
982
- clearable
983
- filterable
984
- class="filter-input"
985
- size="small"
986
- >
987
- <el-option
988
- v-for="branch in availableBranches"
989
- :key="branch"
990
- :label="branch"
991
- :value="branch"
992
- />
993
- </el-select>
994
- </div>
995
-
996
- <div class="filter-item">
997
- <div class="filter-label">提交信息包含:</div>
998
- <el-input
999
- v-model="messageFilter"
1000
- placeholder="关键词"
1001
- clearable
1002
- class="filter-input"
1003
- size="small"
1004
- />
1005
- </div>
1006
-
1007
- <div class="filter-item">
1008
- <div class="filter-label">日期范围:</div>
1009
- <el-date-picker
1010
- v-model="dateRangeFilter"
1011
- type="daterange"
1012
- range-separator="至"
1013
- start-placeholder="开始日期"
1014
- end-placeholder="结束日期"
1015
- format="YYYY-MM-DD"
1016
- value-format="YYYY-MM-DD"
1017
- class="filter-input date-range"
1018
- size="small"
1019
- />
1020
- </div>
1021
-
1022
- <div class="filter-actions">
1023
- <el-button type="primary" size="small" @click="applyFilters">应用筛选</el-button>
1024
- <el-button type="info" size="small" @click="resetFilters">重置</el-button>
1025
- </div>
1026
- </div>
1027
- </div>
1028
-
1029
- <!-- 内容区域,添加上边距以避免被固定头部遮挡 -->
1030
- <div class="content-area" :class="{'with-filter': filterVisible && !showGraphView}">
1031
- <div v-if="errorMessage">{{ errorMessage }}</div>
1032
- <div v-else>
1033
- <!-- 图表视图 -->
1034
- <div v-if="showGraphView" class="graph-view">
1035
- <div class="commit-count" v-if="logsData.length > 0">
1036
- 显示 {{ logsData.length }} 条提交记录 {{ showAllCommits ? '(全部)' : '(分页加载,每页100条)' }}
1037
- </div>
1038
-
1039
- <!-- 添加缩放控制 -->
1040
- <div class="graph-controls">
1041
- <div class="zoom-controls">
1042
- <el-button
1043
- type="primary"
1044
- circle
1045
- size="small"
1046
- @click="zoomOut"
1047
- :disabled="graphScale <= minScale"
1048
- >
1049
- <el-icon><ZoomOut /></el-icon>
1050
- </el-button>
1051
-
1052
- <el-slider
1053
- v-model="graphScale"
1054
- :min="minScale"
1055
- :max="maxScale"
1056
- :step="scaleStep"
1057
- @change="applyScale"
1058
- class="zoom-slider"
1059
- />
1060
-
1061
- <el-button
1062
- type="primary"
1063
- circle
1064
- size="small"
1065
- @click="zoomIn"
1066
- :disabled="graphScale >= maxScale"
1067
- >
1068
- <el-icon><ZoomIn /></el-icon>
1069
- </el-button>
1070
-
1071
- <el-button
1072
- type="primary"
1073
- size="small"
1074
- @click="fitGraphToContainer"
1075
- >
1076
- 自适应大小
1077
- </el-button>
1078
- </div>
1079
-
1080
- <div class="scale-info">
1081
- 缩放: {{ Math.round(graphScale * 100) }}%
1082
- </div>
1083
- </div>
1084
-
1085
- <div ref="graphContainer" class="graph-container"></div>
1086
- </div>
1087
-
1088
- <!-- 表格视图 -->
1089
- <div v-else class="table-view-container">
1090
- <el-table ref="tableRef" :data="filteredLogs" stripe border v-loading="isLoading" class="log-table" :empty-text="isLoading ? '加载中...' : '没有匹配的提交记录'" height="500" @row-contextmenu="handleContextMenu" >
1091
- <el-table-column label="提交哈希" width="100" resizable>
1092
- <template #default="scope">
1093
- <span class="commit-hash" @click="viewCommitDetail(scope.row)">{{ scope.row.hash.substring(0, 7) }}</span>
1094
- </template>
1095
- </el-table-column>
1096
- <el-table-column prop="date" label="日期" width="120" resizable />
1097
- <el-table-column label="作者" width="120" resizable>
1098
- <template #default="scope">
1099
- <el-tooltip :content="scope.row.email" placement="top" :hide-after="1000">
1100
- <span class="author-name">{{ scope.row.author }}</span>
1101
- </el-tooltip>
1102
- </template>
1103
- </el-table-column>
1104
- <el-table-column label="分支" width="180" resizable>
1105
- <template #default="scope">
1106
- <div v-if="scope.row.branch" class="branch-container">
1107
- <el-tag
1108
- v-for="(ref, index) in scope.row.branch.split(',')"
1109
- :key="index"
1110
- size="small"
1111
- :type="getBranchTagType(ref)"
1112
- class="branch-tag"
1113
- >
1114
- {{ formatBranchName(ref) }}
1115
- </el-tag>
1116
- </div>
1117
- </template>
1118
- </el-table-column>
1119
- <el-table-column prop="message" label="提交信息" min-width="250" />
1120
- </el-table>
1121
-
1122
- <!-- 添加底部加载状态和加载更多按钮 -->
1123
- <div v-if="!showAllCommits" class="load-more-container">
1124
- <!-- 显示加载状态和页码信息 -->
1125
- <div class="pagination-info">
1126
- <span>第 {{ currentPage }} 页 {{ totalCommits > 0 ? `/ 共 ${Math.ceil(totalCommits / 100) || 1} 页` : '' }} (总计 {{ totalCommits }} 条记录)</span>
1127
- </div>
1128
-
1129
- <div v-if="isLoadingMore" class="loading-more">
1130
- <div class="loading-spinner"></div>
1131
- <span>加载更多...</span>
1132
- </div>
1133
- <div v-else-if="hasMoreData" class="load-more-button" @click="loadMoreLogs">
1134
- <span>加载更多</span>
1135
- </div>
1136
- <div v-else class="no-more-data">
1137
- <span>没有更多数据了</span>
1138
- <span v-if="logs.length > 0" class="total-loaded">(已加载 {{ logs.length }} 条记录)</span>
1139
- </div>
1140
- </div>
1141
- </div>
1142
- </div>
1143
- </div>
1144
-
1145
- <!-- 提交详情弹窗 -->
1146
- <el-dialog
1147
- v-model="commitDetailVisible"
1148
- :title="`提交详情: ${selectedCommit?.hash ? selectedCommit.hash.substring(0, 7) : '未知'}`"
1149
- width="80%"
1150
- destroy-on-close
1151
- class="commit-detail-dialog"
1152
- >
1153
- <div v-loading="isLoadingCommitDetail" class="commit-detail-container">
1154
- <!-- 提交基本信息 -->
1155
- <div v-if="selectedCommit" class="commit-info">
1156
- <div class="commit-info-header">
1157
- <div class="info-item">
1158
- <span class="item-label">哈希:</span>
1159
- <span class="item-value">{{ selectedCommit.hash }}</span>
1160
- </div>
1161
- <div class="info-item">
1162
- <span class="item-label">作者:</span>
1163
- <span class="item-value">{{ selectedCommit.author }} &lt;{{ selectedCommit.email }}&gt;</span>
1164
- </div>
1165
- <div class="info-item">
1166
- <span class="item-label">日期:</span>
1167
- <span class="item-value">{{ selectedCommit.date }}</span>
1168
- </div>
1169
- </div>
1170
- <div class="commit-message-container">
1171
- <div class="message-label">提交信息:</div>
1172
- <div class="message-content" v-html="formatCommitMessage(selectedCommit.message).replace(/\n/g, '<br>')"></div>
1173
- </div>
1174
- </div>
1175
-
1176
- <!-- 变更文件列表和差异 -->
1177
- <div class="commit-files-diff">
1178
- <div class="files-list">
1179
- <h3>变更文件</h3>
1180
- <el-empty v-if="commitFiles.length === 0" description="没有找到变更文件"></el-empty>
1181
- <ul v-else>
1182
- <li
1183
- v-for="file in commitFiles"
1184
- :key="file"
1185
- :class="{ 'active-file': file === selectedCommitFile }"
1186
- @click="getCommitFileDiff(selectedCommit!.hash, file)"
1187
- >
1188
- {{ file }}
1189
- </li>
1190
- </ul>
1191
- </div>
1192
- <div class="file-diff">
1193
- <h3 v-if="selectedCommitFile">文件差异: {{ selectedCommitFile }}</h3>
1194
- <h3 v-else>文件差异</h3>
1195
- <el-empty v-if="!commitDiff && !isLoadingCommitDetail" description="选择文件查看差异"></el-empty>
1196
- <div v-else-if="commitDiff" v-html="formatDiff(commitDiff)" class="diff-content"></div>
1197
- </div>
1198
- </div>
1199
- </div>
1200
- </el-dialog> </div> <!-- 添加右键菜单 --> <div v-show="contextMenuVisible" class="context-menu" :style="{ top: contextMenuTop + 'px', left: contextMenuLeft + 'px' }" > <div class="context-menu-item" @click="viewCommitDetail(selectedContextCommit)"> <i class="el-icon-view"></i> 查看详情 </div> <div class="context-menu-item" @click="revertCommit(selectedContextCommit)"> <i class="el-icon-delete"></i> 撤销提交 (Revert) </div> <div class="context-menu-item" @click="cherryPickCommit(selectedContextCommit)"> <i class="el-icon-edit"></i> Cherry-Pick 到当前分支 </div> </div></template><style scoped>
1201
- .card {
1202
- background-color: white;
1203
- border-radius: 8px;
1204
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
1205
- height: 100%;
1206
- width: 100%;
1207
- display: flex;
1208
- flex-direction: column;
1209
- border: 1px solid rgba(0, 0, 0, 0.03);
1210
- overflow: hidden;
1211
- }
1212
-
1213
- .log-header {
1214
- display: flex;
1215
- justify-content: space-between;
1216
- align-items: center;
1217
- margin-bottom: 0;
1218
- padding: 8px 16px;
1219
- background-color: white;
1220
- border-bottom: 1px solid #f0f0f0;
1221
- position: sticky;
1222
- top: 0;
1223
- z-index: 100;
1224
- height: 36px;
1225
- flex-shrink: 0; /* 防止头部被压缩 */
1226
- }
1227
-
1228
- .header-left {
1229
- display: flex;
1230
- align-items: center;
1231
- gap: 8px;
1232
- }
1233
-
1234
- .log-header h2 {
1235
- margin: 0;
1236
- font-size: 16px;
1237
- font-weight: 500;
1238
- }
1239
-
1240
- .log-actions {
1241
- display: flex;
1242
- gap: 8px;
1243
- }
1244
-
1245
- .content-area {
1246
- padding: 10px 0;
1247
- flex: 1;
1248
- min-height: 100px;
1249
- height: calc(100% - 52px);
1250
- display: flex;
1251
- flex-direction: column;
1252
- }
1253
-
1254
- .content-area.with-filter {
1255
- height: calc(100% - 52px - 60px); /* 减去header高度和filter高度 */
1256
- }
1257
-
1258
- /* 确保内容区域内的直接子元素占满高度 */
1259
- .content-area > div {
1260
- flex: 1;
1261
- display: flex;
1262
- flex-direction: column;
1263
- }
1264
-
1265
- /* 优化表格区域 */
1266
- .el-table {
1267
- --el-table-border-color: #f0f0f0;
1268
- --el-table-header-bg-color: #f8f9fa;
1269
- border-radius: 4px;
1270
- overflow: hidden;
1271
- }
1272
-
1273
- /* 统一按钮间距 */
1274
- .log-actions {
1275
- display: flex;
1276
- gap: 12px;
1277
- }
1278
-
1279
- .branch-container {
1280
- display: flex;
1281
- flex-wrap: wrap;
1282
- gap: 4px;
1283
- }
1284
-
1285
- .branch-tag {
1286
- margin-right: 4px;
1287
- }
1288
-
1289
- .commit-count {
1290
- margin-bottom: 10px;
1291
- font-size: 14px;
1292
- color: #606266;
1293
- text-align: right;
1294
- }
1295
-
1296
- .graph-view {
1297
- width: 100%;
1298
- flex: 1;
1299
- display: flex;
1300
- flex-direction: column;
1301
- overflow-y: auto;
1302
- }
1303
-
1304
- .graph-container {
1305
- width: 100%;
1306
- flex: 1;
1307
- min-height: 500px;
1308
- border: 1px solid #ebeef5;
1309
- border-radius: 4px;
1310
- padding: 10px;
1311
- background-color: #fff;
1312
- position: relative;
1313
- }
1314
-
1315
- .graph-container svg {
1316
- transform-origin: top left;
1317
- transition: transform 0.2s ease;
1318
- }
1319
-
1320
- .graph-controls {
1321
- display: flex;
1322
- justify-content: space-between;
1323
- align-items: center;
1324
- margin-bottom: 10px;
1325
- }
1326
-
1327
- .zoom-controls {
1328
- display: flex;
1329
- gap: 8px;
1330
- }
1331
-
1332
- .zoom-slider {
1333
- width: 200px;
1334
- }
1335
-
1336
- .scale-info {
1337
- font-size: 14px;
1338
- color: #606266;
1339
- }
1340
-
1341
- .refresh-button-animated {
1342
- animation: pulse 1s;
1343
- }
1344
-
1345
- .refresh-notification {
1346
- background-color: #f0f9eb;
1347
- color: #67c23a;
1348
- padding: 10px 15px;
1349
- border-radius: 8px;
1350
- font-size: 14px;
1351
- border-left: 4px solid #67c23a;
1352
- animation: fadeOut 2s forwards;
1353
- position: fixed;
1354
- top: 20px;
1355
- right: 20px;
1356
- z-index: 9999;
1357
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
1358
- max-width: 300px;
1359
- text-align: center;
1360
- }
1361
-
1362
- @keyframes pulse {
1363
- 0% { transform: scale(1); }
1364
- 50% { transform: scale(1.2); }
1365
- 100% { transform: scale(1); }
1366
- }
1367
-
1368
- @keyframes fadeOut {
1369
- 0% { opacity: 0; transform: translateY(-20px); }
1370
- 20% { opacity: 1; transform: translateY(0); }
1371
- 80% { opacity: 1; }
1372
- 100% { opacity: 0; }
1373
- }
1374
-
1375
- .author-name {
1376
- cursor: pointer;
1377
- white-space: nowrap;
1378
- overflow: hidden;
1379
- text-overflow: ellipsis;
1380
- display: inline-block;
1381
- max-width: 100%;
1382
- }
1383
-
1384
- .commit-hash {
1385
- cursor: pointer;
1386
- color: #409EFF;
1387
- font-family: monospace;
1388
- }
1389
-
1390
- .commit-hash:hover {
1391
- text-decoration: underline;
1392
- }
1393
-
1394
- .commit-detail-container {
1395
- display: flex;
1396
- flex-direction: column;
1397
- gap: 20px;
1398
- }
1399
-
1400
- .commit-info {
1401
- padding: 12px;
1402
- background-color: #f5f7fa;
1403
- border-radius: 8px;
1404
- font-size: 14px;
1405
- display: flex;
1406
- flex-direction: column;
1407
- gap: 12px;
1408
- }
1409
-
1410
- .commit-info-header {
1411
- display: flex;
1412
- flex-wrap: wrap;
1413
- gap: 15px;
1414
- align-items: center;
1415
- background-color: #fff;
1416
- padding: 10px;
1417
- border-radius: 4px;
1418
- border: 1px solid #e4e7ed;
1419
- }
1420
-
1421
- .info-item {
1422
- display: flex;
1423
- align-items: center;
1424
- gap: 5px;
1425
- }
1426
-
1427
- .item-label {
1428
- font-weight: bold;
1429
- color: #606266;
1430
- white-space: nowrap;
1431
- }
1432
-
1433
- .item-value {
1434
- color: #333;
1435
- word-break: break-all;
1436
- }
1437
-
1438
- .commit-message-container {
1439
- display: flex;
1440
- flex-direction: column;
1441
- gap: 5px;
1442
- }
1443
-
1444
- .message-label {
1445
- font-weight: bold;
1446
- color: #606266;
1447
- }
1448
-
1449
- .message-content {
1450
- background-color: #fff;
1451
- padding: 12px;
1452
- border-radius: 4px;
1453
- font-family: monospace;
1454
- white-space: pre-wrap;
1455
- border-left: 4px solid #409EFF;
1456
- line-height: 1.5;
1457
- border: 1px solid #e4e7ed;
1458
- border-left: 4px solid #409EFF;
1459
- }
1460
-
1461
- .commit-files-diff {
1462
- margin-top: 5px;
1463
- display: flex;
1464
- gap: 20px;
1465
- height: 60vh;
1466
- }
1467
-
1468
- .files-list {
1469
- width: 25%;
1470
- overflow-y: auto;
1471
- background-color: #f5f7fa;
1472
- border-radius: 8px;
1473
- padding: 10px;
1474
- }
1475
-
1476
- .files-list h3 {
1477
- margin-top: 0;
1478
- padding-bottom: 10px;
1479
- border-bottom: 1px solid #dcdfe6;
1480
- font-size: 16px;
1481
- }
1482
-
1483
- .files-list ul {
1484
- list-style: none;
1485
- padding: 0;
1486
- margin: 0;
1487
- }
1488
-
1489
- .files-list li {
1490
- padding: 8px 10px;
1491
- cursor: pointer;
1492
- border-radius: 4px;
1493
- margin-bottom: 5px;
1494
- font-family: monospace;
1495
- white-space: nowrap;
1496
- overflow: hidden;
1497
- text-overflow: ellipsis;
1498
- font-size: 13px;
1499
- }
1500
-
1501
- .files-list li:hover {
1502
- background-color: #ecf5ff;
1503
- }
1504
-
1505
- .files-list li.active-file {
1506
- background-color: #409eff;
1507
- color: white;
1508
- }
1509
-
1510
- .file-diff {
1511
- flex: 1;
1512
- display: flex;
1513
- flex-direction: column;
1514
- background-color: #f5f7fa;
1515
- border-radius: 8px;
1516
- padding: 10px;
1517
- overflow: hidden;
1518
- }
1519
-
1520
- .file-diff h3 {
1521
- margin-top: 0;
1522
- padding-bottom: 10px;
1523
- border-bottom: 1px solid #dcdfe6;
1524
- font-size: 16px;
1525
- }
1526
-
1527
- .diff-content {
1528
- flex: 1;
1529
- overflow-y: auto;
1530
- background-color: #fff;
1531
- padding: 10px;
1532
- border-radius: 4px;
1533
- font-family: monospace;
1534
- font-size: 13px;
1535
- line-height: 1.5;
1536
- }
1537
-
1538
- .diff-header {
1539
- font-weight: bold;
1540
- color: #409EFF;
1541
- }
1542
-
1543
- .diff-old-file {
1544
- color: #E6A23C;
1545
- }
1546
-
1547
- .diff-new-file {
1548
- color: #67C23A;
1549
- }
1550
-
1551
- .diff-hunk-header {
1552
- font-weight: bold;
1553
- color: #409EFF;
1554
- }
1555
-
1556
- .diff-added {
1557
- background-color: #f0f9eb;
1558
- color: #67C23A;
1559
- }
1560
-
1561
- .diff-removed {
1562
- background-color: #fef2f2;
1563
- color: #F56C6C;
1564
- }
1565
-
1566
- .diff-context {
1567
- background-color: #f5f7fa;
1568
- }
1569
-
1570
- /* 减小对话框的顶部边距 */
1571
- :deep(.commit-detail-dialog) {
1572
- --el-dialog-margin-top: 7vh;
1573
- }
1574
-
1575
- .history-controls {
1576
- display: flex;
1577
- justify-content: space-between;
1578
- align-items: center;
1579
- margin-bottom: 15px;
1580
- padding: 0;
1581
- position: sticky;
1582
- top: 52px; /* 与 log-header 的高度匹配 */
1583
- z-index: 90;
1584
- background-color: white;
1585
- padding: 5px 0;
1586
- transition: box-shadow 0.3s ease, background-color 0.3s ease, padding 0.2s ease;
1587
- }
1588
-
1589
- /* 当滚动时添加微妙的阴影效果 */
1590
- .content-area:not(:hover) .history-controls:not(:hover) {
1591
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
1592
- }
1593
-
1594
- .history-stats {
1595
- display: flex;
1596
- align-items: center;
1597
- }
1598
-
1599
- .record-count {
1600
- display: flex;
1601
- align-items: center;
1602
- height: 36px;
1603
- padding-left: 15px;
1604
- padding-right: 15px;
1605
- }
1606
-
1607
- .record-count :deep(.el-icon) {
1608
- margin-right: 6px;
1609
- }
1610
-
1611
- .filter-badge :deep(.el-badge__content) {
1612
- background-color: #409EFF;
1613
- }
1614
-
1615
- .filter-panel {
1616
- background-color: #f5f7fa;
1617
- border-radius: 8px;
1618
- padding: 15px;
1619
- margin-bottom: 15px;
1620
- border: 1px solid #e4e7ed;
1621
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
1622
- position: sticky;
1623
- top: 98px; /* history-controls的高度(36px) + padding(10px) + log-header的高度(52px) */
1624
- z-index: 89; /* 比history-controls低一点 */
1625
- transition: box-shadow 0.3s ease, background-color 0.3s ease, transform 0.2s ease;
1626
- }
1627
-
1628
- /* 当滚动时增强视觉效果 */
1629
- .content-area:not(:hover) .filter-panel:not(:hover) {
1630
- box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1);
1631
- }
1632
-
1633
- .filter-panel:hover {
1634
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
1635
- }
1636
-
1637
- .filter-form {
1638
- display: flex;
1639
- flex-wrap: wrap;
1640
- gap: 15px;
1641
- align-items: flex-end;
1642
- }
1643
-
1644
- .filter-item {
1645
- display: flex;
1646
- flex-direction: column;
1647
- gap: 5px;
1648
- }
1649
-
1650
- .filter-label {
1651
- font-size: 13px;
1652
- color: #606266;
1653
- font-weight: bold;
1654
- }
1655
-
1656
- .filter-input {
1657
- width: 200px;
1658
- }
1659
-
1660
- .filter-input.date-range {
1661
- width: 350px;
1662
- }
1663
-
1664
- .filter-actions {
1665
- display: flex;
1666
- align-items: center;
1667
- gap: 10px;
1668
- }
1669
-
1670
- /* 表格样式 */
1671
- .log-table {
1672
- transition: margin-top 0.3s ease;
1673
- min-height: 200px; /* 确保表格有最小高度 */
1674
- height: 100%; /* 填充可用空间 */
1675
- }
1676
-
1677
- /* 为带筛选面板的表格添加顶部边距 */
1678
- .log-table.has-filter {
1679
- margin-top: 10px;
1680
- }
1681
-
1682
- /* 当控件固定时增加表格上边距 */
1683
- .log-table.has-sticky-controls {
1684
- margin-top: 52px !important; /* controls 高度 + 一些额外空间 */
1685
- }
1686
-
1687
- /* 当筛选面板固定时再增加表格上边距 */
1688
- .log-table.has-sticky-filter {
1689
- margin-top: 140px !important; /* 筛选面板高度 + controls 高度 + 一些额外空间 */
1690
- }
1691
-
1692
- /* 表格为空时的样式 */
1693
- .el-table__empty-block {
1694
- min-height: 200px;
1695
- justify-content: center;
1696
- align-items: center;
1697
- }
1698
-
1699
- /* 确保表格容器占满可用空间 */
1700
- .content-area > div:not(.graph-view) {
1701
- display: flex;
1702
- flex-direction: column;
1703
- height: 100%;
1704
- }
1705
-
1706
- /* 表格视图容器 */
1707
- .table-view-container {
1708
- display: flex;
1709
- flex-direction: column;
1710
- flex: 1;
1711
- height: 100%;
1712
- overflow-y: auto;
1713
- }
1714
-
1715
- .log-table {
1716
- width: 100%;
1717
- flex: 1;
1718
- }
1719
-
1720
- /* 表格容器样式 */
1721
- .table-view-container .el-table {
1722
- flex: 1;
1723
- width: 100%;
1724
- }
1725
-
1726
- .table-view-container .el-table__inner-wrapper {
1727
- width: 100%;
1728
- }
1729
-
1730
- .table-view-container .el-table__body-wrapper {
1731
- width: 100%;
1732
- }
1733
-
1734
- .filter-panel.filter-sticky {
1735
- background-color: rgba(245, 247, 250, 0.97);
1736
- backdrop-filter: blur(4px);
1737
- box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
1738
- border-top: none;
1739
- }
1740
-
1741
- .history-controls.controls-sticky {
1742
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
1743
- background-color: rgba(255, 255, 255, 0.98);
1744
- backdrop-filter: blur(4px);
1745
- padding: 8px 0;
1746
- border-bottom: 1px solid rgba(0, 0, 0, 0.05);
1747
- }
1748
-
1749
- /* 筛选面板头部样式 */
1750
- .filter-panel-header {
1751
- background-color: #f5f7fa;
1752
- padding: 10px 16px;
1753
- border-bottom: 1px solid #e4e7ed;
1754
- position: sticky;
1755
- top: 36px; /* 紧贴log-header下方 */
1756
- z-index: 99;
1757
- transition: all 0.3s ease;
1758
- flex-shrink: 0;
1759
- margin-bottom: 0; /* 移除底部边距 */
1760
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
1761
- }
1762
-
1763
- .filter-panel-header .filter-form {
1764
- display: flex;
1765
- flex-wrap: wrap;
1766
- gap: 10px;
1767
- align-items: flex-end;
1768
- justify-content: flex-start;
1769
- }
1770
-
1771
- .filter-panel-header .filter-item {
1772
- margin-right: 12px;
1773
- }
1774
-
1775
- .filter-panel-header .filter-label {
1776
- font-size: 12px;
1777
- color: #606266;
1778
- margin-bottom: 4px;
1779
- }
1780
-
1781
- .filter-panel-header .filter-input {
1782
- width: 180px;
1783
- }
1784
-
1785
- .filter-panel-header .filter-input.date-range {
1786
- width: 320px;
1787
- }
1788
-
1789
- .content-area.with-filter {
1790
- height: calc(100% - 52px - 60px); /* 减去header高度和filter高度 */
1791
- }
1792
-
1793
- /* 记录计数标签 */
1794
- .record-count {
1795
- display: flex;
1796
- align-items: center;
1797
- height: 24px;
1798
- padding-left: 8px;
1799
- padding-right: 8px;
1800
- margin-left: 8px;
1801
- }
1802
-
1803
- .record-count :deep(.el-icon) {
1804
- margin-right: 4px;
1805
- font-size: 12px;
1806
- }
1807
-
1808
- /* 表格视图容器简化 */
1809
- .table-view-container {
1810
- display: flex;
1811
- flex-direction: column;
1812
- flex: 1;
1813
- min-height: 400px; /* 确保至少有一定高度 */
1814
- }
1815
-
1816
- .log-table {
1817
- width: 100%;
1818
- height: 100%;
1819
- min-height: 300px;
1820
- flex: 1;
1821
- }
1822
-
1823
- /* 重置或移除不再需要的样式 */
1824
- .history-controls,
1825
- .filter-panel {
1826
- display: none; /* 隐藏原来的筛选组件 */
1827
- }
1828
-
1829
- .log-table.has-filter,
1830
- .log-table.has-sticky-controls,
1831
- .log-table.has-sticky-filter {
1832
- margin-top: 0 !important; /* 重置原来的边距 */
1833
- }
1834
-
1835
- /* 添加底部加载更多相关样式 */
1836
- .load-more-container {
1837
- display: flex;
1838
- flex-direction: column;
1839
- align-items: center;
1840
- padding: 15px 0;
1841
- border-top: 1px dashed #ebeef5;
1842
- gap: 10px;
1843
- display: none;
1844
- }
1845
-
1846
- .pagination-info {
1847
- font-size: 13px;
1848
- color: #909399;
1849
- margin-bottom: 5px;
1850
- }
1851
-
1852
- .loading-more {
1853
- display: flex;
1854
- align-items: center;
1855
- color: #909399;
1856
- font-size: 14px;
1857
- }
1858
-
1859
- .loading-spinner {
1860
- width: 20px;
1861
- height: 20px;
1862
- margin-right: 10px;
1863
- border: 2px solid #dcdfe6;
1864
- border-top-color: #409eff;
1865
- border-radius: 50%;
1866
- animation: spinner 1s linear infinite;
1867
- }
1868
-
1869
- @keyframes spinner {
1870
- to {transform: rotate(360deg);}
1871
- }
1872
-
1873
- .load-more-button {
1874
- cursor: pointer;
1875
- color: #409eff;
1876
- font-size: 14px;
1877
- padding: 6px 16px;
1878
- border: 1px solid #d9ecff;
1879
- background-color: #ecf5ff;
1880
- border-radius: 4px;
1881
- transition: all 0.3s;
1882
- }
1883
-
1884
- .load-more-button:hover {
1885
- background-color: #d9ecff;
1886
- }
1887
-
1888
- .no-more-data {
1889
- color: #909399;
1890
- font-size: 14px;
1891
- font-style: italic;
1892
- display: flex;
1893
- flex-direction: column;
1894
- align-items: center;
1895
- }
1896
-
1897
- .total-loaded {
1898
- font-size: 12px;
1899
- margin-top: 5px;
1900
- color: #c0c4cc;
1901
- }
1902
-
1903
- /* 右键菜单样式 */
1904
- .context-menu {
1905
- position: fixed;
1906
- background: white;
1907
- border: 1px solid #dcdfe6;
1908
- border-radius: 4px;
1909
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
1910
- padding: 8px 0;
1911
- z-index: 3000;
1912
- min-width: 180px;
1913
- }
1914
-
1915
- .context-menu-item {
1916
- padding: 8px 16px;
1917
- cursor: pointer;
1918
- font-size: 14px;
1919
- display: flex;
1920
- align-items: center;
1921
- }
1922
-
1923
- .context-menu-item:hover {
1924
- background-color: #f5f7fa;
1925
- }
1926
-
1927
- .context-menu-item i {
1928
- margin-right: 8px;
1929
- }
1930
- </style>
1931
-
1932
- /* 添加表格列调整样式 */
1933
- <style>
1934
- .el-table .el-table__cell .cell {
1935
- word-break: break-all;
1936
- }
1937
- </style>