zen-gitsync 2.2.6 → 2.2.7

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.6",
3
+ "version": "2.2.7",
4
4
  "description": "一个 git 自动查看差异并提交的工具",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,4 +1,4 @@
1
- import{d as Ts,r as c,o as $t,a as Vs,E as o,l as fa,c as de,b as pt,w as Ye,e as $,f,n as dt,g as A,h as e,t as B,i as t,u as l,j as pa,k as a,m as Y,p as Mt,F as be,q as Be,s as ge,v as bt,x as rs,y as Ht,z as ma,A as ks,B as Ge,C as w,D as Jt,G as Xe,H as xs,I as is,J as Ls,K as zs,L as Bs,M as ft,N as nt,O as va,P as cs,Q as Dt,R as Fs,S as _t,T as $s,U as ga,V as Pt,W as Me,X as qe,Y as wt,Z as us,_ as xt,$ as ha,a0 as bs,a1 as ds,a2 as ya,a3 as as,a4 as ls,a5 as It,a6 as Nt,a7 as fs,a8 as Ds,a9 as _a,aa as wa,ab as Rs,ac as ka,ad as js,ae as Gs,af as $a,ag as ba,ah as Ca,ai as Os,aj as zt,ak as ut,al as Sa,am as Ta,an as Va,ao as xa,ap as La,aq as za,ar as Ba,as as Fa,at as Da,au as Ra,av as ja,aw as Bt,ax as Ga,ay as Oa,az as Ua,aA as Cs,aB as Ss,aC as Aa,aD as Ae,aE as Pa,aF as Ea}from"./vendor-BHXhVXkb.js";(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const y of document.querySelectorAll('link[rel="modulepreload"]'))p(y);new MutationObserver(y=>{for(const G of y)if(G.type==="childList")for(const R of G.addedNodes)R.tagName==="LINK"&&R.rel==="modulepreload"&&p(R)}).observe(document,{childList:!0,subtree:!0});function m(y){const G={};return y.integrity&&(G.integrity=y.integrity),y.referrerPolicy&&(G.referrerPolicy=y.referrerPolicy),y.crossOrigin==="use-credentials"?G.credentials="include":y.crossOrigin==="anonymous"?G.credentials="omit":G.credentials="same-origin",G}function p(y){if(y.ep)return;y.ep=!0;const G=m(y);fetch(y.href,G)}})();const os=800;function Ma(){const te="3001";return console.log(`从环境变量读取后端端口: ${te}`),parseInt(te,10)}const Ia=Ma(),kt=Ts("git",()=>{const te=c(""),i=c([]),m=c(""),p=c(""),y=c(!1),G=c(!1),R=c(!1),P=c(0),E=c(""),M=c(!1),U=c(!1),I=c(!1),ie=c(!1),O=c(!1),ne=c(0),ue=c(0),ce=c(!1),S=c(""),D=c(0),F=c(0),X=c(!0),j=c(null),Z=c(""),he=c(""),fe=c([]),V=c({staged:[],unstaged:[],untracked:[]}),T=c([]),se=c(!1),K=c(!1),Q=c(!1),le=c(!1),ye=c(!1),Te=c([]),h=c(!1),g=c(!1),ae=c(!1),W=c(!1);function oe(){te.value="",i.value=[],m.value="",p.value="",y.value=!1,G.value=!1,R.value=!1,P.value=0,ne.value=0,ue.value=0,ce.value=!1,S.value="",D.value=0,F.value=0,U.value=!1,I.value=!1,ie.value=!1,O.value=!1,E.value="",M.value=!1,fe.value=[],V.value={staged:[],unstaged:[],untracked:[]},T.value=[],se.value=!1,K.value=!1,Q.value=!1,le.value=!1,ye.value=!1}async function ee(u=!1,d=!1){if(!R.value)return;const z=Date.now();if(!u&&!d&&z-D.value<3e4){console.log("使用缓存的分支状态");return}try{console.log("获取分支状态...");let C="/api/branch-status";const ve=[];u&&ve.push("force=true"),d&&ve.push("countOnly=true"),ve.length>0&&(C+="?"+ve.join("&"));const Je=await(await fetch(C)).json();Je&&(ne.value=Je.ahead||0,ue.value=Je.behind||0,ce.value=Je.hasUpstream||!1,S.value=Je.upstreamBranch||"",D.value=z,console.log(`分支状态更新:领先 ${ne.value} 个提交,落后 ${ue.value} 个提交,上游分支:${ce.value?S.value:"无"}`))}catch(C){console.error("获取分支状态失败:",C),ne.value=0,ue.value=0,ce.value=!1,S.value=""}}async function Ce(){const u=Date.now();if(u-P.value<1e3)return console.log("使用缓存的Git仓库状态:",R.value?"是":"不是"),R.value;try{const z=await(await fetch("/api/current_directory")).json();return R.value=z.isGitRepo===!0,P.value=u,console.log(`当前目录${R.value?"是":"不是"}Git仓库`),R.value}catch(d){return console.error("检查Git仓库状态失败:",d),R.value=!1,P.value=u,!1}}async function Fe(u=!1){try{const C=await(await fetch(u?"/api/branch?force=true":"/api/branch")).json();C.branch&&(te.value=C.branch,console.log(`当前分支更新为: ${C.branch}${u?" (强制刷新)":""}`))}catch(d){console.error("获取分支信息失败:",d)}}async function De(){if(R.value)try{console.log("获取所有分支...");const d=await(await fetch("/api/branches")).json();d.branches&&Array.isArray(d.branches)&&(i.value=d.branches,F.value=Date.now(),console.log(`获取到${d.branches.length}个分支`))}catch(u){console.error("获取所有分支信息失败:",u)}}async function _(u){console.log("切换到分支:",u);try{y.value=!0;const z=await(await fetch("/api/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:u})})).json();return z.success?(o({message:`已切换到分支: ${u}`,type:"success"}),await Fe(!0),await ee(!0),!0):(o({message:`切换分支失败: ${z.error}`,type:"error"}),!1)}catch(d){return o({message:`切换分支失败: ${d.message}`,type:"error"}),!1}finally{y.value=!1}}async function pe(){try{const d=await(await fetch("/api/user-info")).json();d.name&&d.email&&(m.value=d.name,p.value=d.email)}catch(u){console.error("获取用户信息失败:",u)}}async function Se(u,d){if(!u.trim())return o({message:"分支名称不能为空",type:"warning"}),!1;try{G.value=!0;const C=await(await fetch("/api/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newBranchName:u,baseBranch:d||te.value})})).json();return C.success?(o({message:`已创建并切换到分支: ${u}`,type:"success"}),await Fe(!0),await ee(!0),await De(),!0):(o({message:`创建分支失败: ${C.error}`,type:"error"}),!1)}catch(z){return o({message:`创建分支失败: ${z.message}`,type:"error"}),!1}finally{G.value=!1}}async function Le(){try{const d=await(await fetch("/api/clear-user-config",{method:"POST"})).json();return d.success?(m.value="",p.value="",o({message:"已清除Git用户配置",type:"success"}),!0):(o({message:`清除配置失败: ${d.error}`,type:"error"}),!1)}catch(u){return o({message:`清除配置失败: ${u.message}`,type:"error"}),!1}}async function ze(u,d){try{const C=await(await fetch("/api/restore-user-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:u,email:d})})).json();return C.success?(m.value=u,p.value=d,o({message:"已恢复Git用户配置",type:"success"}),!0):(o({message:`恢复配置失败: ${C.error}`,type:"error"}),!1)}catch(z){return o({message:`恢复配置失败: ${z.message}`,type:"error"}),!1}}async function Ke(){if(!R.value)return o({message:"当前目录不是Git仓库",type:"warning"}),!1;try{I.value=!0;const d=await(await fetch("/api/pull",{method:"POST"})).json();return d.success?(o({message:"拉取成功",type:"success"}),await ee(),!0):(d.needsMerge?o({message:`需要合并更改: ${d.pullOutput||"存在冲突需要手动解决"}`,type:"warning",duration:5e3}):o({message:`拉取失败: ${d.error}`,type:"error"}),!1)}catch(u){return o({message:`拉取失败: ${u.message}`,type:"error"}),!1}finally{I.value=!1}}async function Ze(){if(!R.value)return o({message:"当前目录不是Git仓库",type:"warning"}),!1;try{ie.value=!0;const d=await(await fetch("/api/fetch-all",{method:"POST"})).json();return d.success?(o({message:"获取所有远程分支信息成功",type:"success"}),await ee(),!0):(o({message:`获取远程分支信息失败: ${d.error}`,type:"error"}),!1)}catch(u){return o({message:`获取远程分支信息失败: ${u.message}`,type:"error"}),!1}finally{ie.value=!1}}function Pe(){j.value&&j.value.disconnect();try{const u=`http://localhost:${Ia}`;if(console.log("尝试连接Socket.IO服务器:",u),j.value=fa(u,{reconnectionDelayMax:1e4,reconnection:!0,reconnectionAttempts:10,reconnectionDelay:1e3,timeout:2e4,autoConnect:!0,forceNew:!0,transports:["websocket","polling"]}),!j.value){console.error("Socket.IO初始化失败: socket为null");return}console.log("Socket.IO初始化成功,socket ID:",j.value.id||"未连接"),j.value.on("connect",()=>{console.log("成功连接到Socket.IO服务器"),X.value&&j.value&&j.value.emit("start_monitoring")}),j.value.on("project_info",d=>{Z.value=d.projectPath,he.value=d.projectRoomId,console.log(`当前项目: ${d.projectPath}`),console.log(`房间ID: ${d.projectRoomId}`)}),j.value.on("project_changed",d=>{console.log(`项目已切换: ${d.oldProjectPath} -> ${d.newProjectPath}`),Z.value=d.newProjectPath,he.value=d.newProjectRoomId,j.value&&j.value.emit("join_room",d.newProjectRoomId),console.log(`已加入新项目房间: ${d.newProjectRoomId}`)}),j.value.on("disconnect",d=>{console.log("与Socket.IO服务器断开连接:",d)}),j.value.on("git_status_update",d=>{if(X.value){if(d.projectPath&&Z.value&&d.projectPath!==Z.value){console.log(`忽略不同项目的状态更新: ${d.projectPath}`);return}console.log("收到Git状态更新通知:",new Date().toLocaleTimeString()),d.porcelain!==void 0&&L(d.porcelain)}}),j.value.on("monitoring_status",d=>{console.log("文件监控状态:",d.active?"已启动":"已停止")}),j.value.on("connect_error",d=>{console.error("Socket连接错误:",d.message)}),j.value.on("connect_timeout",()=>{console.error("Socket连接超时")}),j.value.on("reconnect",d=>{var z;console.log(`Socket重连成功,尝试次数: ${d}`),X.value&&(console.log("重连后重新发送start_monitoring请求"),(z=j.value)==null||z.emit("start_monitoring"))}),j.value.on("reconnect_attempt",d=>{console.log(`Socket尝试重连,第 ${d} 次尝试`)}),j.value.on("reconnect_error",d=>{console.error("Socket重连错误:",d.message)}),j.value.on("reconnect_failed",()=>{console.error("Socket重连失败,已达到最大重试次数")}),j.value&&!j.value.connected&&(console.log("Socket未连接,尝试手动连接..."),j.value.connect())}catch(u){console.error("Socket.IO连接初始化失败:",u)}}function Qe(){if(console.log("toggleAutoUpdate调用,当前值:",X.value),!j.value){console.error("无法切换自动更新状态: socket连接不存在"),o.error("无法连接到服务器,自动更新可能不会生效"),console.log("尝试重新建立socket连接..."),Pe(),localStorage.setItem("zen-gitsync-auto-update",X.value.toString());return}try{X.value?(console.log("发送start_monitoring命令..."),j.value.emit("start_monitoring"),o.success("自动更新已启用")):(console.log("发送stop_monitoring命令..."),j.value.emit("stop_monitoring"),o.info("自动更新已禁用")),localStorage.setItem("zen-gitsync-auto-update",X.value.toString()),console.log("已保存自动更新设置到本地存储:",X.value)}catch(u){console.error("切换自动更新状态时出错:",u),o.error(`切换自动更新失败: ${u.message}`)}}function L(u){if(u===void 0||u===""){T.value=[];return}const d=u.split(`
1
+ import{d as Ts,r as c,o as $t,a as Vs,E as o,l as fa,c as de,b as pt,w as Ye,e as $,f,n as dt,g as A,h as e,t as B,i as t,u as l,j as pa,k as a,m as Y,p as Mt,F as be,q as Be,s as ge,v as bt,x as rs,y as Ht,z as ma,A as ks,B as Ge,C as w,D as Jt,G as Xe,H as xs,I as is,J as Ls,K as zs,L as Bs,M as ft,N as nt,O as va,P as cs,Q as Dt,R as Fs,S as _t,T as $s,U as ga,V as Pt,W as Me,X as qe,Y as wt,Z as us,_ as xt,$ as ha,a0 as bs,a1 as ds,a2 as ya,a3 as as,a4 as ls,a5 as It,a6 as Nt,a7 as fs,a8 as Ds,a9 as _a,aa as wa,ab as Rs,ac as ka,ad as js,ae as Gs,af as $a,ag as ba,ah as Ca,ai as Os,aj as zt,ak as ut,al as Sa,am as Ta,an as Va,ao as xa,ap as La,aq as za,ar as Ba,as as Fa,at as Da,au as Ra,av as ja,aw as Bt,ax as Ga,ay as Oa,az as Ua,aA as Cs,aB as Ss,aC as Aa,aD as Ae,aE as Pa,aF as Ea}from"./vendor-BHXhVXkb.js";(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const y of document.querySelectorAll('link[rel="modulepreload"]'))p(y);new MutationObserver(y=>{for(const G of y)if(G.type==="childList")for(const R of G.addedNodes)R.tagName==="LINK"&&R.rel==="modulepreload"&&p(R)}).observe(document,{childList:!0,subtree:!0});function m(y){const G={};return y.integrity&&(G.integrity=y.integrity),y.referrerPolicy&&(G.referrerPolicy=y.referrerPolicy),y.crossOrigin==="use-credentials"?G.credentials="include":y.crossOrigin==="anonymous"?G.credentials="omit":G.credentials="same-origin",G}function p(y){if(y.ep)return;y.ep=!0;const G=m(y);fetch(y.href,G)}})();const os=800;function Ma(){const te="3002";return console.log(`从环境变量读取后端端口: ${te}`),parseInt(te,10)}const Ia=Ma(),kt=Ts("git",()=>{const te=c(""),i=c([]),m=c(""),p=c(""),y=c(!1),G=c(!1),R=c(!1),P=c(0),E=c(""),M=c(!1),U=c(!1),I=c(!1),ie=c(!1),O=c(!1),ne=c(0),ue=c(0),ce=c(!1),S=c(""),D=c(0),F=c(0),X=c(!0),j=c(null),Z=c(""),he=c(""),fe=c([]),V=c({staged:[],unstaged:[],untracked:[]}),T=c([]),se=c(!1),K=c(!1),Q=c(!1),le=c(!1),ye=c(!1),Te=c([]),h=c(!1),g=c(!1),ae=c(!1),W=c(!1);function oe(){te.value="",i.value=[],m.value="",p.value="",y.value=!1,G.value=!1,R.value=!1,P.value=0,ne.value=0,ue.value=0,ce.value=!1,S.value="",D.value=0,F.value=0,U.value=!1,I.value=!1,ie.value=!1,O.value=!1,E.value="",M.value=!1,fe.value=[],V.value={staged:[],unstaged:[],untracked:[]},T.value=[],se.value=!1,K.value=!1,Q.value=!1,le.value=!1,ye.value=!1}async function ee(u=!1,d=!1){if(!R.value)return;const z=Date.now();if(!u&&!d&&z-D.value<3e4){console.log("使用缓存的分支状态");return}try{console.log("获取分支状态...");let C="/api/branch-status";const ve=[];u&&ve.push("force=true"),d&&ve.push("countOnly=true"),ve.length>0&&(C+="?"+ve.join("&"));const Je=await(await fetch(C)).json();Je&&(ne.value=Je.ahead||0,ue.value=Je.behind||0,ce.value=Je.hasUpstream||!1,S.value=Je.upstreamBranch||"",D.value=z,console.log(`分支状态更新:领先 ${ne.value} 个提交,落后 ${ue.value} 个提交,上游分支:${ce.value?S.value:"无"}`))}catch(C){console.error("获取分支状态失败:",C),ne.value=0,ue.value=0,ce.value=!1,S.value=""}}async function Ce(){const u=Date.now();if(u-P.value<1e3)return console.log("使用缓存的Git仓库状态:",R.value?"是":"不是"),R.value;try{const z=await(await fetch("/api/current_directory")).json();return R.value=z.isGitRepo===!0,P.value=u,console.log(`当前目录${R.value?"是":"不是"}Git仓库`),R.value}catch(d){return console.error("检查Git仓库状态失败:",d),R.value=!1,P.value=u,!1}}async function Fe(u=!1){try{const C=await(await fetch(u?"/api/branch?force=true":"/api/branch")).json();C.branch&&(te.value=C.branch,console.log(`当前分支更新为: ${C.branch}${u?" (强制刷新)":""}`))}catch(d){console.error("获取分支信息失败:",d)}}async function De(){if(R.value)try{console.log("获取所有分支...");const d=await(await fetch("/api/branches")).json();d.branches&&Array.isArray(d.branches)&&(i.value=d.branches,F.value=Date.now(),console.log(`获取到${d.branches.length}个分支`))}catch(u){console.error("获取所有分支信息失败:",u)}}async function _(u){console.log("切换到分支:",u);try{y.value=!0;const z=await(await fetch("/api/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:u})})).json();return z.success?(o({message:`已切换到分支: ${u}`,type:"success"}),await Fe(!0),await ee(!0),!0):(o({message:`切换分支失败: ${z.error}`,type:"error"}),!1)}catch(d){return o({message:`切换分支失败: ${d.message}`,type:"error"}),!1}finally{y.value=!1}}async function pe(){try{const d=await(await fetch("/api/user-info")).json();d.name&&d.email&&(m.value=d.name,p.value=d.email)}catch(u){console.error("获取用户信息失败:",u)}}async function Se(u,d){if(!u.trim())return o({message:"分支名称不能为空",type:"warning"}),!1;try{G.value=!0;const C=await(await fetch("/api/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newBranchName:u,baseBranch:d||te.value})})).json();return C.success?(o({message:`已创建并切换到分支: ${u}`,type:"success"}),await Fe(!0),await ee(!0),await De(),!0):(o({message:`创建分支失败: ${C.error}`,type:"error"}),!1)}catch(z){return o({message:`创建分支失败: ${z.message}`,type:"error"}),!1}finally{G.value=!1}}async function Le(){try{const d=await(await fetch("/api/clear-user-config",{method:"POST"})).json();return d.success?(m.value="",p.value="",o({message:"已清除Git用户配置",type:"success"}),!0):(o({message:`清除配置失败: ${d.error}`,type:"error"}),!1)}catch(u){return o({message:`清除配置失败: ${u.message}`,type:"error"}),!1}}async function ze(u,d){try{const C=await(await fetch("/api/restore-user-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:u,email:d})})).json();return C.success?(m.value=u,p.value=d,o({message:"已恢复Git用户配置",type:"success"}),!0):(o({message:`恢复配置失败: ${C.error}`,type:"error"}),!1)}catch(z){return o({message:`恢复配置失败: ${z.message}`,type:"error"}),!1}}async function Ke(){if(!R.value)return o({message:"当前目录不是Git仓库",type:"warning"}),!1;try{I.value=!0;const d=await(await fetch("/api/pull",{method:"POST"})).json();return d.success?(o({message:"拉取成功",type:"success"}),await ee(),!0):(d.needsMerge?o({message:`需要合并更改: ${d.pullOutput||"存在冲突需要手动解决"}`,type:"warning",duration:5e3}):o({message:`拉取失败: ${d.error}`,type:"error"}),!1)}catch(u){return o({message:`拉取失败: ${u.message}`,type:"error"}),!1}finally{I.value=!1}}async function Ze(){if(!R.value)return o({message:"当前目录不是Git仓库",type:"warning"}),!1;try{ie.value=!0;const d=await(await fetch("/api/fetch-all",{method:"POST"})).json();return d.success?(o({message:"获取所有远程分支信息成功",type:"success"}),await ee(),!0):(o({message:`获取远程分支信息失败: ${d.error}`,type:"error"}),!1)}catch(u){return o({message:`获取远程分支信息失败: ${u.message}`,type:"error"}),!1}finally{ie.value=!1}}function Pe(){j.value&&j.value.disconnect();try{const u=`http://localhost:${Ia}`;if(console.log("尝试连接Socket.IO服务器:",u),j.value=fa(u,{reconnectionDelayMax:1e4,reconnection:!0,reconnectionAttempts:10,reconnectionDelay:1e3,timeout:2e4,autoConnect:!0,forceNew:!0,transports:["websocket","polling"]}),!j.value){console.error("Socket.IO初始化失败: socket为null");return}console.log("Socket.IO初始化成功,socket ID:",j.value.id||"未连接"),j.value.on("connect",()=>{console.log("成功连接到Socket.IO服务器"),X.value&&j.value&&j.value.emit("start_monitoring")}),j.value.on("project_info",d=>{Z.value=d.projectPath,he.value=d.projectRoomId,console.log(`当前项目: ${d.projectPath}`),console.log(`房间ID: ${d.projectRoomId}`)}),j.value.on("project_changed",d=>{console.log(`项目已切换: ${d.oldProjectPath} -> ${d.newProjectPath}`),Z.value=d.newProjectPath,he.value=d.newProjectRoomId,j.value&&j.value.emit("join_room",d.newProjectRoomId),console.log(`已加入新项目房间: ${d.newProjectRoomId}`)}),j.value.on("disconnect",d=>{console.log("与Socket.IO服务器断开连接:",d)}),j.value.on("git_status_update",d=>{if(X.value){if(d.projectPath&&Z.value&&d.projectPath!==Z.value){console.log(`忽略不同项目的状态更新: ${d.projectPath}`);return}console.log("收到Git状态更新通知:",new Date().toLocaleTimeString()),d.porcelain!==void 0&&L(d.porcelain)}}),j.value.on("monitoring_status",d=>{console.log("文件监控状态:",d.active?"已启动":"已停止")}),j.value.on("connect_error",d=>{console.error("Socket连接错误:",d.message)}),j.value.on("connect_timeout",()=>{console.error("Socket连接超时")}),j.value.on("reconnect",d=>{var z;console.log(`Socket重连成功,尝试次数: ${d}`),X.value&&(console.log("重连后重新发送start_monitoring请求"),(z=j.value)==null||z.emit("start_monitoring"))}),j.value.on("reconnect_attempt",d=>{console.log(`Socket尝试重连,第 ${d} 次尝试`)}),j.value.on("reconnect_error",d=>{console.error("Socket重连错误:",d.message)}),j.value.on("reconnect_failed",()=>{console.error("Socket重连失败,已达到最大重试次数")}),j.value&&!j.value.connected&&(console.log("Socket未连接,尝试手动连接..."),j.value.connect())}catch(u){console.error("Socket.IO连接初始化失败:",u)}}function Qe(){if(console.log("toggleAutoUpdate调用,当前值:",X.value),!j.value){console.error("无法切换自动更新状态: socket连接不存在"),o.error("无法连接到服务器,自动更新可能不会生效"),console.log("尝试重新建立socket连接..."),Pe(),localStorage.setItem("zen-gitsync-auto-update",X.value.toString());return}try{X.value?(console.log("发送start_monitoring命令..."),j.value.emit("start_monitoring"),o.success("自动更新已启用")):(console.log("发送stop_monitoring命令..."),j.value.emit("stop_monitoring"),o.info("自动更新已禁用")),localStorage.setItem("zen-gitsync-auto-update",X.value.toString()),console.log("已保存自动更新设置到本地存储:",X.value)}catch(u){console.error("切换自动更新状态时出错:",u),o.error(`切换自动更新失败: ${u.message}`)}}function L(u){if(u===void 0||u===""){T.value=[];return}const d=u.split(`
2
2
  `),z=[];for(const C of d){const ve=C.match(/^([ MADRCU\?]{2})\s+(.+)$/);if(ve){let Ee="";const Je=ve[1],tt=Je.charAt(0),Rt=Je.charAt(1);tt==="A"||tt==="M"||tt==="D"||tt==="R"?Ee="added":tt===" "&&Rt==="M"?Ee="modified":tt===" "&&Rt==="D"?Ee="deleted":Je==="??"?Ee="untracked":Ee="other",z.push({path:ve[2],type:Ee})}}T.value=z}async function r(u=!0){if(!R.value){console.log("当前目录不是Git仓库,跳过加载提交历史");return}try{se.value=!0,console.log("开始加载提交历史...");const d=new Date().getTime(),C=await(await fetch(`/api/log?page=1&_t=${d}`)).json();C&&C.data&&Array.isArray(C.data)?(fe.value=[...C.data],console.log(`提交历史加载完成,共 ${fe.value.length} 条记录`)):(console.warn("API返回的提交历史格式不正确:",C),fe.value=[])}catch(d){console.error("获取提交历史失败:",d),u&&o({message:`获取提交历史失败: ${d.message}`,type:"error"})}finally{se.value=!1}}async function N(){if(!R.value){console.log("当前目录不是Git仓库,跳过加载Git状态");return}try{K.value=!0,await H()}catch(u){console.error("获取Git状态失败:",u),o({message:`获取Git状态失败: ${u.message}`,type:"error"})}finally{K.value=!1}}async function H(){if(console.log("开始获取Git状态(porcelain格式)..."),!R.value){console.log("当前目录不是Git仓库,跳过加载Git状态");return}try{const d=await(await fetch("/api/status_porcelain")).json();d.status!==void 0?L(d.status):T.value=[]}catch(u){console.error("获取Git状态(porcelain)失败:",u),o({message:`获取Git状态(porcelain)失败: ${u.message}`,type:"error"}),T.value=[]}}async function $e(){if(!R.value)return o.warning("当前目录不是Git仓库"),!1;try{Q.value=!0;const d=await(await fetch("/api/add",{method:"POST"})).json();return d.success?(o({message:"文件已添加到暂存区",type:"success"}),!0):(o({message:`添加文件失败: ${d.error}`,type:"error"}),!1)}catch(u){return o({message:`添加文件失败: ${u.message}`,type:"error"}),!1}finally{Q.value=!1}}async function Re(u){if(!R.value)return o.warning("当前目录不是Git仓库"),!1;try{Q.value=!0;const z=await(await fetch("/api/add-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:u})})).json();return z.success?(o({message:"文件已暂存",type:"success"}),N(),!0):(o({message:`暂存文件失败: ${z.error}`,type:"error"}),!1)}catch(d){return o({message:`暂存文件失败: ${d.message}`,type:"error"}),!1}finally{Q.value=!1}}async function ke(u){if(!R.value)return o.warning("当前目录不是Git仓库"),!1;try{ye.value=!0;const z=await(await fetch("/api/unstage-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:u})})).json();return z.success?(o({message:"已取消暂存文件",type:"success"}),N(),!0):(o({message:`取消暂存失败: ${z.error}`,type:"error"}),!1)}catch(d){return o({message:`取消暂存失败: ${d.message}`,type:"error"}),!1}finally{ye.value=!1}}function _e(u){return new Promise(d=>setTimeout(d,u))}async function je(u,d=!1){if(!R.value)return o.warning("当前目录不是Git仓库"),!1;try{le.value=!0;const C=await(await fetch("/api/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:u,hasNewlines:u.includes(`
3
3
  `),noVerify:d})})).json();return C.success?(o({message:"提交成功",type:"success"}),!0):(o({message:`commitChanges 提交失败: ${C.error}`,type:"error"}),!1)}catch(z){return o({message:`提交失败: ${z.message}`,type:"error"}),!1}finally{le.value=!1}}async function re(){if(!R.value)return o.warning("当前目录不是Git仓库"),!1;try{U.value=!0;const d=await(await fetch("/api/push",{method:"POST"})).json();return d.success?(o({message:"推送成功",type:"success"}),ne.value=0,ue.value=0,await Promise.all([N(),r()]),console.log("推送成功,分支状态已设置为同步 (ahead=0, behind=0)"),!0):(o({message:`推送失败: ${d.error}`,type:"error"}),!1)}catch(u){return o({message:`推送失败: ${u.message}`,type:"error"}),!1}finally{U.value=!1}}async function me(u,d={}){if(!R.value)return o({message:"当前目录不是Git仓库",type:"warning"}),!1;if(!u)return o({message:"请选择要合并的分支",type:"warning"}),!1;if(u===te.value)return o({message:"不能合并当前分支到自身",type:"warning"}),!1;try{O.value=!0;const z=await fetch("/api/merge",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:u,...d})}),C=await z.json();return z.status===409?(o({message:"合并分支时发生冲突,请手动解决",type:"warning",duration:5e3}),!1):C.success?(o({message:`成功合并分支 ${u} 到 ${te.value}`,type:"success"}),await N(),await ee(),!0):(o({message:`合并分支失败: ${C.error}`,type:"error"}),!1)}catch(z){return o({message:`合并分支失败: ${z.message}`,type:"error"}),!1}finally{O.value=!1}}async function Ne(u,d=!1){if(console.log("开始暂存并提交操作..."),!await $e())return!1;console.log("暂存完成,等待Git操作完成..."),await _e(os),console.log("开始提交更改...");const C=await je(u,d);return console.log("暂存并提交操作完成"),C}async function He(u,d=!1){try{if(console.log("开始暂存文件..."),!await $e()||(console.log("暂存完成,等待Git操作完成..."),await _e(os),console.log("开始提交更改..."),!await je(u,d)))return!1;console.log("提交完成,等待Git操作完成..."),await _e(os),console.log("开始推送到远程...");const ve=await re();return console.log("一键推送操作完成,状态已统一刷新"),ve}catch(z){console.error("一键推送操作失败:",z);try{(await(await fetch("/api/remove-lock",{method:"POST"})).json()).success&&o({message:"检测到Git锁定文件冲突,已自动清理,请重试操作",type:"warning"})}catch(C){console.error("清理锁定文件失败:",C)}o({message:`操作失败: ${z.message}`,type:"error"});try{await Promise.all([N(),r(),ee()])}catch(C){console.error("刷新状态失败:",C)}return!1}}async function q(){if(!R.value)return o.warning("当前目录不是Git仓库"),!1;try{ye.value=!0;const d=await(await fetch("/api/reset-head",{method:"POST"})).json();return d.success?(o({message:"已重置暂存区",type:"success"}),N(),!0):(o({message:`重置暂存区失败: ${d.error}`,type:"error"}),!1)}catch(u){return o({message:`重置暂存区失败: ${u.message}`,type:"error"}),!1}finally{ye.value=!1}}async function Oe(u){if(!R.value)return o.warning("当前目录不是Git仓库"),!1;try{ye.value=!0;const z=await(await fetch("/api/reset-to-remote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:u})})).json();return z.success?(o({message:`已重置分支 ${u} 到远程状态`,type:"success"}),N(),r(),!0):(o({message:`重置分支失败: ${z.error}`,type:"error"}),!1)}catch(d){return o({message:`重置分支失败: ${d.message}`,type:"error"}),!1}finally{ye.value=!1}}async function vt(){if(R.value)try{M.value=!0,console.log("获取远程仓库地址...");const d=await(await fetch("/api/remote-url")).json();d.success?(E.value=d.url||"",console.log(`获取到远程仓库地址: ${E.value}`)):(console.warn("获取远程仓库地址失败:",d.error),E.value="")}catch(u){console.error("获取远程仓库地址失败:",u),E.value=""}finally{M.value=!1}}async function Ct(){if(!E.value)return o({message:"没有可复制的远程仓库地址",type:"warning"}),!1;try{return await navigator.clipboard.writeText(E.value),o({message:"已复制远程仓库地址",type:"success"}),!0}catch(u){return console.error("复制远程仓库地址失败:",u),o({message:`复制失败: ${u.message}`,type:"error"}),!1}}$t(()=>{const u=localStorage.getItem("zen-gitsync-auto-update");u!==null&&(X.value=u==="true"),Pe()});function et(){j.value&&(j.value.disconnect(),j.value=null)}Vs(()=>{et()});async function Ue(){if(!R.value)return o.warning("当前目录不是Git仓库"),[];try{h.value=!0;const d=await(await fetch("/api/stash-list")).json();return d.success?(Te.value=d.stashes,d.stashes):(o.error(`获取stash列表失败: ${d.error}`),[])}catch(u){return console.error("获取stash列表失败:",u),o.error(`获取stash列表失败: ${u.message}`),[]}finally{h.value=!1}}async function St(u,d=!1,z=!0){if(!R.value)return o.warning("当前目录不是Git仓库"),!1;try{W.value=!0;const ve=await(await fetch("/api/stash-save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:u,includeUntracked:d,excludeLocked:z})})).json();return ve.success?(o.success(ve.message),await Ue(),await N(),!0):(o.warning(ve.message),!1)}catch(C){return console.error("保存stash失败:",C),o.error(`保存stash失败: ${C.message}`),!1}finally{W.value=!1}}async function k(u,d=!1){if(!R.value)return o.warning("当前目录不是Git仓库"),!1;try{g.value=!0;const z=await fetch("/api/stash-apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stashId:u,pop:d})}),C=await z.json();return z.status===409?(o.warning("应用stash时发生冲突,请手动解决"),!1):C.success?(o.success(C.message),await Ue(),await N(),!0):(o.error(`应用stash失败: ${C.error}`),!1)}catch(z){return console.error("应用stash失败:",z),o.error(`应用stash失败: ${z.message}`),!1}finally{g.value=!1}}async function v(u){if(!R.value)return o.warning("当前目录不是Git仓库"),!1;try{ae.value=!0;const z=await(await fetch("/api/stash-drop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stashId:u})})).json();return z.success?(o.success(z.message),await Ue(),!0):(o.error(`删除stash失败: ${z.error}`),!1)}catch(d){return console.error("删除stash失败:",d),o.error(`删除stash失败: ${d.message}`),!1}finally{ae.value=!1}}async function J(){if(!R.value)return o.warning("当前目录不是Git仓库"),!1;try{ae.value=!0;const d=await(await fetch("/api/stash-clear",{method:"POST"})).json();return d.success?(o.success(d.message),Te.value=[],!0):(o.error(`清空stash失败: ${d.error}`),!1)}catch(u){return console.error("清空stash失败:",u),o.error(`清空stash失败: ${u.message}`),!1}finally{ae.value=!1}}return{currentBranch:te,allBranches:i,userName:m,userEmail:p,isChangingBranch:y,isCreatingBranch:G,isGitRepo:R,lastCheckedTime:P,branchAhead:ne,branchBehind:ue,hasUpstream:ce,upstreamBranch:S,lastBranchStatusTime:D,lastBranchesTime:F,remoteUrl:E,isLoadingRemoteUrl:M,stashes:Te,isLoadingStashes:h,isApplyingStash:g,isDroppingStash:ae,isSavingStash:W,log:fe,status:V,fileList:T,isLoadingLog:se,isLoadingStatus:K,isAddingFiles:Q,isCommiting:le,isResetting:ye,autoUpdateEnabled:X,isPushing:U,isGitPulling:I,isGitFetching:ie,isGitMerging:O,$reset:oe,checkGitRepo:Ce,getCurrentBranch:Fe,getAllBranches:De,changeBranch:_,getUserInfo:pe,createBranch:Se,clearUserConfig:Le,restoreUserConfig:ze,getBranchStatus:ee,gitPull:Ke,gitFetchAll:Ze,initSocketConnection:Pe,toggleAutoUpdate:Qe,parseStatusPorcelain:L,fetchLog:r,fetchStatus:N,fetchStatusPorcelain:H,addToStage:$e,addFileToStage:Re,unstageFile:ke,commitChanges:je,pushToRemote:re,addAndCommit:Ne,addCommitAndPush:He,resetHead:q,resetToRemote:Oe,getRemoteUrl:vt,copyRemoteUrl:Ct,mergeBranch:me,getStashList:Ue,saveStash:St,applyStash:k,dropStash:v,clearAllStashes:J,socket:j,disconnectSocket:et}}),ps=Ts("config",()=>{const te=c(""),i=c([]),m=c([]),p=c([]),y=c([]),G=c(!1),R=c(!1),P=de(()=>({defaultCommitMessage:te.value,descriptionTemplates:i.value,scopeTemplates:m.value,messageTemplates:p.value,lockedFiles:y.value}));async function E(S=!1){if(!S&&R.value&&!G.value)return console.log("使用缓存的配置信息"),P.value;try{G.value=!0,console.log("加载配置信息...");const F=await(await fetch("/api/config/getConfig")).json();return te.value=F.defaultCommitMessage||"",i.value=F.descriptionTemplates||[],m.value=F.scopeTemplates||[],p.value=F.messageTemplates||[],y.value=F.lockedFiles||[],R.value=!0,console.log("配置信息加载完成"),P.value}catch(D){return console.error("加载配置失败:",D),o.error(`加载配置失败: ${D.message}`),null}finally{G.value=!1}}async function M(S){try{const F=await(await fetch("/api/config/saveDefaultMessage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultCommitMessage:S})})).json();return F.success?(te.value=S,o.success("默认提交信息已保存"),!0):(o.error(`保存失败: ${F.error}`),!1)}catch(D){return o.error(`保存失败: ${D.message}`),!1}}async function U(S,D){try{const X=await(await fetch("/api/config/save-template",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({template:S,type:D})})).json();return X.success?(D==="description"?i.value.includes(S)||i.value.push(S):D==="scope"?m.value.includes(S)||m.value.push(S):D==="message"&&(p.value.includes(S)||p.value.push(S)),o.success("模板已保存"),!0):(o.error(`保存模板失败: ${X.error}`),!1)}catch(F){return o.error(`保存模板失败: ${F.message}`),!1}}async function I(S,D){try{const X=await(await fetch("/api/config/delete-template",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({template:S,type:D})})).json();return X.success?(D==="description"?i.value=i.value.filter(j=>j!==S):D==="scope"?m.value=m.value.filter(j=>j!==S):D==="message"&&(p.value=p.value.filter(j=>j!==S)),o.success("模板已删除"),!0):(o.error(`删除模板失败: ${X.error}`),!1)}catch(F){return o.error(`删除模板失败: ${F.message}`),!1}}async function ie(S,D,F){try{const j=await(await fetch("/api/config/update-template",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldTemplate:S,newTemplate:D,type:F})})).json();if(j.success){if(F==="description"){const Z=i.value.indexOf(S);Z!==-1&&(i.value[Z]=D)}else if(F==="scope"){const Z=m.value.indexOf(S);Z!==-1&&(m.value[Z]=D)}else if(F==="message"){const Z=p.value.indexOf(S);Z!==-1&&(p.value[Z]=D)}return o.success("模板已更新"),!0}else return o.error(`更新模板失败: ${j.error}`),!1}catch(X){return o.error(`更新模板失败: ${X.message}`),!1}}async function O(){try{const D=await(await fetch("/api/locked-files")).json();return D.success?(y.value=D.lockedFiles||[],D.lockedFiles):(o.error(`加载锁定文件列表失败: ${D.error}`),[])}catch(S){return console.error("加载锁定文件列表失败:",S),o.error(`加载锁定文件列表失败: ${S.message}`),[]}}async function ne(S){try{const F=await(await fetch("/api/lock-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:S})})).json();return F.success?(await O(),o.success(`文件已锁定: ${S}`),!0):(o.error(`锁定文件失败: ${F.error}`),!1)}catch(D){return console.error("锁定文件失败:",D),o.error(`锁定文件失败: ${D.message}`),!1}}async function ue(S){try{const F=await(await fetch("/api/unlock-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:S})})).json();return F.success?(await O(),o.success(`文件已解锁: ${S}`),!0):(o.error(`解锁文件失败: ${F.error}`),!1)}catch(D){return console.error("解锁文件失败:",D),o.error(`解锁文件失败: ${D.message}`),!1}}async function ce(S){try{const F=await(await fetch("/api/check-file-lock",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:S})})).json();return F.success?F.isLocked:(console.error("检查文件锁定状态失败:",F.error),!1)}catch(D){return console.error("检查文件锁定状态失败:",D),!1}}return{defaultCommitMessage:te,descriptionTemplates:i,scopeTemplates:m,messageTemplates:p,lockedFiles:y,isLoading:G,isLoaded:R,config:P,loadConfig:E,saveDefaultMessage:M,saveTemplate:U,deleteTemplate:I,updateTemplate:ie,loadLockedFiles:O,lockFile:ne,unlockFile:ue,isFileLocked:ce}});function Na(te){return te.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Ha(te){return te?te.split(`
4
4
  `).map(m=>{const p=Na(m);return m.startsWith("diff --git")||m.startsWith("diff --cc")||m.startsWith("diff --combined")?`<div class="diff-header">${p}</div>`:m.startsWith("---")?`<div class="diff-old-file">${p}</div>`:m.startsWith("+++")?`<div class="diff-new-file">${p}</div>`:m.startsWith("@@")?`<div class="diff-hunk-header">${p}</div>`:m.startsWith("+")?`<div class="diff-added">${p}</div>`:m.startsWith("-")?`<div class="diff-removed">${p}</div>`:`<div class="diff-context">${p}</div>`}).join(""):""}function Ja(te){return te?te.trim():"(无提交信息)"}function Wa(te){if(!te)return"";const i=/^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\([^)]+\))?\s*:\s*(.+)$/s,m=te.match(i);return m?m[3].trim():te.trim()}const qa={key:0,class:"files-panel"},Ya={class:"panel-header"},Xa={key:0,class:"file-count"},Ka={class:"files-list"},Za=["onClick"],Qa={class:"file-name"},el={class:"panel-header"},tl={key:0,class:"selected-file"},sl={class:"diff-content"},al=["innerHTML"],ll=pt({__name:"FileDiffViewer",props:{files:{},emptyText:{default:"没有找到变更文件"},diffContent:{default:""},selectedFile:{default:""},height:{default:"100%"},showFileList:{type:Boolean,default:!0}},emits:["file-select"],setup(te,{emit:i}){const m=te,p=i,y=c(""),G=de(()=>m.selectedFile||y.value),R=de(()=>m.files.map(M=>({...M,displayName:M.name||M.path.split("/").pop()||M.path}))),P=de(()=>m.diffContent&&m.diffContent.trim()!=="");function E(M){y.value=M,p("file-select",M)}return Ye(()=>m.selectedFile,M=>{M!==void 0&&(y.value=M)}),Ye(()=>m.files,M=>{if(M.length>0&&!G.value){const U=M[0];E(U.path)}},{immediate:!0}),(M,U)=>(f(),$("div",{class:"file-diff-viewer",style:dt({height:M.height})},[M.showFileList?(f(),$("div",qa,[e("div",Ya,[U[0]||(U[0]=e("h4",null,"变更文件",-1)),M.files.length>0?(f(),$("span",Xa,"("+B(M.files.length)+")",1)):A("",!0)]),e("div",Ka,[t(l(pa),{height:"100%"},{default:a(()=>[M.files.length===0?(f(),Y(l(Mt),{key:0,description:M.emptyText,"image-size":60},null,8,["description"])):A("",!0),(f(!0),$(be,null,Be(R.value,I=>(f(),$("div",{key:I.path,class:ge(["file-item",{active:I.path===G.value,[`file-type-${I.type}`]:I.type}]),onClick:ie=>E(I.path)},[t(l(bt),{class:"file-icon"},{default:a(()=>[t(l(rs))]),_:1}),t(l(Ht),{content:I.path,placement:"top",disabled:I.displayName.length<=35,"hide-after":1e3,"show-after":200},{default:a(()=>[e("span",Qa,B(I.displayName),1)]),_:2},1032,["content","disabled"])],10,Za))),128))]),_:1})])])):A("",!0),e("div",{class:ge(["diff-panel",{"full-width":!M.showFileList}])},[e("div",el,[U[1]||(U[1]=e("h4",null,"文件差异",-1)),G.value?(f(),$("span",tl,B(G.value.split("/").pop()),1)):A("",!0)]),e("div",sl,[P.value?(f(),$("div",{key:1,class:"diff-text",innerHTML:l(Ha)(M.diffContent)},null,8,al)):(f(),Y(l(Mt),{key:0,description:G.value?"该文件没有差异内容":"请选择文件查看差异","image-size":80},null,8,["description"]))])],2)],4))}}),mt=(te,i)=>{const m=te.__vccOpts||te;for(const[p,y]of i)m[p]=y;return m},ms=mt(ll,[["__scopeId","data-v-a936d0d7"]]),ol={class:"common-dialog__footer"},nl=pt({__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(te,{emit:i}){const m=te,p=i,y=de(()=>{if(m.width)return m.width;switch(m.size){case"small":return"30%";case"medium":return"50%";case"large":return"80%";case"extra-large":return"90%";default:return"50%"}}),G=de(()=>{if(m.height)return m.height;switch(m.type){case"full-height":return"calc(100vh - 100px)";case"flex":return"calc(100vh - 160px)";default:return"auto"}}),R=de(()=>{const O={};return(m.type==="full-height"||m.type==="flex")&&(O["--dialog-height"]=G.value),O}),P=de(()=>{const O=[];return m.customClass&&O.push(m.customClass),m.type==="flex"&&O.push("common-dialog--flex"),m.type==="full-height"&&O.push("common-dialog--full-height"),O.join(" ")});function E(){p("update:modelValue",!1),p("close")}function M(){p("confirm")}function U(){p("cancel"),E()}function I(){p("opened")}function ie(){p("closed")}return(O,ne)=>{const ue=Ge;return f(),Y(l(Jt),{"model-value":O.modelValue,title:O.title,width:y.value,top:O.top,style:dt(R.value),"close-on-click-modal":O.closeOnClickModal,"close-on-press-escape":O.closeOnPressEscape,"destroy-on-close":O.destroyOnClose,draggable:O.draggable,class:ge(P.value),"append-to-body":O.appendToBody,"lock-scroll":O.lockScroll,onClose:E,onOpened:I,onClosed:ie},ma({default:a(()=>[ks(O.$slots,"default",{},void 0,!0)]),_:2},[O.showFooter||O.$slots.footer?{name:"footer",fn:a(()=>[ks(O.$slots,"footer",{},()=>[e("div",ol,[O.showCancel?(f(),Y(ue,{key:0,onClick:U},{default:a(()=>[w(B(O.cancelText),1)]),_:1})):A("",!0),t(ue,{type:"primary",loading:O.confirmLoading,onClick:M},{default:a(()=>[w(B(O.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=mt(nl,[["__scopeId","data-v-c1505473"]]),il={class:"card"},rl={class:"status-header"},cl={class:"header-actions"},ul=["element-loading-text"],dl={key:0,class:"status-box"},fl={key:1,class:"status-box-wrap"},pl={key:0,class:"branch-status-info"},ml={class:"branch-sync-status"},vl={class:"sync-status-content"},gl={class:"status-badges"},hl={class:"badge-content"},yl={class:"badge-content"},_l={key:1,class:"file-list-container"},wl={key:0,class:"file-group"},kl={class:"file-list"},$l=["onClick"],bl={class:"file-info"},Cl={class:"file-name-section"},Sl=["title"],Tl={class:"file-directory"},Vl={class:"file-actions"},xl={key:1,class:"file-group"},Ll={class:"file-list"},zl=["onClick"],Bl={class:"file-info"},Fl={class:"file-name-section"},Dl=["title"],Rl={class:"file-directory"},jl={class:"file-actions"},Gl={key:2,class:"file-group"},Ol={class:"file-list"},Ul=["onClick"],Al={class:"file-info"},Pl={class:"file-name-section"},El=["title"],Ml={class:"file-directory"},Il={class:"file-actions"},Nl={key:2,class:"empty-status"},Hl={class:"empty-icon"},Jl={class:"lock-feature-description"},Wl={class:"description-header"},ql={key:0,class:"empty-locked-files"},Yl={class:"empty-icon"},Xl={key:1,class:"locked-files-list"},Kl={class:"locked-files-header"},Zl={class:"locked-file-items"},Ql={class:"file-info"},eo={class:"file-path-container"},to={class:"file-name"},so={class:"file-directory"},ao={class:"file-actions"},lo={class:"dialog-footer"},oo=pt({__name:"GitStatus",props:{initialDirectory:{type:String,default:""}},setup(te,{expose:i}){const m=te,p=kt(),y=ps(),G=de(()=>p.isLoadingStatus),R=c(""),P=c(""),E=c(!1),M=c(!1),U=c(-1),I=de(()=>p.fileList.map(h=>({path:h.path,name:h.path.split("/").pop()||h.path,type:h.type})));async function ie(h){await F(h)}const O=c(!1),ne=c({staged:!1,unstaged:!1,untracked:!1}),ue=c(m.initialDirectory||"");async function ce(){try{if(!ue.value){const g=await(await fetch("/api/current_directory")).json();ue.value=g.directory||"未知目录"}if(!p.isGitRepo)return;await p.fetchStatus(),await p.getBranchStatus(),o({message:"Git 状态已刷新",type:"success"})}catch(h){o({message:"刷新失败: "+h.message,type:"error"})}}async function S(h){try{await Me.confirm(`确认解锁该文件?
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Zen-GitSync - Git同步工具</title>
8
- <script type="module" crossorigin src="/assets/index-CEUlhLPJ.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-CrWfkxTj.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/vendor-BHXhVXkb.js">
10
10
  <link rel="stylesheet" crossorigin href="/assets/vendor-BLnrYq3C.css">
11
11
  <link rel="stylesheet" crossorigin href="/assets/index-GbnGyTcZ.css">
@@ -1891,27 +1891,52 @@ async function startUIServer(noOpen = false, savePort = false) {
1891
1891
  .split('\n')
1892
1892
  .filter(line => line.trim())
1893
1893
  .map(line => {
1894
- const match = line.match(/^..\s+(.+)$/);
1894
+ const match = line.match(/^(..)\s+(.+)$/);
1895
1895
  if (match) {
1896
- let filename = match[1];
1896
+ const status = match[1];
1897
+ let filename = match[2];
1897
1898
  if (filename.startsWith('"') && filename.endsWith('"')) {
1898
1899
  filename = filename.slice(1, -1).replace(/\\(.)/g, '$1');
1899
1900
  }
1900
- return filename;
1901
+ return { status, filename };
1901
1902
  }
1902
1903
  return null;
1903
1904
  })
1904
1905
  .filter(Boolean);
1905
1906
 
1906
1907
  const path = (await import('path')).default;
1907
- const filesToStash = changedFiles.filter(file => {
1908
- const normalizedFile = path.normalize(file);
1908
+ const fs = (await import('fs')).default;
1909
+
1910
+ // 过滤出未锁定且存在的文件
1911
+ const filesToStash = [];
1912
+ for (const item of changedFiles) {
1913
+ const { status, filename } = item;
1914
+ const normalizedFile = path.normalize(filename);
1915
+
1916
+ // 检查是否被锁定
1909
1917
  const isLocked = lockedFiles.some(locked => {
1910
1918
  const normalizedLocked = path.normalize(locked);
1911
1919
  return normalizedFile === normalizedLocked || normalizedFile.startsWith(normalizedLocked + path.sep);
1912
1920
  });
1913
- return !isLocked;
1914
- });
1921
+
1922
+ if (!isLocked) {
1923
+ // 检查文件是否存在(排除已删除的文件和目录)
1924
+ try {
1925
+ const fullPath = path.resolve(filename);
1926
+ const stats = fs.statSync(fullPath);
1927
+ // 只包含文件,不包含目录
1928
+ if (stats.isFile()) {
1929
+ filesToStash.push(filename);
1930
+ }
1931
+ } catch (error) {
1932
+ // 对于已删除的文件(D状态),我们仍然需要包含它们
1933
+ if (status.includes('D')) {
1934
+ filesToStash.push(filename);
1935
+ }
1936
+ // 其他情况(如文件不存在)则跳过
1937
+ }
1938
+ }
1939
+ }
1915
1940
 
1916
1941
  if (filesToStash.length === 0) {
1917
1942
  return res.json({ success: false, message: '所有更改都是锁定文件,无需储藏' });
@@ -697,10 +697,57 @@ async function execGitAddWithLockFilter() {
697
697
  const normalizedGitFile = gitRelativeFile.replace(/\\/g, '/');
698
698
  const normalizedLockedFile = normalizedLocked.replace(/\\/g, '/');
699
699
 
700
- // 精确匹配或目录匹配
701
- return normalizedGitFile === normalizedLockedFile ||
702
- normalizedGitFile.startsWith(normalizedLockedFile + '/');
700
+ // 精确匹配或目录匹配(双向检查)
701
+ const isExactMatch = normalizedGitFile === normalizedLockedFile;
702
+ const isFileInLockedDir = normalizedGitFile.startsWith(normalizedLockedFile + '/');
703
+ const isLockedFileInDir = normalizedLockedFile.startsWith(normalizedGitFile + '/');
704
+
705
+ return isExactMatch || isFileInLockedDir || isLockedFileInDir;
703
706
  });
707
+
708
+ // 额外检查:如果是目录路径,检查该目录下是否有任何未锁定的文件
709
+ if (!isLocked && file.endsWith('/')) {
710
+ // 这是一个目录路径,检查是否该目录下所有文件都被锁定
711
+ const dirPath = file.slice(0, -1); // 移除末尾的 '/'
712
+ const hasUnlockedFilesInDir = modifiedFiles.some(otherFile => {
713
+ if (otherFile === file) return false; // 跳过目录本身
714
+
715
+ const normalizedOtherFile = path.normalize(otherFile).replace(/\\/g, '/');
716
+ const normalizedDirPath = dirPath.replace(/\\/g, '/');
717
+
718
+ // 检查文件是否在这个目录下
719
+ if (normalizedOtherFile.startsWith(normalizedDirPath + '/')) {
720
+ // 检查这个文件是否被锁定
721
+ const isOtherFileLocked = lockedFiles.some(lockedFile => {
722
+ let normalizedLocked;
723
+ if (path.isAbsolute(lockedFile)) {
724
+ const absoluteLocked = path.normalize(lockedFile);
725
+ if (absoluteLocked.startsWith(gitRoot)) {
726
+ normalizedLocked = path.relative(gitRoot, absoluteLocked);
727
+ } else {
728
+ return false;
729
+ }
730
+ } else {
731
+ normalizedLocked = path.normalize(lockedFile);
732
+ }
733
+
734
+ const normalizedLockedFile = normalizedLocked.replace(/\\/g, '/');
735
+ return normalizedOtherFile === normalizedLockedFile ||
736
+ normalizedOtherFile.startsWith(normalizedLockedFile + '/') ||
737
+ normalizedLockedFile.startsWith(normalizedOtherFile + '/');
738
+ });
739
+
740
+ return !isOtherFileLocked; // 如果文件未锁定,返回 true
741
+ }
742
+ return false;
743
+ });
744
+
745
+ // 如果目录下没有未锁定的文件,则跳过这个目录
746
+ if (!hasUnlockedFilesInDir) {
747
+ console.log(chalk.yellow(`🔒 跳过目录(所有文件都被锁定): ${file}`));
748
+ return false;
749
+ }
750
+ }
704
751
 
705
752
  if (isLocked) {
706
753
  console.log(chalk.yellow(`🔒 跳过锁定文件: ${file}`));