From 44a2c54da3049f3f30173613a501cc2773b253b8 Mon Sep 17 00:00:00 2001 From: cfq Date: Wed, 28 Jan 2026 19:16:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(git):=20=E5=A2=9E=E5=BC=BAGit=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E5=8A=9F=E8=83=BD=E5=B9=B6=E6=94=AF=E6=8C=81=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E4=BB=93=E5=BA=93=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加远程仓库URL获取与外部链接打开功能 - 改进git状态显示为可视化文件列表,支持状态分类着色 - 修改git status命令以正确处理特殊字符路径 - 默认提交消息设置为"md helper" - 在Git面板添加打开远程仓库的快捷按钮 --- public/preload/services.js | 49 +++++++++++++++++++++++++- src/components/GitPanel.vue | 68 ++++++++++++++++++++++++++++++++----- src/composables/useGit.js | 33 ++++++++++++++++++ 3 files changed, 141 insertions(+), 9 deletions(-) diff --git a/public/preload/services.js b/public/preload/services.js index 54f4391..0b12fd1 100644 --- a/public/preload/services.js +++ b/public/preload/services.js @@ -105,6 +105,11 @@ window.services = { window.utools.shellShowItemInFolder(itemPath); }, + // 打开外部链接 + openExternal(url) { + window.utools.shellOpenExternal(url); + }, + // --- Image Service --- // 保存图片 @@ -168,7 +173,7 @@ window.services = { }, async gitStatus(dirPath) { - return this.execGit("status --short", dirPath); + return this.execGit("-c core.quotePath=false status --short", dirPath); }, async gitAdd(dirPath, files = ".") { @@ -189,6 +194,48 @@ window.services = { return this.execGit("pull", dirPath); }, + async gitRemoteUrl(dirPath) { + try { + const configPath = path.join(dirPath, '.git', 'config'); + if (!fs.existsSync(configPath)) { + return { success: false, error: 'Config file not found' }; + } + const content = await fs.promises.readFile(configPath, 'utf-8'); + + // 简单解析 ini + // 寻找 [remote "origin"] 及其下的 url + const lines = content.split('\n'); + let inRemoteOrigin = false; + let url = null; + + for (const line of lines) { + const trimmed = line.trim(); + if (trimmed === '[remote "origin"]') { + inRemoteOrigin = true; + continue; + } + if (inRemoteOrigin) { + if (trimmed.startsWith('[')) { + // 进入下一个 section,结束查找 + break; + } + if (trimmed.startsWith('url =')) { + url = trimmed.substring(5).trim(); + break; + } + } + } + + if (url) { + return { success: true, stdout: url }; + } + + return { success: false, error: 'Remote origin url not found' }; + } catch (e) { + return { success: false, error: e.message }; + } + }, + // --- Search Service --- // 搜索文件 (文件名) diff --git a/src/components/GitPanel.vue b/src/components/GitPanel.vue index 062a39a..aa49ec4 100644 --- a/src/components/GitPanel.vue +++ b/src/components/GitPanel.vue @@ -15,6 +15,9 @@ 推送 + + + @@ -24,7 +27,13 @@

状态

-
{{ state.statusOutput || '无变更' }}
+
+
+ {{ file.status }} + {{ file.path }} +
+
+
无变更
@@ -51,15 +60,15 @@