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,790 +0,0 @@
1
- import { defineStore } from 'pinia'
2
- import { ref, onMounted, onUnmounted } from 'vue'
3
- import { ElMessage } from 'element-plus'
4
- import { useGitStore } from './gitStore'
5
- import { io, Socket } from 'socket.io-client'
6
-
7
- // 定义Git操作间隔时间(毫秒)
8
- const GIT_OPERATION_DELAY = 300
9
-
10
- export const useGitLogStore = defineStore('gitLog', () => {
11
- // 引用gitStore获取仓库状态
12
- const gitStore = useGitStore()
13
-
14
- // 定义socket连接
15
- let socket: Socket | null = null
16
- // 自动更新状态开关
17
- const autoUpdateEnabled = ref(true)
18
-
19
- // 状态
20
- const log = ref<any[]>([])
21
- const status = ref<{ staged: string[], unstaged: string[], untracked: string[] }>({
22
- staged: [],
23
- unstaged: [],
24
- untracked: []
25
- })
26
- // 添加Git状态文本
27
- const statusText = ref('')
28
- // 添加fileList状态用于保存porcelain格式的状态
29
- const fileList = ref<{path: string, type: string}[]>([])
30
- const isLoadingLog = ref(false)
31
- const isLoadingStatus = ref(false)
32
- const isAddingFiles = ref(false)
33
- const isCommiting = ref(false)
34
- const isPushing = ref(false)
35
- const isResetting = ref(false)
36
-
37
- // Socket.io连接处理
38
- function initSocketConnection() {
39
- // 如果已经有socket连接,先断开
40
- if (socket) {
41
- socket.disconnect()
42
- }
43
-
44
- // 创建新连接
45
- try {
46
- // 修正Socket.IO连接URL,使用固定的后端服务器端口3000
47
- const backendUrl = 'http://localhost:3000'
48
-
49
- console.log('尝试连接Socket.IO服务器:', backendUrl)
50
-
51
- socket = io(backendUrl, {
52
- reconnectionDelayMax: 10000,
53
- reconnection: true,
54
- reconnectionAttempts: 10,
55
- reconnectionDelay: 1000, // 初始重连延迟1秒
56
- timeout: 20000, // 连接超时时间
57
- autoConnect: true, // 自动连接
58
- forceNew: true, // 强制创建新连接
59
- transports: ['websocket', 'polling'] // 优先使用WebSocket
60
- })
61
-
62
- // 检查socket是否成功创建
63
- if (!socket) {
64
- console.error('Socket.IO初始化失败: socket为null')
65
- return
66
- }
67
- console.log('Socket.IO初始化成功,socket ID:', socket.id || '未连接')
68
-
69
- // 监听连接事件
70
- socket.on('connect', () => {
71
- console.log('成功连接到Socket.IO服务器')
72
-
73
- // 如果自动更新开启,向服务器请求开始监控
74
- if (autoUpdateEnabled.value && socket) {
75
- socket.emit('start_monitoring')
76
- }
77
- })
78
-
79
- // 监听断开连接事件
80
- socket.on('disconnect', (reason) => {
81
- console.log('与Socket.IO服务器断开连接:', reason)
82
- })
83
-
84
- // 监听Git状态更新事件
85
- socket.on('git_status_update', (data) => {
86
- if (!autoUpdateEnabled.value) return
87
-
88
- console.log('收到Git状态更新通知:', new Date().toLocaleTimeString())
89
-
90
- // 更新状态文本
91
- if (data.status) {
92
- statusText.value = data.status
93
- }
94
-
95
- // 更新文件列表
96
- if (data.porcelain !== undefined) {
97
- parseStatusPorcelain(data.porcelain)
98
- }
99
- })
100
-
101
- // 监听监控状态
102
- socket.on('monitoring_status', (data) => {
103
- console.log('文件监控状态:', data.active ? '已启动' : '已停止')
104
- })
105
-
106
- // 添加额外的连接问题诊断
107
- socket.on('connect_error', (error) => {
108
- console.error('Socket连接错误:', error.message)
109
- })
110
-
111
- socket.on('connect_timeout', () => {
112
- console.error('Socket连接超时')
113
- })
114
-
115
- socket.on('reconnect', (attemptNumber) => {
116
- console.log(`Socket重连成功,尝试次数: ${attemptNumber}`)
117
-
118
- // 重连后检查自动更新状态
119
- if (autoUpdateEnabled.value) {
120
- console.log('重连后重新发送start_monitoring请求')
121
- socket?.emit('start_monitoring')
122
- }
123
- })
124
-
125
- socket.on('reconnect_attempt', (attemptNumber) => {
126
- console.log(`Socket尝试重连,第 ${attemptNumber} 次尝试`)
127
- })
128
-
129
- socket.on('reconnect_error', (error) => {
130
- console.error('Socket重连错误:', error.message)
131
- })
132
-
133
- socket.on('reconnect_failed', () => {
134
- console.error('Socket重连失败,已达到最大重试次数')
135
- })
136
-
137
- // 手动尝试连接
138
- if (socket && !socket.connected) {
139
- console.log('Socket未连接,尝试手动连接...')
140
- socket.connect()
141
- }
142
- } catch (error) {
143
- console.error('Socket.IO连接初始化失败:', error)
144
- }
145
- }
146
-
147
- // 切换自动更新状态
148
- function toggleAutoUpdate() {
149
- // autoUpdateEnabled.value = !autoUpdateEnabled.value
150
- console.log('toggleAutoUpdate调用,当前值:', autoUpdateEnabled.value)
151
-
152
- if (!socket) {
153
- console.error('无法切换自动更新状态: socket连接不存在')
154
- ElMessage.error('无法连接到服务器,自动更新可能不会生效')
155
-
156
- // 尝试重新初始化socket连接
157
- console.log('尝试重新建立socket连接...')
158
- initSocketConnection()
159
-
160
- // 即使socket可能不存在,也保存设置
161
- localStorage.setItem('zen-gitsync-auto-update', autoUpdateEnabled.value.toString())
162
- return
163
- }
164
-
165
- try {
166
- if (autoUpdateEnabled.value) {
167
- console.log('发送start_monitoring命令...')
168
- socket.emit('start_monitoring')
169
- ElMessage.success('自动更新已启用')
170
- } else {
171
- console.log('发送stop_monitoring命令...')
172
- socket.emit('stop_monitoring')
173
- ElMessage.info('自动更新已禁用')
174
- }
175
-
176
- // 保存设置到localStorage
177
- localStorage.setItem('zen-gitsync-auto-update', autoUpdateEnabled.value.toString())
178
- console.log('已保存自动更新设置到本地存储:', autoUpdateEnabled.value)
179
- } catch (error) {
180
- console.error('切换自动更新状态时出错:', error)
181
- ElMessage.error(`切换自动更新失败: ${(error as Error).message}`)
182
- }
183
- }
184
-
185
- // 解析 git status --porcelain 输出,提取文件及类型
186
- function parseStatusPorcelain(statusText: string) {
187
- if (statusText === undefined || statusText === '') {
188
- // 如果状态为空字符串,清空文件列表
189
- fileList.value = []
190
- return
191
- }
192
-
193
- const lines = statusText.split('\n')
194
- const files: {path: string, type: string}[] = []
195
- for (const line of lines) {
196
- // 匹配常见的 git status --porcelain 格式
197
- // M: 修改, A: 新增, D: 删除, ??: 未跟踪
198
- const match = line.match(/^([ MADRCU\?]{2})\s+(.+)$/)
199
- if (match) {
200
- let type = ''
201
- const code = match[1]
202
- const indexStatus = code.charAt(0)
203
- const workTreeStatus = code.charAt(1)
204
-
205
- // 根据暂存区状态和工作区状态确定文件类型
206
- if (indexStatus === 'A') {
207
- // 已暂存的新文件
208
- type = 'added'
209
- } else if (indexStatus === 'M') {
210
- // 已暂存的修改文件
211
- type = 'added'
212
- } else if (indexStatus === 'D') {
213
- // 已暂存的删除文件
214
- type = 'added'
215
- } else if (indexStatus === 'R') {
216
- // 已暂存的重命名文件
217
- type = 'added'
218
- } else if (indexStatus === ' ' && workTreeStatus === 'M') {
219
- // 已修改未暂存的文件
220
- type = 'modified'
221
- } else if (indexStatus === ' ' && workTreeStatus === 'D') {
222
- // 已删除未暂存的文件
223
- type = 'deleted'
224
- } else if (code === '??') {
225
- // 未跟踪的文件
226
- type = 'untracked'
227
- } else {
228
- // 其他情况
229
- type = 'other'
230
- }
231
-
232
- files.push({ path: match[2], type })
233
- }
234
- }
235
- fileList.value = files
236
- }
237
-
238
- // 获取提交日志
239
- async function fetchLog(showMessage = true) {
240
- // 检查是否是Git仓库
241
- if (!gitStore.isGitRepo) {
242
- console.log('当前目录不是Git仓库,跳过加载提交历史')
243
- return
244
- }
245
-
246
- try {
247
- isLoadingLog.value = true
248
- console.log('开始加载提交历史...')
249
-
250
- // 增加时间戳参数避免缓存,确保获取最新数据
251
- const timestamp = new Date().getTime()
252
- const response = await fetch(`/api/log?page=1&_t=${timestamp}`)
253
- const data = await response.json()
254
-
255
- if (data && data.data && Array.isArray(data.data)) {
256
- // 清空并更新日志数组
257
- log.value = [...data.data]
258
- console.log(`提交历史加载完成,共 ${log.value.length} 条记录`)
259
- } else {
260
- console.warn('API返回的提交历史格式不正确:', data)
261
- log.value = [] // 如果数据格式不对,清空日志
262
- }
263
-
264
- if (showMessage) {
265
- ElMessage({
266
- message: '提交历史已更新',
267
- type: 'success'
268
- })
269
- }
270
- } catch (error) {
271
- console.error('获取提交历史失败:', error)
272
- if (showMessage) {
273
- ElMessage({
274
- message: `获取提交历史失败: ${(error as Error).message}`,
275
- type: 'error'
276
- })
277
- }
278
- } finally {
279
- isLoadingLog.value = false
280
- }
281
- }
282
-
283
- // 获取Git状态
284
- async function fetchStatus() {
285
- // 检查是否是Git仓库
286
- if (!gitStore.isGitRepo) {
287
- console.log('当前目录不是Git仓库,跳过加载Git状态')
288
- return
289
- }
290
-
291
- try {
292
- isLoadingStatus.value = true
293
- const response = await fetch('/api/status')
294
- const data = await response.json()
295
- if (data.status) {
296
- // 更新状态文本
297
- statusText.value = data.status
298
- status.value = {
299
- staged: data.status.staged || [],
300
- unstaged: data.status.unstaged || [],
301
- untracked: data.status.untracked || []
302
- }
303
- }
304
-
305
- // 同时获取porcelain格式的状态
306
- await fetchStatusPorcelain()
307
- } catch (error) {
308
- console.error('获取Git状态失败:', error)
309
- ElMessage({
310
- message: `获取Git状态失败: ${(error as Error).message}`,
311
- type: 'error'
312
- })
313
- } finally {
314
- isLoadingStatus.value = false
315
- }
316
- }
317
-
318
- // 获取Git状态 (porcelain格式)
319
- async function fetchStatusPorcelain() {
320
- console.log('开始获取Git状态(porcelain格式)...')
321
- // 检查是否是Git仓库
322
- if (!gitStore.isGitRepo) {
323
- console.log('当前目录不是Git仓库,跳过加载Git状态')
324
- return
325
- }
326
-
327
- try {
328
- const response = await fetch('/api/status_porcelain')
329
- const data = await response.json()
330
- if (data.status !== undefined) {
331
- parseStatusPorcelain(data.status)
332
- } else {
333
- // 如果没有收到有效的 status 字段,清空文件列表
334
- fileList.value = []
335
- }
336
- } catch (error) {
337
- console.error('获取Git状态(porcelain)失败:', error)
338
- ElMessage({
339
- message: `获取Git状态(porcelain)失败: ${(error as Error).message}`,
340
- type: 'error'
341
- })
342
- // 清空文件列表
343
- fileList.value = []
344
- }
345
- }
346
-
347
- // 添加文件到暂存区 (git add .)
348
- async function addToStage() {
349
- // 检查是否是Git仓库
350
- if (!gitStore.isGitRepo) {
351
- ElMessage.warning('当前目录不是Git仓库')
352
- return false
353
- }
354
-
355
- try {
356
- isAddingFiles.value = true
357
- const response = await fetch('/api/add', {
358
- method: 'POST'
359
- })
360
-
361
- const result = await response.json()
362
- if (result.success) {
363
- ElMessage({
364
- message: '文件已添加到暂存区',
365
- type: 'success'
366
- })
367
-
368
- // 刷新状态
369
- fetchStatus()
370
-
371
- return true
372
- } else {
373
- ElMessage({
374
- message: `添加文件失败: ${result.error}`,
375
- type: 'error'
376
- })
377
- return false
378
- }
379
- } catch (error) {
380
- ElMessage({
381
- message: `添加文件失败: ${(error as Error).message}`,
382
- type: 'error'
383
- })
384
- return false
385
- } finally {
386
- isAddingFiles.value = false
387
- }
388
- }
389
-
390
- // 添加单个文件到暂存区
391
- async function addFileToStage(filePath: string) {
392
- // 检查是否是Git仓库
393
- if (!gitStore.isGitRepo) {
394
- ElMessage.warning('当前目录不是Git仓库')
395
- return false
396
- }
397
-
398
- try {
399
- isAddingFiles.value = true
400
- const response = await fetch('/api/add-file', {
401
- method: 'POST',
402
- headers: {
403
- 'Content-Type': 'application/json'
404
- },
405
- body: JSON.stringify({ filePath })
406
- })
407
-
408
- const result = await response.json()
409
- if (result.success) {
410
- ElMessage({
411
- message: '文件已暂存',
412
- type: 'success'
413
- })
414
-
415
- // 刷新状态
416
- fetchStatus()
417
-
418
- return true
419
- } else {
420
- ElMessage({
421
- message: `暂存文件失败: ${result.error}`,
422
- type: 'error'
423
- })
424
- return false
425
- }
426
- } catch (error) {
427
- ElMessage({
428
- message: `暂存文件失败: ${(error as Error).message}`,
429
- type: 'error'
430
- })
431
- return false
432
- } finally {
433
- isAddingFiles.value = false
434
- }
435
- }
436
-
437
- // 取消暂存单个文件
438
- async function unstageFile(filePath: string) {
439
- // 检查是否是Git仓库
440
- if (!gitStore.isGitRepo) {
441
- ElMessage.warning('当前目录不是Git仓库')
442
- return false
443
- }
444
-
445
- try {
446
- isResetting.value = true
447
- const response = await fetch('/api/unstage-file', {
448
- method: 'POST',
449
- headers: {
450
- 'Content-Type': 'application/json'
451
- },
452
- body: JSON.stringify({ filePath })
453
- })
454
-
455
- const result = await response.json()
456
- if (result.success) {
457
- ElMessage({
458
- message: '已取消暂存文件',
459
- type: 'success'
460
- })
461
-
462
- // 刷新状态
463
- fetchStatus()
464
-
465
- return true
466
- } else {
467
- ElMessage({
468
- message: `取消暂存失败: ${result.error}`,
469
- type: 'error'
470
- })
471
- return false
472
- }
473
- } catch (error) {
474
- ElMessage({
475
- message: `取消暂存失败: ${(error as Error).message}`,
476
- type: 'error'
477
- })
478
- return false
479
- } finally {
480
- isResetting.value = false
481
- }
482
- }
483
-
484
- // 添加延时函数
485
- function delay(ms: number) {
486
- return new Promise(resolve => setTimeout(resolve, ms))
487
- }
488
-
489
- // 提交更改 (git commit)
490
- async function commitChanges(message: string, noVerify = false) {
491
- // 检查是否是Git仓库
492
- if (!gitStore.isGitRepo) {
493
- ElMessage.warning('当前目录不是Git仓库')
494
- return false
495
- }
496
-
497
- try {
498
- isCommiting.value = true
499
- const response = await fetch('/api/commit', {
500
- method: 'POST',
501
- headers: {
502
- 'Content-Type': 'application/json'
503
- },
504
- body: JSON.stringify({
505
- message,
506
- hasNewlines: message.includes('\n'),
507
- noVerify
508
- })
509
- })
510
-
511
- const result = await response.json()
512
- if (result.success) {
513
- ElMessage({
514
- message: '提交成功',
515
- type: 'success'
516
- })
517
-
518
- // 刷新状态和日志
519
- fetchStatus()
520
- fetchLog()
521
-
522
- // 更新分支状态
523
- gitStore.getBranchStatus()
524
-
525
- return true
526
- } else {
527
- ElMessage({
528
- message: `提交失败: ${result.error}`,
529
- type: 'error'
530
- })
531
- return false
532
- }
533
- } catch (error) {
534
- ElMessage({
535
- message: `提交失败: ${(error as Error).message}`,
536
- type: 'error'
537
- })
538
- return false
539
- } finally {
540
- isCommiting.value = false
541
- }
542
- }
543
-
544
- // 推送到远程
545
- async function pushToRemote() {
546
- // 检查是否是Git仓库
547
- if (!gitStore.isGitRepo) {
548
- ElMessage.warning('当前目录不是Git仓库')
549
- return false
550
- }
551
-
552
- try {
553
- isPushing.value = true
554
- const response = await fetch('/api/push', {
555
- method: 'POST'
556
- })
557
-
558
- const result = await response.json()
559
- if (result.success) {
560
- ElMessage({
561
- message: '推送成功',
562
- type: 'success'
563
- })
564
- // 刷新状态
565
- fetchStatus()
566
-
567
- // 刷新日志
568
- fetchLog()
569
-
570
- // 更新分支状态
571
- gitStore.getBranchStatus()
572
-
573
- return true
574
- } else {
575
- ElMessage({
576
- message: `推送失败: ${result.error}`,
577
- type: 'error'
578
- })
579
- return false
580
- }
581
- } catch (error) {
582
- ElMessage({
583
- message: `推送失败: ${(error as Error).message}`,
584
- type: 'error'
585
- })
586
- return false
587
- } finally {
588
- isPushing.value = false
589
- }
590
- }
591
-
592
- // 暂存并提交
593
- async function addAndCommit(message: string, noVerify = false) {
594
- const addResult = await addToStage()
595
- if (!addResult) return false
596
-
597
- // 使用新的延时常量
598
- await delay(GIT_OPERATION_DELAY)
599
-
600
- return await commitChanges(message, noVerify)
601
- }
602
-
603
- // 暂存、提交并推送
604
- async function addCommitAndPush(message: string, noVerify = false) {
605
- try {
606
- const addResult = await addToStage()
607
- if (!addResult) return false
608
-
609
- // 使用新的延时常量
610
- await delay(GIT_OPERATION_DELAY)
611
-
612
- const commitResult = await commitChanges(message, noVerify)
613
- if (!commitResult) return false
614
-
615
- // 使用新的延时常量
616
- await delay(GIT_OPERATION_DELAY)
617
-
618
- return await pushToRemote()
619
- } catch (error) {
620
- // 如果发生错误,尝试删除 index.lock 文件
621
- try {
622
- const response = await fetch('/api/remove-lock', {
623
- method: 'POST'
624
- })
625
- const result = await response.json()
626
- if (result.success) {
627
- ElMessage({
628
- message: '已清理锁定文件,请重试操作',
629
- type: 'warning'
630
- })
631
- }
632
- } catch (e) {
633
- console.error('清理锁定文件失败:', e)
634
- }
635
-
636
- ElMessage({
637
- message: `操作失败: ${(error as Error).message}`,
638
- type: 'error'
639
- })
640
-
641
- // 即使出错也要刷新状态
642
- fetchStatus()
643
- fetchLog()
644
- gitStore.getBranchStatus()
645
-
646
- return false
647
- }
648
- }
649
-
650
- // 重置暂存区 (git reset HEAD)
651
- async function resetHead() {
652
- // 检查是否是Git仓库
653
- if (!gitStore.isGitRepo) {
654
- ElMessage.warning('当前目录不是Git仓库')
655
- return false
656
- }
657
-
658
- try {
659
- isResetting.value = true
660
- const response = await fetch('/api/reset-head', {
661
- method: 'POST'
662
- })
663
-
664
- const result = await response.json()
665
- if (result.success) {
666
- ElMessage({
667
- message: '已重置暂存区',
668
- type: 'success'
669
- })
670
-
671
- // 刷新状态
672
- fetchStatus()
673
-
674
- return true
675
- } else {
676
- ElMessage({
677
- message: `重置暂存区失败: ${result.error}`,
678
- type: 'error'
679
- })
680
- return false
681
- }
682
- } catch (error) {
683
- ElMessage({
684
- message: `重置暂存区失败: ${(error as Error).message}`,
685
- type: 'error'
686
- })
687
- return false
688
- } finally {
689
- isResetting.value = false
690
- }
691
- }
692
-
693
- // 重置当前分支到远程状态
694
- async function resetToRemote(branch: string) {
695
- // 检查是否是Git仓库
696
- if (!gitStore.isGitRepo) {
697
- ElMessage.warning('当前目录不是Git仓库')
698
- return false
699
- }
700
-
701
- try {
702
- isResetting.value = true
703
- const response = await fetch('/api/reset-to-remote', {
704
- method: 'POST',
705
- headers: {
706
- 'Content-Type': 'application/json'
707
- },
708
- body: JSON.stringify({ branch })
709
- })
710
-
711
- const result = await response.json()
712
- if (result.success) {
713
- ElMessage({
714
- message: `已重置分支 ${branch} 到远程状态`,
715
- type: 'success'
716
- })
717
-
718
- // 刷新状态和日志
719
- fetchStatus()
720
- fetchLog()
721
-
722
- return true
723
- } else {
724
- ElMessage({
725
- message: `重置分支失败: ${result.error}`,
726
- type: 'error'
727
- })
728
- return false
729
- }
730
- } catch (error) {
731
- ElMessage({
732
- message: `重置分支失败: ${(error as Error).message}`,
733
- type: 'error'
734
- })
735
- return false
736
- } finally {
737
- isResetting.value = false
738
- }
739
- }
740
-
741
- // 在组件挂载时初始化socket连接
742
- onMounted(() => {
743
- // 从localStorage加载自动更新设置
744
- const savedAutoUpdate = localStorage.getItem('zen-gitsync-auto-update')
745
- if (savedAutoUpdate !== null) {
746
- autoUpdateEnabled.value = savedAutoUpdate === 'true'
747
- }
748
-
749
- initSocketConnection()
750
- })
751
-
752
- // 在组件卸载时断开socket连接
753
- onUnmounted(() => {
754
- if (socket) {
755
- socket.disconnect()
756
- socket = null
757
- }
758
- })
759
-
760
- return {
761
- // 状态
762
- log,
763
- status,
764
- statusText,
765
- fileList,
766
- isLoadingLog,
767
- isLoadingStatus,
768
- isAddingFiles,
769
- isResetting,
770
- isCommiting,
771
- isPushing,
772
- autoUpdateEnabled,
773
-
774
- // 方法
775
- fetchLog,
776
- fetchStatus,
777
- fetchStatusPorcelain,
778
- parseStatusPorcelain,
779
- addToStage,
780
- addFileToStage,
781
- unstageFile,
782
- commitChanges,
783
- pushToRemote,
784
- addAndCommit,
785
- addCommitAndPush,
786
- resetHead,
787
- resetToRemote,
788
- toggleAutoUpdate
789
- }
790
- })