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 @@