@onescience/onecode-web 1.14.50-202608291724 → 1.14.50-202608311810
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/assets/{account-system-oQdFkFdc.js → account-system-BmjmY4XZ.js} +1 -1
- package/assets/{alert-05-BBfIqCiu.js → alert-01-BeImAytW.js} +1 -1
- package/assets/{alert-01-BAmbeQsE.js → alert-02-DOqMPBaq.js} +1 -1
- package/assets/{alert-02-BhusUFcu.js → alert-04-CzWeMtuD.js} +1 -1
- package/assets/{alert-04-dJmL7I6l.js → alert-05-kxIjawB-.js} +1 -1
- package/assets/alert-06-D79IMzit.js +1 -0
- package/assets/alert-07-CliklbQi.js +1 -0
- package/assets/alert-08-DyQ8AAP1.js +1 -0
- package/assets/alert-10-DEWRIA7A.js +1 -0
- package/assets/{bip-bop-03-FZJL80VI.js → bip-bop-03-D9tgGY_p.js} +1 -1
- package/assets/{bip-bop-04-DQ651lxF.js → bip-bop-04-BhOqWc_7.js} +1 -1
- package/assets/{bip-bop-06-CPpBCuf2.js → bip-bop-06-BCTQF7n9.js} +1 -1
- package/assets/{bip-bop-08-BfHR51H0.js → bip-bop-08-OKkM4TfM.js} +1 -1
- package/assets/bip-bop-09-C2i5vwcb.js +1 -0
- package/assets/dialog-create-project-folder-B6wUCogR.js +1 -0
- package/assets/{dialog-edit-project-BQYyPKNl.js → dialog-edit-project-DViTl2BR.js} +1 -1
- package/assets/{dialog-fork-Ccx9LxV-.js → dialog-fork-B1nhBfd5.js} +1 -1
- package/assets/{dialog-project-upload-CgtitYMN.js → dialog-project-upload-Cl6ps4Rc.js} +2 -2
- package/assets/{dialog-select-directory-CFGHhtly.js → dialog-select-directory-DXe-NQMU.js} +2 -2
- package/assets/{dialog-select-file-B-x4bHeH.js → dialog-select-file-Dck2aJ73.js} +1 -1
- package/assets/{dialog-select-mcp-B6shnm9m.js → dialog-select-mcp-D3SeSlnN.js} +2 -2
- package/assets/{dialog-select-model-DomFYI-e.js → dialog-select-model-CzW20GqV.js} +2 -2
- package/assets/{dialog-terminal-unavailable-_SDcRu3J.js → dialog-terminal-unavailable-B7tfXMnq.js} +1 -1
- package/assets/{ghostty-web-BBmqnyyp.js → ghostty-web-CVmsqsAA.js} +1 -1
- package/assets/{index-C4fYAA4x.css → index-DKqTsr7d.css} +1 -1
- package/assets/{index-B07r4aMH.js → index-ahqm8KFw.js} +191 -191
- package/assets/{nope-02-CilwqZDt.js → nope-02-C3xRWpFh.js} +1 -1
- package/assets/{nope-05-CGuRooCx.js → nope-05-Bm_dmk79.js} +1 -1
- package/assets/{nope-08-CQJdUxjv.js → nope-08-D2UfHY8e.js} +1 -1
- package/assets/{nope-11-DKTEMF5u.js → nope-11-DWzRRAN0.js} +1 -1
- package/assets/nope-12-Yt5DmtPL.js +1 -0
- package/assets/{staplebops-03-BLB7UAs4.js → staplebops-03-vYYlSVqk.js} +1 -1
- package/assets/{staplebops-04-CWqPIvv6.js → staplebops-04-Ct78w6Js.js} +1 -1
- package/assets/{staplebops-06-DtVt1kSo.js → staplebops-06-CplNeopO.js} +1 -1
- package/assets/{staplebops-07-Smpv53Bz.js → staplebops-07-BK1Qb_JE.js} +1 -1
- package/assets/{status-popover-body-B4MK0OkE.js → status-popover-body-Vweam5-A.js} +2 -2
- package/assets/{yup-01-CVF3cP-C.js → yup-01-DFGAflA5.js} +1 -1
- package/assets/{yup-03-B9nTR32O.js → yup-03-DS-RneQM.js} +1 -1
- package/assets/{yup-04-DgqAKopk.js → yup-04-B3jc0ZZw.js} +1 -1
- package/assets/{yup-05-BCPvsWf5.js → yup-05-DOiC3CF2.js} +1 -1
- package/assets/{zh-DNAVnKyH.js → zh-D4XY_6IZ.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/assets/alert-06-Dy9q6inw.js +0 -1
- package/assets/alert-07-CKQ0u25i.js +0 -1
- package/assets/alert-08-ByWbOwnP.js +0 -1
- package/assets/alert-10-Bh8XS4Tg.js +0 -1
- package/assets/bip-bop-09-D2-WFU4T.js +0 -1
- package/assets/dialog-create-project-folder-B0rYGyZi.js +0 -1
- package/assets/nope-12-CNfZ-ZpQ.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as ee,a as Y,b as de,c as me,d as N,o as te,i as a,e as _,f as V,g as X,t as w,h as we,S as k,m as z,j as f,s as E,k as ve,l as ge,n as _e,p as Ce,r as ye,D as xe,M as Se,q as Pe,v as fe,w as ke,x as pe,y as qe,z as Ae,A as Me,B as Te,C as oe,E as De,F as le,G as Ee}from"./index-B07r4aMH.js";var G=w("<p class=os-auth-error>"),Ue=w('<form class=os-auth-form><label><span>账户 / 邮箱</span><input autocomplete=username placeholder=账户名或注册邮箱></label><label><span>密码</span><input autocomplete=current-password type=password placeholder=输入密码></label><button type=submit class="os-button os-button-primary os-auth-submit">'),He=w("<div class=os-auth-links><span>还没有账号?</span><a>创建账号</a><a>忘记密码?"),Le=w("<p>"),Re=w('<div class=os-auth-email-verify><button type=button class="os-button os-button-secondary os-auth-submit"></button><label><span></span><input autocomplete=one-time-code>'),Ie=w("<label><span>邀请码</span><input autocomplete=one-time-code placeholder=请输入邀请码><small class=os-auth-hint>当前已开启注册审核,需填写有效邀请码才能注册。"),Fe=w('<form class=os-auth-form><label><span>账户</span><input autocomplete=username placeholder="例如 researcher01"><small class=os-auth-hint>用作登录标识及个人工作区目录名称。长度 3–32 个字符,须以小写字母开头,仅可包含小写字母、数字、点(.)、下划线(_)与连字符(-)。</small></label><label><span>邮箱</span><input autocomplete=email inputmode=email placeholder=name@example.com><small class=os-auth-hint>用于账号找回与系统通知,亦可作为登录凭证。</small></label><label><span>密码</span><input autocomplete=new-password type=password placeholder="至少 8 位"></label><label><span>确认密码</span><input autocomplete=new-password type=password placeholder=再次输入密码></label><button type=submit class="os-button os-button-primary os-auth-submit">'),Ne=w("<div class=os-auth-links><span>已有账号?</span><a>去登录"),ze=w('<p class=os-auth-hint style="margin:0 0 0.35rem">通过注册邮箱获取验证码后重置密码。若无法收到邮件,请联系管理员。'),Z=w("<p class=os-account-success>"),je=w('<form class=os-auth-form><label><span>账号邮箱</span><input autocomplete=email inputmode=email placeholder=name@example.com></label><button type=submit class="os-button os-button-secondary os-auth-submit">'),Be=w("<label><span>邮件验证码</span><input autocomplete=one-time-code placeholder=输入邮件中的验证码>"),Oe=w('<form class=os-auth-form><label><span>新密码</span><input autocomplete=new-password type=password placeholder="至少 8 位"></label><label><span>确认新密码</span><input autocomplete=new-password type=password placeholder=再次输入新密码></label><button type=submit class="os-button os-button-primary os-auth-submit">'),Ve=w("<div class=os-auth-links><a>返回登录</a><a>创建账号"),Ge=w('<p class=os-auth-hint style="margin:0 0 0.35rem">请设置新密码以完成重置。'),We=w("<main class=os-account-page><div class=os-account-shell>"),Je=w("<section class=os-account-loading><strong>正在加载账号信息</strong><span>请稍候"),Ke=w('<section class=os-account-empty-state><strong></strong><span>登录后可以查看账号资料和开发空间。</span><a href=/login class="os-button os-button-primary">去登录'),Qe=w('<header class=os-account-header><div class=os-account-identity><div class=os-account-avatar></div><div><span class=os-account-kicker>账号中心</span><h1></h1><p></p></div></div><div class=os-account-actions><span class=os-account-status></span><a href=/code class="os-button os-button-secondary">进入科研开发</a><button type=button class="os-button os-button-danger">退出登录</button><button type=button class="os-button os-button-danger">'),Xe=w("<section class=os-account-workspace-hero><div class=os-account-workspace-hero-copy><span class=os-account-kicker>默认项目</span><strong>default</strong><p></p></div><div class=os-account-workspace-hero-meta><code>"),Ye=w('<section class=os-account-content-grid><section class=os-account-panel><div class=os-account-panel-head><strong>基本资料</strong><span class=os-account-session-expiry title="这是当前浏览器登录会话的有效期(约 14 天),不是账号本身到期。重新登录即可续期,账号与工作区数据不受影响。">登录会话 <!>失效</span></div><p class=os-account-session-expiry-note>提示:上方倒计时是登录会话有效期,重新登录即可续期;账号与工作区数据不会因此删除。</p><dl class=os-account-field-grid><div><dt>账户</dt><dd></dd></div><div><dt>邮箱</dt><dd></dd></div><div><dt>创建时间</dt><dd></dd></div><div><dt>默认入口</dt><dd>科研开发工作台</dd></div></dl></section><section class=os-account-panel><div class=os-account-panel-head><strong>修改密码</strong><span>本地账号</span></div><form class=os-account-password-form><label><span>当前密码</span><input autocomplete=current-password type=password placeholder=输入当前密码></label><label><span>新密码</span><input autocomplete=new-password type=password placeholder="至少 8 位"></label><label><span>确认新密码</span><input autocomplete=new-password type=password placeholder=再次输入新密码></label><button type=submit class="os-button os-button-danger os-auth-submit">'),Ze=w('<div class="flex flex-col gap-4 pl-6 pr-2.5 pb-3"><p class="text-14-regular text-text-strong"></p><div class="flex justify-end gap-2"><button type=button class="os-button os-button-secondary"></button><button type=button class="os-button os-button-danger">'),et=w("<main class=os-auth-page><section class=os-auth-shell><section class=os-auth-panel><a class=os-auth-brand href=/>");function ct(){const l=ee(),u=Y(),[m,v]=N({name:"",email:"",password:"",confirmPassword:"",submitting:!1,error:""}),x=()=>typeof m.lockedUntil=="number"&&m.lockedUntil>Date.now(),o=async r=>{if(r.preventDefault(),x()){v("error",`尝试次数过多,请在 ${ot(m.lockedUntil-Date.now())} 后重试`);return}if(!m.email.trim()||!m.password){v("error","请输入账户/邮箱和密码");return}v({submitting:!0,error:"",lockedUntil:void 0});try{await fe(await ke({email:m.email.trim(),password:m.password}),l.storage);const g=pe(location.search);if(l.platform==="desktop"){u(g,{replace:!0});return}location.assign(g)}catch(g){const C=g instanceof Error&&"retryAfterMs"in g?Number(g.retryAfterMs):void 0;v({error:g instanceof Error?g.message:"登录失败,请稍后重试",submitting:!1,lockedUntil:typeof C=="number"&&C>0?Date.now()+C:void 0})}};return _(re,{mode:"login",get children(){return[(()=>{var r=Ue(),g=r.firstChild,C=g.firstChild,S=C.nextSibling,t=g.nextSibling,e=t.firstChild,i=e.nextSibling,p=t.nextSibling;return r.addEventListener("submit",o),S.$$input=n=>v("email",n.currentTarget.value),i.$$input=n=>v("password",n.currentTarget.value),a(r,_(k,{get when(){return m.error},get children(){var n=G();return a(n,()=>m.error),n}}),p),a(p,(()=>{var n=z(()=>!!m.submitting);return()=>n()?"正在登录...":x()?"已锁定,请稍后重试":"登录"})()),f(n=>{var $=m.submitting,s=m.submitting,c=m.submitting||x();return $!==n.e&&(S.disabled=n.e=$),s!==n.t&&(i.disabled=n.t=s),c!==n.a&&(p.disabled=n.a=c),n},{e:void 0,t:void 0,a:void 0}),f(()=>S.value=m.email),f(()=>i.value=m.password),r})(),(()=>{var r=He(),g=r.firstChild,C=g.nextSibling,S=C.nextSibling;return f(t=>{var e=`/register${location.search}`,i=`/forgot-password${location.search}`;return e!==t.e&&E(C,"href",t.e=e),i!==t.t&&E(S,"href",t.t=i),t},{e:void 0,t:void 0}),r})()]}})}function ut(){const l=ee(),u=Y(),[m,v]=V(!1),[x,o]=V(!1),[r,g]=V(!1),[C,S]=V(Date.now()),[t,e]=N({name:"",email:"",password:"",confirmPassword:"",inviteCode:"",emailCode:"",submitting:!1,requestingCode:!1,requestHint:"",cooldownUntil:0,error:""});te(()=>{ve().then(c=>{v(!!c.inviteRequired),o(!!c.emailVerificationRequired)}).catch(()=>{v(!1),o(!1)});const s=window.setInterval(()=>S(Date.now()),250);ge(()=>window.clearInterval(s))});const i=X(()=>Math.max(0,Math.ceil(((t.cooldownUntil??0)-C())/1e3))),p=X(()=>i()>0),n=async()=>{if(t.requestingCode||t.submitting||p())return;const s=ue(t.email);if(s){e({error:s,requestHint:""});return}e({requestingCode:!0,error:"",requestHint:""});try{const c=await Ae({email:t.email.trim()}),b=typeof c.retryAfterMs=="number"&&c.retryAfterMs>0?c.retryAfterMs:6e4;if(c.smtpUnreachable){g(!0),e({requestingCode:!1,requestHint:"无法连接邮件服务器,本次注册无需填写验证码。找回密码仍须邮件验证,收不到验证码请联系管理员。",error:"",cooldownUntil:Date.now()+b});return}g(!1),e({requestingCode:!1,requestHint:"验证码已发送,请查收邮箱后填入下方。",error:"",cooldownUntil:Date.now()+b})}catch(c){const b=c instanceof Error&&"retryAfterMs"in c?Number(c.retryAfterMs):void 0;e({requestingCode:!1,error:c instanceof Error?c.message:"发送验证码失败,请稍后重试",requestHint:"",...typeof b=="number"&&b>0?{cooldownUntil:Date.now()+b}:{}})}},$=async s=>{if(s.preventDefault(),!t.name.trim()||!t.email.trim()||!t.password){e("error","请输入账户、邮箱和密码");return}const c=it(t.name);if(c){e("error",c);return}const b=ue(t.email);if(b){e("error",b);return}if(m()&&!(t.inviteCode??"").trim()){e("error","请填写邀请码");return}if(x()&&!r()&&!(t.emailCode??"").trim()){e("error","请填写邮箱验证码");return}if(t.password.length<8){e("error","密码至少需要 8 位");return}if(t.password!==t.confirmPassword){e("error","两次输入的密码不一致");return}e({submitting:!0,error:""});try{await fe(await qe({name:t.name.trim().toLowerCase(),email:t.email.trim(),password:t.password,...t.inviteCode?.trim()?{inviteCode:t.inviteCode.trim()}:{},...x()&&t.emailCode?.trim()?{emailCode:t.emailCode.trim()}:{}}),l.storage);const d=pe(location.search);if(l.platform==="desktop"){u(d,{replace:!0});return}location.assign(d)}catch(d){e("error",d instanceof Error?d.message:"注册失败,请稍后重试"),e("submitting",!1)}};return _(re,{mode:"register",get children(){return[(()=>{var s=Fe(),c=s.firstChild,b=c.firstChild,d=b.nextSibling,q=c.nextSibling,P=q.firstChild,M=P.nextSibling,U=q.nextSibling,I=U.firstChild,H=I.nextSibling,L=U.nextSibling,W=L.firstChild,J=W.nextSibling,j=L.nextSibling;return s.addEventListener("submit",$),d.$$input=h=>e("name",h.currentTarget.value),E(d,"spellcheck",!1),M.$$input=h=>{e("email",h.currentTarget.value),g(!1)},a(s,_(k,{get when(){return x()},get children(){var h=Re(),T=h.firstChild,D=T.nextSibling,F=D.firstChild,R=F.nextSibling;return T.$$click=()=>void n(),a(T,(()=>{var y=z(()=>!!t.requestingCode);return()=>y()?"正在发送...":z(()=>!!p())()?`重新发送 (${i()}s)`:"发送验证码"})()),a(h,_(k,{get when(){return t.requestHint},get children(){var y=Le();return a(y,()=>t.requestHint),f(()=>_e(y,r()?"os-auth-hint":"os-account-success")),y}}),D),a(F,()=>r()?"邮箱验证码(可不填)":"邮箱验证码"),R.$$input=y=>e("emailCode",y.currentTarget.value),E(R,"spellcheck",!1),f(y=>{var B=t.requestingCode||t.submitting||p()||!t.email.trim(),K=r()?"邮件服务器不可达,可留空":"输入邮件中的验证码",O=t.submitting;return B!==y.e&&(T.disabled=y.e=B),K!==y.t&&E(R,"placeholder",y.t=K),O!==y.a&&(R.disabled=y.a=O),y},{e:void 0,t:void 0,a:void 0}),f(()=>R.value=t.emailCode??""),h}}),U),a(s,_(k,{get when(){return m()},get children(){var h=Ie(),T=h.firstChild,D=T.nextSibling;return D.$$input=F=>e("inviteCode",F.currentTarget.value),E(D,"spellcheck",!1),f(()=>D.value=t.inviteCode??""),h}}),U),H.$$input=h=>e("password",h.currentTarget.value),J.$$input=h=>e("confirmPassword",h.currentTarget.value),a(s,_(k,{get when(){return t.error},get children(){var h=G();return a(h,()=>t.error),h}}),j),a(j,()=>t.submitting?"正在创建...":"创建账号"),f(h=>{var T=t.submitting||t.requestingCode,D=t.submitting;return T!==h.e&&(M.disabled=h.e=T),D!==h.t&&(j.disabled=h.t=D),h},{e:void 0,t:void 0}),f(()=>d.value=t.name),f(()=>M.value=t.email),f(()=>H.value=t.password),f(()=>J.value=t.confirmPassword),s})(),(()=>{var s=Ne(),c=s.firstChild,b=c.nextSibling;return f(()=>E(b,"href",`/login${location.search}`)),s})()]}})}function dt(){const l=Y(),u=typeof location<"u"?new URLSearchParams(location.search).get("token")?.trim()??"":"",m=!!u,[v,x]=V(Date.now()),[o,r]=N({email:"",token:u,newPassword:"",confirmPassword:"",requesting:!1,submitting:!1,error:"",success:"",requestHint:"",cooldownUntil:0});te(()=>{const e=window.setInterval(()=>x(Date.now()),250);ge(()=>window.clearInterval(e))});const g=X(()=>Math.max(0,Math.ceil((o.cooldownUntil-v())/1e3))),C=X(()=>g()>0),S=async()=>{if(!(o.requesting||o.submitting||C())){if(!o.email.trim()){r({error:"请输入账号邮箱",success:"",requestHint:""});return}r({requesting:!0,error:"",success:"",requestHint:""});try{const e=await Me({email:o.email.trim()}),i=typeof e.retryAfterMs=="number"&&e.retryAfterMs>0?e.retryAfterMs:6e4;r({requesting:!1,requestHint:"若该邮箱已注册,验证码将发送至邮箱。请查收后在下方完成重置。",error:"",cooldownUntil:Date.now()+i})}catch(e){const i=e instanceof Error&&"retryAfterMs"in e?Number(e.retryAfterMs):void 0;r({requesting:!1,error:e instanceof Error?e.message:"发送验证码失败,请稍后重试",requestHint:"",...typeof i=="number"&&i>0?{cooldownUntil:Date.now()+i}:{}})}}},t=async e=>{if(e.preventDefault(),!o.token.trim()){r({error:"请输入邮件验证码",success:""});return}if(o.newPassword.length<8){r({error:"新密码至少需要 8 位",success:""});return}if(o.newPassword!==o.confirmPassword){r({error:"两次输入的新密码不一致",success:""});return}r({submitting:!0,error:"",success:""});try{await Te({token:o.token.trim(),newPassword:o.newPassword}),r({submitting:!1,error:"",success:"密码已重置,请使用新密码登录",newPassword:"",confirmPassword:""});const i=new URLSearchParams(location.search);i.delete("token");const p=i.toString();window.setTimeout(()=>l(`/login${p?`?${p}`:""}`,{replace:!0}),1200)}catch(i){r({submitting:!1,error:i instanceof Error?i.message:"重置密码失败,请稍后重试",success:""})}};return _(re,{mode:"forgot-password",get children(){return[_(k,{when:!m,get fallback(){return Ge()},get children(){return ze()}}),_(k,{when:!m,get children(){var e=je(),i=e.firstChild,p=i.firstChild,n=p.nextSibling,$=i.nextSibling;return e.addEventListener("submit",s=>{s.preventDefault(),S()}),n.$$input=s=>r("email",s.currentTarget.value),a($,(()=>{var s=z(()=>!!o.requesting);return()=>s()?"正在发送...":z(()=>!!C())()?`重新发送 (${g()}s)`:"获取验证码"})()),a(e,_(k,{get when(){return o.requestHint},get children(){var s=Z();return a(s,()=>o.requestHint),s}}),null),f(s=>{var c=o.requesting||o.submitting,b=o.requesting||o.submitting||C()||!o.email.trim();return c!==s.e&&(n.disabled=s.e=c),b!==s.t&&($.disabled=s.t=b),s},{e:void 0,t:void 0}),f(()=>n.value=o.email),e}}),(()=>{var e=Oe(),i=e.firstChild,p=i.firstChild,n=p.nextSibling,$=i.nextSibling,s=$.firstChild,c=s.nextSibling,b=$.nextSibling;return e.addEventListener("submit",t),a(e,_(k,{when:!m,get children(){var d=Be(),q=d.firstChild,P=q.nextSibling;return P.$$input=M=>r("token",M.currentTarget.value),f(()=>P.disabled=o.submitting),f(()=>P.value=o.token),d}}),i),n.$$input=d=>r("newPassword",d.currentTarget.value),c.$$input=d=>r("confirmPassword",d.currentTarget.value),a(e,_(k,{get when(){return o.error},get children(){var d=G();return a(d,()=>o.error),d}}),b),a(e,_(k,{get when(){return o.success},get children(){var d=Z();return a(d,()=>o.success),d}}),b),a(b,()=>o.submitting?"正在重置...":"重置密码"),f(d=>{var q=o.submitting,P=o.submitting,M=o.submitting;return q!==d.e&&(n.disabled=d.e=q),P!==d.t&&(c.disabled=d.t=P),M!==d.a&&(b.disabled=d.a=M),d},{e:void 0,t:void 0,a:void 0}),f(()=>n.value=o.newPassword),f(()=>c.value=o.confirmPassword),e})(),(()=>{var e=Ve(),i=e.firstChild,p=i.nextSibling;return f(n=>{var $=`/login${location.search}`,s=`/register${location.search}`;return $!==n.e&&E(i,"href",n.e=$),s!==n.t&&E(p,"href",n.t=s),n},{e:void 0,t:void 0}),e})()]}})}function mt(){const l=ee(),u=Y(),m=de(),v=me(),[x,o]=N({loading:!0,error:""}),[r,g]=N({currentPassword:"",newPassword:"",confirmPassword:"",submitting:!1,error:"",success:""});te(()=>{const i=Ce();if(!i){o({loading:!1,error:"当前未登录"});return}ye(i).then(p=>o({session:p,loading:!1,error:""})).catch(p=>o({loading:!1,error:p instanceof Error?p.message:"会话已失效"}))});const C=()=>{if(l.platform==="desktop"){u("/login",{replace:!0});return}location.assign("/login")},S=()=>{oe(l.storage).finally(()=>C())},t=async()=>{try{await De(),le({variant:"success",icon:"circle-check",title:m.t("account.deleteAccount.toast.success")}),await oe(l.storage),C()}catch(i){le({variant:"error",title:m.t("account.deleteAccount.toast.error"),description:i instanceof Error?i.message:"请稍后重试"})}},e=async(i,p)=>{if(i.preventDefault(),!r.currentPassword||!r.newPassword||!r.confirmPassword){g({error:"请输入当前密码和新密码",success:""});return}if(r.newPassword.length<8){g({error:"新密码至少需要 8 位",success:""});return}if(r.currentPassword===r.newPassword){g({error:"新密码不能与当前密码相同",success:""});return}if(r.newPassword!==r.confirmPassword){g({error:"两次输入的新密码不一致",success:""});return}g({submitting:!0,error:"",success:""});try{await Ee({accountId:p.account.id,currentPassword:r.currentPassword,newPassword:r.newPassword}),g({currentPassword:"",newPassword:"",confirmPassword:"",submitting:!1,error:"",success:"密码已更新,下次登录请使用新密码"})}catch(n){g({submitting:!1,error:n instanceof Error?n.message:"修改密码失败,请稍后重试",success:""})}};return(()=>{var i=We(),p=i.firstChild;return a(p,_(k,{get when(){return!x.loading},get fallback(){return Je()},get children(){return _(k,{get when(){return x.session},get fallback(){return(()=>{var n=Ke(),$=n.firstChild;return a($,()=>x.error||"当前未登录"),n})()},children:n=>[(()=>{var $=Qe(),s=$.firstChild,c=s.firstChild,b=c.nextSibling,d=b.firstChild,q=d.nextSibling,P=q.nextSibling,M=s.nextSibling,U=M.firstChild,I=U.nextSibling,H=I.nextSibling,L=H.nextSibling;return a(c,()=>rt(n().account.name,n().account.email)),a(q,()=>n().account.name),a(P,()=>n().account.email),a(U,()=>nt(n().account.status)),H.$$click=S,L.$$click=()=>v.show(()=>_(tt,{onConfirm:t})),a(L,()=>m.t("account.deleteAccount.button")),$})(),(()=>{var $=Xe(),s=$.firstChild,c=s.firstChild,b=c.nextSibling,d=b.nextSibling,q=s.nextSibling,P=q.firstChild;return a(d,()=>m.t("account.defaultProject.description")),a(P,()=>ce(n())||"未分配"),f(()=>E(P,"title",ce(n()))),$})(),(()=>{var $=Ye(),s=$.firstChild,c=s.firstChild,b=c.firstChild,d=b.nextSibling,q=d.firstChild,P=q.nextSibling;P.nextSibling;var M=c.nextSibling,U=M.nextSibling,I=U.firstChild,H=I.firstChild,L=H.nextSibling,W=I.nextSibling,J=W.firstChild,j=J.nextSibling,h=W.nextSibling,T=h.firstChild,D=T.nextSibling,F=s.nextSibling,R=F.firstChild,y=R.nextSibling,B=y.firstChild,K=B.firstChild,O=K.nextSibling,ne=B.nextSibling,he=ne.firstChild,se=he.nextSibling,ae=ne.nextSibling,$e=ae.firstChild,ie=$e.nextSibling,Q=ae.nextSibling;return a(d,()=>at(n().expiresAt),P),a(L,()=>n().account.name),a(j,()=>n().account.email),a(D,()=>st(n().account.timeCreated)),y.addEventListener("submit",A=>e(A,n())),O.$$input=A=>g("currentPassword",A.currentTarget.value),se.$$input=A=>g("newPassword",A.currentTarget.value),ie.$$input=A=>g("confirmPassword",A.currentTarget.value),a(y,_(k,{get when(){return r.error},get children(){var A=G();return a(A,()=>r.error),A}}),Q),a(y,_(k,{get when(){return r.success},get children(){var A=Z();return a(A,()=>r.success),A}}),Q),a(Q,()=>r.submitting?"正在更新...":"更新密码"),f(()=>Q.disabled=r.submitting),f(()=>O.value=r.currentPassword),f(()=>se.value=r.newPassword),f(()=>ie.value=r.confirmPassword),$})()]})}})),i})()}function tt(l){const u=de(),m=me(),[v,x]=N({submitting:!1,error:""}),o=async()=>{x({submitting:!0,error:""});try{await l.onConfirm(),m.close()}catch(r){x({submitting:!1,error:r instanceof Error?r.message:u.t("account.deleteAccount.toast.error")})}};return _(xe,{get title(){return u.t("account.deleteAccount.title")},fit:!0,transition:!0,get children(){var r=Ze(),g=r.firstChild,C=g.nextSibling,S=C.firstChild,t=S.nextSibling;return a(g,()=>u.t("account.deleteAccount.description")),a(r,_(k,{get when(){return v.error},get children(){var e=G();return a(e,()=>v.error),e}}),C),S.$$click=()=>m.close(),a(S,()=>u.t("common.cancel")),t.$$click=o,a(t,(()=>{var e=z(()=>!!v.submitting);return()=>e()?"注销中...":u.t("account.deleteAccount.confirm")})()),f(e=>{var i=v.submitting,p=v.submitting;return i!==e.e&&(S.disabled=e.e=i),p!==e.t&&(t.disabled=e.t=p),e},{e:void 0,t:void 0}),r}})}function re(l){return(()=>{var u=et(),m=u.firstChild,v=m.firstChild,x=v.firstChild;return a(x,_(Se,{})),a(v,()=>l.children,null),f(()=>E(m,"data-mode",l.mode)),u})()}function rt(l,u){return(l.trim()||u.trim()||"OS").slice(0,2).toUpperCase()}function nt(l){return l==="active"?"正常":l==="frozen"?"已冻结":l==="limited"?"已限流":l==="pending"?"待激活":l||"未知"}function ce(l){return Pe(l)??""}function st(l){return l?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(be(l))):"未记录"}function at(l){const u=Math.ceil(Math.max(0,be(l)-Date.now())/36e5);return u<=0?"已":u<24?`${u} 小时后`:`${Math.ceil(u/24)} 天后`}function it(l){const u=l.trim().toLowerCase();return u?/^[a-z][a-z0-9._-]{2,31}$/.test(u)?u.includes("..")||u.endsWith(".")||u.startsWith(".")?"账户名不能以点开头/结尾,也不能包含连续的点":"":"账户名须为 3–32 位,以小写字母开头,仅含小写字母、数字、点、下划线或连字符":"请填写账户名"}function ue(l){const u=l.trim().toLowerCase();return!u||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u)||u.length>254?"请填写有效邮箱":""}function ot(l){const u=Math.max(1,Math.ceil(l/1e3));if(u<60)return`${u} 秒`;const m=Math.ceil(u/60);return m<60?`${m} 分钟`:"1 小时"}function be(l){return l<1e10?l*1e3:l}we(["input","click"]);export{mt as AccountCenterPage,dt as ForgotPasswordPage,ct as LoginPage,ut as RegisterPage};
|
|
1
|
+
import{u as ee,a as Y,b as de,c as me,d as N,o as te,i as a,e as _,f as V,g as X,t as w,h as we,S as k,m as z,j as f,s as E,k as ve,l as ge,n as _e,p as Ce,r as ye,D as xe,M as Se,q as Pe,v as fe,w as ke,x as pe,y as qe,z as Ae,A as Me,B as Te,C as oe,E as De,F as le,G as Ee}from"./index-ahqm8KFw.js";var G=w("<p class=os-auth-error>"),Ue=w('<form class=os-auth-form><label><span>账户 / 邮箱</span><input autocomplete=username placeholder=账户名或注册邮箱></label><label><span>密码</span><input autocomplete=current-password type=password placeholder=输入密码></label><button type=submit class="os-button os-button-primary os-auth-submit">'),He=w("<div class=os-auth-links><span>还没有账号?</span><a>创建账号</a><a>忘记密码?"),Le=w("<p>"),Re=w('<div class=os-auth-email-verify><button type=button class="os-button os-button-secondary os-auth-submit"></button><label><span></span><input autocomplete=one-time-code>'),Ie=w("<label><span>邀请码</span><input autocomplete=one-time-code placeholder=请输入邀请码><small class=os-auth-hint>当前已开启注册审核,需填写有效邀请码才能注册。"),Fe=w('<form class=os-auth-form><label><span>账户</span><input autocomplete=username placeholder="例如 researcher01"><small class=os-auth-hint>用作登录标识及个人工作区目录名称。长度 3–32 个字符,须以小写字母开头,仅可包含小写字母、数字、点(.)、下划线(_)与连字符(-)。</small></label><label><span>邮箱</span><input autocomplete=email inputmode=email placeholder=name@example.com><small class=os-auth-hint>用于账号找回与系统通知,亦可作为登录凭证。</small></label><label><span>密码</span><input autocomplete=new-password type=password placeholder="至少 8 位"></label><label><span>确认密码</span><input autocomplete=new-password type=password placeholder=再次输入密码></label><button type=submit class="os-button os-button-primary os-auth-submit">'),Ne=w("<div class=os-auth-links><span>已有账号?</span><a>去登录"),ze=w('<p class=os-auth-hint style="margin:0 0 0.35rem">通过注册邮箱获取验证码后重置密码。若无法收到邮件,请联系管理员。'),Z=w("<p class=os-account-success>"),je=w('<form class=os-auth-form><label><span>账号邮箱</span><input autocomplete=email inputmode=email placeholder=name@example.com></label><button type=submit class="os-button os-button-secondary os-auth-submit">'),Be=w("<label><span>邮件验证码</span><input autocomplete=one-time-code placeholder=输入邮件中的验证码>"),Oe=w('<form class=os-auth-form><label><span>新密码</span><input autocomplete=new-password type=password placeholder="至少 8 位"></label><label><span>确认新密码</span><input autocomplete=new-password type=password placeholder=再次输入新密码></label><button type=submit class="os-button os-button-primary os-auth-submit">'),Ve=w("<div class=os-auth-links><a>返回登录</a><a>创建账号"),Ge=w('<p class=os-auth-hint style="margin:0 0 0.35rem">请设置新密码以完成重置。'),We=w("<main class=os-account-page><div class=os-account-shell>"),Je=w("<section class=os-account-loading><strong>正在加载账号信息</strong><span>请稍候"),Ke=w('<section class=os-account-empty-state><strong></strong><span>登录后可以查看账号资料和开发空间。</span><a href=/login class="os-button os-button-primary">去登录'),Qe=w('<header class=os-account-header><div class=os-account-identity><div class=os-account-avatar></div><div><span class=os-account-kicker>账号中心</span><h1></h1><p></p></div></div><div class=os-account-actions><span class=os-account-status></span><a href=/code class="os-button os-button-secondary">进入科研开发</a><button type=button class="os-button os-button-danger">退出登录</button><button type=button class="os-button os-button-danger">'),Xe=w("<section class=os-account-workspace-hero><div class=os-account-workspace-hero-copy><span class=os-account-kicker>默认项目</span><strong>default</strong><p></p></div><div class=os-account-workspace-hero-meta><code>"),Ye=w('<section class=os-account-content-grid><section class=os-account-panel><div class=os-account-panel-head><strong>基本资料</strong><span class=os-account-session-expiry title="这是当前浏览器登录会话的有效期(约 14 天),不是账号本身到期。重新登录即可续期,账号与工作区数据不受影响。">登录会话 <!>失效</span></div><p class=os-account-session-expiry-note>提示:上方倒计时是登录会话有效期,重新登录即可续期;账号与工作区数据不会因此删除。</p><dl class=os-account-field-grid><div><dt>账户</dt><dd></dd></div><div><dt>邮箱</dt><dd></dd></div><div><dt>创建时间</dt><dd></dd></div><div><dt>默认入口</dt><dd>科研开发工作台</dd></div></dl></section><section class=os-account-panel><div class=os-account-panel-head><strong>修改密码</strong><span>本地账号</span></div><form class=os-account-password-form><label><span>当前密码</span><input autocomplete=current-password type=password placeholder=输入当前密码></label><label><span>新密码</span><input autocomplete=new-password type=password placeholder="至少 8 位"></label><label><span>确认新密码</span><input autocomplete=new-password type=password placeholder=再次输入新密码></label><button type=submit class="os-button os-button-danger os-auth-submit">'),Ze=w('<div class="flex flex-col gap-4 pl-6 pr-2.5 pb-3"><p class="text-14-regular text-text-strong"></p><div class="flex justify-end gap-2"><button type=button class="os-button os-button-secondary"></button><button type=button class="os-button os-button-danger">'),et=w("<main class=os-auth-page><section class=os-auth-shell><section class=os-auth-panel><a class=os-auth-brand href=/>");function ct(){const l=ee(),u=Y(),[m,v]=N({name:"",email:"",password:"",confirmPassword:"",submitting:!1,error:""}),x=()=>typeof m.lockedUntil=="number"&&m.lockedUntil>Date.now(),o=async r=>{if(r.preventDefault(),x()){v("error",`尝试次数过多,请在 ${ot(m.lockedUntil-Date.now())} 后重试`);return}if(!m.email.trim()||!m.password){v("error","请输入账户/邮箱和密码");return}v({submitting:!0,error:"",lockedUntil:void 0});try{await fe(await ke({email:m.email.trim(),password:m.password}),l.storage);const g=pe(location.search);if(l.platform==="desktop"){u(g,{replace:!0});return}location.assign(g)}catch(g){const C=g instanceof Error&&"retryAfterMs"in g?Number(g.retryAfterMs):void 0;v({error:g instanceof Error?g.message:"登录失败,请稍后重试",submitting:!1,lockedUntil:typeof C=="number"&&C>0?Date.now()+C:void 0})}};return _(re,{mode:"login",get children(){return[(()=>{var r=Ue(),g=r.firstChild,C=g.firstChild,S=C.nextSibling,t=g.nextSibling,e=t.firstChild,i=e.nextSibling,p=t.nextSibling;return r.addEventListener("submit",o),S.$$input=n=>v("email",n.currentTarget.value),i.$$input=n=>v("password",n.currentTarget.value),a(r,_(k,{get when(){return m.error},get children(){var n=G();return a(n,()=>m.error),n}}),p),a(p,(()=>{var n=z(()=>!!m.submitting);return()=>n()?"正在登录...":x()?"已锁定,请稍后重试":"登录"})()),f(n=>{var $=m.submitting,s=m.submitting,c=m.submitting||x();return $!==n.e&&(S.disabled=n.e=$),s!==n.t&&(i.disabled=n.t=s),c!==n.a&&(p.disabled=n.a=c),n},{e:void 0,t:void 0,a:void 0}),f(()=>S.value=m.email),f(()=>i.value=m.password),r})(),(()=>{var r=He(),g=r.firstChild,C=g.nextSibling,S=C.nextSibling;return f(t=>{var e=`/register${location.search}`,i=`/forgot-password${location.search}`;return e!==t.e&&E(C,"href",t.e=e),i!==t.t&&E(S,"href",t.t=i),t},{e:void 0,t:void 0}),r})()]}})}function ut(){const l=ee(),u=Y(),[m,v]=V(!1),[x,o]=V(!1),[r,g]=V(!1),[C,S]=V(Date.now()),[t,e]=N({name:"",email:"",password:"",confirmPassword:"",inviteCode:"",emailCode:"",submitting:!1,requestingCode:!1,requestHint:"",cooldownUntil:0,error:""});te(()=>{ve().then(c=>{v(!!c.inviteRequired),o(!!c.emailVerificationRequired)}).catch(()=>{v(!1),o(!1)});const s=window.setInterval(()=>S(Date.now()),250);ge(()=>window.clearInterval(s))});const i=X(()=>Math.max(0,Math.ceil(((t.cooldownUntil??0)-C())/1e3))),p=X(()=>i()>0),n=async()=>{if(t.requestingCode||t.submitting||p())return;const s=ue(t.email);if(s){e({error:s,requestHint:""});return}e({requestingCode:!0,error:"",requestHint:""});try{const c=await Ae({email:t.email.trim()}),b=typeof c.retryAfterMs=="number"&&c.retryAfterMs>0?c.retryAfterMs:6e4;if(c.smtpUnreachable){g(!0),e({requestingCode:!1,requestHint:"无法连接邮件服务器,本次注册无需填写验证码。找回密码仍须邮件验证,收不到验证码请联系管理员。",error:"",cooldownUntil:Date.now()+b});return}g(!1),e({requestingCode:!1,requestHint:"验证码已发送,请查收邮箱后填入下方。",error:"",cooldownUntil:Date.now()+b})}catch(c){const b=c instanceof Error&&"retryAfterMs"in c?Number(c.retryAfterMs):void 0;e({requestingCode:!1,error:c instanceof Error?c.message:"发送验证码失败,请稍后重试",requestHint:"",...typeof b=="number"&&b>0?{cooldownUntil:Date.now()+b}:{}})}},$=async s=>{if(s.preventDefault(),!t.name.trim()||!t.email.trim()||!t.password){e("error","请输入账户、邮箱和密码");return}const c=it(t.name);if(c){e("error",c);return}const b=ue(t.email);if(b){e("error",b);return}if(m()&&!(t.inviteCode??"").trim()){e("error","请填写邀请码");return}if(x()&&!r()&&!(t.emailCode??"").trim()){e("error","请填写邮箱验证码");return}if(t.password.length<8){e("error","密码至少需要 8 位");return}if(t.password!==t.confirmPassword){e("error","两次输入的密码不一致");return}e({submitting:!0,error:""});try{await fe(await qe({name:t.name.trim().toLowerCase(),email:t.email.trim(),password:t.password,...t.inviteCode?.trim()?{inviteCode:t.inviteCode.trim()}:{},...x()&&t.emailCode?.trim()?{emailCode:t.emailCode.trim()}:{}}),l.storage);const d=pe(location.search);if(l.platform==="desktop"){u(d,{replace:!0});return}location.assign(d)}catch(d){e("error",d instanceof Error?d.message:"注册失败,请稍后重试"),e("submitting",!1)}};return _(re,{mode:"register",get children(){return[(()=>{var s=Fe(),c=s.firstChild,b=c.firstChild,d=b.nextSibling,q=c.nextSibling,P=q.firstChild,M=P.nextSibling,U=q.nextSibling,I=U.firstChild,H=I.nextSibling,L=U.nextSibling,W=L.firstChild,J=W.nextSibling,j=L.nextSibling;return s.addEventListener("submit",$),d.$$input=h=>e("name",h.currentTarget.value),E(d,"spellcheck",!1),M.$$input=h=>{e("email",h.currentTarget.value),g(!1)},a(s,_(k,{get when(){return x()},get children(){var h=Re(),T=h.firstChild,D=T.nextSibling,F=D.firstChild,R=F.nextSibling;return T.$$click=()=>void n(),a(T,(()=>{var y=z(()=>!!t.requestingCode);return()=>y()?"正在发送...":z(()=>!!p())()?`重新发送 (${i()}s)`:"发送验证码"})()),a(h,_(k,{get when(){return t.requestHint},get children(){var y=Le();return a(y,()=>t.requestHint),f(()=>_e(y,r()?"os-auth-hint":"os-account-success")),y}}),D),a(F,()=>r()?"邮箱验证码(可不填)":"邮箱验证码"),R.$$input=y=>e("emailCode",y.currentTarget.value),E(R,"spellcheck",!1),f(y=>{var B=t.requestingCode||t.submitting||p()||!t.email.trim(),K=r()?"邮件服务器不可达,可留空":"输入邮件中的验证码",O=t.submitting;return B!==y.e&&(T.disabled=y.e=B),K!==y.t&&E(R,"placeholder",y.t=K),O!==y.a&&(R.disabled=y.a=O),y},{e:void 0,t:void 0,a:void 0}),f(()=>R.value=t.emailCode??""),h}}),U),a(s,_(k,{get when(){return m()},get children(){var h=Ie(),T=h.firstChild,D=T.nextSibling;return D.$$input=F=>e("inviteCode",F.currentTarget.value),E(D,"spellcheck",!1),f(()=>D.value=t.inviteCode??""),h}}),U),H.$$input=h=>e("password",h.currentTarget.value),J.$$input=h=>e("confirmPassword",h.currentTarget.value),a(s,_(k,{get when(){return t.error},get children(){var h=G();return a(h,()=>t.error),h}}),j),a(j,()=>t.submitting?"正在创建...":"创建账号"),f(h=>{var T=t.submitting||t.requestingCode,D=t.submitting;return T!==h.e&&(M.disabled=h.e=T),D!==h.t&&(j.disabled=h.t=D),h},{e:void 0,t:void 0}),f(()=>d.value=t.name),f(()=>M.value=t.email),f(()=>H.value=t.password),f(()=>J.value=t.confirmPassword),s})(),(()=>{var s=Ne(),c=s.firstChild,b=c.nextSibling;return f(()=>E(b,"href",`/login${location.search}`)),s})()]}})}function dt(){const l=Y(),u=typeof location<"u"?new URLSearchParams(location.search).get("token")?.trim()??"":"",m=!!u,[v,x]=V(Date.now()),[o,r]=N({email:"",token:u,newPassword:"",confirmPassword:"",requesting:!1,submitting:!1,error:"",success:"",requestHint:"",cooldownUntil:0});te(()=>{const e=window.setInterval(()=>x(Date.now()),250);ge(()=>window.clearInterval(e))});const g=X(()=>Math.max(0,Math.ceil((o.cooldownUntil-v())/1e3))),C=X(()=>g()>0),S=async()=>{if(!(o.requesting||o.submitting||C())){if(!o.email.trim()){r({error:"请输入账号邮箱",success:"",requestHint:""});return}r({requesting:!0,error:"",success:"",requestHint:""});try{const e=await Me({email:o.email.trim()}),i=typeof e.retryAfterMs=="number"&&e.retryAfterMs>0?e.retryAfterMs:6e4;r({requesting:!1,requestHint:"若该邮箱已注册,验证码将发送至邮箱。请查收后在下方完成重置。",error:"",cooldownUntil:Date.now()+i})}catch(e){const i=e instanceof Error&&"retryAfterMs"in e?Number(e.retryAfterMs):void 0;r({requesting:!1,error:e instanceof Error?e.message:"发送验证码失败,请稍后重试",requestHint:"",...typeof i=="number"&&i>0?{cooldownUntil:Date.now()+i}:{}})}}},t=async e=>{if(e.preventDefault(),!o.token.trim()){r({error:"请输入邮件验证码",success:""});return}if(o.newPassword.length<8){r({error:"新密码至少需要 8 位",success:""});return}if(o.newPassword!==o.confirmPassword){r({error:"两次输入的新密码不一致",success:""});return}r({submitting:!0,error:"",success:""});try{await Te({token:o.token.trim(),newPassword:o.newPassword}),r({submitting:!1,error:"",success:"密码已重置,请使用新密码登录",newPassword:"",confirmPassword:""});const i=new URLSearchParams(location.search);i.delete("token");const p=i.toString();window.setTimeout(()=>l(`/login${p?`?${p}`:""}`,{replace:!0}),1200)}catch(i){r({submitting:!1,error:i instanceof Error?i.message:"重置密码失败,请稍后重试",success:""})}};return _(re,{mode:"forgot-password",get children(){return[_(k,{when:!m,get fallback(){return Ge()},get children(){return ze()}}),_(k,{when:!m,get children(){var e=je(),i=e.firstChild,p=i.firstChild,n=p.nextSibling,$=i.nextSibling;return e.addEventListener("submit",s=>{s.preventDefault(),S()}),n.$$input=s=>r("email",s.currentTarget.value),a($,(()=>{var s=z(()=>!!o.requesting);return()=>s()?"正在发送...":z(()=>!!C())()?`重新发送 (${g()}s)`:"获取验证码"})()),a(e,_(k,{get when(){return o.requestHint},get children(){var s=Z();return a(s,()=>o.requestHint),s}}),null),f(s=>{var c=o.requesting||o.submitting,b=o.requesting||o.submitting||C()||!o.email.trim();return c!==s.e&&(n.disabled=s.e=c),b!==s.t&&($.disabled=s.t=b),s},{e:void 0,t:void 0}),f(()=>n.value=o.email),e}}),(()=>{var e=Oe(),i=e.firstChild,p=i.firstChild,n=p.nextSibling,$=i.nextSibling,s=$.firstChild,c=s.nextSibling,b=$.nextSibling;return e.addEventListener("submit",t),a(e,_(k,{when:!m,get children(){var d=Be(),q=d.firstChild,P=q.nextSibling;return P.$$input=M=>r("token",M.currentTarget.value),f(()=>P.disabled=o.submitting),f(()=>P.value=o.token),d}}),i),n.$$input=d=>r("newPassword",d.currentTarget.value),c.$$input=d=>r("confirmPassword",d.currentTarget.value),a(e,_(k,{get when(){return o.error},get children(){var d=G();return a(d,()=>o.error),d}}),b),a(e,_(k,{get when(){return o.success},get children(){var d=Z();return a(d,()=>o.success),d}}),b),a(b,()=>o.submitting?"正在重置...":"重置密码"),f(d=>{var q=o.submitting,P=o.submitting,M=o.submitting;return q!==d.e&&(n.disabled=d.e=q),P!==d.t&&(c.disabled=d.t=P),M!==d.a&&(b.disabled=d.a=M),d},{e:void 0,t:void 0,a:void 0}),f(()=>n.value=o.newPassword),f(()=>c.value=o.confirmPassword),e})(),(()=>{var e=Ve(),i=e.firstChild,p=i.nextSibling;return f(n=>{var $=`/login${location.search}`,s=`/register${location.search}`;return $!==n.e&&E(i,"href",n.e=$),s!==n.t&&E(p,"href",n.t=s),n},{e:void 0,t:void 0}),e})()]}})}function mt(){const l=ee(),u=Y(),m=de(),v=me(),[x,o]=N({loading:!0,error:""}),[r,g]=N({currentPassword:"",newPassword:"",confirmPassword:"",submitting:!1,error:"",success:""});te(()=>{const i=Ce();if(!i){o({loading:!1,error:"当前未登录"});return}ye(i).then(p=>o({session:p,loading:!1,error:""})).catch(p=>o({loading:!1,error:p instanceof Error?p.message:"会话已失效"}))});const C=()=>{if(l.platform==="desktop"){u("/login",{replace:!0});return}location.assign("/login")},S=()=>{oe(l.storage).finally(()=>C())},t=async()=>{try{await De(),le({variant:"success",icon:"circle-check",title:m.t("account.deleteAccount.toast.success")}),await oe(l.storage),C()}catch(i){le({variant:"error",title:m.t("account.deleteAccount.toast.error"),description:i instanceof Error?i.message:"请稍后重试"})}},e=async(i,p)=>{if(i.preventDefault(),!r.currentPassword||!r.newPassword||!r.confirmPassword){g({error:"请输入当前密码和新密码",success:""});return}if(r.newPassword.length<8){g({error:"新密码至少需要 8 位",success:""});return}if(r.currentPassword===r.newPassword){g({error:"新密码不能与当前密码相同",success:""});return}if(r.newPassword!==r.confirmPassword){g({error:"两次输入的新密码不一致",success:""});return}g({submitting:!0,error:"",success:""});try{await Ee({accountId:p.account.id,currentPassword:r.currentPassword,newPassword:r.newPassword}),g({currentPassword:"",newPassword:"",confirmPassword:"",submitting:!1,error:"",success:"密码已更新,下次登录请使用新密码"})}catch(n){g({submitting:!1,error:n instanceof Error?n.message:"修改密码失败,请稍后重试",success:""})}};return(()=>{var i=We(),p=i.firstChild;return a(p,_(k,{get when(){return!x.loading},get fallback(){return Je()},get children(){return _(k,{get when(){return x.session},get fallback(){return(()=>{var n=Ke(),$=n.firstChild;return a($,()=>x.error||"当前未登录"),n})()},children:n=>[(()=>{var $=Qe(),s=$.firstChild,c=s.firstChild,b=c.nextSibling,d=b.firstChild,q=d.nextSibling,P=q.nextSibling,M=s.nextSibling,U=M.firstChild,I=U.nextSibling,H=I.nextSibling,L=H.nextSibling;return a(c,()=>rt(n().account.name,n().account.email)),a(q,()=>n().account.name),a(P,()=>n().account.email),a(U,()=>nt(n().account.status)),H.$$click=S,L.$$click=()=>v.show(()=>_(tt,{onConfirm:t})),a(L,()=>m.t("account.deleteAccount.button")),$})(),(()=>{var $=Xe(),s=$.firstChild,c=s.firstChild,b=c.nextSibling,d=b.nextSibling,q=s.nextSibling,P=q.firstChild;return a(d,()=>m.t("account.defaultProject.description")),a(P,()=>ce(n())||"未分配"),f(()=>E(P,"title",ce(n()))),$})(),(()=>{var $=Ye(),s=$.firstChild,c=s.firstChild,b=c.firstChild,d=b.nextSibling,q=d.firstChild,P=q.nextSibling;P.nextSibling;var M=c.nextSibling,U=M.nextSibling,I=U.firstChild,H=I.firstChild,L=H.nextSibling,W=I.nextSibling,J=W.firstChild,j=J.nextSibling,h=W.nextSibling,T=h.firstChild,D=T.nextSibling,F=s.nextSibling,R=F.firstChild,y=R.nextSibling,B=y.firstChild,K=B.firstChild,O=K.nextSibling,ne=B.nextSibling,he=ne.firstChild,se=he.nextSibling,ae=ne.nextSibling,$e=ae.firstChild,ie=$e.nextSibling,Q=ae.nextSibling;return a(d,()=>at(n().expiresAt),P),a(L,()=>n().account.name),a(j,()=>n().account.email),a(D,()=>st(n().account.timeCreated)),y.addEventListener("submit",A=>e(A,n())),O.$$input=A=>g("currentPassword",A.currentTarget.value),se.$$input=A=>g("newPassword",A.currentTarget.value),ie.$$input=A=>g("confirmPassword",A.currentTarget.value),a(y,_(k,{get when(){return r.error},get children(){var A=G();return a(A,()=>r.error),A}}),Q),a(y,_(k,{get when(){return r.success},get children(){var A=Z();return a(A,()=>r.success),A}}),Q),a(Q,()=>r.submitting?"正在更新...":"更新密码"),f(()=>Q.disabled=r.submitting),f(()=>O.value=r.currentPassword),f(()=>se.value=r.newPassword),f(()=>ie.value=r.confirmPassword),$})()]})}})),i})()}function tt(l){const u=de(),m=me(),[v,x]=N({submitting:!1,error:""}),o=async()=>{x({submitting:!0,error:""});try{await l.onConfirm(),m.close()}catch(r){x({submitting:!1,error:r instanceof Error?r.message:u.t("account.deleteAccount.toast.error")})}};return _(xe,{get title(){return u.t("account.deleteAccount.title")},fit:!0,transition:!0,get children(){var r=Ze(),g=r.firstChild,C=g.nextSibling,S=C.firstChild,t=S.nextSibling;return a(g,()=>u.t("account.deleteAccount.description")),a(r,_(k,{get when(){return v.error},get children(){var e=G();return a(e,()=>v.error),e}}),C),S.$$click=()=>m.close(),a(S,()=>u.t("common.cancel")),t.$$click=o,a(t,(()=>{var e=z(()=>!!v.submitting);return()=>e()?"注销中...":u.t("account.deleteAccount.confirm")})()),f(e=>{var i=v.submitting,p=v.submitting;return i!==e.e&&(S.disabled=e.e=i),p!==e.t&&(t.disabled=e.t=p),e},{e:void 0,t:void 0}),r}})}function re(l){return(()=>{var u=et(),m=u.firstChild,v=m.firstChild,x=v.firstChild;return a(x,_(Se,{})),a(v,()=>l.children,null),f(()=>E(m,"data-mode",l.mode)),u})()}function rt(l,u){return(l.trim()||u.trim()||"OS").slice(0,2).toUpperCase()}function nt(l){return l==="active"?"正常":l==="frozen"?"已冻结":l==="limited"?"已限流":l==="pending"?"待激活":l||"未知"}function ce(l){return Pe(l)??""}function st(l){return l?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(be(l))):"未记录"}function at(l){const u=Math.ceil(Math.max(0,be(l)-Date.now())/36e5);return u<=0?"已":u<24?`${u} 小时后`:`${Math.ceil(u/24)} 天后`}function it(l){const u=l.trim().toLowerCase();return u?/^[a-z][a-z0-9._-]{2,31}$/.test(u)?u.includes("..")||u.endsWith(".")||u.startsWith(".")?"账户名不能以点开头/结尾,也不能包含连续的点":"":"账户名须为 3–32 位,以小写字母开头,仅含小写字母、数字、点、下划线或连字符":"请填写账户名"}function ue(l){const u=l.trim().toLowerCase();return!u||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u)||u.length>254?"请填写有效邮箱":""}function ot(l){const u=Math.max(1,Math.ceil(l/1e3));if(u<60)return`${u} 秒`;const m=Math.ceil(u/60);return m<60?`${m} 分钟`:"1 小时"}function be(l){return l<1e10?l*1e3:l}we(["input","click"]);export{mt as AccountCenterPage,dt as ForgotPasswordPage,ct as LoginPage,ut as RegisterPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/alert-01-BuOD_o_q.aac";export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/alert-02-CS75AsoP.aac";export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/alert-04-CaGsIGFP.aac";export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/alert-05-D2gbGoRH.aac";export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/alert-06-GK5Tqy6u.aac";export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/alert-07-0r0kiLGz.aac";export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/alert-08-CZowNquU.aac";export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/alert-10-Ck5hR7zH.aac";export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/bip-bop-03-DXp7Zb0f.aac";export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/bip-bop-04-CfVtpI7z.aac";export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/bip-bop-06-BuvNosjK.aac";export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/bip-bop-08-DBf7Bwjz.aac";export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="https://cdn.jsdelivr.net/npm/@onescience/onecode-web@1.14.50-202608311810/assets/bip-bop-09-CxEgoAHQ.aac";export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as y,H as C,I as D,b as E,d as k,f as R,X as z,g as u,Y as K,Z as M,$ as G,a0 as H,K as L,a1 as T,e as n,i as a,T as W,a2 as A,S as B,W as v,m as I,D as X,t as S}from"./index-ahqm8KFw.js";var Y=S('<p class="text-12-regular text-text-critical-base">'),Z=S('<form class="flex flex-col gap-6 p-6 pt-0"><div class="flex flex-col gap-4"><p class="text-12-regular text-text-weak"></p><div class="flex flex-col gap-2"><span class="text-14-medium text-text-strong"></span><p class="text-12-regular text-text-weak"></p></div></div><div class="flex justify-end gap-2">');function J(b){const d=y(),F=C(),$=D(),t=E(),[l,j]=k({name:""}),[m,_]=R(z()),i=u(()=>K(M())||$.data.path.project_data_root||"/data"),w=u(()=>{const e=G(l.name,i());return e?`${e}/`:`${i()}/`}),g=u(()=>!!H(l.name)),o=L(()=>({mutationFn:async()=>{const r=(await F.client.path.mkdir({name:l.name.trim()})).data?.path;if(!r)throw new Error("missing path");return r},onSuccess:e=>{T(e,m()),b.onCreated(e),d.close()}}));function P(e){e.preventDefault(),!(o.isPending||!g())&&o.mutate()}return n(X,{get title(){return t.t("command.project.createFolder")},class:"w-full max-w-[480px] mx-auto",get children(){var e=Z(),r=e.firstChild,c=r.firstChild,p=c.nextSibling,f=p.firstChild,x=f.nextSibling,h=r.nextSibling;return e.addEventListener("submit",P),a(r,n(W,{autofocus:!0,type:"text",get label(){return t.t("dialog.project.createFolder.name")},get placeholder(){return t.t("dialog.project.createFolder.placeholder")},get value(){return l.name},onChange:s=>j("name",s)}),c),a(c,()=>t.t("dialog.project.createFolder.path",{path:w()})),a(f,()=>t.t("dialog.project.createFolder.environment")),a(p,n(A,{directory:i,value:m,onChange:_,variant:"field",hideScnet:!0}),x),a(x,()=>t.t("dialog.project.createFolder.environmentHint")),a(r,n(B,{get when(){return o.isError},get children(){var s=Y();return a(s,()=>t.t("dialog.project.createFolder.failed")),s}}),null),a(h,n(v,{type:"button",variant:"ghost",size:"large",onClick:()=>d.close(),get children(){return t.t("common.cancel")}}),null),a(h,n(v,{type:"submit",variant:"primary",size:"large",get disabled(){return o.isPending||!g()},get children(){return I(()=>!!o.isPending)()?t.t("common.confirming"):t.t("common.confirm")}}),null),e}})}export{J as DialogCreateProjectFolder};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as te,H as re,I as ae,b as ie,g as P,J as oe,d as ne,K as le,e as c,i,T as F,S as I,j as $,s as j,L as R,N as K,O as T,P as se,Q as M,R as ce,U as de,V as N,W as G,m as ue,D as ve,t as p,h as ge}from"./index-
|
|
1
|
+
import{c as te,H as re,I as ae,b as ie,g as P,J as oe,d as ne,K as le,e as c,i,T as F,S as I,j as $,s as j,L as R,N as K,O as T,P as se,Q as M,R as ce,U as de,V as N,W as G,m as ue,D as ve,t as p,h as ge}from"./index-ahqm8KFw.js";var fe=p('<div class="flex flex-col gap-2"><label class="text-12-medium text-text-weak"></label><div class="flex gap-1.5">'),me=p('<form class="flex flex-col gap-6 p-6 pt-0"><div class="flex flex-col gap-4"><div class="flex flex-col gap-2"><label class="text-12-medium text-text-weak"></label><div class="flex gap-3 items-start"><div class=relative><div class="relative size-16 rounded-md transition-colors cursor-pointer"></div><div class="absolute inset-0 size-16 bg-surface-raised-stronger-non-alpha/90 rounded-[6px] z-10 pointer-events-none flex items-center justify-center transition-opacity"></div><div class="absolute inset-0 size-16 bg-surface-raised-stronger-non-alpha/90 rounded-[6px] z-10 pointer-events-none flex items-center justify-center transition-opacity"></div></div><input id=icon-upload type=file accept=image/* class=hidden><div class="flex flex-col gap-1.5 text-12-regular text-text-weak self-center"><span></span><span></span></div></div></div></div><div class="flex justify-end gap-2">'),pe=p('<div class="size-full flex items-center justify-center">'),be=p('<img class="size-full object-cover">'),he=p("<button type=button>");const xe=["pink","mint","orange","purple","cyan","lime"];function we(o){const w=te(),U=re(),L=ae(),n=ie(),y=P(()=>oe(o.project.worktree)),O=P(()=>o.project.name||y()),[e,d]=ne({name:O(),color:o.project.icon?.color,iconOverride:o.project.icon?.override,startup:o.project.commands?.start??"",dragOver:!1,iconHover:!1});let _;function z(r){if(!r.type.startsWith("image/"))return;const a=new FileReader;a.onload=f=>{d("iconOverride",f.target?.result),d("iconHover",!1)},a.readAsDataURL(r)}function V(r){r.preventDefault(),d("dragOver",!1);const a=r.dataTransfer?.files[0];a&&z(a)}function W(r){r.preventDefault(),d("dragOver",!0)}function B(){d("dragOver",!1)}function J(r){const f=r.target.files?.[0];f&&z(f)}function Q(){d("iconOverride","")}const b=le(()=>({mutationFn:async()=>{const r=e.name.trim()===y()?"":e.name.trim(),a=e.startup.trim();if(o.project.id&&o.project.id!=="global"){await U.client.project.update({projectID:o.project.id,directory:o.project.worktree,name:r,icon:{color:e.color||"",override:e.iconOverride||""},commands:{start:a}}),L.project.icon(o.project.worktree,e.iconOverride||void 0),w.close();return}L.project.meta(o.project.worktree,{name:r,icon:{color:e.color||void 0,override:e.iconOverride||void 0},commands:{start:a||void 0}}),w.close()}}));function Y(r){r.preventDefault(),!b.isPending&&b.mutate()}return c(ve,{get title(){return n.t("dialog.project.edit.title")},class:"w-full max-w-[480px] mx-auto",get children(){var r=me(),a=r.firstChild,f=a.firstChild,C=f.firstChild,q=C.nextSibling,h=q.firstChild,m=h.firstChild,x=m.nextSibling,k=x.nextSibling,S=h.nextSibling,X=S.nextSibling,D=X.firstChild,Z=D.nextSibling,E=a.nextSibling;return r.addEventListener("submit",Y),i(a,c(F,{autofocus:!0,type:"text",get label(){return n.t("dialog.project.edit.name")},get placeholder(){return y()},get value(){return e.name},onChange:t=>d("name",t)}),f),i(C,()=>n.t("dialog.project.edit.icon")),h.addEventListener("mouseleave",()=>d("iconHover",!1)),h.addEventListener("mouseenter",()=>d("iconHover",!0)),m.$$click=()=>{e.iconOverride&&e.iconHover?Q():_?.click()},m.addEventListener("dragleave",B),m.addEventListener("dragover",W),m.addEventListener("drop",V),i(m,c(I,{get when(){return se(o.project.id,{color:e.color,url:o.project.icon?.url,override:e.iconOverride})},get fallback(){return(()=>{var t=pe();return i(t,c(R,K({get fallback(){return e.name||O()}},()=>T(e.color),{class:"size-full text-[32px]"}))),t})()},children:t=>(()=>{var g=be();return $(u=>{var l=t(),s=n.t("dialog.project.edit.icon.alt");return l!==u.e&&j(g,"src",u.e=l),s!==u.t&&j(g,"alt",u.t=s),u},{e:void 0,t:void 0}),g})()})),i(x,c(M,{name:"cloud-upload",size:"large",class:"text-icon-on-interactive-base drop-shadow-sm"})),i(k,c(M,{name:"trash",size:"large",class:"text-icon-on-interactive-base drop-shadow-sm"})),S.addEventListener("change",J),ce(t=>{_=t},S),i(D,()=>n.t("dialog.project.edit.icon.hint")),i(Z,()=>n.t("dialog.project.edit.icon.recommended")),i(a,c(I,{get when(){return!e.iconOverride},get children(){var t=fe(),g=t.firstChild,u=g.nextSibling;return i(g,()=>n.t("dialog.project.edit.color")),i(u,c(de,{each:xe,children:l=>(()=>{var s=he();return s.$$click=()=>{e.color===l&&!o.project.icon?.url||d("color",e.color===l?void 0:l)},i(s,c(R,K({get fallback(){return e.name||O()}},()=>T(l),{class:"size-full rounded"}))),$(v=>{var H=n.t("dialog.project.edit.color.select",{color:l}),A=e.color===l,ee={"flex items-center justify-center size-10 p-0.5 rounded-lg overflow-hidden transition-colors cursor-default":!0,"bg-transparent border-2 border-icon-strong-base hover:bg-surface-base-hover":e.color===l,"bg-transparent border border-transparent hover:bg-surface-base-hover hover:border-border-weak-base":e.color!==l};return H!==v.e&&j(s,"aria-label",v.e=H),A!==v.t&&j(s,"aria-pressed",v.t=A),v.a=N(s,ee,v.a),v},{e:void 0,t:void 0,a:void 0}),s})()})),t}}),null),i(a,c(F,{multiline:!0,get label(){return n.t("dialog.project.edit.worktree.startup")},get description(){return n.t("dialog.project.edit.worktree.startup.description")},get placeholder(){return n.t("dialog.project.edit.worktree.startup.placeholder")},get value(){return e.startup},onChange:t=>d("startup",t),spellcheck:!1,class:"max-h-14 w-full overflow-y-auto font-mono text-xs"}),null),i(E,c(G,{type:"button",variant:"ghost",size:"large",onClick:()=>w.close(),get children(){return n.t("common.cancel")}}),null),i(E,c(G,{type:"submit",variant:"primary",size:"large",get disabled(){return b.isPending},get children(){return ue(()=>!!b.isPending)()?n.t("common.saving"):n.t("common.save")}}),null),$(t=>{var g={"border-text-interactive-base bg-surface-info-base/20":e.dragOver,"border-border-base hover:border-border-strong":!e.dragOver,"overflow-hidden":!!e.iconOverride},u=!!(e.iconHover&&!e.iconOverride),l=!(e.iconHover&&!e.iconOverride),s=!!(e.iconHover&&e.iconOverride),v=!(e.iconHover&&e.iconOverride);return t.e=N(m,g,t.e),u!==t.t&&x.classList.toggle("opacity-100",t.t=u),l!==t.a&&x.classList.toggle("opacity-0",t.a=l),s!==t.o&&k.classList.toggle("opacity-100",t.o=s),v!==t.i&&k.classList.toggle("opacity-0",t.i=v),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r}})}ge(["click"]);export{we as DialogEditProject};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aQ as S,at as v,a as k,aJ as F,aK as P,aR as _,c as w,b as L,g as $,e as d,a9 as b,i as u,D as I,aS as K,aB as T,F as g,aA as q,t as C}from"./index-ahqm8KFw.js";var E=C('<div class="w-full flex items-center gap-2"><span class="truncate flex-1 min-w-0 text-left font-normal"></span><span class="text-text-weak shrink-0 font-normal">');function M(i){return i.toLocaleTimeString(void 0,{timeStyle:"short"})}const R=()=>{const i=S(),p=v(),f=k(),c=F(),l=P(),h=_(),x=w(),n=L(),y=$(()=>{const t=i.id;if(!t)return[];const a=c.data.message[t]??[],o=[];for(const s of a){if(s.role!=="user")continue;const e=(c.data.part[s.id]??[]).find(r=>r.type==="text"&&!r.synthetic&&!r.ignored);e&&o.push({id:s.id,text:e.text.replace(/\n/g," ").slice(0,200),time:M(new Date(s.time.created))})}return o.reverse()}),D=t=>{if(!t)return;const a=i.id;if(!a)return;const o=c.data.part[t.id]??[],s=K(o,{directory:l.directory,attachmentName:n.t("common.attachment")}),m=T(l.directory);l.client.session.fork({sessionID:a,messageID:t.id}).then(e=>{if(!e.data){g({title:n.t("common.requestFailed")});return}x.close(),h.set(s,void 0,{dir:m,id:e.data.id}),f(q(p.pathname,m,e.data.id))}).catch(e=>{const r=e instanceof Error?e.message:String(e);g({title:n.t("common.requestFailed"),description:r})})};return d(I,{get title(){return n.t("command.session.fork")},get children(){return d(b,{class:"flex-1 min-h-0 [&_[data-slot=list-scroll]]:flex-1 [&_[data-slot=list-scroll]]:min-h-0",get search(){return{placeholder:n.t("common.search.placeholder"),autofocus:!0}},get emptyMessage(){return n.t("dialog.fork.empty")},key:t=>t.id,items:y,filterKeys:["text"],onSelect:D,children:t=>(()=>{var a=E(),o=a.firstChild,s=o.nextSibling;return u(o,()=>t.text),u(s,()=>t.time),a})()})}})};export{R as DialogFork};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as oe,b as se,
|
|
2
|
-
`)),(i>0||c>0)&&b.onUploaded?.()};return n(ve,{get title(){return r.t("command.project.upload")},class:"w-full max-w-[520px] mx-auto",get children(){var l=Ee(),a=l.firstChild,i=a.firstChild,c=i.nextSibling,m=c.firstChild,y=c.nextSibling,d=a.nextSibling,u=d.firstChild,v=u.nextSibling,w=d.nextSibling,ae=w.firstChild,_=w.nextSibling;return t(i,()=>r.t("dialog.project.upload.destinationLabel")),t(c,te,m),t(y,()=>r.t("dialog.project.upload.destinationHint")),t(d,n(k,{type:"button",variant:"secondary",size:"large",get disabled(){return h()},onClick:()=>H?.click(),get children(){return r.t("dialog.project.upload.pickFiles")}}),u),t(d,n(k,{type:"button",variant:"secondary",size:"large",get disabled(){return h()},onClick:()=>M?.click(),get children(){return r.t("dialog.project.upload.pickFolder")}}),u),u.addEventListener("change",e=>{N(e.currentTarget.files),e.currentTarget.value=""}),
|
|
1
|
+
import{c as oe,b as se,a5 as ce,I as de,f as g,g as x,ah as ue,ai as ge,aj as pe,ak as fe,al as he,e as n,i as t,W as k,R as G,S as p,m as V,am as U,an as X,U as xe,ao as me,D as ve,t as f,ap as we,aq as be,F as ye}from"./index-ahqm8KFw.js";var _e=f('<p class="text-12-regular text-icon-warning-base">'),L=f('<p class="text-12-regular text-text-weak">'),$e=f('<ul class="max-h-36 overflow-auto text-12-regular text-text-weak font-mono">'),Se=f('<div class="flex flex-col gap-2 rounded-md border border-border-weak-base bg-background-weak px-3 py-3"><p class="text-13-medium text-text-strong">'),ke=f("<p class=text-text-critical-base>"),je=f('<p class="text-12-regular text-text-critical-base whitespace-pre-wrap">'),Ee=f('<div class="flex flex-col gap-5 p-6 pt-0"><div class="flex flex-col gap-2"><p class="text-12-regular text-text-weak"></p><p class="text-13-medium text-text-strong break-all font-mono">/</p><p class="text-12-regular text-text-weak"></p></div><div class="flex flex-wrap gap-2"><input type=file class=hidden multiple><input type=file class=hidden multiple></div><div class="flex flex-col gap-1 text-12-regular text-text-weak"><p></p></div><div class="flex justify-end gap-2">'),Ce=f("<li class=truncate>");function Le(b){const F=oe(),r=se(),D=ce(),J=de(),[s,K]=g([]),[Q,Y]=g(!1),[T,Z]=g(!1),[I,B]=g(),[ee,j]=g(!0),[h,P]=g(!1),[z,R]=g({done:0,total:0,written:0,skipped:0,failed:0}),[A,$]=g("");let H,M;const te=x(()=>{const l=J.data.path.home,a=b.directory;return l&&a.startsWith(l)?`~${a.slice(l.length)}`:a}),E=x(()=>ue(s())),S=x(()=>ge(s())),O=x(()=>{const l=I();return l===void 0?!1:E()>l}),W=x(()=>s().length>0&&!h()&&!O()),C=x(()=>s().slice(0,pe)),re=x(()=>s().length>0&&!S());fe(()=>{const l=b.directory,a=D.current?.http;if(!l||!a){j(!1);return}let i=!1;return j(!0),he(a.url,l).then(c=>{i||B(c.availableBytes)}).catch(()=>{i||B(void 0)}).finally(()=>{i||j(!1)}),()=>{i=!0}});const N=l=>{if(!l?.length)return;$("");const a=we(l);K(a.entries),Y(a.truncated),a.truncated&&$(r.t("dialog.project.upload.tooManyFiles",{max:String(X),selected:String(a.totalSelected)}))},le=async()=>{const l=D.current?.http;if(!l||!W())return;const a=s();P(!0),$(""),R({done:0,total:a.length,written:0,skipped:0,failed:0});let i=0,c=0,m=0;const y=[];for(let d=0;d<a.length;d+=1){const u=a[d];try{(await be(l.url,b.directory,{path:u.path,file:u.file,overwrite:T()})).status==="written"?i+=1:c+=1}catch(v){m+=1;const w=v instanceof Error?v.message:r.t("dialog.project.upload.failed");y.length<3&&y.push(`${u.path}: ${w}`)}R({done:d+1,total:a.length,written:i,skipped:c,failed:m})}if(P(!1),m===0){ye({title:r.t("toast.project.upload.success",{written:String(i),skipped:String(c)})}),b.onUploaded?.(),F.close();return}$([r.t("dialog.project.upload.partialFailed",{written:String(i),skipped:String(c),failed:String(m)}),...y].join(`
|
|
2
|
+
`)),(i>0||c>0)&&b.onUploaded?.()};return n(ve,{get title(){return r.t("command.project.upload")},class:"w-full max-w-[520px] mx-auto",get children(){var l=Ee(),a=l.firstChild,i=a.firstChild,c=i.nextSibling,m=c.firstChild,y=c.nextSibling,d=a.nextSibling,u=d.firstChild,v=u.nextSibling,w=d.nextSibling,ae=w.firstChild,_=w.nextSibling;return t(i,()=>r.t("dialog.project.upload.destinationLabel")),t(c,te,m),t(y,()=>r.t("dialog.project.upload.destinationHint")),t(d,n(k,{type:"button",variant:"secondary",size:"large",get disabled(){return h()},onClick:()=>H?.click(),get children(){return r.t("dialog.project.upload.pickFiles")}}),u),t(d,n(k,{type:"button",variant:"secondary",size:"large",get disabled(){return h()},onClick:()=>M?.click(),get children(){return r.t("dialog.project.upload.pickFolder")}}),u),u.addEventListener("change",e=>{N(e.currentTarget.files),e.currentTarget.value=""}),G(e=>{H=e},u),v.addEventListener("change",e=>{N(e.currentTarget.files),e.currentTarget.value=""}),G(e=>{M=e,e&&e.setAttribute("webkitdirectory","")},v),t(l,n(p,{get when(){return s().length>0},get children(){var e=Se(),ne=e.firstChild;return t(ne,(()=>{var o=V(()=>!!S());return()=>o()?r.t("dialog.project.upload.folderSummary",{folder:S(),count:String(s().length),size:U(E())}):r.t("dialog.project.upload.summary",{count:String(s().length),size:U(E())})})()),t(e,n(p,{get when(){return Q()},get children(){var o=_e();return t(o,()=>r.t("dialog.project.upload.truncatedHint",{max:String(X)})),o}}),null),t(e,n(p,{get when(){return S()},get children(){var o=L();return t(o,()=>r.t("dialog.project.upload.folderHint")),o}}),null),t(e,n(p,{get when(){return re()},get children(){return[(()=>{var o=$e();return t(o,n(xe,{get each(){return C()},children:ie=>(()=>{var q=Ce();return t(q,()=>ie.path),q})()})),o})(),n(p,{get when(){return s().length>C().length},get children(){var o=L();return t(o,()=>r.t("dialog.project.upload.moreFiles",{count:String(s().length-C().length)})),o}})]}}),null),e}}),w),t(ae,()=>r.t("dialog.project.upload.diskSpace",{space:ee()?r.t("common.loading"):U(I())})),t(w,n(p,{get when(){return O()},get children(){var e=ke();return t(e,()=>r.t("dialog.project.upload.diskInsufficient")),e}}),null),t(l,n(me,{get checked(){return T()},onChange:Z,get disabled(){return h()},get children(){return r.t("dialog.project.upload.overwrite")}}),_),t(l,n(p,{get when(){return h()},get children(){var e=L();return t(e,()=>r.t("dialog.project.upload.progress",{done:String(z().done),total:String(z().total)})),e}}),_),t(l,n(p,{get when(){return A()},get children(){var e=je();return t(e,A),e}}),_),t(_,n(k,{type:"button",variant:"ghost",size:"large",get disabled(){return h()},onClick:()=>F.close(),get children(){return r.t("common.cancel")}}),null),t(_,n(k,{type:"button",variant:"primary",size:"large",get disabled(){return!W()},onClick:()=>void le(),get children(){return V(()=>!!h())()?r.t("dialog.project.upload.uploading"):r.t("dialog.project.upload.confirm")}}),null),l}})}export{Le as DialogProjectUpload};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`);return{absolute:n,search:b,group:o}}function Dt(e){const t=new Set;return e.filter(o=>t.has(o.absolute)?!1:(t.add(o.absolute),!0))}function q(e,t){const o=O(t,t),n=O(e,t);return n===o?{directory:o,path:""}:{directory:o,path:n.slice(o.length+1)}}function $t(e){const t=new Map;let o=0;const n=f=>O(f,e.root()),m=f=>{const a=e.start();if(!a)return;const i=e.root(),h=R(f);if(!h)return{directory:n(p(a)),path:""};const w=e.home();if(h==="~")return{directory:n(p(w||a)),path:""};if(h.startsWith("~/")){const y=kt(w||a,h.slice(2));return z(y,i)?q(y,i):{directory:n(p(a)),path:""}}if(M(h)){const y=p(h);return z(y,i)?q(y,i):{directory:n(p(a)),path:""}}return{directory:n(p(a)),path:h}},c=async f=>{const a=n(p(f)),i=t.get(a);if(i)return i;const h=pt(e.apiRoot(),a);if(h===void 0&&p(a).toLowerCase()!==p(e.apiRoot()).toLowerCase())return t.set(a,Promise.resolve([])),[];const w=mt(e.sdk,h??"",{fetch:e.fetch,headers:e.headers?.()}).then(u=>u.filter(y=>!y.name.startsWith(".")).filter(y=>z(y.absolute,e.root())).map(y=>({name:y.name,absolute:p(R(y.absolute))})));return t.set(a,w),w},b=async(f,a,i)=>
|
|
1
|
+
import{a3 as J,I as N,H as Q,a4 as U,c as tt,b as et,u as rt,a5 as nt,f as st,g as P,a6 as ot,a7 as at,Y as it,Z as E,a8 as z,J as L,e as W,S as ct,i as _,W as lt,a9 as ut,aa as H,ab as ft,D as ht,t as Z,ac as dt,ad as O,ae as pt,af as mt}from"./index-ahqm8KFw.js";const wt=8;async function Y(e,t,o,n){const m=await e(t);return o?J.go(o,m,{key:"name",limit:n}).map(c=>c.obj.absolute):m.slice(0,n).map(c=>c.absolute)}async function yt(e,t,o,n){const m=n?.limit,c=n?.maxDepth??wt;if(!o)return Y(e,t,"",m);const b=[],k=new Set;let f=[t];for(let a=0;a<c&&f.length>0&&b.length<m;a++){const i=[];for(const h of f){const w=await e(h);for(const u of w)if(!k.has(u.absolute)){if(k.add(u.absolute),J.single(o,u.name)&&(b.push(u.absolute),b.length>=m))return b;i.push(u.absolute)}}f=i}return b}var gt=Z('<div class="px-4 pb-3">'),vt=Z('<div class="w-full flex items-center justify-between rounded-md"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular min-w-0"><span class="text-text-strong whitespace-nowrap">~</span><span class="text-text-weak whitespace-nowrap">/'),bt=Z('<div class="w-full flex items-center justify-between rounded-md"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular min-w-0"><span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0"></span><span class="text-text-strong whitespace-nowrap"></span><span class="text-text-weak whitespace-nowrap">/');function T(e){return((e??"").split(/\r?\n/)[0]??"").replace(/[\u0000-\u001F\u007F]/g,"").trim()}function xt(e){const t=e.replaceAll("\\","/");return t.startsWith("//")&&!t.startsWith("///")?"//"+t.slice(2).replace(/\/+/g,"/"):t.replace(/\/+/g,"/")}function R(e){const t=xt(e);return/^[A-Za-z]:$/.test(t)?t+"/":t}function p(e){const t=R(e);return t==="/"||t==="//"||/^[A-Za-z]:\/$/.test(t)?t:t.replace(/\/+$/,"")}function kt(e,t){const o=p(e??""),n=p(t).replace(/^\/+/,"");return o?n?o.endsWith("/")?o+n:o+"/"+n:o:n}function M(e){const t=R(e);return t.startsWith("//")?"//":t.startsWith("/")?"/":/^[A-Za-z]:\//.test(t)?t.slice(0,3):""}function Pt(e){const t=p(e);if(t==="/"||t==="//"||/^[A-Za-z]:\/$/.test(t))return t;const o=t.lastIndexOf("/");return o<=0?"/":o===2&&/^[A-Za-z]:/.test(t)?t.slice(0,3):t.slice(0,o)}function Rt(e){const t=R(e.trim());return t?t.startsWith("~")?"tilde":M(t)?"absolute":"relative":"relative"}function V(e,t){const o=p(e);if(!t)return"";const n=p(t),m=o.toLowerCase(),c=n.toLowerCase();return m===c?"~":m.startsWith(c+"/")?"~"+o.slice(n.length):""}function K(e,t,o){const n=p(e);return Rt(t)==="absolute"?n:V(n,o)||n}function G(e,t,o){const n=p(e),m=V(n,t),c=k=>k?k.endsWith("/")?k:k+"/":"",b=Array.from(new Set([n,c(n),m,c(m),L(n)].filter(Boolean))).join(`
|
|
2
|
+
`);return{absolute:n,search:b,group:o}}function Dt(e){const t=new Set;return e.filter(o=>t.has(o.absolute)?!1:(t.add(o.absolute),!0))}function q(e,t){const o=O(t,t),n=O(e,t);return n===o?{directory:o,path:""}:{directory:o,path:n.slice(o.length+1)}}function $t(e){const t=new Map;let o=0;const n=f=>O(f,e.root()),m=f=>{const a=e.start();if(!a)return;const i=e.root(),h=R(f);if(!h)return{directory:n(p(a)),path:""};const w=e.home();if(h==="~")return{directory:n(p(w||a)),path:""};if(h.startsWith("~/")){const y=kt(w||a,h.slice(2));return z(y,i)?q(y,i):{directory:n(p(a)),path:""}}if(M(h)){const y=p(h);return z(y,i)?q(y,i):{directory:n(p(a)),path:""}}return{directory:n(p(a)),path:h}},c=async f=>{const a=n(p(f)),i=t.get(a);if(i)return i;const h=pt(e.apiRoot(),a);if(h===void 0&&p(a).toLowerCase()!==p(e.apiRoot()).toLowerCase())return t.set(a,Promise.resolve([])),[];const w=mt(e.sdk,h??"",{fetch:e.fetch,headers:e.headers?.()}).then(u=>u.filter(y=>!y.name.startsWith(".")).filter(y=>z(y.absolute,e.root())).map(y=>({name:y.name,absolute:p(R(y.absolute))})));return t.set(a,w),w},b=async(f,a,i)=>Y(c,n(f),a,i),k=async(f,a,i)=>yt(c,n(f),a,{limit:i});return async f=>{const a=++o,i=()=>a===o,h=T(f),w=m(h);if(!w)return[];const u=R(h),y=u.startsWith("~")||!!M(u)||u.includes("/"),D=R(w.path);if(!y){const s=D?await k(w.directory,D,50):await b(w.directory,"",50);return i()?s.slice(0,50):[]}const $=u.endsWith("/"),S=D.replace(/^\/+/,"").replace(/\/+$/,"").split("/").filter(s=>s&&s!=="."),F=12,B=4,j=async(s,v)=>{let d=v;for(const A of s){if(!i())return[];if(A===".."){d=d.map(I=>n(Pt(I)));continue}const X=(await Promise.all(d.map(I=>b(I,A,B)))).flat();if(!i())return[];if(d=Array.from(new Set(X)).slice(0,F),d.length===0)return[]}return d},C=[w.directory];if($){const s=await j(S,C);if(s.length===0)return[];const v=(await Promise.all(s.map(d=>b(d,"",50)))).flat();return i()?Array.from(new Set(v)).slice(0,50):[]}const r=S.slice(0,-1),l=S[S.length-1]??"",g=await j(r,C);if(g.length===0)return[];const x=(await Promise.all(g.map(s=>b(s,l,50)))).flat();return i()?Array.from(new Set(x)).slice(0,50):[]}}function Wt(e){const t=N(),o=Q(),n=U(),m=tt(),c=et(),b=rt(),k=nt(),[f,a]=st("");let i;const h=P(()=>!(t.data.path.home||t.data.path.directory)),[w]=ot(()=>h()?!0:void 0,async()=>o.client.path.get().then(r=>r.data).catch(()=>{}),{initialValue:void 0}),u=P(()=>t.data.path.home||w()?.home||""),y=P(()=>{const r=t.data.path.project_data_root?t.data.path:w();return at(r)}),D=P(()=>it(E())),$=P(()=>{const r=D();return r||y()}),S=P(()=>$()),F=$t({sdk:o,home:u,start:S,root:$,apiRoot:$,fetch:b.fetch,headers:()=>{if(E())return;const r=k.current?.http;if(r?.password)return{Authorization:`Basic ${dt({username:r.username,password:r.password})}`}}}),B=P(()=>{const r=$(),l=D(),g=n.projects.list().filter(s=>z(s.worktree,r)).filter(s=>!l||s.worktree!==l),x=new Map(t.data.project.map(s=>[s.worktree,s]));return g.map((s,v)=>({project:s,at:x.get(s.worktree)?.time?.updated??x.get(s.worktree)?.time?.created??0,index:v})).sort((s,v)=>v.at-s.at||s.index-v.index).slice(0,5).map(({project:s})=>{const v=x.get(s.worktree),d=G(s.worktree,u(),"recent"),A=s.name||v?.name||L(s.worktree);return{...d,search:`${d.search}
|
|
3
3
|
${A}`}})}),j=async r=>{const l=T(r),g=await F(l),x=l.endsWith("/"),s=g.map(v=>{const d=G(v,u(),"folders");return x?{...d,search:`${d.search}
|
|
4
4
|
${l}`}:d});return Dt([...B(),...s])};function C(r){e.onSelect(e.multiple?[r]:r),m.close()}return W(ht,{get title(){return e.title??c.t("command.project.open")},get children(){return[W(ct,{get when(){return e.onCreateFolder},children:r=>(()=>{var l=gt();return _(l,W(lt,{size:"normal",variant:"ghost",icon:"folder-add-left",class:"w-full justify-start",onClick:()=>r()(),get children(){return c.t("command.project.createFolder")}})),l})()}),W(ut,{get search(){return{placeholder:c.t("dialog.directory.search.placeholder"),autofocus:!0}},get emptyMessage(){return c.t("dialog.directory.empty")},get loadingMessage(){return c.t("common.loading")},items:j,key:r=>r.absolute,filterKeys:["search"],groupBy:r=>r.group,sortGroupsBy:(r,l)=>r.category===l.category?0:r.category==="recent"?-1:1,groupHeader:r=>r.category==="recent"?c.t("home.recentProjects"):c.t("command.project.open"),ref:r=>i=r,onFilter:r=>a(T(r)),onKeyEvent:(r,l)=>{if(r.key!=="Tab"||r.shiftKey||!l)return;r.preventDefault(),r.stopPropagation();const g=K(l.absolute,f(),u());i?.setFilter(g.endsWith("/")?g:g+"/")},onSelect:r=>{r&&C(r.absolute)},children:r=>{const l=K(r.absolute,f(),u());return l==="~"?(()=>{var g=vt(),x=g.firstChild,s=x.firstChild;return _(x,W(H,{get node(){return{path:r.absolute,type:"directory"}},class:"shrink-0 size-4"}),s),g})():(()=>{var g=bt(),x=g.firstChild,s=x.firstChild,v=s.firstChild,d=v.nextSibling;return _(x,W(H,{get node(){return{path:r.absolute,type:"directory"}},class:"shrink-0 size-4"}),s),_(v,()=>ft(l)),_(d,()=>L(l)),g})()}})]}})}export{Wt as DialogSelectDirectory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as f,j as E,V as U,t as $,
|
|
1
|
+
import{i as f,j as E,V as U,t as $,ar as X,b as Z,a4 as ee,as as te,c as ne,at as se,a as ae,H as re,I as oe,au as ie,f as ce,g as b,av as le,l as de,e as w,a9 as ue,aw as fe,ax as P,S as C,ay as ge,Q as he,aa as pe,ab as me,J as A,D as we,az as ye,aA as ve,aB as be}from"./index-ahqm8KFw.js";var xe=$("<span data-component=keybind>");function ke(t){return(()=>{var n=xe();return f(n,()=>t.children),E(r=>U(n,{...t.classList,[t.class??""]:!!t.class},r)),n})()}function $e(t,n){const r=Math.floor(Math.max(0,t)/1e3),l=Math.floor(r/60),s=Math.floor(l/60),d=Math.floor(s/24);return r<60?n("common.time.justNow"):l<60?n("common.time.minutesAgo.short",{count:l}):s<24?n("common.time.hoursAgo.short",{count:s}):n("common.time.daysAgo.short",{count:d})}function Se(t,n){return $e(Date.now()-new Date(t).getTime(),n)}var K=$('<span class="text-14-regular text-text-weak truncate">'),_e=$('<div class="w-full flex items-center justify-between gap-4"><div class="flex items-center gap-2 min-w-0"><span class="text-14-regular text-text-strong whitespace-nowrap">'),De=$('<span class="text-12-regular text-text-weak whitespace-nowrap ml-2">'),Me=$('<div class="w-full flex items-center justify-between rounded-md pl-1"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center gap-2 min-w-0"><span class="text-14-regular text-text-strong truncate">'),Ce=$('<div class="w-full flex items-center justify-between rounded-md pl-1"><div class="flex items-center gap-x-3 grow min-w-0"><div class="flex items-center text-14-regular"><span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0"></span><span class="text-text-strong whitespace-nowrap">');const I=5,Fe=["session.new","workspace.new","session.previous","session.next","terminal.toggle","review.toggle"],N=t=>{const n=new Set,r=[];for(const l of t)n.has(l.id)||(n.add(l.id),r.push(l));return r},q=(t,n)=>({id:"command:"+t.id,type:"command",title:t.title,description:t.description,keybind:t.keybind,category:n,option:t}),F=(t,n)=>({id:"file:"+t,type:"file",title:t,category:n,path:t}),Te=(t,n)=>({id:`session:${t.directory}:${t.id}`,type:"session",title:t.title,description:t.description,category:n,directory:t.directory,sessionID:t.id,archived:t.archived,updated:t.updated});function Ee(t){const n=b(()=>t.filesOnly()?[]:t.command.options.filter(s=>!s.disabled&&!s.hidden&&!s.id.startsWith("suggested.")&&s.id!=="file.open")),r=b(()=>{const s=t.language.t("palette.group.commands");return n().map(d=>q(d,s))}),l=b(()=>{const s=n(),d=new Map(Fe.map((o,c)=>[o,c])),y=s.filter(o=>d.has(o.id)),i=y.length?y:s.slice(0,I),h=y.length?[...i].sort((o,c)=>(d.get(o.id)??0)-(d.get(c.id)??0)):i,v=t.language.t("palette.group.commands");return h.map(o=>q(o,v))});return{allowed:n,list:r,picks:l}}function Ie(t){const n=ye({tabs:t.tabs,pathFromTab:t.file.pathFromTab,normalizeTab:s=>s.startsWith("file://")?t.file.tab(s):s}),r=b(()=>{const s=n.openedTabs(),d=n.activeFileTab(),y=d?[d,...s.filter(o=>o!==d)]:s,i=new Set,h=t.language.t("palette.group.files"),v=[];for(const o of y){const c=t.file.pathFromTab(o);c&&(i.has(c)||(i.add(c),v.push(F(c,h))))}return v.slice(0,I)}),l=b(()=>{const s=t.language.t("palette.group.files");return t.file.tree.children("").filter(i=>i.type==="file").map(i=>i.path).sort((i,h)=>i.localeCompare(h)).slice(0,I).map(i=>F(i,s))});return{recent:r,root:l}}function Le(t){const n={token:0,inflight:void 0,cached:void 0};return{sessions:l=>{if(!l.trim())return n.token+=1,n.inflight=void 0,n.cached=void 0,[];if(n.cached)return n.cached;if(n.inflight)return n.inflight;const d=n.token,y=t.workspaces();return y.length===0?[]:(n.inflight=Promise.all(y.map(i=>{const h=t.label(i);return t.globalSDK.client.session.list({directory:i,roots:!0}).then(v=>(v.data??[]).filter(o=>!!o?.id).map(o=>({id:o.id,title:o.title??t.language.t("command.session.new"),description:h,directory:i,archived:o.time?.archived,updated:o.time?.updated}))).catch(()=>[])})).then(i=>{if(n.token!==d)return[];const h=new Set,v=t.language.t("command.category.session"),o=i.flat().filter(c=>{const S=`${c.directory}:${c.id}`;return h.has(S)?!1:(h.add(S),!0)}).map(c=>Te(c,v));return n.cached=o,o}).catch(()=>[]).finally(()=>{n.inflight=void 0}),n.inflight)}}}function Oe(t){const n=X(),r=Z(),l=ee(),s=te(),d=ne(),y=se(),i=ae(),h=re(),v=oe(),{params:o,tabs:c,view:S}=ie(),D=()=>t.mode==="files",k={cleanup:void 0,committed:!1},[z,H]=ce(!1),L=Ee({filesOnly:D,command:n,language:r}),_=Ie({file:s,tabs:c,language:r}),j=b(()=>le(o.dir)??""),O=b(()=>{const e=j();if(e)return l.projects.list().find(a=>a.worktree===e||a.sandboxes?.includes(e))}),R=b(()=>{const e=j(),a=O();if(!a)return e?[e]:[];const u=[a.worktree,...a.sandboxes??[]];return e&&!u.includes(e)?[...u,e]:u}),G=b(()=>v.data.path.home),B=e=>{const a=O(),u=a&&e===a.worktree?r.t("workspace.type.local"):r.t("workspace.type.sandbox"),[p]=v.child(e,{bootstrap:!1}),g=G(),m=g?e.replace(g,"~"):e,x=p.vcs?.branch??A(e);return`${u} : ${x||m}`},{sessions:W}=Le({workspaces:R,label:B,globalSDK:h,language:r}),J=async e=>{const a=e.trim();if(H(a.length>0),!a&&D()){const x=s.tree.state("")?.loaded,T=x?Promise.resolve():s.tree.list(""),M=N([..._.recent(),..._.root()]);return x||M.length>0?M:(await T,N([..._.recent(),..._.root()]))}if(!a)return[...L.picks(),..._.recent()];if(D()){const x=await s.searchFiles(a),T=r.t("palette.group.files");return x.map(M=>F(M,T))}const[u,p]=await Promise.all([s.searchFiles(a),Promise.resolve(W(a))]),g=r.t("palette.group.files"),m=u.map(x=>F(x,g));return[...L.list(),...p,...m]},Q=e=>{k.cleanup?.(),e&&e.type==="command"&&(k.cleanup=e.option?.onHighlight?.())},V=e=>{const a=s.tab(e);c().open(a),s.load(e),S().reviewPanel.opened()||S().reviewPanel.open(),l.fileTree.setTab("all"),t.onOpenFile?.(e),c().setActive(a)},Y=e=>{if(e){if(k.committed=!0,k.cleanup=void 0,d.close(),e.type==="command"){e.option?.onSelect?.("palette");return}if(e.type==="session"){if(!e.directory||!e.sessionID)return;i(ve(y.pathname,be(e.directory),e.sessionID));return}e.path&&V(e.path)}};return de(()=>{k.committed||k.cleanup?.()}),w(we,{class:"pt-3 pb-0 !max-h-[480px]",transition:!0,get children(){return w(ue,{get search(){return{placeholder:D()?r.t("session.header.searchFiles"):r.t("palette.search.placeholder"),autofocus:!0,hideIcon:!0}},get emptyMessage(){return r.t("palette.empty")},get loadingMessage(){return r.t("common.loading")},items:J,key:e=>e.id,filterKeys:["title","description","category"],get groupBy(){return z()?e=>e.category:()=>""},onMove:Q,onSelect:Y,children:e=>w(fe,{get fallback(){return(()=>{var a=Ce(),u=a.firstChild,p=u.firstChild,g=p.firstChild,m=g.nextSibling;return f(u,w(pe,{get node(){return{path:e.path??"",type:"file"}},class:"shrink-0 size-4"}),p),f(g,()=>me(e.path??"")),f(m,()=>A(e.path??"")),a})()},get children(){return[w(P,{get when(){return e.type==="command"},get children(){var a=_e(),u=a.firstChild,p=u.firstChild;return f(p,()=>e.title),f(u,w(C,{get when(){return e.description},get children(){var g=K();return f(g,()=>e.description),g}}),null),f(a,w(C,{get when(){return e.keybind},get children(){return w(ke,{class:"rounded-[4px]",get children(){return ge(e.keybind??"",r.t)}})}}),null),a}}),w(P,{get when(){return e.type==="session"},get children(){var a=Me(),u=a.firstChild,p=u.firstChild,g=p.firstChild;return f(u,w(he,{name:"bubble-5",size:"small",class:"shrink-0 text-icon-weak"}),p),f(g,()=>e.title),f(p,w(C,{get when(){return e.description},get children(){var m=K();return f(m,()=>e.description),E(()=>m.classList.toggle("opacity-70",!!e.archived)),m}}),null),f(a,w(C,{get when(){return e.updated},get children(){var m=De();return f(m,()=>Se(new Date(e.updated).toISOString(),r.t)),m}}),null),E(()=>g.classList.toggle("opacity-70",!!e.archived)),a}})]}})})}})}export{Oe as DialogSelectFile};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`):""}function ge(a,r){return r.type==="remote"?j({name:a,transport:"remote",url:r.url??"",headers:I(r.headers),enabled:r.enabled!==!1}):j({name:a,transport:"local",command:ue(r.command??[]),environment:I(r.environment),enabled:r.enabled!==!1})}function pe(a,r,g){const d=a.name.trim();if(!d)return"name";if(d!==g&&r.includes(d))return"duplicate";if(a.transport==="local")return
|
|
1
|
+
import{aJ as Z,I as ee,aK as te,b as re,aL as ne,aM as ae,d as le,g as C,K as Q,F as L,i as n,e as c,aE as ie,m as F,S as w,a9 as oe,W as O,aN as A,T as M,aO as se,D as ce,aP as de,t as v,h as me}from"./index-ahqm8KFw.js";function j(a){return{name:"",transport:"local",command:"",environment:"",url:"",headers:"",enabled:!0,...a}}function W(a){const r=[],g=/"([^"]*)"|'([^']*)'|(\S+)/g;let d;for(;d=g.exec(a.trim());)r.push(d[1]??d[2]??d[3]??"");return r.filter(t=>t.length>0)}function ue(a){return a.map(r=>/[\s"']/.test(r)?`"${r.replaceAll('"','\\"')}"`:r).join(" ")}function G(a){const r={};for(const g of a.split(/\r?\n/)){const d=g.trim();if(!d||d.startsWith("#"))continue;const t=d.indexOf("=");if(t<=0)continue;const k=d.slice(0,t).trim(),T=d.slice(t+1).trim();k&&(r[k]=T)}return Object.keys(r).length>0?r:void 0}function I(a){return a?Object.entries(a).map(([r,g])=>`${r}=${g}`).join(`
|
|
2
|
+
`):""}function ge(a,r){return r.type==="remote"?j({name:a,transport:"remote",url:r.url??"",headers:I(r.headers),enabled:r.enabled!==!1}):j({name:a,transport:"local",command:ue(r.command??[]),environment:I(r.environment),enabled:r.enabled!==!1})}function pe(a,r,g){const d=a.name.trim();if(!d)return"name";if(d!==g&&r.includes(d))return"duplicate";if(a.transport==="local")return W(a.command).length===0?"command":void 0;if(!a.url.trim())return"url"}function fe(a){const r=a.enabled;return a.transport==="remote"?{type:"remote",url:a.url.trim(),enabled:r,headers:G(a.headers)}:{type:"local",command:W(a.command),enabled:r,environment:G(a.environment)}}var he=v('<div class="flex items-center gap-2 -ml-2"><span>'),ve=v('<div class="flex flex-col gap-3 min-h-0 px-5 pb-5"><div class=shrink-0>'),N=v('<div class="flex flex-col gap-5">'),be=v('<p class="text-12-regular text-text-critical-base">'),xe=v('<div class="flex h-full min-h-0 flex-col px-5 pb-5"><div class="min-h-0 flex-1 overflow-y-auto pr-1"><div class="flex flex-col gap-5 rounded-md bg-surface-base p-5"><div class="flex flex-col gap-2"><span class="text-12-medium text-text-strong"></span></div><div class="flex items-center justify-between gap-3 rounded-md border border-border-weak-base px-3 py-3"><div class="flex flex-col gap-1"><span class="text-13-medium text-text-strong"></span><span class="text-12-regular text-text-weak"></span></div></div></div></div><div class="shrink-0 flex justify-end gap-2 pt-4">'),ye=v('<span class="text-11-regular text-text-weaker">'),_e=v('<span class="text-11-regular text-text-weak">'),$e=v('<span class="text-11-regular text-text-weaker truncate">'),Ce=v('<div class="w-full flex items-center justify-between gap-x-3"><div class="flex flex-col gap-0.5 min-w-0"><div class="flex items-center gap-2"><span class=truncate></span></div></div><div class="flex items-center gap-2 shrink-0">');const we={connected:"mcp.status.connected",failed:"mcp.status.failed",needs_auth:"mcp.status.needs_auth",disabled:"mcp.status.disabled"},V={name:"dialog.mcp.error.name",command:"dialog.mcp.error.command",url:"dialog.mcp.error.url",duplicate:"dialog.mcp.error.duplicate"},Pe=a=>{const r=Z(),g=ee(),d=te(),t=re(),k=ne(),T=ae(),[s,y]=le({mode:a.initialMode==="add"?"form":"list",editing:void 0,form:j(),error:""}),P=C(()=>g.data.config.mcp??{}),q=C(()=>{const e=new Set([...Object.keys(P()),...Object.keys(r.data.mcp??{})]);return Array.from(e).map(o=>({name:o,status:r.data.mcp?.[o]?.status??(P()[o]?"disabled":void 0)})).sort((o,l)=>o.name.localeCompare(l.name))}),J=C(()=>Object.keys(P())),x=e=>y("form",e),z=()=>k.refetchQueries(T.mcp(de(r.directory))),b=Q(()=>({mutationFn:async e=>{r.data.mcp[e]?.status==="connected"?await d.client.mcp.disconnect({name:e}):await d.client.mcp.connect({name:e})},onSuccess:()=>z(),onError:e=>{L({variant:"error",title:t.t("common.requestFailed"),description:e instanceof Error?e.message:String(e)})}})),u=Q(()=>({mutationFn:async()=>{const e=pe(s.form,J(),s.editing);if(e)throw y("error",t.t(V[e])),new Error(e);y("error","");const o=s.form.name.trim(),l=fe(s.form),m={...P()};return s.editing&&s.editing!==o&&delete m[s.editing],m[o]=l,await g.updateConfig({mcp:m}),l.enabled!==!1&&await d.client.mcp.add({name:o,config:l}).catch(()=>{}),o},onSuccess:async()=>{L({title:t.t("dialog.mcp.toast.saved")});const e=async()=>{await Promise.all([z(),k.invalidateQueries({queryKey:["config"]})])};await e(),setTimeout(()=>void e(),500),setTimeout(()=>void e(),1500),B()},onError:e=>{e instanceof Error&&e.message in V||L({variant:"error",title:t.t("common.requestFailed"),description:e instanceof Error?e.message:String(e)})}})),R=C(()=>q().filter(e=>e.status==="connected").length),H=C(()=>q().length);function B(){y({mode:"list",editing:void 0,form:j(),error:""})}function U(){y({mode:"form",editing:void 0,form:j(),error:""})}function X(e){const o=P()[e];if(!o||!("type"in o)){L({variant:"error",title:t.t("dialog.mcp.error.missingConfig")});return}y({mode:"form",editing:e,form:ge(e,o),error:""})}const Y=C(()=>s.mode!=="form"?t.t("dialog.mcp.title"):(()=>{var e=he(),o=e.firstChild;return n(e,c(ie,{icon:"arrow-left",variant:"ghost",onClick:B,get"aria-label"(){return t.t("common.goBack")}}),o),n(o,(()=>{var l=F(()=>!!s.editing);return()=>l()?t.t("dialog.mcp.editTitle"):t.t("dialog.mcp.addTitle")})()),e})());return c(ce,{size:"large",get title(){return Y()},get description(){return F(()=>s.mode==="list")()?t.t("dialog.mcp.description",{enabled:R(),total:H()}):t.t("dialog.mcp.form.hint")},class:"overflow-hidden [&_[data-slot=dialog-body]]:h-full [&_[data-slot=dialog-body]]:min-h-0 [&_[data-slot=dialog-body]]:overflow-hidden",get children(){return c(w,{get when(){return s.mode==="list"},get fallback(){return(()=>{var e=xe(),o=e.firstChild,l=o.firstChild,m=l.firstChild,S=m.firstChild,_=m.nextSibling,E=_.firstChild,K=E.firstChild,p=K.nextSibling,$=o.nextSibling;return n(l,c(M,{get label(){return t.t("dialog.mcp.form.name")},get placeholder(){return t.t("dialog.mcp.form.namePlaceholder")},get value(){return s.form.name},get disabled(){return u.isPending||!!s.editing},onChange:i=>x({name:i})}),m),n(S,()=>t.t("dialog.mcp.form.transport")),n(m,c(se,{options:["local","remote"],get current(){return s.form.transport},value:i=>i,label:i=>i==="local"?t.t("dialog.mcp.form.transport.local"):t.t("dialog.mcp.form.transport.remote"),onSelect:i=>{!i||u.isPending||x({transport:i})}}),null),n(l,c(w,{get when(){return s.form.transport==="local"},get fallback(){return(()=>{var i=N();return n(i,c(M,{get label(){return t.t("dialog.mcp.form.url")},get placeholder(){return t.t("dialog.mcp.form.urlPlaceholder")},get value(){return s.form.url},get disabled(){return u.isPending},onChange:h=>x({url:h})}),null),n(i,c(M,{multiline:!0,get label(){return t.t("dialog.mcp.form.headers")},get placeholder(){return t.t("dialog.mcp.form.headersPlaceholder")},get value(){return s.form.headers},get disabled(){return u.isPending},onChange:h=>x({headers:h}),class:"min-h-24"}),null),i})()},get children(){var i=N();return n(i,c(M,{get label(){return t.t("dialog.mcp.form.command")},get placeholder(){return t.t("dialog.mcp.form.commandPlaceholder")},get value(){return s.form.command},get disabled(){return u.isPending},onChange:h=>x({command:h})}),null),n(i,c(M,{multiline:!0,get label(){return t.t("dialog.mcp.form.environment")},get placeholder(){return t.t("dialog.mcp.form.environmentPlaceholder")},get value(){return s.form.environment},get disabled(){return u.isPending},onChange:h=>x({environment:h}),class:"min-h-24"}),null),i}}),_),n(K,()=>t.t("dialog.mcp.form.enabled")),n(p,()=>t.t("dialog.mcp.form.enabledDescription")),n(_,c(A,{get checked(){return s.form.enabled},get disabled(){return u.isPending},onChange:i=>x({enabled:i})}),null),n(l,c(w,{get when(){return s.error},get children(){var i=be();return n(i,()=>s.error),i}}),null),n($,c(O,{variant:"ghost",size:"large",onClick:B,get disabled(){return u.isPending},get children(){return t.t("common.cancel")}}),null),n($,c(O,{variant:"primary",size:"large",get disabled(){return u.isPending},onClick:()=>{u.isPending||u.mutate()},get children(){return F(()=>!!u.isPending)()?t.t("common.saving"):t.t("common.save")}}),null),e})()},get children(){var e=ve(),o=e.firstChild;return n(e,c(oe,{get search(){return{placeholder:t.t("common.search.placeholder"),autofocus:!0}},get emptyMessage(){return t.t("dialog.mcp.empty")},key:l=>l?.name??"",items:q,filterKeys:["name","status"],sortBy:(l,m)=>l.name.localeCompare(m.name),onSelect:l=>{!l||b.isPending||b.mutate(l.name)},children:l=>{const m=()=>r.data.mcp[l.name],S=()=>m()?.status??l.status,_=()=>{const p=S()?we[S()]:void 0;if(p)return t.t(p)},E=()=>{const p=m();return p?.status==="failed"?p.error:void 0},K=()=>S()==="connected";return(()=>{var p=Ce(),$=p.firstChild,i=$.firstChild,h=i.firstChild,D=$.nextSibling;return n(h,()=>l.name),n(i,c(w,{get when(){return _()},get children(){var f=ye();return n(f,_),f}}),null),n(i,c(w,{get when(){return F(()=>!!b.isPending)()&&b.variables===l.name},get children(){var f=_e();return n(f,()=>t.t("common.loading.ellipsis")),f}}),null),n($,c(w,{get when(){return E()},get children(){var f=$e();return n(f,E),f}}),null),D.$$click=f=>f.stopPropagation(),n(D,c(O,{variant:"ghost",class:"h-7 px-2 text-12-regular",onClick:()=>X(l.name),get children(){return t.t("common.edit")}}),null),n(D,c(A,{get checked(){return K()},get disabled(){return F(()=>!!b.isPending)()&&b.variables===l.name},onChange:()=>{b.isPending||b.mutate(l.name)}}),null),p})()}}),o),n(o,c(O,{variant:"secondary",icon:"plus-small",size:"large",onClick:U,class:"py-1.5 pl-1.5 pr-3",get children(){return t.t("dialog.mcp.addButton")}})),e}})}})};me(["click"]);export{Pe as DialogSelectMcp};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{b as x,i as d,e as i,S as h,t as
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-ahqm8KFw.js","assets/index-DKqTsr7d.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{b as x,i as d,e as i,S as h,t as _,c as y,W as C,D as M,d as O,aC as v,N as k,aD as D,aE as P,aF as E,g as z,aG as b,aH as p,a9 as B,aI as L,_ as I}from"./index-ahqm8KFw.js";var F=_('<div class="flex flex-col gap-1 py-1"><div class=text-13-medium></div><div class="text-12-regular text-text-invert-base"></div><div class="text-12-regular text-text-invert-base">'),j=_('<div class="text-12-regular text-text-invert-base">');const A=o=>{const n=x(),a=e=>{const l=`${e.id} ${e.name}`.toLowerCase();return/claude|anthropic/.test(l)?n.t("model.provider.anthropic"):/gpt|o[1-4]|codex|openai/.test(l)?n.t("model.provider.openai"):/gemini|palm|bard|google/.test(l)?n.t("model.provider.google"):/grok|xai/.test(l)?n.t("model.provider.xai"):/llama|meta/.test(l)?n.t("model.provider.meta"):e.provider.name},c=e=>e==="text"?n.t("model.input.text"):e==="image"?n.t("model.input.image"):e==="audio"?n.t("model.input.audio"):e==="video"?n.t("model.input.video"):e==="pdf"?n.t("model.input.pdf"):e,t=()=>{const e=[];o.latest&&e.push(n.t("model.tag.latest")),o.free&&e.push(n.t("model.tag.free")),o.limited&&e.push(n.t("model.tag.limited"));const l=e.length?` (${e.join(", ")})`:"";return`${a(o.model)} ${o.model.name}${l}`},r=()=>{if(o.model.capabilities){const g=o.model.capabilities.input,f=["text","image","audio","video","pdf"].filter(m=>g[m]).map(m=>c(m));return f.length?f.join(", "):void 0}const e=o.model.modalities?.input;if(!e)return;const l=e.map(g=>c(g));return l.length?l.join(", "):void 0},u=()=>o.model.capabilities?o.model.capabilities.reasoning?n.t("model.tooltip.reasoning.allowed"):n.t("model.tooltip.reasoning.none"):o.model.reasoning?n.t("model.tooltip.reasoning.allowed"):n.t("model.tooltip.reasoning.none"),s=()=>n.t("model.tooltip.context",{limit:o.model.limit.context.toLocaleString()});return(()=>{var e=F(),l=e.firstChild,g=l.nextSibling,S=g.nextSibling;return d(l,t),d(e,i(h,{get when(){return r()},children:f=>(()=>{var m=j();return d(m,()=>n.t("model.tooltip.allows",{inputs:f()})),m})()}),g),d(g,u),d(S,s),e})()};var G=_('<div class="w-full flex items-center gap-x-2 text-13-regular"><span class=truncate>'),K=_('<div class="flex items-center gap-1">');const $=(o,n)=>o==="opencode"&&(!n||n.input===0),w=o=>o==="onescience",T=o=>{const n=o.model??E().model,a=x(),c=z(()=>n.list().filter(r=>o.provider?r.provider.id===o.provider:!0).filter(r=>n.visible({modelID:r.id,providerID:r.provider.id})).map(r=>({...r,search:[r.provider.name,r.provider.id,r.name,r.id,r.family,$(r.provider.id,r.cost)?"free 免费":"",w(r.provider.id)?"limited 限免":"",r.latest?"latest 最新":""].join(" ")})));return i(B,{get class(){return`flex-1 min-h-0 [&_[data-slot=list-scroll]]:flex-1 [&_[data-slot=list-scroll]]:min-h-0 ${o.class??""}`},get search(){return{placeholder:a.t("dialog.model.search.placeholder"),autofocus:!0,action:o.action}},get emptyMessage(){return a.t("dialog.model.empty")},key:t=>`${t.provider.id}:${t.id}`,items:c,get current(){return n.current()},scrollToCurrent:!1,filterKeys:["search"],sortBy:(t,r)=>t.name.localeCompare(r.name),groupBy:t=>t.provider.name,sortGroupsBy:(t,r)=>{const u=t.items[0].provider.id,s=r.items[0].provider.id;return p.includes(u)&&!p.includes(s)?-1:!p.includes(u)&&p.includes(s)?1:p.indexOf(u)-p.indexOf(s)},itemWrapper:(t,r)=>i(D,{class:"w-full",placement:"right-start",gutter:12,get value(){return i(A,{model:t,get latest(){return t.latest},get free(){return $(t.provider.id,t.cost)},get limited(){return w(t.provider.id)}})},children:r}),onSelect:t=>{n.set(t?{modelID:t.id,providerID:t.provider.id}:void 0,{recent:!0}),o.onSelect()},children:t=>(()=>{var r=G(),u=r.firstChild;return d(u,()=>t.name),d(r,i(h,{get when(){return $(t.provider.id,t.cost)},get children(){return i(b,{get children(){return a.t("model.tag.free")}})}}),null),d(r,i(h,{get when(){return w(t.provider.id)},get children(){return i(b,{get children(){return a.t("model.tag.limited")}})}}),null),d(r,i(h,{get when(){return t.latest},get children(){return i(b,{get children(){return a.t("model.tag.latest")}})}}),null),r})()})};function R(o){const[n,a]=O({open:!1,dismiss:null}),c=y(),t=e=>{a("dismiss",e),a("open",!1)},r=()=>{t("manage"),c.show(()=>i(L,{tab:"models"}))},u=()=>{t("provider"),I(()=>import("./index-ahqm8KFw.js").then(e=>e.a_),__vite__mapDeps([0,1])).then(e=>{c.show(()=>i(e.DialogSelectProvider,{}))})},s=x();return i(v,{get open(){return n.open},onOpenChange:e=>{e&&a("dismiss",null),a("open",e)},modal:!1,placement:"top-start",gutter:4,get children(){return[i(v.Trigger,k({get as(){return o.triggerAs??"div"}},()=>o.triggerProps,{get children(){return o.children}})),i(v.Portal,{get children(){return i(v.Content,{class:"w-72 h-80 flex flex-col p-2 rounded-md border border-border-base bg-surface-raised-stronger-non-alpha shadow-md z-50 outline-none overflow-hidden",onEscapeKeyDown:e=>{t("escape"),e.preventDefault(),e.stopPropagation()},onPointerDownOutside:()=>t("outside"),onFocusOutside:()=>t("outside"),onCloseAutoFocus:e=>{const l=n.dismiss;l==="outside"&&e.preventDefault(),(l==="escape"||l==="select")&&(e.preventDefault(),o.onClose?.(l)),a("dismiss",null)},get children(){return[i(v.Title,{class:"sr-only",get children(){return s.t("dialog.model.select.title")}}),i(T,{get provider(){return o.provider},get model(){return o.model},onSelect:()=>t("select"),class:"p-1",get action(){return(()=>{var e=K();return d(e,i(D,{placement:"top",get value(){return s.t("command.provider.connect")},get children(){return i(P,{icon:"plus-small",variant:"ghost",iconSize:"normal",class:"size-6",get"aria-label"(){return s.t("command.provider.connect")},onClick:u})}}),null),d(e,i(D,{placement:"top",get value(){return s.t("settings.models.title")},get children(){return i(P,{icon:"sliders",variant:"ghost",iconSize:"normal",class:"size-6",get"aria-label"(){return s.t("settings.models.title")},onClick:r})}}),null),e})()}})]}})}})]}})}const V=o=>{const n=y(),a=x(),c=()=>{I(()=>import("./index-ahqm8KFw.js").then(r=>r.a_),__vite__mapDeps([0,1])).then(r=>{n.show(()=>i(r.DialogSelectProvider,{}))})},t=()=>{n.show(()=>i(L,{tab:"models"}))};return i(M,{get title(){return a.t("dialog.model.select.title")},get action(){return i(C,{class:"h-7 -my-1 text-14-medium",icon:"plus-small",tabIndex:-1,onClick:c,get children(){return a.t("command.provider.connect")}})},get children(){return[i(T,{get provider(){return o.provider},get model(){return o.model},onSelect:()=>n.close()}),i(C,{variant:"ghost",class:"ml-3 mt-5 mb-6 text-text-base self-start",onClick:t,get children(){return a.t("settings.models.title")}})]}})};export{V as DialogSelectModel,R as ModelSelectorPopover};
|
package/assets/{dialog-terminal-unavailable-_SDcRu3J.js → dialog-terminal-unavailable-B7tfXMnq.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{c as $,g as r,
|
|
1
|
+
import{c as $,g as r,Z as I,ag as A,e as s,i as a,S as m,W as x,D as N,t as b}from"./index-ahqm8KFw.js";var T=b('<pre class="m-0 shrink-0 max-h-28 overflow-y-auto rounded-lg border border-border-weak-base bg-background-weak p-3 text-12-regular text-text-strong leading-5 whitespace-pre-wrap break-all">服务端返回:'),D=b('<pre class="m-0 shrink-0 max-h-24 overflow-y-auto rounded-lg border border-border-weak-base bg-background-weak p-3 text-12-regular text-text-strong leading-5 whitespace-pre-wrap break-all">探测详情:'),S=b('<div class="flex flex-col gap-2 min-w-0 min-h-0"><div class="flex items-center justify-between gap-2 shrink-0"><strong class="text-13-medium text-text-strong">建议在服务器上执行</strong></div><pre class="m-0 max-h-[36vh] overflow-y-auto rounded-lg border border-border-weak-base bg-background-weak p-3 text-12-regular text-text-strong leading-5 whitespace-pre-wrap break-all">'),L=b('<div class="flex flex-col gap-4 px-6 pb-6 pt-0 min-h-0"><p class="text-14-regular text-text-weak m-0 leading-6 shrink-0"></p><p class="text-12-regular text-text-weak m-0 shrink-0">修改环境变量后需重启 OneCode,并在浏览器中重新登录后再打开终端。</p><div class="flex justify-end shrink-0">');function M(f={}){const k=$(),l=r(()=>I()),n=r(()=>l()?.capabilities.terminalUnavailableReason??""),w=r(()=>l()?.capabilities.terminalUnavailableDetail??""),i=r(()=>l()?.capabilities.terminalIsolation??""),h=r(()=>(f.failure??"").trim()),u=r(()=>!!l()&&l()?.capabilities.terminal===!0&&!n()),d=r(()=>!n()&&!u()&&i()==="bubblewrap"),p=r(()=>{if(u())return i()==="docker"?["# 1) 无 GPU:改用 bubblewrap 后重启 OneCode,并重新登录","export ONECODE_TERMINAL_ISOLATION=bubblewrap","# 2) 有 GPU 且必须用 docker:给运行账号加组后重新登录系统再启 OneCode",'sudo usermod -aG docker "$USER"',"docker info"]:i()==="bubblewrap"?["# A. 临时绕过隔离(先验证终端能否打开)","export ONECODE_TERMINAL_ISOLATION=native","# 然后重启 onecode,浏览器重新登录后再开终端","","# B. 继续用 bubblewrap 时,在运行 OneCode 的机器上检查:","which bwrap; bwrap --version","bwrap --unshare-all --die-with-parent --new-session --proc /proc --dev /dev --ro-bind-try /usr /usr --ro-bind-try /bin /bin --tmpfs /tmp -- /usr/bin/true; echo exit:$?","cat /proc/sys/kernel/unprivileged_userns_clone","cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns 2>/dev/null || true","","# C. 若 exit 非 0,可临时放开(需管理员;重启后可能失效)","sudo sysctl -w kernel.unprivileged_userns_clone=1","sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0","","# D. 服务端日志(搜 creating session / exited)",'ls ~/.local/share/opencode/log/ 2>/dev/null || ls "$HOME"/.local/share/opencode/log/']:["# 查看服务端日志(搜 creating session / exited)",'ls ~/.local/share/opencode/log/ 2>/dev/null || ls "$HOME"/.local/share/opencode/log/',"# 临时可改:export ONECODE_TERMINAL_ISOLATION=native 后重启并重新登录"];const e=A(l());return Array.isArray(e)&&e.length>0?e:d()?["export ONECODE_TERMINAL_ISOLATION=native","cat /proc/sys/kernel/unprivileged_userns_clone"]:[]}),v=r(()=>p().length>0),_=r(()=>u()?"无法打开终端":n()==="docker-missing"?"无法打开终端:Docker 不可用":n()==="disabled"?"无法打开终端:服务未启用":n()==="bubblewrap-unusable"?"无法打开终端:bubblewrap 异常":d()?"无法打开终端:隔离环境异常":"无法打开终端:需要 bubblewrap"),O=r(()=>u()?i()==="docker"?"隔离模式为 docker,创建终端失败。常见原因是当前用户无权访问 docker.sock。无 GPU 请改用 bubblewrap;有 GPU 请把运行账号加入 docker 组。":i()==="bubblewrap"?"隔离模式为 bubblewrap,创建终端失败(服务端 POST /pty 返回错误)。可先按下方 A 改用 native 验证;若需继续隔离,再按 B/C 检查 bubblewrap 与内核命名空间。":`隔离模式为 ${i()||"native"},创建终端失败。请按下方命令查看日志或临时调整隔离模式后重试。`:n()==="docker-missing"?"已配置 docker 隔离,但当前用户无法使用 Docker。无 GPU 请改用 bubblewrap;有 GPU 请将运行账号加入 docker 组。":n()==="disabled"?"服务端未启用平台账号终端。":n()==="bubblewrap-unusable"?"已安装 bubblewrap,但无法创建用户命名空间。请按下方命令检查后重启 OneCode 并重新登录。":d()?"bubblewrap 终端启动失败。可临时改用 native,或检查 user namespace 相关 sysctl。":"需要安装 bubblewrap 后重启 OneCode 并重新登录。容器部署可使用 ONECODE_TERMINAL_ISOLATION=native。"),C=async()=>{const e=p().filter(o=>o.trim().length>0&&!o.trim().startsWith("#")).join(`
|
|
2
2
|
`);if(e)try{await navigator.clipboard.writeText(e)}catch{}};return s(N,{get title(){return _()},class:"w-full max-w-[560px] mx-auto",size:"large",get children(){var e=L(),o=e.firstChild,c=o.nextSibling,y=c.nextSibling;return a(o,O),a(e,s(m,{get when(){return h()},get children(){var t=T();return t.firstChild,a(t,h,null),t}}),c),a(e,s(m,{get when(){return w()},get children(){var t=D();return t.firstChild,a(t,w,null),t}}),c),a(e,s(m,{get when(){return v()},get children(){var t=S(),g=t.firstChild;g.firstChild;var E=g.nextSibling;return a(g,s(x,{type:"button",size:"normal",variant:"ghost",onClick:()=>void C(),children:"复制命令"}),null),a(E,()=>p().join(`
|
|
3
3
|
`)),t}}),c),a(y,s(x,{type:"button",variant:"primary",size:"large",onClick:()=>k.close(),children:"知道了"})),e}})}export{M as DialogTerminalUnavailable};
|