zen-gitsync 2.2.8 → 2.3.1

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.2.8",
3
+ "version": "2.3.1",
4
4
  "description": "一个 git 自动查看差异并提交的工具",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -498,6 +498,26 @@ async function publishToNpm() {
498
498
  try {
499
499
  execSync('npm publish --registry=https://registry.npmjs.org/', { stdio: 'inherit' });
500
500
  console.log(chalk.green('已成功发布到NPM'));
501
+
502
+ // 发布成功后执行更新和查看命令
503
+ console.log(chalk.blue('\n=== 发布后操作 ==='));
504
+
505
+ try {
506
+ console.log(chalk.gray('执行 npm run update:g...'));
507
+ execSync('npm run update:g', { stdio: 'inherit' });
508
+ console.log(chalk.green('✅ update:g 执行完成'));
509
+ } catch (error) {
510
+ console.error(chalk.red('❌ update:g 执行失败:'), error.message);
511
+ }
512
+
513
+ try {
514
+ console.log(chalk.gray('执行 npm run npm:ls:g...'));
515
+ execSync('npm run npm:ls:g', { stdio: 'inherit' });
516
+ console.log(chalk.green('✅ npm:ls:g 执行完成'));
517
+ } catch (error) {
518
+ console.error(chalk.red('❌ npm:ls:g 执行失败:'), error.message);
519
+ }
520
+
501
521
  } catch (error) {
502
522
  console.error(chalk.red('发布到NPM失败:'), error);
503
523
  throw error;
@@ -0,0 +1,45 @@
1
+ import{d as ms,r as d,c as q,E as o,o as dt,a as vs,l as Xs,b as xe,w as je,e as S,f as v,n as ft,g as Y,h as e,t as A,i as t,u as n,j as Zs,k as s,m as Z,p as zt,F as Fe,q as Ae,s as ke,v as Ye,x as he,y as eo,z as x,A as st,B as Yt,C as to,D as rs,G as Vt,H as Xe,I as Rt,J as St,K as jt,L as bt,M as gs,N as Kt,O as Qt,P as hs,Q as ys,R as _s,S as ws,T as so,U as Xt,V as Lt,W as ks,X as cs,Y as oo,Z as He,_ as Zt,$ as es,a0 as Tt,a1 as $s,a2 as Gt,a3 as ao,a4 as bs,a5 as lo,a6 as Ct,a7 as ut,a8 as no,a9 as io,aa as ro,ab as ts,ac as us,ad as co,ae as Dt,af as Ot,ag as Cs,ah as uo,ai as fo,aj as Ss,ak as Ts,al as po,am as mo,an as vo,ao as Fs,ap as $t,aq as Vs,ar as rt,as as go,at as ho,au as yo,av as _o,aw as wo,ax as ko,ay as $o,az as bo,aA as Co,aB as So,aC as To,aD as Fo,aE as ds,aF as fs,aG as Vo,aH as Ge,aI as Lo,aJ as xo}from"./vendor-Cw2fOyGk.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const p of document.querySelectorAll('link[rel="modulepreload"]'))i(p);new MutationObserver(p=>{for(const _ of p)if(_.type==="childList")for(const R of _.addedNodes)R.tagName==="LINK"&&R.rel==="modulepreload"&&i(R)}).observe(document,{childList:!0,subtree:!0});function l(p){const _={};return p.integrity&&(_.integrity=p.integrity),p.referrerPolicy&&(_.referrerPolicy=p.referrerPolicy),p.crossOrigin==="use-credentials"?_.credentials="include":p.crossOrigin==="anonymous"?_.credentials="omit":_.credentials="same-origin",_}function i(p){if(p.ep)return;p.ep=!0;const _=l(p);fetch(p.href,_)}})();const ot=ms("config",()=>{const N=d(""),r=d([]),l=d([]),i=d([]),p=d([]),_=d(!1),R=d(!1),h=q(()=>({defaultCommitMessage:N.value,descriptionTemplates:r.value,scopeTemplates:l.value,messageTemplates:i.value,lockedFiles:p.value}));async function U(B=!1){if(!B&&R.value&&!_.value)return console.log("使用缓存的配置信息"),h.value;try{_.value=!0,console.log("加载配置信息...");const j=await(await fetch("/api/config/getConfig")).json();return N.value=j.defaultCommitMessage||"",r.value=j.descriptionTemplates||[],l.value=j.scopeTemplates||[],i.value=j.messageTemplates||[],p.value=j.lockedFiles||[],R.value=!0,console.log("配置信息加载完成"),h.value}catch(C){return console.error("加载配置失败:",C),o.error(`加载配置失败: ${C.message}`),null}finally{_.value=!1}}async function te(B){try{const j=await(await fetch("/api/config/saveDefaultMessage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultCommitMessage:B})})).json();return j.success?(N.value=B,o.success("默认提交信息已保存"),!0):(o.error(`保存失败: ${j.error}`),!1)}catch(C){return o.error(`保存失败: ${C.message}`),!1}}async function M(B,C){try{const ce=await(await fetch("/api/config/save-template",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({template:B,type:C})})).json();return ce.success?(C==="description"?r.value.includes(B)||r.value.push(B):C==="scope"?l.value.includes(B)||l.value.push(B):C==="message"&&(i.value.includes(B)||i.value.push(B)),o.success("模板已保存"),!0):(o.error(`保存模板失败: ${ce.error}`),!1)}catch(j){return o.error(`保存模板失败: ${j.message}`),!1}}async function H(B,C){try{const ce=await(await fetch("/api/config/delete-template",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({template:B,type:C})})).json();return ce.success?(C==="description"?r.value=r.value.filter(ne=>ne!==B):C==="scope"?l.value=l.value.filter(ne=>ne!==B):C==="message"&&(i.value=i.value.filter(ne=>ne!==B)),o.success("模板已删除"),!0):(o.error(`删除模板失败: ${ce.error}`),!1)}catch(j){return o.error(`删除模板失败: ${j.message}`),!1}}async function y(B,C,j){try{const ne=await(await fetch("/api/config/update-template",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldTemplate:B,newTemplate:C,type:j})})).json();if(ne.success){if(j==="description"){const k=r.value.indexOf(B);k!==-1&&(r.value[k]=C)}else if(j==="scope"){const k=l.value.indexOf(B);k!==-1&&(l.value[k]=C)}else if(j==="message"){const k=i.value.indexOf(B);k!==-1&&(i.value[k]=C)}return o.success("模板已更新"),!0}else return o.error(`更新模板失败: ${ne.error}`),!1}catch(ce){return o.error(`更新模板失败: ${ce.message}`),!1}}async function w(){try{const C=await(await fetch("/api/locked-files")).json();return C.success?(p.value=C.lockedFiles||[],C.lockedFiles):(o.error(`加载锁定文件列表失败: ${C.error}`),[])}catch(B){return console.error("加载锁定文件列表失败:",B),o.error(`加载锁定文件列表失败: ${B.message}`),[]}}async function E(B){try{const j=await(await fetch("/api/lock-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:B})})).json();return j.success?(await w(),o.success(`文件已锁定: ${B}`),!0):(o.error(`锁定文件失败: ${j.error}`),!1)}catch(C){return console.error("锁定文件失败:",C),o.error(`锁定文件失败: ${C.message}`),!1}}async function I(B){try{const j=await(await fetch("/api/unlock-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:B})})).json();return j.success?(await w(),o.success(`文件已解锁: ${B}`),!0):(o.error(`解锁文件失败: ${j.error}`),!1)}catch(C){return console.error("解锁文件失败:",C),o.error(`解锁文件失败: ${C.message}`),!1}}async function se(B){try{const j=await(await fetch("/api/check-file-lock",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:B})})).json();return j.success?j.isLocked:(console.error("检查文件锁定状态失败:",j.error),!1)}catch(C){return console.error("检查文件锁定状态失败:",C),!1}}return{defaultCommitMessage:N,descriptionTemplates:r,scopeTemplates:l,messageTemplates:i,lockedFiles:p,isLoading:_,isLoaded:R,config:h,loadConfig:U,saveDefaultMessage:te,saveTemplate:M,deleteTemplate:H,updateTemplate:y,loadLockedFiles:w,lockFile:E,unlockFile:I,isFileLocked:se}}),Ht=800;function Bo(){const N=window.location.port||"80";if(N==="5173"||N==="4173"||N==="5544"){const l="3001";return console.log(`开发环境:从环境变量读取后端端口 ${l}`),parseInt(l,10)}const r=parseInt(N,10);return console.log(`生产环境:使用当前页面端口 ${r}`),r}const Po=Bo(),Qe=ms("git",()=>{const N=ot(),r=d(""),l=d([]),i=d(""),p=d(""),_=d(!1),R=d(!1),h=d(!1),U=d(0),te=d(""),M=d(!1),H=d(!1),y=d(!1),w=d(!1),E=d(!1),I=d(0),se=d(0),B=d(!1),C=d(""),j=d(0),ce=d(0),ne=d(!0),k=d(null),D=d(""),ye=d(""),F=d([]),O=d({staged:[],unstaged:[],untracked:[]}),K=d([]),ue=d(!1),ve=d(!1),me=d(!1),ie=d(!1),re=d(!1),Q=d([]),pe=d(!1),z=d(!1),T=d(!1),ae=d(!1);function X(){r.value="",l.value=[],i.value="",p.value="",_.value=!1,R.value=!1,h.value=!1,U.value=0,I.value=0,se.value=0,B.value=!1,C.value="",j.value=0,ce.value=0,H.value=!1,y.value=!1,w.value=!1,E.value=!1,te.value="",M.value=!1,F.value=[],O.value={staged:[],unstaged:[],untracked:[]},K.value=[],ue.value=!1,ve.value=!1,me.value=!1,ie.value=!1,re.value=!1}async function de(c=!1,f=!1){if(!h.value)return;const V=Date.now();if(!c&&!f&&V-j.value<3e4){console.log("使用缓存的分支状态");return}try{console.log("获取分支状态...");let b="/api/branch-status";const fe=[];c&&fe.push("force=true"),f&&fe.push("countOnly=true"),fe.length>0&&(b+="?"+fe.join("&"));const Ee=await(await fetch(b)).json();Ee&&(I.value=Ee.ahead||0,se.value=Ee.behind||0,B.value=Ee.hasUpstream||!1,C.value=Ee.upstreamBranch||"",j.value=V,console.log(`分支状态更新:领先 ${I.value} 个提交,落后 ${se.value} 个提交,上游分支:${B.value?C.value:"无"}`))}catch(b){console.error("获取分支状态失败:",b),I.value=0,se.value=0,B.value=!1,C.value=""}}async function Te(){const c=Date.now();if(c-U.value<1e3)return console.log("使用缓存的Git仓库状态:",h.value?"是":"不是"),h.value;try{const V=await(await fetch("/api/current_directory")).json();return h.value=V.isGitRepo===!0,U.value=c,console.log(`当前目录${h.value?"是":"不是"}Git仓库`),h.value}catch(f){return console.error("检查Git仓库状态失败:",f),h.value=!1,U.value=c,!1}}async function Le(c=!1){try{const b=await(await fetch(c?"/api/branch?force=true":"/api/branch")).json();b.branch&&(r.value=b.branch,console.log(`当前分支更新为: ${b.branch}${c?" (强制刷新)":""}`))}catch(f){console.error("获取分支信息失败:",f)}}async function De(){if(h.value)try{console.log("获取所有分支...");const f=await(await fetch("/api/branches")).json();f.branches&&Array.isArray(f.branches)&&(l.value=f.branches,ce.value=Date.now(),console.log(`获取到${f.branches.length}个分支`))}catch(c){console.error("获取所有分支信息失败:",c)}}async function Pe(c){console.log("切换到分支:",c);try{_.value=!0;const V=await(await fetch("/api/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:c})})).json();return V.success?(o({message:`已切换到分支: ${c}`,type:"success"}),await Le(!0),await de(!0),!0):(o({message:`切换分支失败: ${V.error}`,type:"error"}),!1)}catch(f){return o({message:`切换分支失败: ${f.message}`,type:"error"}),!1}finally{_.value=!1}}async function oe(){try{const f=await(await fetch("/api/user-info")).json();f.name&&f.email&&(i.value=f.name,p.value=f.email)}catch(c){console.error("获取用户信息失败:",c)}}async function Oe(c,f){if(!c.trim())return o({message:"分支名称不能为空",type:"warning"}),!1;try{R.value=!0;const b=await(await fetch("/api/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newBranchName:c,baseBranch:f||r.value})})).json();return b.success?(o({message:`已创建并切换到分支: ${c}`,type:"success"}),await Le(!0),await de(!0),await De(),!0):(o({message:`创建分支失败: ${b.error}`,type:"error"}),!1)}catch(V){return o({message:`创建分支失败: ${V.message}`,type:"error"}),!1}finally{R.value=!1}}async function Me(){try{const f=await(await fetch("/api/clear-user-config",{method:"POST"})).json();return f.success?(i.value="",p.value="",o({message:"已清除Git用户配置",type:"success"}),!0):(o({message:`清除配置失败: ${f.error}`,type:"error"}),!1)}catch(c){return o({message:`清除配置失败: ${c.message}`,type:"error"}),!1}}async function at(c,f){try{const b=await(await fetch("/api/restore-user-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c,email:f})})).json();return b.success?(i.value=c,p.value=f,o({message:"已恢复Git用户配置",type:"success"}),!0):(o({message:`恢复配置失败: ${b.error}`,type:"error"}),!1)}catch(V){return o({message:`恢复配置失败: ${V.message}`,type:"error"}),!1}}async function Ze(){if(!h.value)return o({message:"当前目录不是Git仓库",type:"warning"}),!1;try{y.value=!0;const f=await(await fetch("/api/pull",{method:"POST"})).json();return f.success?(o({message:"拉取成功",type:"success"}),await de(),!0):(f.needsMerge?o({message:`需要合并更改: ${f.pullOutput||"存在冲突需要手动解决"}`,type:"warning",duration:5e3}):o({message:`拉取失败: ${f.error}`,type:"error"}),!1)}catch(c){return o({message:`拉取失败: ${c.message}`,type:"error"}),!1}finally{y.value=!1}}async function Ne(){if(!h.value)return o({message:"当前目录不是Git仓库",type:"warning"}),!1;try{w.value=!0;const f=await(await fetch("/api/fetch-all",{method:"POST"})).json();return f.success?(o({message:"获取所有远程分支信息成功",type:"success"}),await de(),!0):(o({message:`获取远程分支信息失败: ${f.error}`,type:"error"}),!1)}catch(c){return o({message:`获取远程分支信息失败: ${c.message}`,type:"error"}),!1}finally{w.value=!1}}async function Je(){k.value&&k.value.disconnect();try{const c=`http://localhost:${Po}`;if(console.log("尝试连接Socket.IO服务器:",c),k.value=Xs(c,{reconnectionDelayMax:1e4,reconnection:!0,reconnectionAttempts:10,reconnectionDelay:1e3,timeout:2e4,autoConnect:!0,forceNew:!0,transports:["websocket","polling"]}),!k.value){console.error("Socket.IO初始化失败: socket为null");return}console.log("Socket.IO客户端已创建,开始注册事件监听器..."),k.value.on("connect",()=>{var f;console.log("✅ Socket.IO连接成功,事件监听器已生效,Socket ID:",(f=k.value)==null?void 0:f.id),ne.value&&k.value&&k.value.emit("start_monitoring")}),k.value.on("project_info",f=>{D.value=f.projectPath,ye.value=f.projectRoomId,console.log(`当前项目: ${f.projectPath}`),console.log(`房间ID: ${f.projectRoomId}`)}),k.value.on("project_changed",f=>{console.log(`项目已切换: ${f.oldProjectPath} -> ${f.newProjectPath}`),D.value=f.newProjectPath,ye.value=f.newProjectRoomId,k.value&&k.value.emit("join_room",f.newProjectRoomId),console.log(`已加入新项目房间: ${f.newProjectRoomId}`)}),k.value.on("disconnect",f=>{console.log("与Socket.IO服务器断开连接:",f)}),k.value.on("git_status_update",f=>{if(ne.value){if(console.log("✅ 成功监听到 git_status_update 事件:",new Date().toLocaleTimeString()),console.log("git_status_update data ==>",f),console.log("currentProjectPath.value ==>",D.value),console.log("data.projectPath ==>",f.projectPath),f.projectPath&&D.value&&f.projectPath!==D.value){console.log(`忽略不同项目的状态更新: ${f.projectPath}`);return}console.log("正在更新 Git 文件状态..."),f.porcelain!==void 0&&u(f.porcelain)}}),k.value.on("monitoring_status",f=>{console.log("文件监控状态:",f.active?"已启动":"已停止")}),k.value.on("connect_error",f=>{console.error("Socket连接错误:",f.message)}),k.value.on("connect_timeout",()=>{console.error("Socket连接超时")}),k.value.on("reconnect",f=>{var V;console.log(`Socket重连成功,尝试次数: ${f}`),ne.value&&(console.log("重连后重新发送start_monitoring请求"),(V=k.value)==null||V.emit("start_monitoring"))}),k.value.on("reconnect_attempt",f=>{console.log(`Socket尝试重连,第 ${f} 次尝试`)}),k.value.on("reconnect_error",f=>{console.error("Socket重连错误:",f.message)}),k.value.on("reconnect_failed",()=>{console.error("Socket重连失败,已达到最大重试次数")}),console.log("Socket.IO事件监听器注册完成:connect, project_info, project_changed, git_status_update, monitoring_status"),k.value&&!k.value.connected&&(console.log("Socket未连接,尝试手动连接..."),k.value.connect())}catch(c){console.error("Socket.IO连接初始化失败:",c)}}function P(){if(console.log("toggleAutoUpdate调用,当前值:",ne.value),!k.value){console.error("无法切换自动更新状态: socket连接不存在"),o.error("无法连接到服务器,自动更新可能不会生效"),console.log("尝试重新建立socket连接..."),Je(),localStorage.setItem("zen-gitsync-auto-update",ne.value.toString());return}try{ne.value?(console.log("发送start_monitoring命令..."),k.value.emit("start_monitoring"),o.success("自动更新已启用")):(console.log("发送stop_monitoring命令..."),k.value.emit("stop_monitoring"),o.info("自动更新已禁用")),localStorage.setItem("zen-gitsync-auto-update",ne.value.toString()),console.log("已保存自动更新设置到本地存储:",ne.value)}catch(c){console.error("切换自动更新状态时出错:",c),o.error(`切换自动更新失败: ${c.message}`)}}function u(c){if(c===void 0||c===""){K.value=[];return}const f=c.split(`
2
+ `),V=[];for(const b of f){const fe=b.match(/^([ MADRCU\?]{2})\s+(.+)$/);if(fe){let ze="";const Ee=fe[1],tt=Ee.charAt(0),ht=Ee.charAt(1);tt==="A"||tt==="M"||tt==="D"||tt==="R"?ze="added":tt===" "&&ht==="M"?ze="modified":tt===" "&&ht==="D"?ze="deleted":Ee==="??"?ze="untracked":ze="other",V.push({path:fe[2],type:ze})}}K.value=V}async function le(c=!0){if(!h.value){console.log("当前目录不是Git仓库,跳过加载提交历史");return}try{ue.value=!0,console.log("开始加载提交历史...");const f=new Date().getTime(),b=await(await fetch(`/api/log?page=1&_t=${f}`)).json();b&&b.data&&Array.isArray(b.data)?(F.value=[...b.data],console.log(`提交历史加载完成,共 ${F.value.length} 条记录`)):(console.warn("API返回的提交历史格式不正确:",b),F.value=[])}catch(f){console.error("获取提交历史失败:",f),c&&o({message:`获取提交历史失败: ${f.message}`,type:"error"})}finally{ue.value=!1}}async function J(){if(!h.value){console.log("当前目录不是Git仓库,跳过加载Git状态");return}try{ve.value=!0,await Se()}catch(c){console.error("获取Git状态失败:",c),o({message:`获取Git状态失败: ${c.message}`,type:"error"})}finally{ve.value=!1}}async function Se(){if(console.log("开始获取Git状态(porcelain格式)..."),!h.value){console.log("当前目录不是Git仓库,跳过加载Git状态");return}try{const f=await(await fetch("/api/status_porcelain")).json();f.status!==void 0?u(f.status):K.value=[]}catch(c){console.error("获取Git状态(porcelain)失败:",c),o({message:`获取Git状态(porcelain)失败: ${c.message}`,type:"error"}),K.value=[]}}async function Ve(){if(!h.value)return o.warning("当前目录不是Git仓库"),!1;try{me.value=!0;const c=K.value.filter(f=>{const V=f.path.replace(/\\/g,"/");return!N.lockedFiles.some(fe=>{const ze=fe.replace(/\\/g,"/");return V===ze})});if(c.length===0)return o({message:"没有需要暂存的文件(所有文件都被锁定)",type:"warning"}),!1;if(c.length===K.value.length){const V=await(await fetch("/api/add",{method:"POST"})).json();return V.success?(o({message:"文件已添加到暂存区",type:"success"}),!0):(o({message:`添加文件失败: ${V.error}`,type:"error"}),!1)}else{const V=await(await fetch("/api/add-filtered",{method:"POST"})).json();if(V.success){const b=K.value.length-c.length;let fe=`已添加 ${c.length} 个文件到暂存区`;return b>0&&(fe+=`,跳过 ${b} 个锁定文件`),o({message:fe,type:"success"}),!0}else return o({message:`添加文件失败: ${V.error}`,type:"error"}),!1}}catch(c){return o({message:`添加文件失败: ${c.message}`,type:"error"}),!1}finally{me.value=!1}}async function _e(){if(!h.value)return o.warning("当前目录不是Git仓库"),!1;try{me.value=!0;const f=await(await fetch("/api/add-all",{method:"POST"})).json();return f.success?(o({message:"所有文件已添加到暂存区",type:"success"}),!0):(o({message:`添加文件失败: ${f.error}`,type:"error"}),!1)}catch(c){return o({message:`添加文件失败: ${c.message}`,type:"error"}),!1}finally{me.value=!1}}async function $e(c){if(!h.value)return o.warning("当前目录不是Git仓库"),!1;try{me.value=!0;const V=await(await fetch("/api/add-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:c})})).json();return V.success?(o({message:"文件已暂存",type:"success"}),J(),!0):(o({message:`暂存文件失败: ${V.error}`,type:"error"}),!1)}catch(f){return o({message:`暂存文件失败: ${f.message}`,type:"error"}),!1}finally{me.value=!1}}async function Ue(c){if(!h.value)return o.warning("当前目录不是Git仓库"),!1;try{re.value=!0;const V=await(await fetch("/api/unstage-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:c})})).json();return V.success?(o({message:"已取消暂存文件",type:"success"}),J(),!0):(o({message:`取消暂存失败: ${V.error}`,type:"error"}),!1)}catch(f){return o({message:`取消暂存失败: ${f.message}`,type:"error"}),!1}finally{re.value=!1}}function be(c){return new Promise(f=>setTimeout(f,c))}async function Ce(c,f=!1){if(!h.value)return o.warning("当前目录不是Git仓库"),!1;try{ie.value=!0;const b=await(await fetch("/api/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:c,hasNewlines:c.includes(`
3
+ `),noVerify:f})})).json();return b.success?(o({message:"提交成功",type:"success"}),!0):(o({message:`commitChanges 提交失败: ${b.error}`,type:"error"}),!1)}catch(V){return o({message:`提交失败: ${V.message}`,type:"error"}),!1}finally{ie.value=!1}}async function We(){if(!h.value)return o.warning("当前目录不是Git仓库"),!1;try{H.value=!0;const f=await(await fetch("/api/push",{method:"POST"})).json();return f.success?(I.value=0,se.value=0,await Promise.all([J(),le()]),console.log("推送成功,分支状态已设置为同步 (ahead=0, behind=0)"),!0):(o({message:`推送失败: ${f.error}`,type:"error"}),!1)}catch(c){return o({message:`推送失败: ${c.message}`,type:"error"}),!1}finally{H.value=!1}}async function Ie(c,f={}){if(!h.value)return o({message:"当前目录不是Git仓库",type:"warning"}),!1;if(!c)return o({message:"请选择要合并的分支",type:"warning"}),!1;if(c===r.value)return o({message:"不能合并当前分支到自身",type:"warning"}),!1;try{E.value=!0;const V=await fetch("/api/merge",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:c,...f})}),b=await V.json();return V.status===409?(o({message:"合并分支时发生冲突,请手动解决",type:"warning",duration:5e3}),!1):b.success?(o({message:`成功合并分支 ${c} 到 ${r.value}`,type:"success"}),await J(),await de(),!0):(o({message:`合并分支失败: ${b.error}`,type:"error"}),!1)}catch(V){return o({message:`合并分支失败: ${V.message}`,type:"error"}),!1}finally{E.value=!1}}async function ee(c,f=!1){if(console.log("开始暂存并提交操作..."),!await Ve())return!1;console.log("暂存完成,等待Git操作完成..."),await be(Ht),console.log("开始提交更改...");const b=await Ce(c,f);return console.log("暂存并提交操作完成"),b}async function lt(c,f=!1){try{if(console.log("开始暂存文件..."),!await Ve()||(console.log("暂存完成,等待Git操作完成..."),await be(Ht),console.log("开始提交更改..."),!await Ce(c,f)))return!1;console.log("提交完成,等待Git操作完成..."),await be(Ht),console.log("开始推送到远程...");const fe=await We();return console.log("一键推送操作完成,状态已统一刷新"),fe}catch(V){console.error("一键推送操作失败:",V);try{(await(await fetch("/api/remove-lock",{method:"POST"})).json()).success&&o({message:"检测到Git锁定文件冲突,已自动清理,请重试操作",type:"warning"})}catch(b){console.error("清理锁定文件失败:",b)}o({message:`操作失败: ${V.message}`,type:"error"});try{await Promise.all([J(),le(),de()])}catch(b){console.error("刷新状态失败:",b)}return!1}}async function nt(){if(!h.value)return o.warning("当前目录不是Git仓库"),!1;try{re.value=!0;const f=await(await fetch("/api/reset-head",{method:"POST"})).json();return f.success?(o({message:"已重置暂存区",type:"success"}),J(),!0):(o({message:`重置暂存区失败: ${f.error}`,type:"error"}),!1)}catch(c){return o({message:`重置暂存区失败: ${c.message}`,type:"error"}),!1}finally{re.value=!1}}async function pt(c){if(!h.value)return o.warning("当前目录不是Git仓库"),!1;try{re.value=!0;const V=await(await fetch("/api/reset-to-remote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:c})})).json();return V.success?(o({message:`已重置分支 ${c} 到远程状态`,type:"success"}),J(),le(),!0):(o({message:`重置分支失败: ${V.error}`,type:"error"}),!1)}catch(f){return o({message:`重置分支失败: ${f.message}`,type:"error"}),!1}finally{re.value=!1}}async function mt(){if(h.value)try{M.value=!0,console.log("获取远程仓库地址...");const f=await(await fetch("/api/remote-url")).json();f.success?(te.value=f.url||"",console.log(`获取到远程仓库地址: ${te.value}`)):(console.warn("获取远程仓库地址失败:",f.error),te.value="")}catch(c){console.error("获取远程仓库地址失败:",c),te.value=""}finally{M.value=!1}}async function vt(){if(!te.value)return o({message:"没有可复制的远程仓库地址",type:"warning"}),!1;try{return await navigator.clipboard.writeText(te.value),o({message:"已复制远程仓库地址",type:"success"}),!0}catch(c){return console.error("复制远程仓库地址失败:",c),o({message:`复制失败: ${c.message}`,type:"error"}),!1}}dt(()=>{const c=localStorage.getItem("zen-gitsync-auto-update");c!==null&&(ne.value=c==="true"),Je()});function et(){k.value&&(k.value.disconnect(),k.value=null)}vs(()=>{et()});async function Re(){if(!h.value)return o.warning("当前目录不是Git仓库"),[];try{pe.value=!0;const f=await(await fetch("/api/stash-list")).json();return f.success?(Q.value=f.stashes,f.stashes):(o.error(`获取stash列表失败: ${f.error}`),[])}catch(c){return console.error("获取stash列表失败:",c),o.error(`获取stash列表失败: ${c.message}`),[]}finally{pe.value=!1}}async function gt(c,f=!1,V=!0){if(!h.value)return o.warning("当前目录不是Git仓库"),!1;try{ae.value=!0;const fe=await(await fetch("/api/stash-save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:c,includeUntracked:f,excludeLocked:V})})).json();return fe.success?(o.success(fe.message),await Re(),await J(),!0):(o.warning(fe.message),!1)}catch(b){return console.error("保存stash失败:",b),o.error(`保存stash失败: ${b.message}`),!1}finally{ae.value=!1}}async function $(c,f=!1){if(!h.value)return o.warning("当前目录不是Git仓库"),!1;try{z.value=!0;const V=await fetch("/api/stash-apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stashId:c,pop:f})}),b=await V.json();return V.status===409?(o.warning("应用stash时发生冲突,请手动解决"),!1):b.success?(o.success(b.message),await Re(),await J(),!0):(o.error(`应用stash失败: ${b.error}`),!1)}catch(V){return console.error("应用stash失败:",V),o.error(`应用stash失败: ${V.message}`),!1}finally{z.value=!1}}async function g(c){if(!h.value)return o.warning("当前目录不是Git仓库"),!1;try{T.value=!0;const V=await(await fetch("/api/stash-drop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stashId:c})})).json();return V.success?(o.success(V.message),await Re(),!0):(o.error(`删除stash失败: ${V.error}`),!1)}catch(f){return console.error("删除stash失败:",f),o.error(`删除stash失败: ${f.message}`),!1}finally{T.value=!1}}async function W(){if(!h.value)return o.warning("当前目录不是Git仓库"),!1;try{T.value=!0;const f=await(await fetch("/api/stash-clear",{method:"POST"})).json();return f.success?(o.success(f.message),Q.value=[],!0):(o.error(`清空stash失败: ${f.error}`),!1)}catch(c){return console.error("清空stash失败:",c),o.error(`清空stash失败: ${c.message}`),!1}finally{T.value=!1}}return{currentBranch:r,allBranches:l,userName:i,userEmail:p,isChangingBranch:_,isCreatingBranch:R,isGitRepo:h,lastCheckedTime:U,branchAhead:I,branchBehind:se,hasUpstream:B,upstreamBranch:C,lastBranchStatusTime:j,lastBranchesTime:ce,remoteUrl:te,isLoadingRemoteUrl:M,stashes:Q,isLoadingStashes:pe,isApplyingStash:z,isDroppingStash:T,isSavingStash:ae,log:F,status:O,fileList:K,isLoadingLog:ue,isLoadingStatus:ve,isAddingFiles:me,isCommiting:ie,isResetting:re,autoUpdateEnabled:ne,isPushing:H,isGitPulling:y,isGitFetching:w,isGitMerging:E,$reset:X,checkGitRepo:Te,getCurrentBranch:Le,getAllBranches:De,changeBranch:Pe,getUserInfo:oe,createBranch:Oe,clearUserConfig:Me,restoreUserConfig:at,getBranchStatus:de,gitPull:Ze,gitFetchAll:Ne,initSocketConnection:Je,toggleAutoUpdate:P,parseStatusPorcelain:u,fetchLog:le,fetchStatus:J,fetchStatusPorcelain:Se,addToStage:Ve,addAllToStage:_e,addFileToStage:$e,unstageFile:Ue,commitChanges:Ce,pushToRemote:We,addAndCommit:ee,addCommitAndPush:lt,resetHead:nt,resetToRemote:pt,getRemoteUrl:mt,copyRemoteUrl:vt,mergeBranch:Ie,getStashList:Re,saveStash:gt,applyStash:$,dropStash:g,clearAllStashes:W,socket:k,disconnectSocket:et}});function zo(N){return N.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function jo(N){return N?N.split(`
4
+ `).map(l=>{const i=zo(l);return l.startsWith("diff --git")||l.startsWith("diff --cc")||l.startsWith("diff --combined")?`<div class="diff-header">${i}</div>`:l.startsWith("---")?`<div class="diff-old-file">${i}</div>`:l.startsWith("+++")?`<div class="diff-new-file">${i}</div>`:l.startsWith("@@")?`<div class="diff-hunk-header">${i}</div>`:l.startsWith("+")?`<div class="diff-added">${i}</div>`:l.startsWith("-")?`<div class="diff-removed">${i}</div>`:`<div class="diff-context">${i}</div>`}).join(""):""}function Do(N){return N?N.trim():"(无提交信息)"}function Oo(N){if(!N)return"";const r=/^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\([^)]+\))?\s*:\s*(.+)$/s,l=N.match(r);return l?l[3].trim():N.trim()}const Ro="/assets/vscode-twqwGmNt.webp",Go={key:0,class:"files-panel"},Ao={class:"panel-header"},Mo={key:0,class:"file-count"},Uo={class:"files-list"},Eo=["onClick"],Io={class:"file-name"},No={class:"panel-header"},Ho={class:"header-right"},Jo={key:0,class:"selected-file"},Wo={key:1,class:"action-buttons"},qo=["src"],Yo={class:"diff-content"},Ko=["innerHTML"],Qo=xe({__name:"FileDiffViewer",props:{files:{},emptyText:{default:"没有找到变更文件"},diffContent:{default:""},selectedFile:{default:""},height:{default:"100%"},showFileList:{type:Boolean,default:!0},context:{default:"git-status"},showOpenButton:{type:Boolean,default:!0}},emits:["file-select","open-file","open-with-vscode"],setup(N,{emit:r}){const l=N,i=r,p=d(""),_=q(()=>l.selectedFile||p.value),R=q(()=>l.files.map(y=>({...y,displayName:y.name||y.path.split("/").pop()||y.path}))),h=q(()=>l.diffContent&&l.diffContent.trim()!=="");function U(y){p.value=y,i("file-select",y)}function te(){if(!_.value){o.warning("请先选择一个文件");return}i("open-file",_.value,l.context)}function M(){if(!_.value){o.warning("请先选择一个文件");return}i("open-with-vscode",_.value,l.context)}const H=q(()=>{switch(l.context){case"git-status":return"在系统默认编辑器中打开文件";case"commit-detail":return"打开该提交时的文件版本";case"stash-detail":return"打开该stash中的文件版本";default:return"打开文件"}});return je(()=>l.selectedFile,y=>{y!==void 0&&(p.value=y)}),je(()=>l.files,y=>{if(y.length>0&&!_.value){const w=y[0];U(w.path)}},{immediate:!0}),(y,w)=>(v(),S("div",{class:"file-diff-viewer",style:ft({height:y.height})},[y.showFileList?(v(),S("div",Go,[e("div",Ao,[w[0]||(w[0]=e("h4",null,"变更文件",-1)),y.files.length>0?(v(),S("span",Mo,"("+A(y.files.length)+")",1)):Y("",!0)]),e("div",Uo,[t(n(Zs),{height:"100%"},{default:s(()=>[y.files.length===0?(v(),Z(n(zt),{key:0,description:y.emptyText,"image-size":60},null,8,["description"])):Y("",!0),(v(!0),S(Fe,null,Ae(R.value,E=>(v(),S("div",{key:E.path,class:ke(["file-item",{active:E.path===_.value,[`file-type-${E.type}`]:E.type}]),onClick:I=>U(E.path)},[t(n(st),{class:"file-icon"},{default:s(()=>[t(n(Yt))]),_:1}),t(n(Ye),{content:E.path,placement:"top",disabled:E.displayName.length<=35,"hide-after":1e3,"show-after":200},{default:s(()=>[e("span",Io,A(E.displayName),1)]),_:2},1032,["content","disabled"])],10,Eo))),128))]),_:1})])])):Y("",!0),e("div",{class:ke(["diff-panel",{"full-width":!y.showFileList}])},[e("div",No,[w[3]||(w[3]=e("h4",null,"文件差异",-1)),e("div",Ho,[_.value?(v(),S("span",Jo,A(_.value.split("/").pop()),1)):Y("",!0),y.showOpenButton&&_.value?(v(),S("div",Wo,[t(n(Ye),{content:H.value,placement:"top",effect:"light"},{default:s(()=>[t(n(he),{type:"primary",size:"small",icon:n(eo),onClick:te,class:"open-file-btn"},{default:s(()=>w[1]||(w[1]=[x(" 打开文件 ")])),_:1},8,["icon"])]),_:1},8,["content"]),t(n(Ye),{content:"用VSCode打开文件",placement:"top",effect:"light"},{default:s(()=>[t(n(he),{type:"success",size:"small",onClick:M,class:"vscode-btn"},{default:s(()=>[e("img",{src:n(Ro),alt:"VSCode",class:"vscode-icon"},null,8,qo),w[2]||(w[2]=x(" VSCode "))]),_:1})]),_:1})])):Y("",!0)])]),e("div",Yo,[h.value?(v(),S("div",{key:1,class:"diff-text",innerHTML:n(jo)(y.diffContent)},null,8,Ko)):(v(),Z(n(zt),{key:0,description:_.value?"该文件没有差异内容":"请选择文件查看差异","image-size":80},null,8,["description"]))])],2)],4))}}),Be=(N,r)=>{const l=N.__vccOpts||N;for(const[i,p]of r)l[i]=p;return l},ss=Be(Qo,[["__scopeId","data-v-1640713a"]]),Xo={class:"common-dialog__footer"},Zo=xe({__name:"CommonDialog",props:{modelValue:{type:Boolean},title:{},size:{default:"medium"},type:{default:"default"},width:{},height:{},top:{default:"8vh"},closeOnClickModal:{type:Boolean,default:!1},closeOnPressEscape:{type:Boolean,default:!0},destroyOnClose:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},customClass:{},appendToBody:{type:Boolean,default:!1},lockScroll:{type:Boolean,default:!0},showFooter:{type:Boolean,default:!1},confirmText:{default:"确定"},cancelText:{default:"取消"},showCancel:{type:Boolean,default:!0},confirmLoading:{type:Boolean,default:!1}},emits:["update:modelValue","confirm","cancel","close","opened","closed"],setup(N,{emit:r}){const l=N,i=r,p=q(()=>{if(l.width)return l.width;switch(l.size){case"small":return"30%";case"medium":return"50%";case"large":return"80%";case"extra-large":return"90%";default:return"50%"}}),_=q(()=>{if(l.height)return l.height;switch(l.type){case"full-height":return"calc(100vh - 100px)";case"flex":return"calc(100vh - 160px)";default:return"auto"}}),R=q(()=>{const w={};return(l.type==="full-height"||l.type==="flex")&&(w["--dialog-height"]=_.value),w}),h=q(()=>{const w=[];return l.customClass&&w.push(l.customClass),l.type==="flex"&&w.push("common-dialog--flex"),l.type==="full-height"&&w.push("common-dialog--full-height"),w.join(" ")});function U(){i("update:modelValue",!1),i("close")}function te(){i("confirm")}function M(){i("cancel"),U()}function H(){i("opened")}function y(){i("closed")}return(w,E)=>{const I=he;return v(),Z(n(Vt),{"model-value":w.modelValue,title:w.title,width:p.value,top:w.top,style:ft(R.value),"close-on-click-modal":w.closeOnClickModal,"close-on-press-escape":w.closeOnPressEscape,"destroy-on-close":w.destroyOnClose,draggable:w.draggable,class:ke(h.value),"append-to-body":w.appendToBody,"lock-scroll":w.lockScroll,onClose:U,onOpened:H,onClosed:y},to({default:s(()=>[rs(w.$slots,"default",{},void 0,!0)]),_:2},[w.showFooter||w.$slots.footer?{name:"footer",fn:s(()=>[rs(w.$slots,"footer",{},()=>[e("div",Xo,[w.showCancel?(v(),Z(I,{key:0,onClick:M},{default:s(()=>[x(A(w.cancelText),1)]),_:1})):Y("",!0),t(I,{type:"primary",loading:w.confirmLoading,onClick:te},{default:s(()=>[x(A(w.confirmText),1)]),_:1},8,["loading"])])],!0)]),key:"0"}:void 0]),1032,["model-value","title","width","top","style","close-on-click-modal","close-on-press-escape","destroy-on-close","draggable","class","append-to-body","lock-scroll"])}}}),Ft=Be(Zo,[["__scopeId","data-v-c1505473"]]),ea={key:0,class:"file-group"},ta={class:"file-list"},sa=["onClick"],oa={class:"file-info"},aa={class:"file-name-section"},la=["title"],na={class:"file-directory"},ia={class:"file-actions"},ra={key:1,style:{"font-size":"16px","font-weight":"bold"}},ca=xe({__name:"FileGroup",props:{files:{},title:{},groupKey:{},collapsedGroups:{},isFileLocked:{type:Function},getFileName:{type:Function},getFileDirectory:{type:Function}},emits:["toggleCollapse","fileClick","toggleFileLock","stageFile","unstageFile","revertFileChanges"],setup(N,{emit:r}){const l=N,i=r,p=q(()=>l.files.length>0),_=q(()=>l.collapsedGroups[l.groupKey]);function R(){i("toggleCollapse",l.groupKey)}function h(w){i("fileClick",w)}function U(w,E){E.stopPropagation(),i("toggleFileLock",w)}function te(w,E){E.stopPropagation(),i("stageFile",w)}function M(w,E){E.stopPropagation(),i("unstageFile",w)}function H(w,E){E.stopPropagation(),i("revertFileChanges",w)}function y(w){switch(w){case"added":return[{type:"unstage",tooltip:"取消暂存",buttonType:"warning",icon:"-",handler:M}];case"modified":case"deleted":return[{type:"stage",tooltip:"添加到暂存区",buttonType:"success",icon:"+",handler:te},{type:"revert",tooltip:"撤回修改",buttonType:"danger",icon:Qt,handler:H}];case"untracked":return[{type:"stage",tooltip:"添加到暂存区",buttonType:"success",icon:"+",handler:te},{type:"delete",tooltip:"删除文件",buttonType:"danger",icon:Kt,handler:H}];default:return[]}}return(w,E)=>{const I=st,se=Ye,B=he;return p.value?(v(),S("div",ea,[e("div",{class:"file-group-header",onClick:R},[t(I,{class:ke(["collapse-icon",{collapsed:_.value}])},{default:s(()=>[t(n(Rt))]),_:1},8,["class"]),e("span",null,A(w.title),1)]),Xe(e("div",ta,[(v(!0),S(Fe,null,Ae(w.files,C=>(v(),S("div",{key:C.path,class:"file-item",onClick:j=>h(C)},[e("div",oa,[e("div",{class:ke(["file-status-indicator",[C.type,{locked:l.isFileLocked(C.path)}]])},null,2),e("div",aa,[t(se,{content:l.getFileName(C.path),placement:"top",disabled:l.getFileName(C.path).length<=25,"hide-after":1e3,"show-after":200},{default:s(()=>[e("span",{class:ke(["file-name",{"locked-file-name":l.isFileLocked(C.path)}])},[x(A(l.getFileName(C.path))+" ",1),l.isFileLocked(C.path)?(v(),Z(I,{key:0,class:"lock-indicator"},{default:s(()=>[t(n(jt))]),_:1})):Y("",!0)],2)]),_:2},1032,["content","disabled"])]),e("div",{class:"file-path-section",title:l.getFileDirectory(C.path)},[t(se,{content:l.getFileDirectory(C.path),placement:"top",disabled:l.getFileDirectory(C.path).length<=30,"hide-after":1e3,"show-after":200},{default:s(()=>[e("span",na,A(l.getFileDirectory(C.path)),1)]),_:2},1032,["content","disabled"])],8,la)]),e("div",ia,[t(se,{content:l.isFileLocked(C.path)?"解锁文件":"锁定文件",placement:"top","hide-after":1e3,"show-after":200},{default:s(()=>[t(B,{type:l.isFileLocked(C.path)?"danger":"info",size:"small",text:"",onClick:j=>U(C.path,j),class:"file-action-btn"},{default:s(()=>[t(I,{size:"16"},{default:s(()=>[(v(),Z(bt(l.isFileLocked(C.path)?n(jt):n(gs))))]),_:2},1024)]),_:2},1032,["type","onClick"])]),_:2},1032,["content"]),(v(!0),S(Fe,null,Ae(y(C.type),j=>(v(),Z(se,{key:j.type,content:j.tooltip,placement:"top","hide-after":1e3,"show-after":200},{default:s(()=>[t(B,{type:j.buttonType,size:"small",text:"",onClick:ce=>j.handler(C.path,ce),class:"file-action-btn"},{default:s(()=>[typeof j.icon!="string"?(v(),Z(I,{key:0,size:"16"},{default:s(()=>[(v(),Z(bt(j.icon)))]),_:2},1024)):(v(),S("span",ra,A(j.icon),1))]),_:2},1032,["type","onClick"])]),_:2},1032,["content"]))),128))])],8,sa))),128))],512),[[St,!_.value]])])):Y("",!0)}}}),Jt=Be(ca,[["__scopeId","data-v-1197e0f9"]]),ua={class:"card"},da={class:"status-header"},fa={class:"header-actions"},pa=["element-loading-text"],ma={key:0,class:"status-box"},va={key:1,class:"status-box-wrap"},ga={key:0,class:"branch-status-info"},ha={class:"branch-sync-status"},ya={class:"sync-status-content"},_a={class:"status-badges"},wa={class:"badge-content"},ka={class:"badge-content"},$a={key:1,class:"file-list-container"},ba={key:2,class:"empty-status"},Ca={class:"empty-icon"},Sa={class:"lock-feature-description"},Ta={class:"description-header"},Fa={key:0,class:"empty-locked-files"},Va={class:"empty-icon"},La={key:1,class:"locked-files-list"},xa={class:"locked-files-header"},Ba={class:"locked-file-items"},Pa={class:"file-info"},za={class:"file-path-container"},ja={class:"file-name"},Da={class:"file-directory"},Oa={class:"file-actions"},Ra={class:"dialog-footer"},Ga=xe({__name:"GitStatus",props:{initialDirectory:{type:String,default:""}},setup(N,{expose:r}){const l=N,i=Qe(),p=ot(),_=q(()=>i.isLoadingStatus),R=d(""),h=d(""),U=d(!1),te=d(!1),M=d(-1),H=q(()=>i.fileList.map(z=>({path:z.path,name:z.path.split("/").pop()||z.path,type:z.type})));async function y(z){await ne(z)}async function w(z,T){try{const X=await(await fetch("/api/open-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:z,context:T})})).json();X.success?o.success(X.message):o.error(X.error||"打开文件失败")}catch(ae){o.error(`打开文件失败: ${ae.message}`)}}async function E(z,T){try{const X=await(await fetch("/api/open-with-vscode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:z,context:T})})).json();X.success?o.success(X.message):o.error(X.error||"用VSCode打开文件失败")}catch(ae){o.error(`用VSCode打开文件失败: ${ae.message}`)}}const I=d(!1),se=d({staged:!1,unstaged:!1,untracked:!1}),B=d(l.initialDirectory||"");async function C(){try{if(!B.value){const T=await(await fetch("/api/current_directory")).json();B.value=T.directory||"未知目录"}if(!i.isGitRepo)return;await i.fetchStatus(),await i.getBranchStatus(),o({message:"Git 状态已刷新",type:"success"})}catch(z){o({message:"刷新失败: "+z.message,type:"error"})}}async function j(z){try{await He.confirm(`确认解锁该文件?
5
+ ${z}`,"确认解锁",{type:"warning",confirmButtonText:"解锁",cancelButtonText:"取消"}),await p.unlockFile(z)}catch{}}async function ce(){if(p.lockedFiles.length)try{await He.confirm(`确认解锁所有已锁定文件?共 ${p.lockedFiles.length} 个。`,"清空全部锁定",{type:"warning",confirmButtonText:"全部解锁",cancelButtonText:"取消"});const z=[...p.lockedFiles];await Promise.all(z.map(T=>p.unlockFile(T))),await p.loadLockedFiles(),o.success("已清空所有文件锁定")}catch{}}async function ne(z){try{te.value=!0,R.value=z,M.value=i.fileList.findIndex(ae=>ae.path===z);const T=i.fileList[M.value];if(T&&T.type==="untracked")try{const X=await(await fetch(`/api/file-content?file=${encodeURIComponent(z)}`)).json();X.success&&X.content?h.value=`diff --git a/${z} b/${z}
6
+ 新文件: ${z}
7
+ --- /dev/null
8
+ +++ b/${z}
9
+ @@ -0,0 +1,${X.content.split(`
10
+ `).length} @@
11
+ `+X.content.split(`
12
+ `).map(de=>`+${de}`).join(`
13
+ `):h.value=`这是一个新文件,尚未被Git跟踪。
14
+ 添加到暂存区后可以提交该文件。`}catch(ae){console.error("获取未跟踪文件内容失败:",ae),h.value=`这是一个新文件,尚未被Git跟踪。
15
+ 添加到暂存区后可以提交该文件。`}else if(T&&T.type==="added"){const X=await(await fetch(`/api/diff-cached?file=${encodeURIComponent(z)}`)).json();h.value=X.diff||"没有变更"}else{const X=await(await fetch(`/api/diff?file=${encodeURIComponent(z)}`)).json();h.value=X.diff||"没有变更"}}catch(T){o({message:"获取文件差异失败: "+T.message,type:"error"}),h.value="获取差异失败: "+T.message}finally{te.value=!1}}function k(z){if(U.value=!0,i.fileList.length>0){const T=i.fileList.find(ae=>ae.path===z.path)||i.fileList[0];ne(T.path)}}async function D(z){await i.addFileToStage(z)}async function ye(z){await i.unstageFile(z)}async function F(){await O()}async function O(){try{if(!i.isGitRepo)return;await i.fetchStatus(),o({message:"Git 文件状态已刷新",type:"success"})}catch(z){o({message:"刷新失败: "+z.message,type:"error"})}}async function K(){try{await i.gitPull(),await C()}catch(z){console.error("拉取操作发生错误:",z)}}async function ue(){try{await i.gitFetchAll(),await C()}catch(z){console.error("获取远程分支信息操作发生错误:",z)}}async function ve(z){try{await He.confirm(`确定要撤回文件 "${z}" 的所有修改吗?此操作无法撤销。`,"撤回修改",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"});const ae=await(await fetch("/api/revert_file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:z})})).json();ae.success?(o.success("已撤回文件修改"),await C()):o.error(ae.error?`撤回失败: ${ae.error}`:"撤回文件修改失败,请重试")}catch(T){if(T==="cancel"||T.message==="cancel")return;const ae=T.message||"未知错误";ae!=="undefined"?o.error(`撤回文件修改失败: ${ae}`):o.error("撤回文件修改失败,请重试")}}function me(z){const T=z.split("/");return T[T.length-1]}function ie(z){const T=z.split("/");return T.length<=1?"":T.slice(0,-1).join("/")}function re(z){const T=z.replace(/\\/g,"/");return p.lockedFiles.some(X=>{const de=X.replace(/\\/g,"/");return T===de})}function Q(z){re(z)?p.unlockFile(z):p.lockFile(z)}function pe(z){se.value[z]=!se.value[z]}return dt(()=>{C(),p.loadConfig(),p.loadLockedFiles()}),je(()=>i.autoUpdateEnabled,(z,T)=>{console.log(`自动更新状态变更: ${T} -> ${z}`),i.toggleAutoUpdate()},{immediate:!1}),r({refreshStatus:F}),(z,T)=>{const ae=hs,X=Ye,de=he,Te=st,Le=Lt,De=oo,Pe=Xt;return v(),S(Fe,null,[e("div",ua,[e("div",da,[T[5]||(T[5]=e("h2",null,"Git 状态",-1)),e("div",fa,[t(X,{content:n(i).autoUpdateEnabled?"禁用自动更新文件状态":"启用自动更新文件状态",placement:"top","hide-after":1e3,"show-after":200},{default:s(()=>[t(ae,{modelValue:n(i).autoUpdateEnabled,"onUpdate:modelValue":T[0]||(T[0]=oe=>n(i).autoUpdateEnabled=oe),style:{"--el-switch-on-color":"#67C23A","--el-switch-off-color":"#909399","margin-right":"10px"},"inline-prompt":"","active-icon":n(ys),"inactive-icon":n(Kt),class:"auto-update-switch"},null,8,["modelValue","active-icon","inactive-icon"])]),_:1},8,["content"]),t(X,{content:"Git Pull (拉取远程更新)",placement:"top","hide-after":1e3,"show-after":200},{default:s(()=>[t(de,{type:"primary",icon:n(_s),circle:"",size:"small",onClick:K,loading:n(i).isGitPulling,disabled:!n(i).hasUpstream},null,8,["icon","loading","disabled"])]),_:1}),t(X,{content:"Git Fetch All (获取所有远程分支)",placement:"top","hide-after":1e3,"show-after":200},{default:s(()=>[Xe(t(de,{type:"primary",icon:n(ws),circle:"",size:"small",onClick:ue,loading:n(i).isGitFetching},null,8,["icon","loading"]),[[St,!1]])]),_:1}),n(p).lockedFiles.length>0?(v(),Z(X,{key:0,content:"管理锁定文件",placement:"top","hide-after":1e3,"show-after":200},{default:s(()=>[t(de,{type:"warning",circle:"",size:"small",onClick:T[1]||(T[1]=oe=>I.value=!0)},{default:s(()=>[t(Te,null,{default:s(()=>[t(n(jt))]),_:1})]),_:1})]),_:1})):Y("",!0),t(X,{content:"刷新状态",placement:"top","hide-after":1e3,"show-after":200},{default:s(()=>[t(de,{type:"primary",icon:n(so),circle:"",size:"small",onClick:F,loading:_.value},null,8,["icon","loading"])]),_:1})])]),Xe((v(),S("div",{class:"card-content","element-loading-text":n(i).isGitPulling?"正在拉取代码...":"正在获取远程分支信息..."},[n(i).isGitRepo?(v(),S("div",va,[n(i).hasUpstream&&(n(i).branchAhead>0||n(i).branchBehind>0)?(v(),S("div",ga,[e("div",ha,[e("div",ya,[t(X,{content:"本地分支与远程分支的状态对比",placement:"top","show-after":200},{default:s(()=>[e("div",_a,[n(i).branchAhead>0?(v(),Z(Le,{key:0,size:"small",type:"warning",class:"status-badge"},{default:s(()=>[e("span",wa,[t(Te,null,{default:s(()=>[t(n(ks))]),_:1}),x(" 你的分支领先 'origin/"+A(n(i).currentBranch)+"' "+A(n(i).branchAhead)+" 个提交 ",1)])]),_:1})):Y("",!0),n(i).branchBehind>0?(v(),Z(Le,{key:1,size:"small",type:"info",class:"status-badge"},{default:s(()=>[e("span",ka,[t(Te,null,{default:s(()=>[t(n(Rt))]),_:1}),x(" 你的分支落后 'origin/"+A(n(i).currentBranch)+"' "+A(n(i).branchBehind)+" 个提交 ",1)])]),_:1})):Y("",!0)])]),_:1})])])])):Y("",!0),n(i).fileList.length?(v(),S("div",$a,[t(Jt,{files:n(i).fileList.filter(oe=>oe.type==="added"),title:"已暂存的更改","group-key":"staged","collapsed-groups":se.value,"is-file-locked":re,"get-file-name":me,"get-file-directory":ie,onToggleCollapse:pe,onFileClick:k,onToggleFileLock:Q,onUnstageFile:ye},null,8,["files","collapsed-groups"]),t(Jt,{files:n(i).fileList.filter(oe=>oe.type==="modified"||oe.type==="deleted"),title:"未暂存的更改","group-key":"unstaged","collapsed-groups":se.value,"is-file-locked":re,"get-file-name":me,"get-file-directory":ie,onToggleCollapse:pe,onFileClick:k,onToggleFileLock:Q,onStageFile:D,onRevertFileChanges:ve},null,8,["files","collapsed-groups"]),t(Jt,{files:n(i).fileList.filter(oe=>oe.type==="untracked"),title:"未跟踪的文件","group-key":"untracked","collapsed-groups":se.value,"is-file-locked":re,"get-file-name":me,"get-file-directory":ie,onToggleCollapse:pe,onFileClick:k,onToggleFileLock:Q,onStageFile:D,onRevertFileChanges:ve},null,8,["files","collapsed-groups"])])):n(i).isGitRepo?(v(),S("div",ba,[e("div",Ca,[t(Te,null,{default:s(()=>[t(n(Yt))]),_:1})]),T[7]||(T[7]=e("div",{class:"empty-text"},"没有检测到任何更改",-1)),T[8]||(T[8]=e("div",{class:"empty-subtext"},"工作区是干净的",-1))])):Y("",!0)])):(v(),S("div",ma,T[6]||(T[6]=[e("div",{class:"empty-status"},[e("p",null,"当前目录不是Git仓库")],-1)])))],8,pa)),[[Pe,n(i).isGitPulling||n(i).isGitFetching]])]),t(Ft,{modelValue:U.value,"onUpdate:modelValue":T[2]||(T[2]=oe=>U.value=oe),title:"文件差异","custom-class":"file-diff-dialog",size:"extra-large",type:"flex","destroy-on-close":""},{default:s(()=>[t(ss,{files:H.value,diffContent:h.value,selectedFile:R.value,context:"git-status",emptyText:"选择文件查看差异",onFileSelect:y,onOpenFile:w,onOpenWithVscode:E},null,8,["files","diffContent","selectedFile"])]),_:1},8,["modelValue"]),t(Ft,{modelValue:I.value,"onUpdate:modelValue":T[4]||(T[4]=oe=>I.value=oe),title:"锁定文件管理",size:"large","destroy-on-close":""},{footer:s(()=>[e("span",Ra,[t(de,{onClick:T[3]||(T[3]=oe=>I.value=!1)},{default:s(()=>T[16]||(T[16]=[x("关闭")])),_:1})])]),default:s(()=>[e("div",Sa,[e("div",Ta,[t(Te,{class:"description-icon"},{default:s(()=>[t(n(cs))]),_:1}),T[9]||(T[9]=e("span",{class:"description-title"},"文件锁定功能说明",-1))]),T[10]||(T[10]=e("div",{class:"description-content"},[e("ul",null,[e("li",null,"锁定的文件在执行 Git 提交时会被自动跳过,不会被添加到暂存区")])],-1))]),t(De),n(p).lockedFiles.length===0?(v(),S("div",Fa,[e("div",Va,[t(Te,null,{default:s(()=>[t(n(jt))]),_:1})]),T[11]||(T[11]=e("p",null,"当前没有锁定的文件",-1)),T[12]||(T[12]=e("p",{class:"empty-tip"},"您可以在文件列表中点击锁定按钮来锁定文件",-1))])):(v(),S("div",La,[e("div",xa,[e("span",null,"🔒 已锁定 "+A(n(p).lockedFiles.length)+" 个文件",1),t(X,{content:"这些文件在提交时会被自动跳过",placement:"top"},{default:s(()=>[t(Te,{class:"info-icon"},{default:s(()=>[t(n(cs))]),_:1})]),_:1}),T[14]||(T[14]=e("div",{style:{flex:"1"}},null,-1)),t(de,{type:"danger",size:"small",plain:"",disabled:!n(p).lockedFiles.length,onClick:ce},{default:s(()=>T[13]||(T[13]=[x(" 清空全部锁定 ")])),_:1},8,["disabled"])]),e("div",Ba,[(v(!0),S(Fe,null,Ae(n(p).lockedFiles,oe=>(v(),S("div",{key:oe,class:"locked-file-item"},[e("div",Pa,[T[15]||(T[15]=e("div",{class:"file-status-indicator locked"},null,-1)),e("div",za,[e("span",ja,A(me(oe)),1),e("span",Da,A(ie(oe)),1)])]),e("div",Oa,[t(X,{content:"解锁文件",placement:"top","hide-after":1e3},{default:s(()=>[t(de,{type:"danger",size:"small",circle:"",class:"file-action-btn",icon:n(gs),"aria-label":"解锁",onClick:Oe=>j(oe)},null,8,["icon","onClick"])]),_:2},1024)])]))),128))])]))]),_:1},8,["modelValue"])],64)}}}),Aa=Be(Ga,[["__scopeId","data-v-3573605e"]]),Ma={class:"loading-container"},Ua={class:"loading-text"},Ea={key:0,class:"loading-progress"},Ia=xe({__name:"GlobalLoading",props:{visible:{type:Boolean,default:!1},text:{default:"加载中..."},showProgress:{type:Boolean,default:!1},progress:{default:0}},setup(N){return(r,l)=>(v(),Z(Zt,{to:"body"},[t(es,{name:"loading-fade"},{default:s(()=>[r.visible?(v(),S("div",{key:0,class:"global-loading-overlay",onClick:l[0]||(l[0]=Tt(()=>{},["stop"]))},[e("div",Ma,[l[1]||(l[1]=e("div",{class:"loading-spinner"},[e("div",{class:"spinner-ring"}),e("div",{class:"spinner-ring"}),e("div",{class:"spinner-ring"})],-1)),e("div",Ua,A(r.text),1),r.showProgress?(v(),S("div",Ea,[e("div",{class:"progress-bar",style:ft({width:r.progress+"%"})},null,4)])):Y("",!0)])])):Y("",!0)]),_:1})]))}}),Na=Be(Ia,[["__scopeId","data-v-12e53b20"]]),Ha={class:"success-container"},Ja={class:"success-text"},Wa={key:0,class:"success-description"},qa=xe({__name:"SuccessModal",props:{visible:{type:Boolean,default:!1},text:{default:"操作成功!"},description:{default:""}},setup(N){return(r,l)=>(v(),Z(Zt,{to:"body"},[t(es,{name:"success-fade"},{default:s(()=>[r.visible?(v(),S("div",{key:0,class:"success-overlay",onClick:l[0]||(l[0]=Tt(()=>{},["stop"]))},[e("div",Ha,[l[1]||(l[1]=e("div",{class:"success-icon"},[e("svg",{viewBox:"0 0 52 52",class:"success-svg"},[e("circle",{class:"success-circle",cx:"26",cy:"26",r:"25",fill:"none"}),e("path",{class:"success-check",fill:"none",d:"m14.1 27.2l7.1 7.2 16.7-16.8"})])],-1)),e("div",Ja,A(r.text),1),r.description?(v(),S("div",Wa,A(r.description),1)):Y("",!0)])])):Y("",!0)]),_:1})]))}}),Ya=Be(qa,[["__scopeId","data-v-c64a7b5e"]]),Ke=$s({visible:!1,text:"加载中...",showProgress:!1,progress:0});function Ka(){return{loadingState:Ke,show:_=>{Ke.visible=!0,Ke.text=(_==null?void 0:_.text)||"加载中...",Ke.showProgress=(_==null?void 0:_.showProgress)||!1,Ke.progress=(_==null?void 0:_.progress)||0},hide:()=>{Ke.visible=!1},updateProgress:_=>{Ke.progress=Math.max(0,Math.min(100,_))},updateText:_=>{Ke.text=_},setText:_=>{Ke.visible&&(Ke.text=_)}}}const wt=$s({visible:!1,text:"操作成功!",description:""});function Qa(){const N=l=>{wt.visible=!0,wt.text=(l==null?void 0:l.text)||"操作成功!",wt.description=(l==null?void 0:l.description)||"";const i=(l==null?void 0:l.duration)||2e3;setTimeout(()=>{r()},i)},r=()=>{wt.visible=!1};return{successState:wt,show:N,hide:r}}const Xa={class:"template-form"},Za={class:"template-form-buttons"},el={key:0,class:"template-list"},tl={class:"template-content"},sl={class:"template-actions"},ol={key:1,class:"templates-container"},al={class:"message-templates-list"},ll={class:"templates-scroll-area"},nl={class:"template-content"},il={class:"template-actions"},rl={key:0,class:"current-default-message"},cl={class:"default-message-content"},ul={key:2,class:"message-help-text"},dl=xe({__name:"TemplateManager",props:{visible:{type:Boolean},type:{},title:{},placeholder:{default:"输入新模板内容"},editPlaceholder:{default:"编辑模板内容"},emptyDescription:{default:"暂无保存的模板"},showDefaultSection:{type:Boolean,default:!1},showHelpText:{type:Boolean,default:!1}},emits:["update:visible","use-template","set-default"],setup(N,{expose:r,emit:l}){const i=N,p=l,_=ot(),R=d(""),h=d(!1),U=d(""),te=d(-1),M=q(()=>{switch(i.type){case"description":return _.descriptionTemplates||[];case"scope":return _.scopeTemplates||[];case"message":return _.messageTemplates||[];default:return[]}}),H=q(()=>i.type==="message"?_.defaultCommitMessage:""),y=q(()=>h.value?i.editPlaceholder:i.placeholder),w=q(()=>h.value?"更新模板":"添加模板"),E=q({get:()=>i.visible,set:k=>p("update:visible",k)});je(E,k=>{k||I()});function I(){R.value="",h.value=!1,U.value="",te.value=-1}async function se(){if(!R.value.trim()){o.warning("模板内容不能为空");return}try{h.value?await _.updateTemplate(U.value,R.value,i.type)&&(o.success("模板更新成功"),I()):await _.saveTemplate(R.value,i.type)&&(o.success("模板保存成功"),R.value="")}catch(k){o.error(`模板保存失败: ${k.message}`)}}function B(k){p("use-template",k),i.type!=="message"&&(E.value=!1)}function C(k,D){h.value=!0,U.value=k,R.value=k,te.value=D}function j(){I()}async function ce(k){try{await _.deleteTemplate(k,i.type)&&o.success("模板删除成功")}catch(D){o.error(`模板删除失败: ${D.message}`)}}async function ne(){if(!(i.type!=="message"||!R.value.trim()))try{await _.saveDefaultMessage(R.value)&&(p("set-default",R.value),o.success("默认提交信息设置成功"))}catch(k){o.error(`设置默认提交信息失败: ${k.message}`)}}return r({resetForm:I}),(k,D)=>{const ye=Gt,F=he,O=zt,K=lo,ue=bs,ve=Lt,me=Vt;return v(),Z(me,{modelValue:E.value,"onUpdate:modelValue":D[1]||(D[1]=ie=>E.value=ie),title:k.title,width:"80vw",top:"70px",style:{height:"calc(100vh - 140px)"},"close-on-click-modal":!1,class:ke(k.type==="message"?"message-template-dialog":"template-dialog")},{default:s(()=>[e("div",{class:ke(["template-container",{"message-template-container":k.type==="message"}])},[e("div",Xa,[t(ye,{modelValue:R.value,"onUpdate:modelValue":D[0]||(D[0]=ie=>R.value=ie),placeholder:y.value,class:"template-input",clearable:"",onKeyup:ao(se,["enter"])},null,8,["modelValue","placeholder"]),e("div",Za,[h.value?(v(),Z(F,{key:0,onClick:j},{default:s(()=>D[2]||(D[2]=[x("取消")])),_:1})):Y("",!0),t(F,{type:"primary",onClick:se,disabled:!R.value.trim()},{default:s(()=>[x(A(w.value),1)]),_:1},8,["disabled"]),k.type==="message"?(v(),Z(F,{key:1,type:"success",onClick:ne,disabled:!R.value.trim()},{default:s(()=>D[3]||(D[3]=[x(" 设为默认提交信息 ")])),_:1},8,["disabled"])):Y("",!0)])]),k.type!=="message"?(v(),S("div",el,[e("h3",null,"已保存"+A(k.type==="description"?"模板":"作用域"),1),M.value.length===0?(v(),Z(O,{key:0,description:k.emptyDescription},null,8,["description"])):Y("",!0),(v(!0),S(Fe,null,Ae(M.value,(ie,re)=>(v(),Z(ue,{key:re,class:"template-item"},{default:s(()=>[t(K,{justify:"space-between",align:"middle",style:{width:"100%"}},{default:s(()=>[e("div",tl,A(ie),1),e("div",sl,[t(F,{type:"primary",size:"small",onClick:Q=>B(ie)},{default:s(()=>D[4]||(D[4]=[x("使用")])),_:2},1032,["onClick"]),t(F,{type:"warning",size:"small",icon:n(Ct),onClick:Q=>C(ie,re)},{default:s(()=>D[5]||(D[5]=[x(" 编辑 ")])),_:2},1032,["icon","onClick"]),t(F,{type:"danger",size:"small",onClick:Q=>ce(ie)},{default:s(()=>D[6]||(D[6]=[x("删除")])),_:2},1032,["onClick"])])]),_:2},1024)]),_:2},1024))),128))])):(v(),S("div",ol,[e("div",al,[D[10]||(D[10]=e("h3",null,"已保存模板",-1)),e("div",ll,[M.value.length===0?(v(),Z(O,{key:0,description:k.emptyDescription},null,8,["description"])):Y("",!0),(v(!0),S(Fe,null,Ae(M.value,(ie,re)=>(v(),Z(ue,{key:re,class:"template-item"},{default:s(()=>[t(K,{justify:"space-between",align:"middle",style:{width:"100%"}},{default:s(()=>[e("div",nl,A(ie),1),e("div",il,[t(F,{type:"primary",size:"small",onClick:Q=>B(ie)},{default:s(()=>D[7]||(D[7]=[x("使用")])),_:2},1032,["onClick"]),t(F,{type:"warning",size:"small",icon:n(Ct),onClick:Q=>C(ie,re)},{default:s(()=>D[8]||(D[8]=[x(" 编辑 ")])),_:2},1032,["icon","onClick"]),t(F,{type:"danger",size:"small",onClick:Q=>ce(ie)},{default:s(()=>D[9]||(D[9]=[x("删除")])),_:2},1032,["onClick"])])]),_:2},1024)]),_:2},1024))),128))])]),k.showDefaultSection?(v(),S("div",rl,[D[18]||(D[18]=e("h3",null,"当前默认提交信息",-1)),H.value?(v(),Z(ue,{key:0,class:"default-message-card"},{default:s(()=>[e("div",cl,A(H.value),1)]),_:1})):(v(),Z(O,{key:1,description:"尚未设置默认提交信息","image-size":100})),k.showHelpText?(v(),S("div",ul,[D[16]||(D[16]=e("h4",null,"关于默认提交信息",-1)),D[17]||(D[17]=e("p",null,"默认提交信息将在未输入提交信息时自动使用。",-1)),e("p",null,[D[13]||(D[13]=x("你可以通过点击左侧模板的")),t(ve,{size:"small",type:"primary"},{default:s(()=>D[11]||(D[11]=[x("使用")])),_:1}),D[14]||(D[14]=x("按钮先选择喜欢的模板,然后点击上方")),t(ve,{size:"small",type:"success"},{default:s(()=>D[12]||(D[12]=[x("设为默认提交信息")])),_:1}),D[15]||(D[15]=x("按钮保存。"))])])):Y("",!0)])):Y("",!0)]))],2)]),_:1},8,["modelValue","title","class"])}}}),Wt=Be(dl,[["__scopeId","data-v-7943f6e9"]]),fl={class:"git-command-preview"},pl={class:"preview-container"},ml={class:"preview-title"},vl={class:"preview-content code-command"},gl=xe({__name:"GitCommandPreview",props:{command:{},title:{default:"Git命令预览:"},copyButtonText:{default:"复制命令"},placeholder:{default:"<命令内容>"}},setup(N){const r=N,l=q(()=>r.command||r.placeholder);async function i(){if(!r.command){o.warning("没有可复制的命令内容");return}try{await navigator.clipboard.writeText(r.command),o.success("命令已复制到剪贴板")}catch(p){o.error(`复制失败: ${p.message}`)}}return(p,_)=>{const R=he;return v(),S("div",fl,[e("div",pl,[e("div",ml,A(p.title),1),e("div",vl,A(l.value),1),t(R,{type:"primary",icon:n(ut),size:"small",onClick:i,title:p.copyButtonText,class:"copy-command-btn"},null,8,["icon","title"])])])}}}),ps=Be(gl,[["__scopeId","data-v-3c53a3e7"]]),hl={class:"one-push-content"},yl={class:"one-push-text"},_l={key:0,class:"one-push-desc"},wl=xe({__name:"QuickPushButton",props:{from:{default:"form"},hasUserCommitMessage:{type:Boolean,default:!1},finalCommitMessage:{default:""},skipHooks:{type:Boolean,default:!1}},emits:["beforePush","afterPush","clearFields"],setup(N,{emit:r}){const l=Qe(),i=ot(),p=N,_=r;function R(y){const w=y.replace(/\\/g,"/");return i.lockedFiles.some(E=>{const I=E.replace(/\\/g,"/");return w===I})}const h=q(()=>l.fileList.some(y=>!R(y.path))),U=q(()=>!h.value||!p.hasUserCommitMessage||!l.hasUpstream),te=q(()=>l.isAddingFiles||l.isCommiting||l.isPushing),M=q(()=>h.value?p.hasUserCommitMessage?l.hasUpstream?"一键完成:暂存所有更改 → 提交 → 推送到远程仓库":"当前分支没有上游分支":"请输入提交信息":"没有需要提交的更改");async function H(){_("beforePush");try{const y=await l.addCommitAndPush(p.finalCommitMessage,p.skipHooks);y&&_("clearFields"),_("afterPush",y)}catch(y){console.error("一键推送失败:",y),_("afterPush",!1)}}return(y,w)=>{const E=st,I=he;return v(),Z(n(Ye),{content:M.value,placement:"top","show-after":200},{default:s(()=>[t(I,{type:"success",onClick:H,loading:te.value,disabled:U.value,class:ke([y.from,"one-push-button"])},{default:s(()=>[e("div",hl,[t(E,{class:"one-push-icon"},{default:s(()=>[t(n(no))]),_:1}),e("div",yl,[w[0]||(w[0]=e("span",{class:"one-push-title"},"一键推送所有",-1)),y.from==="form"?(v(),S("span",_l,"暂存 + 提交 + 推送")):Y("",!0)])])]),_:1},8,["loading","disabled","class"])]),_:1},8,["content"])}}}),Ls=Be(wl,[["__scopeId","data-v-58e155b2"]]),kl={key:0},$l=xe({__name:"StageButton",props:{from:{default:"form"}},emits:["click"],setup(N,{emit:r}){const l=r,i=Qe(),p=ot();function _(y){const w=y.replace(/\\/g,"/");return p.lockedFiles.some(E=>{const I=E.replace(/\\/g,"/");return w===I})}function R(){return p.lockedFiles.length===0?!1:i.fileList.some(y=>["modified","deleted","untracked"].includes(y.type)?_(y.path):!1)}const h=q(()=>i.fileList.filter(y=>["modified","deleted","untracked"].includes(y.type)&&!_(y.path)).length),U=q(()=>i.fileList.some(y=>["modified","deleted","untracked"].includes(y.type)&&!_(y.path))),te=q(()=>!U.value),M=q(()=>U.value?R()?`暂存${h.value}个未暂存文件(逐个添加)`:"暂存所有更改(git add .)":"没有需要暂存的更改");async function H(){l("click");try{let y;R()?y=await i.addToStage():y=await i.addAllToStage(),y&&i.fetchStatus()}catch(y){console.error("添加文件失败:",y)}}return(y,w)=>{const E=he,I=Ye;return v(),Z(I,{content:M.value,placement:"top",effect:"light","popper-class":"git-cmd-tooltip","open-delay":200},{default:s(()=>[t(E,{type:"primary",onClick:H,loading:n(i).isAddingFiles,disabled:te.value,class:ke(["stage-button",`from-${y.from}`])},{default:s(()=>[w[0]||(w[0]=x(" 暂存更改 ")),h.value>0?(v(),S("span",kl,"("+A(h.value)+")",1)):Y("",!0)]),_:1},8,["loading","disabled","class"])]),_:1},8,["content"])}}}),xs=Be($l,[["__scopeId","data-v-67a3259e"]]),bl={key:0},Cl=xe({__name:"CommitButton",props:{from:{default:"form"},hasUserCommitMessage:{type:Boolean,default:!1},finalCommitMessage:{default:""},skipHooks:{type:Boolean,default:!1}},emits:["click","beforeCommit","afterCommit"],setup(N,{emit:r}){const l=N,i=r,p=Qe(),_=ot();function R(y){const w=y.replace(/\\/g,"/");return _.lockedFiles.some(E=>{const I=E.replace(/\\/g,"/");return w===I})}const h=q(()=>p.fileList.filter(y=>y.type==="added"&&!R(y.path)).length),U=q(()=>h.value>0),te=q(()=>!U.value||!l.hasUserCommitMessage),M=q(()=>U.value?l.hasUserCommitMessage?`提交${h.value}个已暂存文件`:"请输入提交信息":"没有已暂存的更改");async function H(){if(l.finalCommitMessage.trim()){i("beforeCommit"),i("click");try{const y=await p.commitChanges(l.finalCommitMessage,l.skipHooks);y&&(p.fetchStatus(),p.fetchLog(),p.getBranchStatus(!0)),i("afterCommit",y)}catch(y){console.error("提交失败:",y),i("afterCommit",!1)}}}return(y,w)=>{const E=he,I=Ye;return v(),Z(I,{content:M.value,placement:"top",effect:"light","popper-class":"git-cmd-tooltip","open-delay":200},{default:s(()=>[t(E,{type:"primary",onClick:H,loading:n(p).isLoadingStatus,disabled:te.value,class:ke(["commit-button",`from-${y.from}`])},{default:s(()=>[w[0]||(w[0]=x(" 提交 ")),h.value>0?(v(),S("span",bl,"("+A(h.value)+")",1)):Y("",!0)]),_:1},8,["loading","disabled","class"])]),_:1},8,["content"])}}}),Bs=Be(Cl,[["__scopeId","data-v-5a88b7bc"]]),Sl={key:0},Tl=xe({__name:"PushButton",props:{from:{default:"form"}},emits:["click","beforePush","afterPush"],setup(N,{emit:r}){const l=r,i=Qe(),p=q(()=>i.branchAhead>0),_=q(()=>i.fileList.some(H=>H.type==="added")),R=q(()=>i.hasUpstream&&p.value&&!_.value),h=q(()=>!R.value),U=q(()=>i.hasUpstream?p.value?_.value?"有未提交的暂存更改,请先提交":`推送${i.branchAhead}个本地提交`:"没有需要推送的提交":"当前分支没有上游分支"),te=q(()=>R.value?{backgroundColor:"#67c23a",borderColor:"#67c23a"}:{});async function M(){l("beforePush"),l("click");try{const H=await i.pushToRemote();H&&await new Promise(y=>setTimeout(y,200)),l("afterPush",H)}catch(H){console.error("推送失败:",H),l("afterPush",!1)}}return(H,y)=>{const w=he,E=Ye;return v(),Z(E,{content:U.value,placement:"top",effect:"light","popper-class":"git-cmd-tooltip","open-delay":200},{default:s(()=>[t(w,{type:"primary",icon:n(io),onClick:M,loading:n(i).isPushing,disabled:h.value,style:ft(te.value),class:ke(["push-button",`from-${H.from}`])},{default:s(()=>[y[0]||(y[0]=x(" 推送 ")),p.value?(v(),S("span",Sl,"("+A(n(i).branchAhead)+")",1)):Y("",!0)]),_:1},8,["icon","loading","disabled","style","class"])]),_:1},8,["content"])}}}),Ps=Be(Tl,[["__scopeId","data-v-3c2392d6"]]),Fl={class:"form-bottom-actions"},Vl={class:"actions-flex-container"},Ll={class:"left-actions"},xl={class:"button-grid"},Bl={class:"right-actions"},Pl=xe({__name:"GitActionButtons",props:{hasUserCommitMessage:{type:Boolean,default:!1},finalCommitMessage:{default:""},skipHooks:{type:Boolean,default:!1},from:{default:"form"}},emits:["afterCommit","afterPush","beforePush","clearFields"],setup(N,{emit:r}){const l=r;function i(h){l("afterCommit",h)}function p(h){l("afterPush",h)}function _(){l("beforePush")}function R(){l("clearFields")}return(h,U)=>(v(),S("div",Fl,[e("div",Vl,[e("div",Ll,[e("div",xl,[t(xs,{onClick:()=>{},from:h.from},null,8,["from"]),t(Bs,{"has-user-commit-message":h.hasUserCommitMessage,"final-commit-message":h.finalCommitMessage,"skip-hooks":h.skipHooks,onBeforeCommit:()=>{},onAfterCommit:i,onClick:()=>{},from:h.from},null,8,["has-user-commit-message","final-commit-message","skip-hooks","from"]),t(Ps,{onBeforePush:()=>{},onAfterPush:p,onClick:()=>{},from:h.from},null,8,["from"])])]),e("div",Bl,[t(Ls,{from:h.from,"has-user-commit-message":h.hasUserCommitMessage,"final-commit-message":h.finalCommitMessage,"skip-hooks":h.skipHooks,onBeforePush:_,onAfterPush:p,onClearFields:R},null,8,["from","has-user-commit-message","final-commit-message","skip-hooks"])])])]))}}),zl=Be(Pl,[["__scopeId","data-v-6cf9ea2c"]]),jl={class:"card-header"},Dl={class:"header-actions"},Ol={class:"card-content"},Rl={class:"layout-container"},Gl={key:0,class:"git-config-warning"},Al={key:1,class:"commit-section"},Ml={class:"top-actions-container"},Ul={class:"commit-options"},El={class:"option-card"},Il={class:"option-header"},Nl={class:"option-icon"},Hl={class:"option-card"},Jl={class:"option-header"},Wl={class:"option-icon warning"},ql={class:"option-card"},Yl={class:"option-header"},Kl={class:"option-icon success"},Ql={key:0,class:"commit-form"},Xl={class:"description-container"},Zl={key:1,class:"standard-commit-form"},en={class:"standard-commit-header"},tn={class:"type-scope-container"},sn={class:"scope-wrapper"},on={class:"description-container"},an={class:"advanced-fields"},ln={class:"actions-section"},nn={class:"action-groups"},rn={class:"operations-wrapper"},cn={class:"action-group"},un={class:"group-buttons"},dn={key:0},fn={class:"action-group"},pn={class:"group-buttons"},mn={class:"action-group reset-group"},vn={class:"group-buttons"},gn={key:0},hn={class:"action-group branch-group"},yn={class:"group-buttons"},_n={class:"action-group"},wn={class:"group-buttons"},kn={class:"dialog-footer"},$n={class:"config-warning-content"},bn={class:"warning-message"},Cn={class:"dialog-footer"},Sn={class:"stash-dialog-content"},Tn={class:"merge-dialog-content"},Fn={class:"merge-intro"},Vn={class:"merge-options"},Ln={class:"dialog-footer"},xn={class:"stash-list-content"},Bn={class:"stash-action-buttons"},Pn={key:0,class:"stash-list-actions"},zn={class:"stash-content"},jn={key:0,class:"stash-info-row"},Dn={class:"stash-id"},On={class:"stash-id-value"},Rn={class:"stash-description"},Gn={class:"stash-description-value"},An={class:"stash-main-content"},Mn={key:0,class:"status-updating-indicator"},Un=xe({__name:"CommitForm",setup(N){const r=Qe(),l=ot(),i=d(""),{loadingState:p,show:_,hide:R,setText:h}=Ka(),{successState:U,show:te}=Qa(),M=d(!1),H=d("输入提交信息..."),y=d(""),w=d(!1),E=d("feat"),I=d(""),se=d(""),B=d(""),C=d(""),j=d(!1),ce=d(""),ne=d(!1),k=d(!1),D=d(""),ye=d([]),F=d(!1),O=d(!1),K=d(""),ue=d({noFf:!1,squash:!1,noCommit:!1,message:""}),ve=d([]),me=d(!1),ie=d(!1),re=d(!1),Q=d(!1),pe=d(!1),z=[{value:"feat",label:"feat: 新功能"},{value:"fix",label:"fix: 修复bug"},{value:"docs",label:"docs: 文档修改"},{value:"style",label:"style: 样式修改"},{value:"refactor",label:"refactor: 代码重构"},{value:"test",label:"test: 测试代码"},{value:"chore",label:"chore: 构建/工具修改"}],T=d(!1),ae=d(!1),X=d(""),de=d(!1),Te=d(!0),Le=d(!1),De=d(null),Pe=d([]),oe=d(""),Oe=d(!1),Me=d("");function at(){X.value="",de.value=!1,Te.value=!0,T.value=!0}async function Ze(){try{const a=await(await fetch("/api/config/check-file-format")).json();let G="";a.success&&(a.exists?a.isValidJson||(G=`系统配置文件格式有误:${a.error}
16
+ 编辑后保存可能会覆盖原文件内容。`):G="系统配置文件不存在,将使用默认配置。");const ge=l.config;if(ce.value=JSON.stringify(ge,null,2),G){D.value=G,k.value=!0;return}j.value=!0}catch{o.error("加载配置失败")}}async function Ne(){try{ne.value=!0;let m;try{m=JSON.parse(ce.value)}catch(ge){o.error(`JSON 解析失败: ${ge.message||ge}`);return}const G=await(await fetch("/api/config/saveAll",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:m})})).json();if(!G.success)throw new Error(G.error||"保存失败");await l.loadConfig(!0);try{await l.loadLockedFiles()}catch{}try{Array.isArray(l.descriptionTemplates)&&(ye.value=[...l.descriptionTemplates])}catch{}try{Array.isArray(l.scopeTemplates)&&(ve.value=[...l.scopeTemplates])}catch{}try{Array.isArray(l.messageTemplates)&&(We.value=[...l.messageTemplates])}catch{}o.success("配置已保存"),j.value=!1}catch(m){o.error(`保存配置失败: ${m.message||m}`)}finally{ne.value=!1}}async function Je(){try{const m=await fetch("/api/config/open-file",{method:"POST"}),a=await m.json();if(!m.ok||!(a!=null&&a.success))throw new Error((a==null?void 0:a.error)||"打开失败");o.success("已用系统程序打开配置文件")}catch(m){o.error(`打开配置文件失败: ${(m==null?void 0:m.message)||m}`)}}function P(m){k.value=!1,m==="continue"?j.value=!0:m==="open"&&Je()}function u(){r.getStashList(),ae.value=!0}async function le(){try{await r.saveStash(X.value,de.value,Te.value),T.value=!1}catch(m){console.error("储藏失败:",m)}}async function J(m,a=!1){try{await r.applyStash(m,a),a&&await r.getStashList()}catch(G){console.error("应用储藏失败:",G)}}async function Se(m){He.confirm("确定要删除此储藏吗?此操作不可恢复。","删除储藏",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{await r.dropStash(m),await r.getStashList()}).catch(()=>{})}async function Ve(){He.confirm("确定要清空所有储藏吗?此操作不可恢复。","清空所有储藏",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{await r.clearAllStashes(),await r.getStashList()}).catch(()=>{})}async function _e(m){if(m){De.value=m,Le.value=!0,Oe.value=!0,Pe.value=[],oe.value="",Me.value="";try{if(!m.id||m.id.length<7){oe.value="无效的stash ID",Oe.value=!1;return}const G=await(await fetch(`/api/stash-files?stashId=${encodeURIComponent(m.id)}`)).json();G.success&&Array.isArray(G.files)?(Pe.value=G.files,Pe.value.length>0?await $e(m.id,Pe.value[0]):oe.value="该stash没有变更文件"):oe.value=`获取文件列表失败: ${G.error||"未知错误"}`}catch(a){oe.value=`获取stash详情失败: ${a.message}`}finally{Oe.value=!1}}}async function $e(m,a){Oe.value=!0,Me.value=a;try{const ge=await(await fetch(`/api/stash-file-diff?stashId=${encodeURIComponent(m)}&file=${encodeURIComponent(a)}`)).json();ge.success?oe.value=ge.diff||"没有变更内容":oe.value=`获取差异失败: ${ge.error||"未知错误"}`}catch(G){oe.value=`获取差异失败: ${G.message}`}finally{Oe.value=!1}}function Ue(m){De.value&&$e(De.value.id,m)}async function be(m,a){try{const ge=await(await fetch("/api/open-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:m,context:a})})).json();ge.success?o.success(ge.message):o.error(ge.error||"打开文件失败")}catch(G){o.error(`打开文件失败: ${G.message}`)}}async function Ce(m,a){try{const ge=await(await fetch("/api/open-with-vscode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:m,context:a})})).json();ge.success?o.success(ge.message):o.error(ge.error||"用VSCode打开文件失败")}catch(G){o.error(`用VSCode打开文件失败: ${G.message}`)}}const We=d([]);je(w,m=>{localStorage.setItem("zen-gitsync-standard-commit",m.toString())}),je(re,m=>{localStorage.setItem("zen-gitsync-skip-hooks",m.toString())}),je(Q,m=>{localStorage.setItem("zen-gitsync-auto-quick-push",m.toString())});const Ie=q(()=>{if(!w.value)return i.value||y.value;let m=`${E.value||""}`;return I.value&&(m+=`(${I.value})`),m+=`: ${se.value}`,B.value&&(m+=`
17
+
18
+ ${B.value}`),C.value&&(m+=`
19
+
20
+ ${C.value}`),m}),ee=q(()=>w.value?E.value.trim()!==""&&se.value.trim()!=="":i.value.trim()!==""),lt=q(()=>Pe.value.map(m=>({path:m,name:m.split("/").pop()||m}))),nt=q(()=>{let m=`git commit -m "${Ie.value}"`;return re.value&&(m+=" --no-verify"),m});function pt(){const m=l.config;m&&(H.value=`输入提交信息 (默认: ${m.defaultCommitMessage})`,y.value=m.defaultCommitMessage||"",m.descriptionTemplates&&Array.isArray(m.descriptionTemplates)&&(ye.value=m.descriptionTemplates),m.scopeTemplates&&Array.isArray(m.scopeTemplates)&&(ve.value=m.scopeTemplates),m.messageTemplates&&Array.isArray(m.messageTemplates)&&(We.value=m.messageTemplates))}function mt(m){se.value=m,F.value=!1}function vt(m){I.value=m,me.value=!1}function et(){F.value=!0}function Re(){me.value=!0}function gt(){te({text:"操作成功!",description:"已完成操作",duration:2e3})}async function $(){try{await r.gitPull(),await r.fetchStatus(),await r.fetchLog(!1)}catch(m){console.error("拉取操作发生错误:",m)}}async function g(){try{await r.gitFetchAll(),await r.fetchStatus(),await r.fetchLog(!1)}catch(m){console.error("获取远程分支信息操作发生错误:",m)}}async function W(){if(!Ie.value.trim()){o({message:"提交信息不能为空",type:"warning"});return}try{await r.addAndCommit(Ie.value,re.value),f(),r.fetchStatus(),r.fetchLog()}catch(m){o({message:`暂存并提交失败: ${m.message}`,type:"error"})}}async function c(){try{await He.confirm(`确定要重置当前分支 "${r.currentBranch}" 到远程状态吗?这将丢失所有未推送的提交和本地更改。`,"重置到远程分支",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}),await r.resetToRemote(r.currentBranch)&&(r.fetchStatus(),r.fetchLog())}catch(m){m!=="cancel"&&o({message:`重置到远程分支失败: ${m.message}`,type:"error"})}}function f(){i.value="",se.value="",B.value="",C.value=""}function V(){_({text:"正在暂存文件...",showProgress:!1})}function b(m){if(R(),m){M.value=!0;try{setTimeout(async()=>{try{console.log("推送成功,状态已更新")}catch(a){console.error("一键推送后处理失败:",a)}finally{M.value=!1}},1e3)}catch(a){console.error("一键推送后处理失败:",a),M.value=!1}}}function fe(m){const a=m.replace(/\\/g,"/");return l.lockedFiles.some(G=>{const ge=G.replace(/\\/g,"/");return a===ge})}const ze=q(()=>r.fileList.some(m=>["modified","deleted","untracked"].includes(m.type)&&!fe(m.path))),Ee=q(()=>r.fileList.filter(m=>m.type==="added"&&!fe(m.path)).length),tt=q(()=>Ee.value>0),ht=q(()=>r.fileList.some(m=>!fe(m.path))),js=q(()=>r.branchAhead>0),At=q(()=>r.branchBehind>0),os=q(()=>tt.value),Ds=q(()=>r.hasUpstream&&(js.value||At.value||ht.value));function Os(m){i.value=m,ie.value=!1}async function as(m){if(!(!Q.value||!ee.value||!r.fileList.some(G=>!fe(G.path))||!ee.value||!r.hasUpstream)&&m.key==="Enter"&&!m.shiftKey){m.preventDefault();try{V();const G=await r.addCommitAndPush(Ie.value,re.value);G&&f(),b(G)}catch(G){console.error("回车自动一键提交失败:",G),b(!1)}}}async function Rs(m){try{await l.saveDefaultMessage(m)&&o.success("默认提交信息设置成功")}catch(a){o.error(`设置默认提交信息失败: ${a.message}`)}}je(()=>r.isAddingFiles,m=>{m&&p.visible&&h("正在暂存文件...")}),je(()=>r.isCommiting,m=>{m&&p.visible&&h("正在提交更改...")}),je(()=>r.isPushing,m=>{m&&p.visible&&h("正在推送到远程仓库...")}),dt(async()=>{const m=localStorage.getItem("zen-gitsync-standard-commit");m!==null&&(w.value=m==="true");const a=localStorage.getItem("zen-gitsync-skip-hooks");a!==null&&(re.value=a==="true");const G=localStorage.getItem("zen-gitsync-auto-quick-push");G!==null&&(Q.value=G==="true"),je(()=>l.config,pt,{immediate:!0}),l.config||await l.loadConfig()});function Gs(){K.value="",ue.value={noFf:!1,squash:!1,noCommit:!1,message:""},ct.value="all",O.value=!0,r.allBranches.length===0&&r.getAllBranches()}const ct=d("all"),As=q(()=>{const m=r.allBranches.filter(a=>a!==r.currentBranch);if(console.log("筛选分支列表:",{allBranches:r.allBranches,currentBranch:r.currentBranch,branchTypeFilter:ct.value,filteredBranches:m}),ct.value==="local"){const a=m.filter(G=>!G.includes("origin/"));return console.log("本地分支:",a),a}else if(ct.value==="remote"){const a=m.filter(G=>G.includes("origin/"));return console.log("远程分支:",a),a}else return console.log("所有分支:",m),m});async function Ms(){if(!K.value){o({message:"请选择要合并的分支",type:"warning"});return}try{await r.mergeBranch(K.value,ue.value)&&(O.value=!1,await r.fetchStatus(),await r.fetchLog(!1))}catch(m){console.error("合并分支操作发生错误:",m)}}const xt=d(!1);function Us(){xt.value=!xt.value}function Es(m,a){const ge=[...m?ye.value.filter(we=>we.toLowerCase().includes(m.toLowerCase())).map(we=>({value:we})):ye.value.map(we=>({value:we})),{value:"⚙️ 管理模板...",isSettings:!0}];a(ge)}function Is(m,a){const ge=[...m?ve.value.filter(we=>we.toLowerCase().includes(m.toLowerCase())).map(we=>({value:we})):ve.value.map(we=>({value:we})),{value:"⚙️ 管理模板...",isSettings:!0}];a(ge)}function Ns(m){m.isSettings?(et(),se.value=""):se.value=m.value}function Hs(m){m.isSettings?(Re(),I.value=""):I.value=m.value}function Js(m,a){const ge=[...m?We.value.filter(we=>we.toLowerCase().includes(m.toLowerCase())).map(we=>({value:we})):We.value.map(we=>({value:we})),{value:"⚙️ 管理模板...",isSettings:!0}];a(ge)}function Ws(m){m.isSettings?(ie.value=!0,i.value=""):i.value=m.value}return(m,a)=>{const G=he,ge=ts,we=st,Mt=hs,Ut=co,ls=Dt,ns=Ot,yt=Gt,qe=Ye,qs=fo,Bt=Vt,it=Ts,_t=po,is=Ss,Et=vo,Ys=mo,It=$t,Ks=Fs,Qs=Xt;return v(),S(Fe,null,[e("div",{class:ke(["card",{"is-pushing":n(r).isPushing}])},[e("div",jl,[a[39]||(a[39]=e("h2",null,"提交更改",-1)),e("div",Dl,[t(G,{size:"small",type:"primary",icon:n(Ct),onClick:Ze},{default:s(()=>a[38]||(a[38]=[x("配置")])),_:1},8,["icon"]),t(G,{type:"primary",icon:n(ro),size:"small",circle:"",onClick:Us,class:"git-tools-button"},null,8,["icon"])])]),e("div",Ol,[e("div",Rl,[n(r).userName===""||n(r).userEmail===""?(v(),S("div",Gl,[t(ge,{title:"Git用户信息未配置",type:"warning",closable:!1,"show-icon":""},{default:s(()=>a[40]||(a[40]=[e("p",null,"您需要配置Git用户名和邮箱才能提交代码。请使用以下命令配置:",-1),e("pre",{class:"config-command"},`git config --global user.name "Your Name"
21
+ git config --global user.email "your.email@example.com"`,-1)])),_:1})])):(v(),S("div",Al,[e("div",Ml,[t(zl,{"has-user-commit-message":ee.value,"final-commit-message":Ie.value,"skip-hooks":re.value,from:"form",onAfterCommit:a[0]||(a[0]=L=>{L&&f()}),onAfterPush:b,onBeforePush:V,onClearFields:f},null,8,["has-user-commit-message","final-commit-message","skip-hooks"])]),e("div",Ul,[e("div",El,[e("div",Il,[e("div",Nl,[t(we,null,{default:s(()=>[t(n(Ct))]),_:1})]),a[41]||(a[41]=e("div",{class:"option-info"},[e("h4",{class:"option-title"},"提交模式"),e("p",{class:"option-desc"},"选择传统或标准化提交格式")],-1)),t(Mt,{modelValue:w.value,"onUpdate:modelValue":a[1]||(a[1]=L=>w.value=L),"active-text":"标准化","inactive-text":"普通","active-color":"#409eff",class:"option-switch"},null,8,["modelValue"])])]),e("div",Hl,[e("div",Jl,[e("div",Wl,[t(we,null,{default:s(()=>[t(n(us))]),_:1})]),a[42]||(a[42]=e("div",{class:"option-info"},[e("h4",{class:"option-title"},"跳过钩子检查"),e("p",{class:"option-desc"},"添加--no-verify参数")],-1)),t(Mt,{modelValue:re.value,"onUpdate:modelValue":a[2]||(a[2]=L=>re.value=L),"active-color":"#f56c6c",class:"option-switch"},null,8,["modelValue"])])]),e("div",ql,[e("div",Yl,[e("div",Kl,[t(we,null,{default:s(()=>[t(n(ys))]),_:1})]),a[43]||(a[43]=e("div",{class:"option-info"},[e("h4",{class:"option-title"},"回车自动提交"),e("p",{class:"option-desc"},"输入提交信息后按回车直接执行一键推送")],-1)),t(Mt,{modelValue:Q.value,"onUpdate:modelValue":a[3]||(a[3]=L=>Q.value=L),"active-color":"#67c23a",class:"option-switch"},null,8,["modelValue"])])])]),w.value?(v(),S("div",Zl,[e("div",en,[e("div",tn,[t(ns,{modelValue:E.value,"onUpdate:modelValue":a[5]||(a[5]=L=>E.value=L),placeholder:"提交类型",class:"type-select",clearable:"",teleported:!1},{default:s(()=>[(v(),S(Fe,null,Ae(z,L=>t(ls,{key:L.value,label:L.label,value:L.value},null,8,["label","value"])),64))]),_:1},8,["modelValue"]),e("div",sn,[t(Ut,{modelValue:I.value,"onUpdate:modelValue":a[6]||(a[6]=L=>I.value=L),"fetch-suggestions":Is,placeholder:"作用域(可选)",class:"scope-input",clearable:"",onSelect:Hs,teleported:!1},null,8,["modelValue"])])]),e("div",on,[t(Ut,{modelValue:se.value,"onUpdate:modelValue":a[7]||(a[7]=L=>se.value=L),"fetch-suggestions":Es,placeholder:"简短描述(必填)",class:"description-input",clearable:"",onSelect:Ns,onKeydown:as,teleported:!1},null,8,["modelValue"])])]),e("div",{class:"advanced-options-toggle",onClick:a[8]||(a[8]=L=>pe.value=!pe.value)},[e("span",null,A(pe.value?"收起":"正文及页脚"),1),t(we,{class:ke(["toggle-icon",{"is-active":pe.value}])},{default:s(()=>[t(n(Rt))]),_:1},8,["class"])]),Xe(e("div",an,[t(yt,{modelValue:B.value,"onUpdate:modelValue":a[9]||(a[9]=L=>B.value=L),type:"textarea",rows:4,placeholder:"正文(可选):详细描述本次提交的内容和原因",class:"body-input",clearable:""},null,8,["modelValue"]),t(yt,{modelValue:C.value,"onUpdate:modelValue":a[10]||(a[10]=L=>C.value=L),placeholder:"页脚(可选):如 Closes #123",class:"footer-input",clearable:""},null,8,["modelValue"])],512),[[St,pe.value]]),t(ps,{command:nt.value,title:"Git提交命令预览:",placeholder:'git commit -m "<提交信息>"'},null,8,["command"])])):(v(),S("div",Ql,[e("div",Xl,[t(Ut,{modelValue:i.value,"onUpdate:modelValue":a[4]||(a[4]=L=>i.value=L),"fetch-suggestions":Js,placeholder:H.value,type:"textarea",rows:6,resize:"none",class:"commit-message-input",onSelect:Ws,onKeydown:as,teleported:!1},null,8,["modelValue","placeholder"])]),t(ps,{command:nt.value,title:"Git提交命令预览:",placeholder:'git commit -m "<提交信息>"'},null,8,["command"])]))]))])])],2),t(qs,{modelValue:xt.value,"onUpdate:modelValue":a[13]||(a[13]=L=>xt.value=L),title:"Git 操作",direction:"rtl",size:"340px","with-header":!0,"show-close":!0,"destroy-on-close":!1,class:"git-operations-drawer"},{default:s(()=>[e("div",ln,[e("div",nn,[e("div",rn,[e("div",cn,[a[46]||(a[46]=e("div",{class:"group-title"},"基础操作",-1)),e("div",un,[t(xs,{onClick:()=>{},from:"drawer"}),t(Bs,{"has-user-commit-message":ee.value,"final-commit-message":Ie.value,"skip-hooks":re.value,onBeforeCommit:()=>{},onAfterCommit:a[11]||(a[11]=L=>{L&&f()}),onClick:()=>{},from:"drawer"},null,8,["has-user-commit-message","final-commit-message","skip-hooks"]),t(Ps,{onBeforePush:()=>{},onAfterPush:a[12]||(a[12]=L=>{L&&gt()}),onClick:()=>{},from:"drawer"}),t(qe,{content:At.value?`拉取${n(r).branchBehind}个远程提交`:"git pull",placement:"top",effect:"light","popper-class":"git-cmd-tooltip","open-delay":200},{default:s(()=>[t(G,{type:"primary",icon:n(_s),onClick:$,loading:n(r).isGitPulling,disabled:!n(r).hasUpstream,class:"action-button",style:ft(n(r).hasUpstream?{color:"white",backgroundColor:"#1e90ff",borderColor:"#1e90ff"}:{})},{default:s(()=>[a[44]||(a[44]=x(" 拉取 ")),At.value?(v(),S("span",dn,"("+A(n(r).branchBehind)+")",1)):Y("",!0)]),_:1},8,["icon","loading","disabled","style"])]),_:1},8,["content"]),t(qe,{content:"git fetch --all",placement:"top",effect:"light","popper-class":"git-cmd-tooltip","open-delay":200},{default:s(()=>[t(G,{type:"info",icon:n(ws),onClick:g,loading:n(r).isGitFetching,class:"action-button",style:{color:"white","background-color":"#1e90ff","border-color":"#1e90ff"}},{default:s(()=>a[45]||(a[45]=[x(" 获取所有远程分支 ")])),_:1},8,["icon","loading"])]),_:1})])]),e("div",fn,[a[48]||(a[48]=e("div",{class:"group-title"},"组合操作",-1)),e("div",pn,[t(qe,{content:"git add + git commit",placement:"top",effect:"light","popper-class":"git-cmd-tooltip","open-delay":200},{default:s(()=>[t(G,{type:"primary",icon:n(Ct),onClick:W,loading:n(r).isAddingFiles||n(r).isCommiting,disabled:!ze.value||!ee.value,class:"action-button"},{default:s(()=>a[47]||(a[47]=[x(" 暂存并提交 ")])),_:1},8,["icon","loading","disabled"])]),_:1}),t(Ls,{from:"drawer","has-user-commit-message":ee.value,"final-commit-message":Ie.value,"skip-hooks":re.value,onBeforePush:V,onAfterPush:b,onClearFields:f},null,8,["has-user-commit-message","final-commit-message","skip-hooks"])])])]),e("div",mn,[a[51]||(a[51]=e("div",{class:"group-title"},"重置操作",-1)),e("div",vn,[t(qe,{content:os.value?`撤销${Ee.value}个已暂存文件`:"git reset HEAD",placement:"top",effect:"light","popper-class":"git-cmd-tooltip","open-delay":200},{default:s(()=>[t(G,{type:"warning",icon:n(Qt),onClick:n(r).resetHead,loading:n(r).isResetting,disabled:!os.value,class:"action-button reset-button"},{default:s(()=>[a[49]||(a[49]=x(" 重置暂存区 ")),Ee.value>0?(v(),S("span",gn,"("+A(Ee.value)+")",1)):Y("",!0)]),_:1},8,["icon","onClick","loading","disabled"])]),_:1},8,["content"]),t(qe,{content:"git reset --hard origin/branch",placement:"top",effect:"light","popper-class":"git-cmd-tooltip","open-delay":200},{default:s(()=>[t(G,{type:"danger",icon:n(Cs),onClick:c,loading:n(r).isResetting,disabled:!Ds.value,class:"action-button danger-button"},{default:s(()=>a[50]||(a[50]=[x(" 重置到远程 ")])),_:1},8,["icon","loading","disabled"])]),_:1})])]),e("div",hn,[a[53]||(a[53]=e("div",{class:"group-title"},"分支操作",-1)),e("div",yn,[t(qe,{content:"合并其他分支到当前分支",placement:"top",effect:"light","popper-class":"git-cmd-tooltip","open-delay":200},{default:s(()=>[t(G,{type:"primary",icon:n(uo),onClick:Gs,loading:n(r).isGitMerging,class:"action-button merge-button"},{default:s(()=>a[52]||(a[52]=[x(" 合并分支 ")])),_:1},8,["icon","loading"])]),_:1})])]),e("div",_n,[a[56]||(a[56]=e("div",{class:"group-title"},"储藏操作",-1)),e("div",wn,[t(qe,{content:"将工作区更改储藏起来",placement:"top",effect:"light","popper-class":"git-cmd-tooltip","open-delay":200},{default:s(()=>[t(G,{type:"warning",onClick:at,loading:n(r).isSavingStash,disabled:!ht.value,class:"action-button"},{default:s(()=>a[54]||(a[54]=[x(" 储藏更改 ")])),_:1},8,["loading","disabled"])]),_:1}),t(qe,{content:"查看和管理所有储藏记录",placement:"top",effect:"light","popper-class":"git-cmd-tooltip","open-delay":200},{default:s(()=>[t(G,{type:"info",onClick:u,class:"action-button"},{default:s(()=>a[55]||(a[55]=[x(" 储藏列表 ")])),_:1})]),_:1})])])])])]),_:1},8,["modelValue"]),t(Bt,{class:"config-editor-dialog",title:"编辑配置 JSON",modelValue:j.value,"onUpdate:modelValue":a[16]||(a[16]=L=>j.value=L),width:"60%"},{footer:s(()=>[e("span",kn,[t(G,{onClick:Je},{default:s(()=>a[57]||(a[57]=[x("打开系统配置文件")])),_:1}),t(G,{onClick:a[15]||(a[15]=L=>j.value=!1)},{default:s(()=>a[58]||(a[58]=[x("取消")])),_:1}),t(G,{type:"primary",loading:ne.value,onClick:Ne},{default:s(()=>a[59]||(a[59]=[x("保存")])),_:1},8,["loading"])])]),default:s(()=>[t(yt,{modelValue:ce.value,"onUpdate:modelValue":a[14]||(a[14]=L=>ce.value=L),type:"textarea",rows:18,spellcheck:"false",autocomplete:"off",placeholder:"在此编辑当前项目配置的 JSON"},null,8,["modelValue"])]),_:1},8,["modelValue"]),t(Bt,{modelValue:k.value,"onUpdate:modelValue":a[20]||(a[20]=L=>k.value=L),title:"配置文件格式提示",width:"500px","close-on-click-modal":!1,"close-on-press-escape":!1,"show-close":!1},{footer:s(()=>[e("span",Cn,[t(G,{onClick:a[17]||(a[17]=L=>P("cancel"))},{default:s(()=>a[60]||(a[60]=[x("取消")])),_:1}),t(G,{type:"info",onClick:a[18]||(a[18]=L=>P("open"))},{default:s(()=>a[61]||(a[61]=[x("打开系统配置文件")])),_:1}),t(G,{type:"primary",onClick:a[19]||(a[19]=L=>P("continue"))},{default:s(()=>a[62]||(a[62]=[x("继续编辑")])),_:1})])]),default:s(()=>[e("div",$n,[t(we,{class:"warning-icon",color:"#f56c6c",size:"24"},{default:s(()=>[t(n(us))]),_:1}),e("p",bn,A(D.value),1)])]),_:1},8,["modelValue"]),t(Wt,{visible:F.value,"onUpdate:visible":a[21]||(a[21]=L=>F.value=L),type:"description",title:"简短描述模板设置",placeholder:"输入新模板内容","edit-placeholder":"编辑模板内容","empty-description":"暂无保存的模板",onUseTemplate:mt},null,8,["visible"]),t(Wt,{visible:me.value,"onUpdate:visible":a[22]||(a[22]=L=>me.value=L),type:"scope",title:"作用域模板设置",placeholder:"输入新作用域模板","edit-placeholder":"编辑作用域模板内容","empty-description":"暂无保存的作用域",onUseTemplate:vt},null,8,["visible"]),t(Wt,{visible:ie.value,"onUpdate:visible":a[23]||(a[23]=L=>ie.value=L),type:"message",title:"默认提交信息设置",placeholder:"输入新模板内容","edit-placeholder":"编辑模板内容","empty-description":"暂无保存的模板","show-default-section":!0,"show-help-text":!0,onUseTemplate:Os,onSetDefault:Rs},null,8,["visible"]),t(Ft,{modelValue:T.value,"onUpdate:modelValue":a[27]||(a[27]=L=>T.value=L),title:"储藏更改 (Git Stash)",size:"medium","close-on-click-modal":!1,"show-footer":"","confirm-text":"储藏","confirm-loading":n(r).isSavingStash,onConfirm:le},{default:s(()=>[e("div",Sn,[a[65]||(a[65]=e("p",null,"将当前工作区的更改储藏起来,稍后可以再次应用。",-1)),t(is,{"label-position":"top"},{default:s(()=>[t(it,{label:"储藏说明 (可选)"},{default:s(()=>[t(yt,{modelValue:X.value,"onUpdate:modelValue":a[24]||(a[24]=L=>X.value=L),placeholder:"输入储藏说明(可选)",clearable:""},null,8,["modelValue"])]),_:1}),t(it,null,{default:s(()=>[t(_t,{modelValue:de.value,"onUpdate:modelValue":a[25]||(a[25]=L=>de.value=L)},{default:s(()=>a[63]||(a[63]=[x(" 包含未跟踪文件 (--include-untracked) ")])),_:1},8,["modelValue"])]),_:1}),t(it,null,{default:s(()=>[t(_t,{modelValue:Te.value,"onUpdate:modelValue":a[26]||(a[26]=L=>Te.value=L)},{default:s(()=>a[64]||(a[64]=[x(" 排除锁定文件 ")])),_:1},8,["modelValue"])]),_:1})]),_:1})])]),_:1},8,["modelValue","confirm-loading"]),t(Bt,{title:"合并分支",modelValue:O.value,"onUpdate:modelValue":a[35]||(a[35]=L=>O.value=L),width:"500px","close-on-click-modal":!1,class:"merge-dialog"},{footer:s(()=>[e("div",Ln,[t(G,{onClick:a[34]||(a[34]=L=>O.value=!1)},{default:s(()=>a[72]||(a[72]=[x("取消")])),_:1}),t(G,{type:"primary",onClick:Ms,loading:n(r).isGitMerging,disabled:!K.value,class:"merge-confirm-btn"},{default:s(()=>a[73]||(a[73]=[x(" 合并 ")])),_:1},8,["loading","disabled"])])]),default:s(()=>[e("div",Tn,[e("p",Fn,"选择要合并到当前分支 ("+A(n(r).currentBranch)+") 的分支:",1),t(is,{"label-position":"top"},{default:s(()=>[t(it,{label:"分支类型"},{default:s(()=>[t(Ys,{modelValue:ct.value,"onUpdate:modelValue":a[28]||(a[28]=L=>ct.value=L),size:"small"},{default:s(()=>[t(Et,{label:"all"},{default:s(()=>a[66]||(a[66]=[x("所有分支")])),_:1}),t(Et,{label:"local"},{default:s(()=>a[67]||(a[67]=[x("本地分支")])),_:1}),t(Et,{label:"remote"},{default:s(()=>a[68]||(a[68]=[x("远程分支")])),_:1})]),_:1},8,["modelValue"])]),_:1}),t(it,{label:"选择分支"},{default:s(()=>[t(ns,{modelValue:K.value,"onUpdate:modelValue":a[29]||(a[29]=L=>K.value=L),placeholder:"选择要合并的分支",style:{width:"100%"},filterable:"",teleported:!1},{default:s(()=>[(v(!0),S(Fe,null,Ae(As.value,L=>(v(),Z(ls,{key:L,label:L,value:L},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),t(it,{label:"合并选项"},{default:s(()=>[e("div",Vn,[t(_t,{modelValue:ue.value.noFf,"onUpdate:modelValue":a[30]||(a[30]=L=>ue.value.noFf=L)},{default:s(()=>[t(qe,{content:"创建合并提交,即使可以使用快进合并",placement:"top"},{default:s(()=>a[69]||(a[69]=[e("span",null,"禁用快进合并 (--no-ff)",-1)])),_:1})]),_:1},8,["modelValue"]),t(_t,{modelValue:ue.value.squash,"onUpdate:modelValue":a[31]||(a[31]=L=>ue.value.squash=L)},{default:s(()=>[t(qe,{content:"将多个提交压缩为一个提交",placement:"top"},{default:s(()=>a[70]||(a[70]=[e("span",null,"压缩提交 (--squash)",-1)])),_:1})]),_:1},8,["modelValue"]),t(_t,{modelValue:ue.value.noCommit,"onUpdate:modelValue":a[32]||(a[32]=L=>ue.value.noCommit=L)},{default:s(()=>[t(qe,{content:"执行合并但不自动创建提交",placement:"top"},{default:s(()=>a[71]||(a[71]=[e("span",null,"不自动提交 (--no-commit)",-1)])),_:1})]),_:1},8,["modelValue"])])]),_:1}),ue.value.noFf&&!ue.value.noCommit?(v(),Z(it,{key:0,label:"合并提交信息 (可选)"},{default:s(()=>[t(yt,{modelValue:ue.value.message,"onUpdate:modelValue":a[33]||(a[33]=L=>ue.value.message=L),type:"textarea",rows:3,placeholder:"输入自定义合并提交信息"},null,8,["modelValue"])]),_:1})):Y("",!0)]),_:1})])]),_:1},8,["modelValue"]),t(Bt,{title:"储藏列表 (Git Stash)",modelValue:ae.value,"onUpdate:modelValue":a[36]||(a[36]=L=>ae.value=L),width:"600px","close-on-click-modal":!1},{default:s(()=>[e("div",xn,[Xe((v(),Z(Ks,{data:n(r).stashes,stripe:"",style:{width:"100%"},"empty-text":"暂无储藏记录"},{default:s(()=>[t(It,{prop:"id",label:"ID",width:"100"}),t(It,{prop:"description",label:"描述"}),t(It,{label:"操作",width:"280"},{default:s(L=>[e("div",Bn,[t(G,{size:"small",type:"info",onClick:Nt=>_e(L.row),loading:Oe.value},{default:s(()=>a[74]||(a[74]=[x(" 查看 ")])),_:2},1032,["onClick","loading"]),t(G,{size:"small",onClick:Nt=>J(L.row.id,!1),loading:n(r).isApplyingStash},{default:s(()=>a[75]||(a[75]=[x(" 应用 ")])),_:2},1032,["onClick","loading"]),t(G,{size:"small",type:"primary",onClick:Nt=>J(L.row.id,!0),loading:n(r).isApplyingStash},{default:s(()=>a[76]||(a[76]=[x(" 应用并删除 ")])),_:2},1032,["onClick","loading"]),t(G,{size:"small",type:"danger",onClick:Nt=>Se(L.row.id),loading:n(r).isDroppingStash},{default:s(()=>a[77]||(a[77]=[x(" 删除 ")])),_:2},1032,["onClick","loading"])])]),_:1})]),_:1},8,["data"])),[[Qs,n(r).isLoadingStashes]]),n(r).stashes.length>0?(v(),S("div",Pn,[t(G,{type:"danger",onClick:Ve,loading:n(r).isDroppingStash},{default:s(()=>a[78]||(a[78]=[x(" 清空所有储藏 ")])),_:1},8,["loading"])])):Y("",!0)])]),_:1},8,["modelValue"]),t(Ft,{modelValue:Le.value,"onUpdate:modelValue":a[37]||(a[37]=L=>Le.value=L),title:"储藏详情","custom-class":"stash-detail-dialog",size:"extra-large",type:"flex","close-on-click-modal":!1},{default:s(()=>[e("div",zn,[De.value?(v(),S("div",jn,[e("div",Dn,[a[79]||(a[79]=e("span",{class:"info-label"},"Stash ID:",-1)),e("code",On,A(De.value.id),1)]),e("div",Rn,[a[80]||(a[80]=e("span",{class:"info-label"},"描述:",-1)),e("span",Gn,A(De.value.description),1)])])):Y("",!0),e("div",An,[t(ss,{files:lt.value,diffContent:oe.value,selectedFile:Me.value,context:"stash-detail",emptyText:"该stash没有变更文件",onFileSelect:Ue,onOpenFile:be,onOpenWithVscode:Ce},null,8,["files","diffContent","selectedFile"])])])]),_:1},8,["modelValue"]),t(es,{name:"el-fade-in-linear"},{default:s(()=>[M.value?(v(),S("div",Mn,[t(we,{class:"is-loading"},{default:s(()=>[t(n(Vs))]),_:1}),a[81]||(a[81]=e("span",null,"更新状态中...",-1))])):Y("",!0)]),_:1}),t(Na,{visible:n(p).visible,text:n(p).text,"show-progress":n(p).showProgress,progress:n(p).progress},null,8,["visible","text","show-progress","progress"]),t(Ya,{visible:n(U).visible,text:n(U).text,description:n(U).description},null,8,["visible","text","description"])],64)}}}),En=Be(Un,[["__scopeId","data-v-621b662f"]]),In={class:"log-header"},Nn={class:"log-actions"},Hn={key:0,class:"filter-panel-header"},Jn={class:"filter-form"},Wn={class:"filter-item"},qn={class:"filter-item"},Yn={class:"filter-item"},Kn={class:"filter-item"},Qn={class:"filter-actions"},Xn={key:0},Zn={key:1,class:"content-area-content"},ei={key:0,class:"graph-view"},ti={key:0,class:"commit-count"},si={class:"graph-controls"},oi={class:"zoom-controls"},ai={class:"scale-info"},li={key:1,class:"table-view-container"},ni=["onClick"],ii={class:"commit-message-cell"},ri={class:"message-content"},ci={key:0,class:"branch-container"},ui={class:"message-text"},di={class:"author-name"};const fi={class:"commit-detail-container"},pi={key:0,class:"commit-info"},mi={class:"commit-info-header"},vi={class:"info-item"},gi={class:"item-value"},hi={class:"info-item"},yi={class:"item-value"},_i={class:"info-item"},wi={class:"item-value"},ki={class:"commit-message-container"},$i=["innerHTML"],kt=.5,Pt=1.5,qt=.1,bi=xe({__name:"LogList",setup(N,{expose:r}){const l=Qe();let i=[];const p=d(i),_=d(""),R=d(!1),h=q(()=>l.isLoadingLog||R.value),U=d(!1),te=d(0),M=d(!1),H=d(null),y=d(1),w=d(!0),E=d(!1),I=d(null),se=d(!1),B=d(null),C=d([]),j=d(""),ce=d(!1),ne=d(""),k=d(1),D=d(!1),ye=d(!1),F=d([]),O=d(""),K=d(null),ue=d([]),ve=d([]),me=d([]),ie=d(!1),re=d(0),Q=d(0),pe=d(null),z=q(()=>p.value),T=q(()=>C.value.map($=>({path:$,name:$.split("/").pop()||$})));async function ae($=!1,g=1){if(!Qe().isGitRepo){_.value="当前目录不是Git仓库";return}try{g>1?E.value=!0:R.value=!0;const c=new URLSearchParams;c.append("page",g.toString()),c.append("all",$.toString()),c.append("with_parents","true"),F.value.length>0&&c.append("author",F.value.join(",")),ve.value.length>0&&c.append("branch",ve.value.join(",")),O.value&&c.append("message",O.value),K.value&&Array.isArray(K.value)&&K.value.length===2&&(c.append("dateFrom",K.value[0]),c.append("dateTo",K.value[1])),c.append("_t",Date.now().toString());const V=await(await fetch(`/api/log?${c.toString()}`)).json();if(!V||!V.data||!Array.isArray(V.data)){_.value="加载提交历史失败: 服务器返回数据格式不正确";return}const b=g>1;b?V.data.forEach(fe=>i.push(fe)):(i.length=0,V.data.forEach(fe=>i.push(fe))),p.value=[...i],y.value=g,te.value=V.total||i.length,w.value=V.hasMore===!0,b||(D.value=!0,setTimeout(()=>{D.value=!1},2e3)),!b&&M.value?setTimeout(X,0):!b&&!M.value&&!$&&rt(()=>{Me(),setTimeout(et,200)}),_.value=""}catch(c){_.value="加载提交历史失败: "+(c instanceof Error?c.message:String(c)),g>1&&(w.value=!1)}finally{g>1?E.value=!1:R.value=!1}}async function X(){if(H.value&&i.length!==0)try{H.value.innerHTML="";const $=To(H.value,{orientation:"vertical-reverse",template:"metro",author:"提交者 <committer@example.com>"}),g={},W=$.branch(l.currentBranch||"main");g[l.currentBranch||"main"]=W,i.forEach(c=>{let f=W;if(c.branch){const V=Le(c.branch.split(",")[0]);g[V]||(g[V]=$.branch(V)),f=g[V]}f.commit({hash:c.hash,subject:c.message,author:`${c.author} <${c.email}>`})}),setTimeout(()=>{le()},100)}catch($){_.value="渲染图表失败: "+($ instanceof Error?$.message:String($))}}function de(){M.value=!M.value,M.value&&i.length>0&&setTimeout(X,0)}function Te(){U.value=!U.value,U.value||(w.value=!0),y.value=1,ae(U.value),rt(()=>{setTimeout(()=>{!M.value&&!U.value&&(Me(),et())},300)})}function Le($){return $.includes("HEAD -> ")?$.replace("HEAD -> ",""):$.includes("origin/")?$:$.trim()}function De($){return $.includes("HEAD")?"success":$.includes("origin/")?"warning":"info"}const Pe=d(null),oe=d(null);function Oe($){if(M.value||!w.value||E.value||h.value)return;const g=$.target,{scrollTop:W,scrollHeight:c,clientHeight:f}=g;c-W-f<=20&&be()}function Me(){if(!Pe.value)return;const $=Pe.value.$el.querySelector(".el-table__body-wrapper");$&&(oe.value=$,oe.value&&(oe.value.removeEventListener("scroll",Oe,!0),oe.value.addEventListener("scroll",Oe,!0)))}function at(){oe.value&&(oe.value.removeEventListener("scroll",Oe,!0),oe.value=null)}function Ze($){$.key==="Escape"&&Re.value&&(Re.value=!1)}dt(()=>{l.isGitRepo?(l.log.length>0?(i.length=0,l.log.forEach($=>i.push($)),te.value=l.log.length,M.value&&setTimeout(()=>{X()},100)):ae(),Ie()):_.value="当前目录不是Git仓库",rt(()=>{setTimeout(()=>{Me()},500)}),je(()=>Pe.value,$=>{$&&!M.value&&!U.value&&rt(()=>{Me()})}),window.addEventListener("keydown",Ze)}),je(()=>l.allBranches,$=>{$&&$.length>0?me.value=[...$].sort():me.value=[]},{immediate:!0}),go(()=>{at(),I.value!==null&&(window.clearInterval(I.value),I.value=null),window.removeEventListener("keydown",Ze)});async function Ne(){await l.fetchLog(!0),i.length=0,l.log.forEach($=>i.push($)),p.value=[...i],te.value=l.log.length,y.value=1,w.value=!1,D.value=!0,setTimeout(()=>{D.value=!1},2e3),M.value&&(await rt(),X())}je(()=>l.log,$=>{try{i.length=0,Array.isArray($)&&$.forEach(g=>g&&i.push(g)),te.value=i.length,y.value=1,p.value=[...i],D.value=!0,setTimeout(()=>{D.value=!1},2e3),M.value&&i.length>0&&setTimeout(X,0)}catch{}},{immediate:!0}),r({refreshLog:Ne});function Je(){k.value<Pt&&(k.value=Math.min(Pt,k.value+qt),u())}function P(){k.value>kt&&(k.value=Math.max(kt,k.value-qt),u())}function u(){if(!H.value)return;const $=H.value.querySelector("svg");$&&($.style.transform=`scale(${k.value})`,$.style.transformOrigin="top left")}function le(){if(!H.value)return;const $=H.value.querySelector("svg");if(!$)return;const g=$.getBoundingClientRect().width/k.value,W=H.value.clientWidth;g>W?k.value=Math.max(kt,W/g):k.value=1,u()}async function J($){if($){B.value=$,se.value=!0,ce.value=!0,C.value=[],j.value="",ne.value="";try{if(!$.hash||$.hash.length<7){j.value="无效的提交哈希值",ce.value=!1;return}const W=await(await fetch(`/api/commit-files?hash=${$.hash}`)).json();W.success&&Array.isArray(W.files)?(C.value=W.files,C.value.length>0?await Se($.hash,C.value[0]):j.value="该提交没有变更文件"):j.value=`获取文件列表失败: ${W.error||"未知错误"}`}catch(g){j.value=`获取提交详情失败: ${g.message}`}finally{ce.value=!1}}}async function Se($,g){ce.value=!0,ne.value=g;try{const c=await(await fetch(`/api/commit-file-diff?hash=${$}&file=${encodeURIComponent(g)}`)).json();c.success?j.value=c.diff||"没有变更内容":j.value=`获取差异失败: ${c.error||"未知错误"}`}catch(W){j.value=`获取差异失败: ${W.message}`}finally{ce.value=!1}}function Ve($){B.value&&Se(B.value.hash,$)}async function _e($,g){try{const c=await(await fetch("/api/open-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:$,context:g})})).json();c.success?o.success(c.message):o.error(c.error||"打开文件失败")}catch(W){o.error(`打开文件失败: ${W.message}`)}}async function $e($,g){try{const c=await(await fetch("/api/open-with-vscode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:$,context:g})})).json();c.success?o.success(c.message):o.error(c.error||"用VSCode打开文件失败")}catch(W){o.error(`用VSCode打开文件失败: ${W.message}`)}}async function Ue($){try{const g=Oo($);await navigator.clipboard.writeText(g),o.success("提交信息已复制到剪贴板")}catch{o.error("复制失败")}}function be(){!w.value||E.value||h.value||ae(U.value,y.value+1)}function Ce(){F.value=[],ve.value=[],O.value="",K.value=null,y.value=1,ae(U.value,1)}function We(){y.value=1,ae(U.value,1)}async function Ie(){try{const g=await(await fetch("/api/authors")).json();g.success&&Array.isArray(g.authors)?ue.value=g.authors.sort():ee()}catch{ee()}}function ee(){const $=new Set;p.value.forEach(g=>{g.author&&$.add(g.author)}),ue.value=Array.from($).sort()}je(()=>p.value,()=>{},{deep:!0});function lt($,g,W){W.preventDefault(),re.value=W.clientY,Q.value=W.clientX,pe.value=$,ie.value=!0;const c=()=>{ie.value=!1,document.removeEventListener("click",c)};setTimeout(()=>{document.addEventListener("click",c)},0)}async function nt($){if($)try{await He.confirm(`确定要撤销提交 ${$.hash.substring(0,7)} 吗?这将创建一个新的提交来撤销这次提交的更改。`,"撤销提交确认",{confirmButtonText:"确认",cancelButtonText:"取消",type:"warning"});const W=await(await fetch("/api/revert-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:$.hash})})).json();W.success?(o.success(W.message||"已成功撤销提交"),Ne(),l.fetchStatus(),l.getBranchStatus()):o.error(W.error||"撤销提交失败")}catch(g){g!=="cancel"&&o.error("撤销提交失败: "+(g.message||g))}}async function pt($){if($)try{await He.confirm(`确定要将提交 ${$.hash.substring(0,7)} Cherry-Pick 到当前分支吗?`,"Cherry-Pick确认",{confirmButtonText:"确认",cancelButtonText:"取消",type:"warning"});const W=await(await fetch("/api/cherry-pick-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:$.hash})})).json();W.success?(o.success(W.message||"已成功Cherry-Pick提交"),Ne(),l.fetchStatus(),l.getBranchStatus()):o.error(W.error||"Cherry-Pick提交失败")}catch(g){g!=="cancel"&&o.error("Cherry-Pick提交失败: "+(g.message||g))}}async function mt($){if($)try{await navigator.clipboard.writeText($.hash),o.success(`已复制提交哈希: ${$.hash.substring(0,7)}`)}catch(g){o.error(`复制提交哈希失败: ${g.message}`)}}async function vt($){if($)try{await He.confirm(`确定要将当前分支重置(hard)到提交 ${$.hash.substring(0,7)} 吗?
22
+
23
+ 警告:这将丢失该提交之后的所有更改!`,"重置确认",{confirmButtonText:"确认重置",cancelButtonText:"取消",type:"warning",dangerouslyUseHTMLString:!0});const W=await(await fetch("/api/reset-to-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:$.hash})})).json();W.success?(o.success(W.message||"已成功重置到指定提交"),Ne(),l.fetchStatus(),l.getBranchStatus()):o.error(W.error||"重置到指定提交失败")}catch(g){g!=="cancel"&&o.error("重置到指定提交失败: "+(g.message||g))}}function et(){if(M.value||!w.value||E.value||h.value||U.value)return;if(!oe.value){Me();return}const{scrollTop:$,scrollHeight:g,clientHeight:W}=oe.value;g-$-W<=50&&be()}je(()=>M.value,$=>{!$&&!U.value&&rt(()=>{Me(),setTimeout(et,200)})});const Re=d(!1);function gt(){Re.value=!Re.value,rt(()=>{M.value&&H.value&&X()})}return($,g)=>{var V;const W=st,c=Ye,f=Xt;return v(),S(Fe,null,[e("div",{class:ke(["card",{"fullscreen-mode":Re.value}])},[e("div",In,[g[13]||(g[13]=e("div",{class:"header-left"},[e("h2",null,"提交历史")],-1)),e("div",Nn,[M.value?Y("",!0):(v(),Z(n(he),{key:0,type:ye.value?"primary":"default",size:"small",onClick:g[0]||(g[0]=b=>ye.value=!ye.value),class:ke(["action-button filter-button icon-only-button",{"active-filter":ye.value}])},{icon:s(()=>[t(W,null,{default:s(()=>[t(n(ho))]),_:1})]),_:1},8,["type","class"])),t(n(he),{type:"primary",size:"small",onClick:de,class:ke(["action-button view-mode-button icon-only-button",{"active-view":M.value}])},{icon:s(()=>[t(W,null,{default:s(()=>[(v(),Z(bt(M.value?n(Yt):n(yo))))]),_:1})]),_:1},8,["class"]),Xe(t(n(he),{type:"success",size:"small",onClick:Te,loading:h.value,class:ke(["action-button commit-display-button",{"active-commits":U.value}])},{icon:s(()=>[t(W,null,{default:s(()=>[(v(),Z(bt(U.value?n(_o):n(wo))))]),_:1})]),default:s(()=>[x(" "+A(U.value?"显示分页加载":"显示所有提交"),1)]),_:1},8,["loading","class"]),[[St,!1]]),t(n(he),{type:"info",size:"small",onClick:gt,class:ke(["action-button fullscreen-button icon-only-button",{"active-fullscreen":Re.value}])},{icon:s(()=>[t(W,null,{default:s(()=>[(v(),Z(bt(Re.value?n(Kt):n(ko))))]),_:1})]),_:1},8,["class"]),t(n(he),{circle:"",size:"small",onClick:g[1]||(g[1]=b=>Ne()),class:ke([{"refresh-button-animated":D.value},"action-button refresh-button"])},{default:s(()=>[h.value?(v(),Z(W,{key:1},{default:s(()=>[t(n(Vs))]),_:1})):(v(),Z(W,{key:0},{default:s(()=>[t(n(Qt))]),_:1}))]),_:1},8,["class"])])]),ye.value&&!M.value?(v(),S("div",Hn,[e("div",Jn,[e("div",Wn,[t(n(Ot),{modelValue:F.value,"onUpdate:modelValue":g[2]||(g[2]=b=>F.value=b),placeholder:"选择作者",multiple:"",clearable:"",filterable:"",class:"filter-input",size:"small"},{prefix:s(()=>g[14]||(g[14]=[e("span",{class:"compact-label"},"作者",-1)])),default:s(()=>[(v(!0),S(Fe,null,Ae(ue.value,b=>(v(),Z(n(Dt),{key:b,label:b,value:b},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),e("div",qn,[t(n(Ot),{modelValue:ve.value,"onUpdate:modelValue":g[3]||(g[3]=b=>ve.value=b),placeholder:"选择分支",multiple:"",clearable:"",filterable:"",class:"filter-input",size:"small"},{prefix:s(()=>g[15]||(g[15]=[e("span",{class:"compact-label"},"分支",-1)])),default:s(()=>[(v(!0),S(Fe,null,Ae(me.value,b=>(v(),Z(n(Dt),{key:b,label:b,value:b},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),e("div",Yn,[t(n(Gt),{modelValue:O.value,"onUpdate:modelValue":g[4]||(g[4]=b=>O.value=b),placeholder:"提交信息关键词",clearable:"",class:"filter-input",size:"small"},{prefix:s(()=>g[16]||(g[16]=[e("span",{class:"compact-label"},"信息",-1)])),_:1},8,["modelValue"])]),e("div",Kn,[t(n($o),{modelValue:K.value,"onUpdate:modelValue":g[5]||(g[5]=b=>K.value=b),type:"daterange","range-separator":"至","start-placeholder":"开始日期","end-placeholder":"结束日期",format:"YYYY-MM-DD","value-format":"YYYY-MM-DD",class:"filter-input date-range",size:"small"},{prefix:s(()=>g[17]||(g[17]=[e("span",{class:"compact-label"},"日期",-1)])),_:1},8,["modelValue"])]),e("div",Qn,[t(n(he),{type:"primary",size:"small",onClick:We,class:"filter-action-button"},{default:s(()=>g[18]||(g[18]=[x("应用")])),_:1}),t(n(he),{type:"info",size:"small",onClick:Ce,class:"filter-action-button"},{default:s(()=>g[19]||(g[19]=[x("重置")])),_:1})])])])):Y("",!0),e("div",{class:ke(["content-area",{"with-filter":ye.value&&!M.value}])},[_.value?(v(),S("div",Xn,A(_.value),1)):(v(),S("div",Zn,[M.value?(v(),S("div",ei,[n(i).length>0?(v(),S("div",ti," 显示 "+A(n(i).length)+" 条提交记录 "+A(U.value?"(全部)":"(分页加载,每页20条)"),1)):Y("",!0),e("div",si,[e("div",oi,[t(n(he),{type:"primary",circle:"",size:"small",onClick:P,disabled:k.value<=kt},{default:s(()=>[t(W,null,{default:s(()=>[t(n(bo))]),_:1})]),_:1},8,["disabled"]),t(n(Co),{modelValue:k.value,"onUpdate:modelValue":g[6]||(g[6]=b=>k.value=b),min:kt,max:Pt,step:qt,onChange:u,class:"zoom-slider"},null,8,["modelValue"]),t(n(he),{type:"primary",circle:"",size:"small",onClick:Je,disabled:k.value>=Pt},{default:s(()=>[t(W,null,{default:s(()=>[t(n(So))]),_:1})]),_:1},8,["disabled"]),t(n(he),{type:"primary",size:"small",onClick:le},{default:s(()=>g[20]||(g[20]=[x(" 自适应大小 ")])),_:1})]),e("div",ai," 缩放: "+A(Math.round(k.value*100))+"% ",1)]),e("div",{ref_key:"graphContainer",ref:H,class:"graph-container"},null,512)])):(v(),S("div",li,[Xe((v(),Z(n(Fs),{ref_key:"tableRef",ref:Pe,data:z.value,stripe:"",border:"",class:"log-table","empty-text":h.value?"加载中...":"没有匹配的提交记录",height:"450",onRowContextmenu:lt},{default:s(()=>[t(n($t),{label:"哈希",width:"80",resizable:""},{default:s(b=>[e("span",{class:"commit-hash",onClick:fe=>J(b.row)},A(b.row.hash.substring(0,6)),9,ni)]),_:1}),t(n($t),{label:"提交信息","min-width":"300"},{default:s(b=>[e("div",ii,[e("div",ri,[b.row.branch?(v(),S("div",ci,[(v(!0),S(Fe,null,Ae(b.row.branch.split(","),(fe,ze)=>(v(),Z(n(Lt),{key:ze,size:"small",type:De(fe),class:"branch-tag"},{default:s(()=>[x(A(Le(fe)),1)]),_:2},1032,["type"]))),128))])):Y("",!0),e("span",ui,A(b.row.message),1),t(n(he),{type:"text",icon:n(ut),size:"small",onClick:Tt(fe=>Ue(b.row.message),["stop"]),class:"copy-message-btn",title:"复制纯净提交信息(不含类型前缀)"},null,8,["icon","onClick"])])])]),_:1}),t(n($t),{prop:"date",label:"日期",width:"150",resizable:""}),t(n($t),{label:"作者",width:"100",resizable:""},{default:s(b=>[t(c,{content:b.row.email,placement:"top","hide-after":1e3,"show-after":200},{default:s(()=>[e("span",di,A(b.row.author),1)]),_:2},1032,["content"])]),_:1})]),_:1},8,["data","empty-text"])),[[f,h.value]]),(U.value,Y("",!0))]))]))],2),t(Ft,{modelValue:se.value,"onUpdate:modelValue":g[7]||(g[7]=b=>se.value=b),title:`提交详情: ${(V=B.value)!=null&&V.hash?B.value.hash.substring(0,7):"未知"}`,size:"extra-large",type:"flex","destroy-on-close":"","custom-class":"commit-detail-dialog"},{default:s(()=>[Xe((v(),S("div",fi,[B.value?(v(),S("div",pi,[e("div",mi,[e("div",vi,[g[24]||(g[24]=e("span",{class:"item-label"},"哈希:",-1)),e("span",gi,A(B.value.hash),1)]),e("div",hi,[g[25]||(g[25]=e("span",{class:"item-label"},"作者:",-1)),e("span",yi,A(B.value.author)+" <"+A(B.value.email)+">",1)]),e("div",_i,[g[26]||(g[26]=e("span",{class:"item-label"},"日期:",-1)),e("span",wi,A(B.value.date),1)])]),e("div",ki,[g[27]||(g[27]=e("div",{class:"message-label"},"提交信息:",-1)),e("div",{class:"message-content",innerHTML:n(Do)(B.value.message).replace(/\n/g,"<br>")},null,8,$i)])])):Y("",!0),t(ss,{files:T.value,loading:ce.value,diffContent:j.value,selectedFile:ne.value,context:"commit-detail",emptyText:"没有找到变更文件",onFileSelect:Ve,onOpenFile:_e,onOpenWithVscode:$e},null,8,["files","loading","diffContent","selectedFile"])])),[[f,ce.value]])]),_:1},8,["modelValue","title"])],2),Xe(e("div",{class:ke(["context-menu",{"fullscreen-context-menu":Re.value}]),style:ft({top:re.value+"px",left:Q.value+"px"})},[e("div",{class:"context-menu-item",onClick:g[8]||(g[8]=b=>J(pe.value))},g[28]||(g[28]=[e("i",{class:"el-icon-view"},null,-1),x(" 查看详情 ")])),e("div",{class:"context-menu-item",onClick:g[9]||(g[9]=b=>mt(pe.value))},g[29]||(g[29]=[e("i",{class:"el-icon-document-copy"},null,-1),x(" 复制提交哈希 ")])),e("div",{class:"context-menu-item",onClick:g[10]||(g[10]=b=>vt(pe.value))},g[30]||(g[30]=[e("i",{class:"el-icon-refresh-right"},null,-1),x(" 重置到该提交(hard) ")])),e("div",{class:"context-menu-item",onClick:g[11]||(g[11]=b=>nt(pe.value))},g[31]||(g[31]=[e("i",{class:"el-icon-delete"},null,-1),x(" 撤销提交 (Revert) ")])),e("div",{class:"context-menu-item",onClick:g[12]||(g[12]=b=>pt(pe.value))},g[32]||(g[32]=[e("i",{class:"el-icon-edit"},null,-1),x(" Cherry-Pick 到当前分支 ")]))],6),[[St,ie.value]])],64)}}}),Ci=Be(bi,[["__scopeId","data-v-c85ca6b0"]]),Si={class:"dialog-content"},Ti={class:"dialog-toolbar"},Fi={class:"history-scroll"},Vi={key:0,class:"loading-state"},Li={key:2,class:"history-list"},xi=["onClick"],Bi={class:"command-info"},Pi={class:"command-text"},zi={class:"command-meta"},ji={class:"timestamp"},Di={class:"duration"},Oi={class:"item-actions"},Ri={key:0,class:"item-details"},Gi={key:0,class:"output-section"},Ai={class:"output-header"},Mi={class:"output-content"},Ui={key:0,class:"truncation-notice"},Ei={class:"output-header"},Ii={class:"output-content"},Ni={key:0,class:"truncation-notice"},Hi={key:2,class:"output-section error"},Ji={class:"output-content"},Wi=xe({__name:"CommandHistory",setup(N){const r=Qe(),l=d([]),i=d(!1),p=d(!1),_=d(!1),R=d(!1),h=d(new Set),U=d(!1),te=d(!1);function M(){te.value=!0,l.value.length===0&&H()}async function H(){try{if(i.value=!0,r.socket&&r.socket.connected)r.socket.emit("request_full_history");else{const O=await(await fetch("/api/command-history")).json();O.success?l.value=O.history:o.error(`加载命令历史失败: ${O.error}`)}}catch(F){o.error(`加载命令历史失败: ${F.message}`)}finally{i.value=!1}}async function y(){if(l.value.length===0){o.warning("没有可复制的命令历史");return}try{_.value=!0;const F=l.value.map(O=>{let K=`# ${I(O.timestamp)} (耗时: ${se(O.executionTime)}) - ${O.success?"成功":"失败"}
24
+ `;if(K+=`${O.command}
25
+ `,O.stdout&&(K+=`
26
+ # 输出:
27
+ ${O.stdout}
28
+ `),O.stderr){const ue=ne(O.command)?"输出信息":"错误输出";K+=`
29
+ # ${ue}:
30
+ ${O.stderr}
31
+ `}return O.error&&(K+=`
32
+ # 错误信息:
33
+ ${O.error}
34
+ `),K}).join(`
35
+ ---
36
+
37
+ `);await navigator.clipboard.writeText(F),o.success("命令历史已复制到剪贴板")}catch(F){o.error(`复制失败: ${F.message}`)}finally{_.value=!1}}async function w(){if(l.value.length===0){o.warning("没有可复制的命令");return}try{U.value=!0;const F=l.value.map(O=>O.command).join(`
38
+ `);await navigator.clipboard.writeText(F),o.success("命令列表已复制到剪贴板")}catch(F){o.error(`复制失败: ${F.message}`)}finally{U.value=!1}}async function E(){try{if(await He.confirm("确定要清空所有命令历史记录吗?此操作不可恢复。","清空命令历史",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}),p.value=!0,r.socket&&r.socket.connected)r.socket.emit("clear_command_history");else{const O=await(await fetch("/api/clear-command-history",{method:"POST",headers:{"Content-Type":"application/json"}})).json();O.success?(l.value=[],o.success("命令历史已清空")):o.error(`清空命令历史失败: ${O.error}`)}}catch(F){F!=="cancel"&&F.toString()!=="Error: cancel"&&o.error(`清空命令历史失败: ${F.message}`)}finally{p.value=!1}}function I(F){return new Date(F).toLocaleString()}function se(F){return F<1e3?`${F}ms`:`${(F/1e3).toFixed(2)}s`}function B(F){h.value.has(F)?h.value.delete(F):h.value.add(F)}function C(F){return h.value.has(F)}async function j(F){try{await navigator.clipboard.writeText(F),o.success("命令已复制到剪贴板")}catch(O){o.error(`复制失败: ${O.message}`)}}function ce(F){return F.includes("git push")||F.includes("git-push")}function ne(F){return!!ce(F)}async function k(F){try{let O="";if(F.stdout&&(O+=`标准输出:
39
+ ${F.stdout}
40
+
41
+ `),F.stderr){const K=ne(F.command)?"输出信息":"错误输出";O+=`${K}:
42
+ ${F.stderr}
43
+
44
+ `}F.error&&(O+=`错误信息:
45
+ ${F.error}`),await navigator.clipboard.writeText(O.trim()),o.success("输出已复制到剪贴板")}catch(O){o.error(`复制失败: ${O.message}`)}}function D(){if(!r.socket){console.error("Socket实例不可用");return}r.socket.on("initial_command_history",F=>{l.value=F.history,R.value=!0}),r.socket.on("command_history_update",F=>{l.value.unshift(F.newCommand),l.value.length>100&&l.value.pop(),R.value=!0}),r.socket.on("full_command_history",F=>{l.value=F.history,i.value=!1,R.value=!0}),r.socket.on("command_history_cleared",F=>{F.success&&(l.value=[],o.success("命令历史已清空")),p.value=!1}),r.socket.on("connect",()=>{R.value=!0,o.success("已连接到实时命令历史")}),r.socket.on("disconnect",()=>{R.value=!1,o.warning("实时命令历史连接已断开")})}function ye(){r.socket&&(r.socket.off("initial_command_history"),r.socket.off("command_history_update"),r.socket.off("full_command_history"),r.socket.off("command_history_cleared"))}return dt(()=>{D(),r.socket||(console.log("尝试初始化Socket连接"),r.initSocketConnection())}),vs(()=>{ye()}),(F,O)=>{const K=he,ue=Lt,ve=st,me=zt,ie=ts,re=Vt;return v(),S(Fe,null,[t(K,{type:"primary",icon:n(Fo),onClick:M,class:"command-history-button",title:"查看Git命令历史"},null,8,["icon"]),(v(),Z(Zt,{to:"body"},[t(re,{modelValue:te.value,"onUpdate:modelValue":O[0]||(O[0]=Q=>te.value=Q),title:"Git 命令历史",width:"80%",top:"5vh","destroy-on-close":"",class:"command-history-dialog","z-index":99999,"append-to-body":"",modal:""},{default:s(()=>[e("div",Si,[e("div",Ti,[t(ue,{type:R.value?"success":"danger",size:"small",effect:"dark",class:"socket-status"},{default:s(()=>[x(A(R.value?"实时更新":"未连接"),1)]),_:1},8,["type"]),t(K,{type:"success",icon:n(ut),circle:"",size:"small",onClick:w,loading:U.value,class:"copy-commands-button",title:"只复制命令列表(不含输出)",disabled:l.value.length===0},null,8,["icon","loading","disabled"]),t(K,{type:"primary",icon:n(ut),circle:"",size:"small",onClick:y,loading:_.value,class:"copy-all-button",title:"复制完整命令历史(含输出)",disabled:l.value.length===0},null,8,["icon","loading","disabled"]),t(K,{type:"danger",icon:n(Cs),circle:"",size:"small",onClick:E,loading:p.value,class:"clear-button",title:"清空命令历史",disabled:l.value.length===0},null,8,["icon","loading","disabled"])]),e("div",Fi,[i.value&&l.value.length===0?(v(),S("div",Vi,[t(ve,{class:"loading-icon is-loading"},{default:s(()=>O[1]||(O[1]=[e("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},[e("path",{fill:"currentColor",d:"M512 64a32 32 0 0 1 32 32v192a32 32 0 0 1-64 0V96a32 32 0 0 1 32-32zm0 640a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V736a32 32 0 0 1 32-32zm448-192a32 32 0 0 1-32 32H736a32 32 0 1 1 0-64h192a32 32 0 0 1 32 32zm-640 0a32 32 0 0 1-32 32H96a32 32 0 0 1 0-64h192a32 32 0 0 1 32 32zM195.2 195.2a32 32 0 0 1 45.248 0L376.32 331.008a32 32 0 0 1-45.248 45.248L195.2 240.448a32 32 0 0 1 0-45.248zm452.544 452.544a32 32 0 0 1 45.248 0L828.8 783.552a32 32 0 0 1-45.248 45.248L647.744 692.992a32 32 0 0 1 0-45.248zM828.8 195.264a32 32 0 0 1 0 45.184L692.992 376.32a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0zm-452.544 452.48a32 32 0 0 1 0 45.248L240.448 828.8a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0z"})],-1)])),_:1}),O[2]||(O[2]=e("div",{class:"loading-text"},"加载命令历史...",-1))])):l.value.length===0?(v(),Z(me,{key:1,description:"暂无命令历史"})):(v(),S("div",Li,[(v(!0),S(Fe,null,Ae(l.value,(Q,pe)=>(v(),S("div",{key:pe,class:ke(["history-item",{"is-error":!Q.success}])},[e("div",{class:"item-header",onClick:z=>B(pe)},[e("div",Bi,[e("div",Pi,[t(ue,{size:"small",type:Q.success?"success":"danger",effect:"dark",class:"status-tag"},{default:s(()=>[x(A(Q.success?"成功":"失败"),1)]),_:2},1032,["type"]),e("code",null,A(Q.command),1)]),e("div",zi,[e("span",ji,A(I(Q.timestamp)),1),e("span",Di,"耗时: "+A(se(Q.executionTime)),1)])]),e("div",Oi,[t(K,{type:"primary",icon:n(ut),circle:"",size:"small",onClick:Tt(z=>j(Q.command),["stop"]),title:"复制命令"},null,8,["icon","onClick"]),t(K,{type:C(pe)?"primary":"default",icon:C(pe)?n(ks):n(Rt),circle:"",size:"small",onClick:Tt(z=>B(pe),["stop"]),title:"展开/收起"},null,8,["type","icon","onClick"])])],8,xi),C(pe)?(v(),S("div",Ri,[Q.stdout?(v(),S("div",Gi,[e("div",Ai,[O[3]||(O[3]=e("h4",null,"标准输出",-1)),t(K,{type:"primary",icon:n(ut),circle:"",size:"small",onClick:z=>k(Q),title:"复制输出"},null,8,["icon","onClick"])]),e("pre",Mi,A(Q.stdout),1),Q.isStdoutTruncated?(v(),S("div",Ui,[t(ie,{type:"info",closable:!1,"show-icon":""},{default:s(()=>O[4]||(O[4]=[x(" 输出内容过长已被截断,请直接执行命令查看完整输出 ")])),_:1})])):Y("",!0)])):Y("",!0),Q.stderr?(v(),S("div",{key:1,class:ke(["output-section",ne(Q.command)?"":"error"])},[e("div",Ei,[e("h4",null,A(ne(Q.command)?"输出信息":"错误输出"),1)]),e("pre",Ii,A(Q.stderr),1),Q.isStderrTruncated?(v(),S("div",Ni,[t(ie,{type:"info",closable:!1,"show-icon":""},{default:s(()=>[x(A(ne(Q.command)?"输出信息":"错误输出")+"内容过长已被截断,请直接执行命令查看完整输出 ",1)]),_:2},1024)])):Y("",!0)],2)):Y("",!0),Q.error?(v(),S("div",Hi,[O[5]||(O[5]=e("div",{class:"output-header"},[e("h4",null,"错误信息")],-1)),e("pre",Ji,A(Q.error),1)])):Y("",!0)])):Y("",!0)],2))),128))]))])])]),_:1},8,["modelValue"])]))],64)}}}),qi=Be(Wi,[["__scopeId","data-v-123bc700"]]),Yi="data:image/svg+xml,%3csvg%20width='200'%20height='200'%20viewBox='0%200%20200%20200'%20xmlns='http://www.w3.org/2000/svg'%3e%3c!--%20主分支%20--%3e%3cline%20x1='40'%20y1='40'%20x2='40'%20y2='160'%20stroke='%2334495e'%20stroke-width='8'%20stroke-linecap='round'%20/%3e%3c!--%20特性分支%20--%3e%3cpath%20d='M40,70%20C60,70%2080,90%2080,110%20L80,130'%20stroke='%233498db'%20stroke-width='8'%20stroke-linecap='round'%20stroke-linejoin='round'%20fill='none'%20/%3e%3c!--%20开发分支%20--%3e%3cpath%20d='M40,100%20C60,100%20100,110%20100,130%20L100,160'%20stroke='%232ecc71'%20stroke-width='8'%20stroke-linecap='round'%20stroke-linejoin='round'%20fill='none'%20/%3e%3c!--%20修复分支%20--%3e%3cpath%20d='M40,130%20C60,130%20120,140%20120,160'%20stroke='%23e74c3c'%20stroke-width='8'%20stroke-linecap='round'%20stroke-linejoin='round'%20fill='none'%20/%3e%3c!--%20合并点%20--%3e%3cpath%20d='M80,130%20C80,145%2060,145%2040,145'%20stroke='%233498db'%20stroke-width='8'%20stroke-linecap='round'%20stroke-linejoin='round'%20fill='none'%20/%3e%3c!--%20节点%20--%3e%3ccircle%20cx='40'%20cy='40'%20r='10'%20fill='%2334495e'%20/%3e%3ccircle%20cx='40'%20cy='70'%20r='10'%20fill='%2334495e'%20/%3e%3ccircle%20cx='40'%20cy='100'%20r='10'%20fill='%2334495e'%20/%3e%3ccircle%20cx='40'%20cy='130'%20r='10'%20fill='%2334495e'%20/%3e%3ccircle%20cx='40'%20cy='145'%20r='10'%20fill='%2334495e'%20/%3e%3ccircle%20cx='40'%20cy='160'%20r='10'%20fill='%2334495e'%20/%3e%3ccircle%20cx='80'%20cy='130'%20r='10'%20fill='%233498db'%20/%3e%3ccircle%20cx='100'%20cy='160'%20r='10'%20fill='%232ecc71'%20/%3e%3ccircle%20cx='120'%20cy='160'%20r='10'%20fill='%23e74c3c'%20/%3e%3c/svg%3e",Ki={class:"main-header"},Qi={class:"header-left"},Xi=["src"],Zi={class:"header-info"},er={key:0,id:"user-info"},tr={class:"user-name"},sr={class:"user-email"},or={key:1,id:"user-info"},ar={class:"directory-selector"},lr={class:"directory-display"},nr={class:"directory-icon"},ir=["title"],rr={class:"directory-actions"},cr={key:2,class:"command-history-section"},ur={class:"main-container"},dr={key:0,class:"loading-container"},fr={class:"loading-spinner"},pr={key:1,class:"grid-layout"},mr={class:"git-status-panel"},vr={key:0,class:"commit-form-panel"},gr={key:0,class:"card"},hr={class:"tips"},yr={key:1,class:"commit-form-panel"},_r={key:2,class:"log-list-panel"},wr={class:"dialog-footer"},kr={class:"main-footer"},$r={key:0,class:"branch-info"},br={class:"branch-wrapper"},Cr={key:1,class:"footer-right"},Sr={class:"repo-url"},Tr={class:"dialog-footer"},Fr={class:"directory-input-group"},Vr={class:"recent-directories"},Lr={class:"dialog-footer"},xr=xe({__name:"App",setup(N){const r=d(""),l=d(null),i=d(null),p=Qe(),_=ot(),R=d(!1),h=d("");function U(){_.config&&(r.value=`默认提交信息: ${_.config.defaultCommitMessage}`)}async function te(){try{const u=await(await fetch("/api/current_directory")).json();return h.value=u.directory||"未知目录",u}catch(P){return console.error("获取当前目录失败:",P),{directory:"未知目录",isGitRepo:!1}}}dt(async()=>{console.log("---------- 页面初始化开始 ----------");try{const P=await te();_.isLoaded||await _.loadConfig(),U(),p.isGitRepo=P.isGitRepo===!0,p.lastCheckedTime=Date.now(),p.isGitRepo?await Promise.all([p.getCurrentBranch(!0),p.getAllBranches(),p.getUserInfo(),p.getRemoteUrl(),p.getBranchStatus(!0)]):o.warning("当前目录不是Git仓库,部分功能将不可用")}catch(P){console.error("初始化失败:",P)}finally{R.value=!0,console.log("---------- 页面初始化完成 ----------"),setTimeout(()=>{ie()},100)}});const M=d(!1),H=d(""),y=d("");async function w(){await p.createBranch(H.value,y.value)&&(M.value=!1,H.value="",i.value&&i.value.refreshStatus(),l.value&&l.value.refreshLog())}function E(){y.value=p.currentBranch,M.value=!0}async function I(P){await p.changeBranch(P)&&(i.value&&i.value.refreshStatus(),l.value&&l.value.refreshLog())}const se=d(!1),B=d(""),C=d("");function j(){B.value=p.userName,C.value=p.userEmail,se.value=!0}async function ce(){if(!B.value||!C.value){o.warning("用户名和邮箱不能为空");return}await p.restoreUserConfig(B.value,C.value)&&(se.value=!1)}async function ne(){await p.clearUserConfig()&&(B.value="",C.value="")}let k=!1,D=!1,ye=!1,F=0,O=0,K="",ue="",ve=null;function me(){const P=document.querySelector(".grid-layout");if(!P)return;const u=getComputedStyle(P).gridTemplateColumns.split(" "),le=getComputedStyle(P).gridTemplateRows.split(" ");if(u.length>=3&&le.length>=3){const J=parseFloat(u[0]),Se=parseFloat(u[2]),Ve=J+Se,_e=J/Ve,$e=parseFloat(le[0]),Ue=parseFloat(le[2]),be=$e+Ue,Ce=$e/be;localStorage.setItem("zen-gitsync-layout-left-ratio",_e.toString()),localStorage.setItem("zen-gitsync-layout-top-ratio",Ce.toString()),console.log(`布局比例已保存 - 左侧: ${(_e*100).toFixed(0)}%, 上方: ${(Ce*100).toFixed(0)}%`),localStorage.setItem("zen-gitsync-layout-bottom-left-ratio",_e.toString()),console.log(`底部布局比例已保存 - 左侧: ${(_e*100).toFixed(0)}%`)}}function ie(){const P=document.querySelector(".grid-layout");if(!P)return;const u=localStorage.getItem("zen-gitsync-layout-left-ratio"),le=localStorage.getItem("zen-gitsync-layout-top-ratio");if(u){const J=parseFloat(u),Se=1-J;P.style.gridTemplateColumns=`${J}fr 8px ${Se}fr`,console.log(`已恢复左侧比例: ${(J*100).toFixed(0)}%`)}else P.style.gridTemplateColumns="1fr 8px 3fr";if(le){const J=parseFloat(le),Se=1-J;P.style.gridTemplateRows=`${J}fr 8px ${Se}fr`,console.log(`已恢复上方比例: ${(J*100).toFixed(0)}%`)}}function re(P){var J;const u=P.currentTarget;if(!u||!u.id)return;ve=u.id,ve==="v-resizer"?k=!0:ve==="v-resizer-bottom"&&(D=!0),F=P.clientX;const le=document.querySelector(".grid-layout");K=getComputedStyle(le).gridTemplateColumns,(J=document.getElementById(ve))==null||J.classList.add("active"),document.addEventListener("mousemove",Q),document.addEventListener("mouseup",pe),P.preventDefault()}function Q(P){if(!k&&!D)return;const u=document.querySelector(".grid-layout"),le=P.clientX-F,J=K.split(" ");if(J.length>=3){const Se=parseFloat(J[0]),Ve=parseFloat(J[2]),_e=Se+Ve,$e=(Se+le/u.clientWidth*_e)/_e,Ue=1-$e,be=.1,Ce=.5;$e<be?u.style.gridTemplateColumns=`${be}fr 8px ${1-be}fr`:$e>Ce?u.style.gridTemplateColumns=`${Ce}fr 8px ${1-Ce}fr`:u.style.gridTemplateColumns=`${$e}fr 8px ${Ue}fr`}}function pe(){var P,u;k=!1,D=!1,(P=document.getElementById("v-resizer"))==null||P.classList.remove("active"),(u=document.getElementById("v-resizer-bottom"))==null||u.classList.remove("active"),document.removeEventListener("mousemove",Q),document.removeEventListener("mouseup",pe),me()}function z(P){var le;ye=!0,O=P.clientY;const u=document.querySelector(".grid-layout");ue=getComputedStyle(u).gridTemplateRows,(le=document.getElementById("h-resizer"))==null||le.classList.add("active"),document.addEventListener("mousemove",T),document.addEventListener("mouseup",ae),P.preventDefault()}function T(P){if(!ye)return;const u=document.querySelector(".grid-layout"),le=P.clientY-O,J=ue.split(" ");if(J.length>=3){const Se=parseFloat(J[0]),Ve=parseFloat(J[2]),_e=Se+Ve,$e=(Se+le/u.clientHeight*_e)/_e,Ue=1-$e,be=.2,Ce=.8;$e<be?u.style.gridTemplateRows=`${be}fr 8px ${1-be}fr`:$e>Ce?u.style.gridTemplateRows=`${Ce}fr 8px ${1-Ce}fr`:u.style.gridTemplateRows=`${$e}fr 8px ${Ue}fr`}}function ae(){var P;ye=!1,(P=document.getElementById("h-resizer"))==null||P.classList.remove("active"),document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",ae),me()}const X=d(!1),de=d(""),Te=d(!1),Le=d([]);async function De(){if(!h.value){o.warning("当前目录路径为空");return}try{await navigator.clipboard.writeText(h.value),o.success("已复制目录路径")}catch(P){console.error("复制目录路径失败:",P),o.error(`复制失败: ${P.message}`)}}function Pe(){de.value=h.value,X.value=!0,oe()}async function oe(){try{const u=await(await fetch("/api/recent_directories")).json();u.success&&Array.isArray(u.directories)&&(Le.value=u.directories)}catch(P){console.error("获取最近目录失败:",P)}}async function Oe(){if(!de.value){o.warning("目录路径不能为空");return}try{Te.value=!0;const u=await(await fetch("/api/change_directory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:de.value})})).json();u.success?(o.success("已切换工作目录"),h.value=u.directory,X.value=!1,await Me(u.directory),await oe(),p.isGitRepo=u.isGitRepo,await _.loadConfig(!0),u.isGitRepo?(await Promise.all([p.getCurrentBranch(),p.getAllBranches(),p.getUserInfo(),p.getRemoteUrl()]),i.value&&i.value.refreshStatus(),l.value&&l.value.refreshLog()):(o.warning("当前目录不是Git仓库,部分功能将不可用"),p.$reset())):o.error(u.error||"切换目录失败")}catch(P){o.error(`切换目录失败: ${P.message}`)}finally{Te.value=!1}}async function Me(P){try{await fetch("/api/save_recent_directory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:P})})}catch(u){console.error("保存最近目录失败:",u)}}async function at(){try{if(!h.value){o.warning("当前目录路径为空");return}const u=await(await fetch("/api/open_directory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:h.value})})).json();u.success?o.success("已在文件管理器中打开目录"):u.error&&o.error(u.error)}catch(P){console.error("打开目录失败:",P),o.error(`打开目录失败: ${P.message}`)}}async function Ze(){try{const u=await(await fetch("/api/browse_directory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPath:de.value||h.value})})).json();u.success?Ne(u):u.error&&o.error(u.error)}catch(P){console.error("浏览目录失败:",P),o.error(`浏览目录失败: ${P.message}`)}}function Ne(P){!P||!P.items||He.alert(Ge("div",{class:"directory-browser"},[Ge("div",{class:"current-path"},[Ge("span",{class:"path-label"},"当前路径: "),Ge("span",{class:"path-value"},P.path)]),Ge("div",{class:"directory-list"},[P.parentPath?Ge("div",{class:"directory-item parent-dir",onClick:()=>{Je(P.parentPath)}},[Ge("span",{class:"dir-icon"},Ge("svg",{class:"folder-icon",viewBox:"0 0 24 24",width:"20",height:"20",style:{fill:"#E6A23C"}},[Ge("path",{d:"M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})])),Ge("span",{class:"dir-name"},"返回上级目录")]):null,...P.items.map(u=>Ge("div",{class:"directory-item",onClick:()=>{Je(u.path)}},[Ge("span",{class:"dir-icon"},Ge("svg",{class:"folder-icon",viewBox:"0 0 24 24",width:"20",height:"20",style:{fill:"#409EFF"}},[Ge("path",{d:"M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})])),Ge("span",{class:"dir-name"},u.name)]))])]),"浏览并选择目录",{confirmButtonText:"使用当前目录",customClass:"directory-browser-dialog",callback:u=>{u==="confirm"&&(de.value=P.path)}})}async function Je(P){try{He.close(),setTimeout(async()=>{try{const le=await(await fetch("/api/browse_directory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPath:P})})).json();le.success?Ne(le):le.error&&o.error(le.error)}catch(u){console.error("浏览目录失败:",u),o.error(`浏览目录失败: ${u.message}`)}},100)}catch(u){console.error("处理目录选择时出错:",u),o.error(`处理目录选择时出错: ${u.message}`)}}return(P,u)=>{const le=st,J=he,Se=bs,Ve=Gt,_e=Ts,$e=Dt,Ue=Ot,be=Ss,Ce=Vt,We=ts,Ie=Lt;return v(),S(Fe,null,[e("header",Ki,[e("div",Qi,[e("img",{src:n(Yi),alt:"Zen GitSync Logo",class:"logo"},null,8,Xi),u[14]||(u[14]=e("h1",null,"Zen GitSync",-1))]),e("div",Zi,[n(p).userName&&n(p).userEmail?(v(),S("div",er,[e("span",tr,A(n(p).userName),1),e("span",sr,"<"+A(n(p).userEmail)+">",1),t(J,{type:"primary",size:"small",onClick:j,class:"user-settings-btn",circle:""},{default:s(()=>[t(le,null,{default:s(()=>[t(n(ds))]),_:1})]),_:1})])):(v(),S("div",or,[u[15]||(u[15]=e("span",{class:"user-label"},"用户: ",-1)),u[16]||(u[16]=e("span",{class:"user-warning"},"未配置",-1)),t(J,{type:"primary",size:"small",onClick:j,class:"user-settings-btn",circle:""},{default:s(()=>[t(le,null,{default:s(()=>[t(n(ds))]),_:1})]),_:1})])),e("div",ar,[e("div",lr,[e("div",nr,[t(le,null,{default:s(()=>[t(n(fs))]),_:1})]),e("div",{class:"directory-path",title:h.value},A(h.value),9,ir)]),e("div",rr,[t(J,{type:"primary",size:"small",onClick:Pe,class:"dir-button",circle:"",title:"切换目录"},{default:s(()=>[t(le,null,{default:s(()=>u[17]||(u[17]=[e("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},[e("path",{fill:"currentColor",d:"M128 192v640h768V320H485.76L357.504 192H128zm-32-64h287.872l128.384 128H928a32 32 0 0 1 32 32v576a32 32 0 0 1-32 32H96a32 32 0 0 1-32-32V160a32 32 0 0 1 32-32z"})],-1)])),_:1})]),_:1}),t(J,{type:"success",size:"small",onClick:at,class:"dir-button",circle:"",title:"在资源管理器中打开"},{default:s(()=>[t(le,null,{default:s(()=>u[18]||(u[18]=[e("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},[e("path",{fill:"currentColor",d:"M928 444H820V330.4c0-17.7-14.3-32-32-32H473L355.7 186.2a8.15 8.15 0 0 0-5.5-2.2H96c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h698c13 0 24.8-7.9 29.7-20l134-332c1.5-3.8 2.3-7.9 2.3-12 0-17.7-14.3-32-32-32zM136 256h188.5l119.6 114.4H748V444H238c-13 0-24.8 7.9-29.7 20L136 643.2V256zm635.3 512H159l103.3-256h612.4L771.3 768z"})],-1)])),_:1})]),_:1}),t(J,{type:"info",size:"small",onClick:De,class:"dir-button",circle:"",title:"复制路径"},{default:s(()=>[t(le,null,{default:s(()=>u[19]||(u[19]=[e("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},[e("path",{fill:"currentColor",d:"M768 832a128 128 0 0 1-128 128H192A128 128 0 0 1 64 832V384a128 128 0 0 1 128-128v64a64 64 0 0 0-64 64v448a64 64 0 0 0 64 64h448a64 64 0 0 0 64-64h64z"}),e("path",{fill:"currentColor",d:"M384 128a64 64 0 0 0-64 64v448a64 64 0 0 0 64 64h448a64 64 0 0 0 64-64V192a64 64 0 0 0-64-64H384zm0-64h448a128 128 0 0 1 128 128v448a128 128 0 0 1-128 128H384a128 128 0 0 1-128-128V192A128 128 0 0 1 384 64z"})],-1)])),_:1})]),_:1})])]),n(p).isGitRepo?(v(),S("div",cr,[t(qi)])):Y("",!0)])]),e("main",ur,[R.value?(v(),S("div",pr,[e("div",mr,[t(Aa,{ref_key:"gitStatusRef",ref:i,"initial-directory":h.value},null,8,["initial-directory"])]),e("div",{class:"vertical-resizer",id:"v-resizer",onMousedown:re},null,32),n(p).isGitRepo?(v(),S("div",vr,[!n(p).userName||!n(p).userEmail?(v(),S("div",gr,[u[25]||(u[25]=e("h2",null,"Git用户未配置",-1)),u[26]||(u[26]=e("p",null,"请先配置Git用户信息才能进行提交操作。",-1)),e("div",hr,[u[23]||(u[23]=e("h3",null,"您可以通过以下方式配置:",-1)),u[24]||(u[24]=e("ol",null,[e("li",null,"点击右上角的设置按钮,配置用户名和邮箱"),e("li",null,"或者使用命令行配置:"),e("div",{class:"code-block"},[x(' git config --global user.name "您的用户名"'),e("br"),x(' git config --global user.email "您的邮箱" ')])],-1)),t(J,{type:"primary",onClick:j},{default:s(()=>u[22]||(u[22]=[x(" 立即配置 ")])),_:1})])])):(v(),Z(En,{key:1}))])):(v(),S("div",yr,u[27]||(u[27]=[e("div",{class:"card",style:{padding:"20px"}},[e("h2",null,"Git仓库初始化"),e("p",null,"当前目录不是Git仓库,请先初始化Git仓库或切换到Git仓库目录。"),e("div",{class:"tips"},[e("h3",null,"可以使用以下命令初始化仓库:"),e("div",{class:"code-block"},"git init")])],-1)]))),e("div",{class:"horizontal-resizer",id:"h-resizer",onMousedown:z},null,32),n(p).isGitRepo?(v(),S("div",_r,[t(Ci,{ref_key:"logListRef",ref:l},null,512)])):Y("",!0),t(Ce,{modelValue:M.value,"onUpdate:modelValue":u[3]||(u[3]=ee=>M.value=ee),title:"创建新分支",width:"30%","destroy-on-close":""},{footer:s(()=>[e("span",wr,[t(J,{onClick:u[2]||(u[2]=ee=>M.value=!1)},{default:s(()=>u[28]||(u[28]=[x("取消")])),_:1}),t(J,{type:"primary",onClick:w,loading:n(p).isCreatingBranch},{default:s(()=>u[29]||(u[29]=[x(" 创建 ")])),_:1},8,["loading"])])]),default:s(()=>[t(be,{model:{newBranchName:H.value,selectedBaseBranch:y.value}},{default:s(()=>[t(_e,{label:"新分支名称"},{default:s(()=>[t(Ve,{modelValue:H.value,"onUpdate:modelValue":u[0]||(u[0]=ee=>H.value=ee),placeholder:"请输入新分支名称"},null,8,["modelValue"])]),_:1}),t(_e,{label:"基于分支"},{default:s(()=>[t(Ue,{modelValue:y.value,"onUpdate:modelValue":u[1]||(u[1]=ee=>y.value=ee),placeholder:"选择基础分支",style:{width:"100%"}},{default:s(()=>[(v(!0),S(Fe,null,Ae(n(p).allBranches,ee=>(v(),Z($e,{key:ee,label:ee,value:ee},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue"])])):(v(),S("div",dr,[t(Se,{class:"loading-card"},{default:s(()=>[e("div",fr,[t(le,{class:"is-loading"},{default:s(()=>u[20]||(u[20]=[e("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},[e("path",{fill:"currentColor",d:"M512 64a32 32 0 0 1 32 32v192a32 32 0 0 1-64 0V96a32 32 0 0 1 32-32zm0 640a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V736a32 32 0 0 1 32-32zm448-192a32 32 0 0 1-32 32H736a32 32 0 1 1 0-64h192a32 32 0 0 1 32 32zm-640 0a32 32 0 0 1-32 32H96a32 32 0 0 1 0-64h192a32 32 0 0 1 32 32zM195.2 195.2a32 32 0 0 1 45.248 0L376.32 331.008a32 32 0 0 1-45.248 45.248L195.2 240.448a32 32 0 0 1 0-45.248zm452.544 452.544a32 32 0 0 1 45.248 0L828.8 783.552a32 32 0 0 1-45.248 45.248L647.744 692.992a32 32 0 0 1 0-45.248zM828.8 195.264a32 32 0 0 1 0 45.184L692.992 376.32a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0zm-452.544 452.48a32 32 0 0 1 0 45.248L240.448 828.8a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0z"})],-1)])),_:1})]),u[21]||(u[21]=e("div",{class:"loading-text"},"加载中...",-1))]),_:1})]))]),e("footer",kr,[n(p).currentBranch?(v(),S("div",$r,[e("div",br,[u[31]||(u[31]=e("span",{class:"branch-label"},"当前分支:",-1)),t(Ue,{modelValue:n(p).currentBranch,"onUpdate:modelValue":u[4]||(u[4]=ee=>n(p).currentBranch=ee),size:"small",onChange:I,loading:n(p).isChangingBranch,class:"branch-select"},{default:s(()=>[(v(!0),S(Fe,null,Ae(n(p).allBranches,ee=>(v(),Z($e,{key:ee,label:ee,value:ee},null,8,["label","value"]))),128))]),_:1},8,["modelValue","loading"]),t(J,{type:"primary",size:"small",onClick:E,class:"create-branch-btn"},{default:s(()=>[t(le,null,{default:s(()=>[t(n(Vo))]),_:1}),u[30]||(u[30]=x(" 新建分支 "))]),_:1})])])):Y("",!0),n(p).remoteUrl?(v(),S("div",Cr,[u[33]||(u[33]=e("span",{class:"repo-url-label"},"远程仓库:",-1)),e("span",Sr,A(n(p).remoteUrl),1),t(J,{type:"primary",circle:"",size:"small",onClick:u[5]||(u[5]=ee=>n(p).copyRemoteUrl()),class:"copy-url-btn",title:"复制仓库地址"},{default:s(()=>[t(le,null,{default:s(()=>u[32]||(u[32]=[e("svg",{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},[e("path",{fill:"currentColor",d:"M768 832a128 128 0 0 1-128 128H192A128 128 0 0 1 64 832V384a128 128 0 0 1 128-128v64a64 64 0 0 0-64 64v448a64 64 0 0 0 64 64h448a64 64 0 0 0 64-64h64z"}),e("path",{fill:"currentColor",d:"M384 128a64 64 0 0 0-64 64v448a64 64 0 0 0 64 64h448a64 64 0 0 0 64-64V192a64 64 0 0 0-64-64H384zm0-64h448a128 128 0 0 1 128 128v448a128 128 0 0 1-128 128H384a128 128 0 0 1-128-128V192A128 128 0 0 1 384 64z"})],-1)])),_:1})]),_:1})])):Y("",!0)]),t(Ce,{modelValue:se.value,"onUpdate:modelValue":u[9]||(u[9]=ee=>se.value=ee),title:"Git用户设置",width:"30%","destroy-on-close":""},{footer:s(()=>[e("span",Tr,[t(J,{type:"danger",onClick:ne},{default:s(()=>u[35]||(u[35]=[x(" 清除配置 ")])),_:1}),t(J,{onClick:u[8]||(u[8]=ee=>se.value=!1)},{default:s(()=>u[36]||(u[36]=[x("取消")])),_:1}),t(J,{type:"primary",onClick:ce},{default:s(()=>u[37]||(u[37]=[x(" 保存 ")])),_:1})])]),default:s(()=>[t(be,null,{default:s(()=>[t(_e,{label:"用户名"},{default:s(()=>[t(Ve,{modelValue:B.value,"onUpdate:modelValue":u[6]||(u[6]=ee=>B.value=ee),placeholder:"请输入Git用户名"},null,8,["modelValue"])]),_:1}),t(_e,{label:"邮箱"},{default:s(()=>[t(Ve,{modelValue:C.value,"onUpdate:modelValue":u[7]||(u[7]=ee=>C.value=ee),placeholder:"请输入Git邮箱"},null,8,["modelValue"])]),_:1}),t(_e,null,{default:s(()=>[t(We,{type:"info",closable:!1,"show-icon":""},{default:s(()=>u[34]||(u[34]=[x(" 这些设置将影响全局Git配置,对所有Git仓库生效。 ")])),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),t(Ce,{modelValue:X.value,"onUpdate:modelValue":u[13]||(u[13]=ee=>X.value=ee),title:"切换工作目录",width:"50%","destroy-on-close":""},{footer:s(()=>[e("span",Lr,[t(J,{onClick:u[11]||(u[11]=ee=>X.value=!1)},{default:s(()=>u[39]||(u[39]=[x("取消")])),_:1}),t(J,{type:"primary",onClick:u[12]||(u[12]=ee=>Oe()),loading:Te.value},{default:s(()=>u[40]||(u[40]=[x(" 切换 ")])),_:1},8,["loading"])])]),default:s(()=>[t(be,null,{default:s(()=>[t(_e,{label:"目录路径"},{default:s(()=>[e("div",Fr,[t(Ve,{modelValue:de.value,"onUpdate:modelValue":u[10]||(u[10]=ee=>de.value=ee),placeholder:"请输入目录路径"},null,8,["modelValue"]),t(J,{type:"primary",onClick:Ze},{default:s(()=>[t(le,null,{default:s(()=>[t(n(fs))]),_:1}),u[38]||(u[38]=x(" 浏览 "))]),_:1})])]),_:1}),Le.value.length>0?(v(),Z(_e,{key:0,label:"常用目录"},{default:s(()=>[e("div",Vr,[(v(!0),S(Fe,null,Ae(Le.value,(ee,lt)=>(v(),Z(Ie,{key:lt,class:"recent-dir-tag",onClick:nt=>de.value=ee,effect:"plain"},{default:s(()=>[x(A(ee),1)]),_:2},1032,["onClick"]))),128))])]),_:1})):Y("",!0)]),_:1})]),_:1},8,["modelValue"])],64)}}}),Br=Be(xr,[["__scopeId","data-v-882efda6"]]),zs=Lo(Br);zs.use(xo());zs.mount("#app");