zen-gitsync 2.0.8 → 2.1.0

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.8",
3
+ "version": "2.1.0",
4
4
  "description": "一个 git 自动查看差异并提交的工具",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -7,6 +7,7 @@ import { ElMessage } from 'element-plus'
7
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
+ import { useConfigStore } from './stores/configStore'
10
11
 
11
12
  const configInfo = ref('')
12
13
  // 添加组件实例类型
@@ -15,6 +16,8 @@ const gitStatusRef = ref<InstanceType<typeof GitStatus> | null>(null)
15
16
 
16
17
  // 使用Git Store
17
18
  const gitStore = useGitStore()
19
+ // 使用Config Store
20
+ const configStore = useConfigStore()
18
21
 
19
22
  // 添加初始化完成状态
20
23
  const initCompleted = ref(false)
@@ -23,9 +26,10 @@ const currentDirectory = ref('')
23
26
  // 加载配置
24
27
  async function loadConfig() {
25
28
  try {
26
- const response = await fetch('/api/config/getConfig')
27
- const config = await response.json()
28
- configInfo.value = `默认提交信息: ${config.defaultCommitMessage}`
29
+ const config = await configStore.loadConfig()
30
+ if (config) {
31
+ configInfo.value = `默认提交信息: ${config.defaultCommitMessage}`
32
+ }
29
33
  } catch (error) {
30
34
  console.error('加载配置失败:', error)
31
35
  }
@@ -60,14 +64,12 @@ onMounted(async () => {
60
64
 
61
65
  // 只有是Git仓库的情况下才加载Git相关信息
62
66
  if (gitStore.isGitRepo) {
63
- // 只获取分支和用户信息,不重复获取日志
67
+ // 并行获取所有Git信息,确保每个API只调用一次
64
68
  await Promise.all([
65
- gitStore.getCurrentBranch(),
66
- gitStore.getAllBranches(),
67
- gitStore.getUserInfo()
69
+ gitStore.getCurrentBranch(), // 获取当前分支
70
+ gitStore.getAllBranches(), // 获取所有分支
71
+ gitStore.getUserInfo() // 获取用户信息
68
72
  ])
69
-
70
- // 日志信息通过LogList组件直接加载即可,避免重复调用
71
73
  } else {
72
74
  ElMessage.warning('当前目录不是Git仓库,部分功能将不可用')
73
75
  }
@@ -447,7 +449,7 @@ function stopHResize() {
447
449
  </template>
448
450
  </div>
449
451
  <div class="commit-form-panel" v-else>
450
- <div class="card">
452
+ <div class="card" style="padding: 20px;">
451
453
  <h2>Git仓库初始化</h2>
452
454
  <p>当前目录不是Git仓库,请先初始化Git仓库或切换到Git仓库目录。</p>
453
455
  <!-- 实用提示 -->