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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-gitsync",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "一个 git 自动查看差异并提交的工具",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -9,6 +9,7 @@ export {}
9
9
  declare module 'vue' {
10
10
  export interface GlobalComponents {
11
11
  CommitForm: typeof import('./src/components/CommitForm.vue')['default']
12
+ ElAlert: typeof import('element-plus/es')['ElAlert']
12
13
  ElButton: typeof import('element-plus/es')['ElButton']
13
14
  ElCard: typeof import('element-plus/es')['ElCard']
14
15
  ElDialog: typeof import('element-plus/es')['ElDialog']
@@ -4,7 +4,7 @@ import GitStatus from './components/GitStatus.vue'
4
4
  import CommitForm from './components/CommitForm.vue'
5
5
  import LogList from './components/LogList.vue'
6
6
  import { ElMessage } from 'element-plus'
7
- import { Plus } from '@element-plus/icons-vue'
7
+ import { Plus, Setting } from '@element-plus/icons-vue'
8
8
  import logo from './assets/logo.svg'
9
9
  import { useGitStore } from './stores/gitStore'
10
10
 
@@ -81,40 +81,6 @@ onMounted(async () => {
81
81
  }
82
82
  })
83
83
 
84
- // 处理提交成功事件
85
- function handleCommitSuccess() {
86
- // 不再调用gitLogStore.fetchLog(),改用更新LogList组件
87
-
88
- // 刷新Git状态
89
- if (gitStatusRef.value) {
90
- gitStatusRef.value.refreshStatus()
91
- }
92
-
93
- // 直接刷新提交历史
94
- if (logListRef.value) {
95
- logListRef.value.refreshLog()
96
- }
97
- }
98
-
99
- // 处理推送成功事件
100
- function handlePushSuccess() {
101
- // 不再调用gitLogStore.fetchLog(),改用更新LogList组件
102
- gitStore.getCurrentBranch()
103
-
104
- // 直接刷新提交历史
105
- if (logListRef.value) {
106
- logListRef.value.refreshLog()
107
- }
108
- }
109
-
110
- // 处理状态更新事件
111
- function handleStatusUpdate() {
112
- // 刷新Git状态
113
- if (gitStatusRef.value) {
114
- gitStatusRef.value.refreshStatus()
115
- }
116
- }
117
-
118
84
  const createBranchDialogVisible = ref(false)
119
85
  const newBranchName = ref('')
120
86
  const selectedBaseBranch = ref('')
@@ -164,6 +130,40 @@ async function handleBranchChange(branch: string) {
164
130
  }
165
131
  }
166
132
  }
133
+
134
+ // 添加用户设置相关状态
135
+ const userSettingsDialogVisible = ref(false)
136
+ const tempUserName = ref('')
137
+ const tempUserEmail = ref('')
138
+
139
+ // 打开用户设置对话框
140
+ function openUserSettingsDialog() {
141
+ tempUserName.value = gitStore.userName
142
+ tempUserEmail.value = gitStore.userEmail
143
+ userSettingsDialogVisible.value = true
144
+ }
145
+
146
+ // 保存用户设置
147
+ async function saveUserSettings() {
148
+ if (!tempUserName.value || !tempUserEmail.value) {
149
+ ElMessage.warning('用户名和邮箱不能为空')
150
+ return
151
+ }
152
+
153
+ const success = await gitStore.restoreUserConfig(tempUserName.value, tempUserEmail.value)
154
+ if (success) {
155
+ userSettingsDialogVisible.value = false
156
+ }
157
+ }
158
+
159
+ // 清除用户配置
160
+ async function clearUserSettings() {
161
+ const success = await gitStore.clearUserConfig()
162
+ if (success) {
163
+ tempUserName.value = ''
164
+ tempUserEmail.value = ''
165
+ }
166
+ }
167
167
  </script>
168
168
 
169
169
  <template>
@@ -177,6 +177,28 @@ async function handleBranchChange(branch: string) {
177
177
  <span class="user-label">用户:</span>
178
178
  <span class="user-name">{{ gitStore.userName }}</span>
179
179
  <span class="user-email">&lt;{{ gitStore.userEmail }}&gt;</span>
180
+ <el-button
181
+ type="primary"
182
+ size="small"
183
+ @click="openUserSettingsDialog"
184
+ class="user-settings-btn"
185
+ circle
186
+ >
187
+ <el-icon><Setting /></el-icon>
188
+ </el-button>
189
+ </div>
190
+ <div id="user-info" v-else>
191
+ <span class="user-label">用户: </span>
192
+ <span class="user-warning">未配置</span>
193
+ <el-button
194
+ type="primary"
195
+ size="small"
196
+ @click="openUserSettingsDialog"
197
+ class="user-settings-btn"
198
+ circle
199
+ >
200
+ <el-icon><Setting /></el-icon>
201
+ </el-button>
180
202
  </div>
181
203
  <!-- <div id="config-info">{{ configInfo }}</div> -->
182
204
  </div>
@@ -203,12 +225,33 @@ async function handleBranchChange(branch: string) {
203
225
 
204
226
  <!-- 右侧提交表单和历史 -->
205
227
  <div class="right-panel" v-if="gitStore.isGitRepo">
206
- <CommitForm
207
- @commit-success="handleCommitSuccess"
208
- @push-success="handlePushSuccess"
209
- @status-update="handleStatusUpdate"
210
- />
211
- <LogList ref="logListRef" />
228
+ <!-- 当用户未配置时显示配置提示 -->
229
+ <div v-if="!gitStore.userName || !gitStore.userEmail" class="card">
230
+ <h2>Git用户未配置</h2>
231
+ <p>请先配置Git用户信息才能进行提交操作。</p>
232
+ <div class="tips">
233
+ <h3>您可以通过以下方式配置:</h3>
234
+ <ol>
235
+ <li>点击右上角的设置按钮,配置用户名和邮箱</li>
236
+ <li>或者使用命令行配置:</li>
237
+ <div class="code-block">
238
+ git config --global user.name "您的用户名"<br>
239
+ git config --global user.email "您的邮箱"
240
+ </div>
241
+ </ol>
242
+ <el-button
243
+ type="primary"
244
+ @click="openUserSettingsDialog"
245
+ >
246
+ 立即配置
247
+ </el-button>
248
+ </div>
249
+ </div>
250
+ <!-- 用户已配置显示提交表单 -->
251
+ <template v-else>
252
+ <CommitForm />
253
+ <LogList ref="logListRef" />
254
+ </template>
212
255
  </div>
213
256
  <div class="right-panel" v-else>
214
257
  <div class="card">
@@ -263,34 +306,80 @@ async function handleBranchChange(branch: string) {
263
306
 
264
307
  <footer class="main-footer">
265
308
  <div class="branch-info" v-if="gitStore.currentBranch">
266
- <span class="branch-label">当前分支:</span>
267
- <el-select
268
- v-model="gitStore.currentBranch"
269
- size="small"
270
- @change="handleBranchChange"
271
- :loading="gitStore.isChangingBranch"
272
- class="branch-select"
273
- >
274
- <el-option
275
- v-for="branch in gitStore.allBranches"
276
- :key="branch"
277
- :label="branch"
278
- :value="branch"
279
- />
280
- </el-select>
281
- <el-button
282
- type="primary"
283
- size="small"
284
- @click="openCreateBranchDialog"
285
- style="margin-left: 5px;"
286
- >
287
- <el-icon><Plus /></el-icon>
288
- </el-button>
309
+ <div class="branch-wrapper">
310
+ <span class="branch-label">当前分支:</span>
311
+ <el-select
312
+ v-model="gitStore.currentBranch"
313
+ size="small"
314
+ @change="handleBranchChange"
315
+ :loading="gitStore.isChangingBranch"
316
+ class="branch-select"
317
+ >
318
+ <el-option
319
+ v-for="branch in gitStore.allBranches"
320
+ :key="branch"
321
+ :label="branch"
322
+ :value="branch"
323
+ />
324
+ </el-select>
325
+ <el-button
326
+ type="primary"
327
+ size="small"
328
+ @click="openCreateBranchDialog"
329
+ class="create-branch-btn"
330
+ >
331
+ <el-icon><Plus /></el-icon>
332
+ 新建分支
333
+ </el-button>
334
+ </div>
289
335
  </div>
290
336
  <div class="footer-right">
291
337
  <!-- <span>Zen GitSync © 2024</span> -->
292
338
  </div>
293
339
  </footer>
340
+
341
+ <!-- 用户设置对话框 -->
342
+ <el-dialog
343
+ v-model="userSettingsDialogVisible"
344
+ title="Git用户设置"
345
+ width="30%"
346
+ destroy-on-close
347
+ >
348
+ <el-form>
349
+ <el-form-item label="用户名">
350
+ <el-input v-model="tempUserName" placeholder="请输入Git用户名" />
351
+ </el-form-item>
352
+ <el-form-item label="邮箱">
353
+ <el-input v-model="tempUserEmail" placeholder="请输入Git邮箱" />
354
+ </el-form-item>
355
+ <el-form-item>
356
+ <el-alert
357
+ type="info"
358
+ :closable="false"
359
+ show-icon
360
+ >
361
+ 这些设置将影响全局Git配置,对所有Git仓库生效。
362
+ </el-alert>
363
+ </el-form-item>
364
+ </el-form>
365
+ <template #footer>
366
+ <span class="dialog-footer">
367
+ <el-button
368
+ type="danger"
369
+ @click="clearUserSettings"
370
+ >
371
+ 清除配置
372
+ </el-button>
373
+ <el-button @click="userSettingsDialogVisible = false">取消</el-button>
374
+ <el-button
375
+ type="primary"
376
+ @click="saveUserSettings"
377
+ >
378
+ 保存
379
+ </el-button>
380
+ </span>
381
+ </template>
382
+ </el-dialog>
294
383
  </template>
295
384
 
296
385
  <style>
@@ -443,10 +532,10 @@ h1 {
443
532
  font-size: 12px;
444
533
  }
445
534
  /* 添加分支选择框样式 */
446
- .branch-select {
535
+ /* .branch-select {
447
536
  width: 150px;
448
537
  margin-left: 5px;
449
- }
538
+ } */
450
539
 
451
540
  /* 调整下拉选择框在深色背景下的样式 */
452
541
  .branch-select :deep(.el-input__inner) {
@@ -506,6 +595,15 @@ h1 {
506
595
  font-size: 18px;
507
596
  color: #606266;
508
597
  }
598
+
599
+ .user-settings-btn {
600
+ margin-left: 10px;
601
+ }
602
+
603
+ .user-warning {
604
+ color: #E6A23C;
605
+ font-weight: bold;
606
+ }
509
607
  </style>
510
608
 
511
609
  <style scoped>
@@ -528,15 +626,63 @@ h1 {
528
626
  left: 0;
529
627
  right: 0;
530
628
  z-index: 100;
629
+ box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
531
630
  }
532
631
 
533
632
  .branch-info {
534
633
  display: flex;
535
634
  align-items: center;
635
+ gap: 10px;
636
+ }
637
+
638
+ .branch-wrapper {
639
+ display: flex;
640
+ align-items: center;
641
+ background-color: rgba(255, 255, 255, 0.15);
642
+ border-radius: 4px;
643
+ padding: 8px 12px;
644
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
645
+ transition: all 0.3s;
646
+ }
647
+
648
+ .branch-wrapper:hover {
649
+ background-color: rgba(255, 255, 255, 0.2);
650
+ }
651
+
652
+ .branch-label {
653
+ font-weight: bold;
654
+ margin-right: 10px;
655
+ color: #ffffff;
656
+ }
657
+
658
+ .branch-select {
659
+ width: 200px;
660
+ margin-right: 10px;
661
+ }
662
+
663
+ .create-branch-btn {
664
+ background-color: #2ea44f;
665
+ border-color: #2ea44f;
666
+ transition: all 0.3s;
667
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
668
+ }
669
+
670
+ .create-branch-btn:hover {
671
+ background-color: #3bbc63;
672
+ border-color: #3bbc63;
673
+ transform: translateY(-2px);
674
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
536
675
  }
537
676
 
538
677
  .footer-right {
539
- color: rgba(255, 255, 255, 0.7);
540
- font-size: 12px;
678
+ display: flex;
679
+ align-items: center;
680
+ gap: 10px;
681
+ color: rgba(255, 255, 255, 0.9);
682
+ font-size: 13px;
683
+ background-color: rgba(255, 255, 255, 0.1);
684
+ padding: 8px 12px;
685
+ border-radius: 4px;
686
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
541
687
  }
542
688
  </style>