@tom2012/cc-web 2026.5.20-a → 2026.5.24-a

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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/backend/dist/__tests__/browser-proxy.test.d.ts +2 -0
  3. package/backend/dist/__tests__/browser-proxy.test.d.ts.map +1 -0
  4. package/backend/dist/__tests__/browser-proxy.test.js +306 -0
  5. package/backend/dist/__tests__/browser-proxy.test.js.map +1 -0
  6. package/backend/dist/__tests__/cli-prompt-detector.test.js +31 -0
  7. package/backend/dist/__tests__/cli-prompt-detector.test.js.map +1 -1
  8. package/backend/dist/cli-prompt-detector.d.ts.map +1 -1
  9. package/backend/dist/cli-prompt-detector.js +23 -4
  10. package/backend/dist/cli-prompt-detector.js.map +1 -1
  11. package/backend/dist/index.d.ts.map +1 -1
  12. package/backend/dist/index.js +5 -0
  13. package/backend/dist/index.js.map +1 -1
  14. package/backend/dist/notify-service.d.ts +1 -0
  15. package/backend/dist/notify-service.d.ts.map +1 -1
  16. package/backend/dist/notify-service.js +1 -0
  17. package/backend/dist/notify-service.js.map +1 -1
  18. package/backend/dist/routes/browser-proxy.d.ts +31 -0
  19. package/backend/dist/routes/browser-proxy.d.ts.map +1 -0
  20. package/backend/dist/routes/browser-proxy.js +363 -0
  21. package/backend/dist/routes/browser-proxy.js.map +1 -0
  22. package/frontend/dist/assets/{ChatOverlay-CGyDxUxJ.js → ChatOverlay-W-pSFHsV.js} +1 -1
  23. package/frontend/dist/assets/{GraphPreview-B9kooQxE.js → GraphPreview-CcuxUzQH.js} +1 -1
  24. package/frontend/dist/assets/{MobilePage-3uMLckd9.js → MobilePage-DEBO3i1o.js} +3 -3
  25. package/frontend/dist/assets/{OfficePreview-l1O2K0sM.js → OfficePreview-DY-ew_ex.js} +2 -2
  26. package/frontend/dist/assets/{PdfPreview-fZPK_FeM.js → PdfPreview-Bl0MS_5m.js} +1 -1
  27. package/frontend/dist/assets/{ProjectPage-CBFQ2TQC.js → ProjectPage-tcwSSEFX.js} +5 -5
  28. package/frontend/dist/assets/SettingsPage-DU649aEa.js +13 -0
  29. package/frontend/dist/assets/{SkillHubPage-DfsO4OIa.js → SkillHubPage-hH5XcB57.js} +2 -2
  30. package/frontend/dist/assets/{chevron-down-C53vkdK1.js → chevron-down-B3q2CU-d.js} +1 -1
  31. package/frontend/dist/assets/{index-BbEFdJn-.js → index-CZOz50el.js} +1 -1
  32. package/frontend/dist/assets/{index-3NT40D4Y.js → index-DsYny3RQ.js} +1 -1
  33. package/frontend/dist/assets/{index-BnxUVJSG.js → index-nYsy3LMF.js} +3 -3
  34. package/frontend/dist/assets/{jszip.min-D5b8OJpG.js → jszip.min-9o6zKk8v.js} +1 -1
  35. package/frontend/dist/assets/{search-F_MnOHbB.js → search-B9B3Cq4V.js} +1 -1
  36. package/frontend/dist/assets/select-BOLkADQv.js +13 -0
  37. package/frontend/dist/index.html +1 -1
  38. package/package.json +1 -1
  39. package/frontend/dist/assets/SettingsPage-BZ3vBlYj.js +0 -13
  40. package/frontend/dist/assets/select-MFyjPNJE.js +0 -13
@@ -0,0 +1,13 @@
1
+ import{c as e,r as s,a8 as t,b3 as a,j as n,aa as c,a9 as l,a5 as i,d as r,aH as o,aJ as d,b4 as h,t as m,a0 as u,I as x,B as p,U as g,X as j,D as b,b5 as y,b6 as f,b7 as _,b8 as v,u as k,b9 as N,T as w,ba as C,bb as S,bc as M,bd as T,be as E,aI as R,bf as I,bg as P,i as H,S as F,bh as L,aD as z,L as A,s as q,bi as U}from"./index-nYsy3LMF.js";import{u as V,n as G,i as O,j as B,k as D,l as Q,m as W,S as Z,U as $,E as J,T as X,a as K,b as Y,c as ee}from"./select-BOLkADQv.js";import{C as se}from"./index-DsYny3RQ.js";import"./chevron-down-B3q2CU-d.js";
2
+ /**
3
+ * @license lucide-react v0.309.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const te=e("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]),ae=e("AlertTriangle",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),ne=e("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]),ce=e("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]),le=e("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),ie=e("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]),re=e("UploadCloud",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M12 12v9",key:"192myk"}],["path",{d:"m16 16-4-4-4 4",key:"119tzi"}]]);
8
+ /**
9
+ * @license lucide-react v0.309.0 - ISC
10
+ *
11
+ * This source code is licensed under the ISC license.
12
+ * See the LICENSE file in the root directory of this source tree.
13
+ */var oe="Switch",[de]=i(oe),[he,me]=de(oe),ue=s.forwardRef((e,i)=>{const{__scopeSwitch:r,name:o,checked:d,defaultChecked:h,required:m,disabled:u,value:x="on",onCheckedChange:p,form:g,...j}=e,[b,y]=s.useState(null),f=t(i,e=>y(e)),_=s.useRef(!1),v=!b||(g||!!b.closest("form")),[k,N]=a({prop:d,defaultProp:h??!1,onChange:p,caller:oe});return n.jsxs(he,{scope:r,checked:k,disabled:u,children:[n.jsx(c.button,{type:"button",role:"switch","aria-checked":k,"aria-required":m,"data-state":je(k),"data-disabled":u?"":void 0,disabled:u,value:x,...j,ref:f,onClick:l(e.onClick,e=>{N(e=>!e),v&&(_.current=e.isPropagationStopped(),_.current||e.stopPropagation())})}),v&&n.jsx(ge,{control:b,bubbles:!_.current,name:o,value:x,checked:k,required:m,disabled:u,form:g,style:{transform:"translateX(-100%)"}})]})});ue.displayName=oe;var xe="SwitchThumb",pe=s.forwardRef((e,s)=>{const{__scopeSwitch:t,...a}=e,l=me(xe,t);return n.jsx(c.span,{"data-state":je(l.checked),"data-disabled":l.disabled?"":void 0,...a,ref:s})});pe.displayName=xe;var ge=s.forwardRef(({__scopeSwitch:e,control:a,checked:c,bubbles:l=!0,...i},r)=>{const o=s.useRef(null),d=t(o,r),h=V(c),m=G(a);return s.useEffect(()=>{const e=o.current;if(!e)return;const s=window.HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(s,"checked").set;if(h!==c&&t){const s=new Event("click",{bubbles:l});t.call(e,c),e.dispatchEvent(s)}},[h,c,l]),n.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:c,...i,tabIndex:-1,ref:d,style:{...i.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function je(e){return e?"checked":"unchecked"}ge.displayName="SwitchBubbleInput";var be=ue,ye=pe;const fe=s.forwardRef(({className:e,...s},t)=>n.jsx(be,{className:r("peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...s,ref:t,children:n.jsx(ye,{className:r("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));fe.displayName=be.displayName;function _e(){const{t:e}=o(),[t,a]=s.useState(null),[c,l]=s.useState(!0),[i,r]=s.useState(!1),[k,N]=s.useState(!1),[w,C]=s.useState(!1),[S,M]=s.useState(!1),[T,E]=s.useState(null),[R,I]=s.useState(0),[P,H]=s.useState(""),[F,L]=s.useState("");d({onStart:e=>{E(e.projectId),I(0)},onProgress:e=>{E(e.projectId),I(e.filesTransferred)},onDone:()=>{E(null),I(0)}}),s.useEffect(()=>{let s=!1;return h().then(e=>{s||(a(e),L(e.defaultExcludes.join("\n")))}).catch(s=>m.error(e("sync_section.load_failed",{message:s.message}))).finally(()=>{s||l(!1)}),()=>{s=!0}},[e]);const z=(e,s)=>{a(t=>t?{...t,[e]:s}:t)};return c||!t?n.jsx("div",{className:"text-sm text-muted-foreground",children:e("sync_section.loading")}):n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-sm font-semibold mb-3",children:e("sync_section.server_section")}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[n.jsxs("div",{children:[n.jsx(u,{htmlFor:"sync-host",children:e("sync_section.host")}),n.jsx(x,{id:"sync-host",value:t.host,onChange:e=>z("host",e.target.value),placeholder:"example.com"})]}),n.jsxs("div",{children:[n.jsx(u,{htmlFor:"sync-port",children:e("sync_section.port")}),n.jsx(x,{id:"sync-port",type:"number",value:t.port,onChange:e=>z("port",Number(e.target.value)||22)})]}),n.jsxs("div",{children:[n.jsx(u,{htmlFor:"sync-user",children:e("sync_section.user")}),n.jsx(x,{id:"sync-user",value:t.user,onChange:e=>z("user",e.target.value),placeholder:"tom"})]}),n.jsxs("div",{children:[n.jsx(u,{htmlFor:"sync-remote",children:e("sync_section.remote_root")}),n.jsx(x,{id:"sync-remote",value:t.remoteRoot,onChange:e=>z("remoteRoot",e.target.value),placeholder:"/data/projects"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",dangerouslySetInnerHTML:{__html:e("sync_section.remote_root_hint")}})]})]})]}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-sm font-semibold mb-3",children:e("sync_section.auth_section")}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[n.jsxs("div",{children:[n.jsx(u,{children:e("sync_section.auth_method")}),n.jsxs(O,{value:t.authMethod,onValueChange:e=>z("authMethod",e),children:[n.jsx(B,{children:n.jsx(D,{})}),n.jsxs(Q,{children:[n.jsx(W,{value:"key",children:"SSH key"}),n.jsx(W,{value:"password",children:e("sync_section.auth_password")})]})]})]}),"key"===t.authMethod?n.jsxs("div",{children:[n.jsx(u,{htmlFor:"sync-key",children:e("sync_section.key_path")}),n.jsx(x,{id:"sync-key",value:t.keyPath??"",onChange:e=>z("keyPath",e.target.value),placeholder:"~/.ssh/id_rsa"})]}):n.jsxs("div",{children:[n.jsx(u,{htmlFor:"sync-pw",children:e("sync_section.password")}),n.jsx(x,{id:"sync-pw",type:"password",value:P,onChange:e=>H(e.target.value),placeholder:t.passwordSet?e("sync_section.password_set_placeholder"):e("sync_section.password_unset_placeholder")}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",dangerouslySetInnerHTML:{__html:e("sync_section.sshpass_hint")}})]})]})]}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-sm font-semibold mb-3",children:e("sync_section.strategy_section")}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[n.jsxs("div",{children:[n.jsx(u,{children:e("sync_section.direction")}),n.jsxs(O,{value:t.direction,onValueChange:e=>z("direction",e),children:[n.jsx(B,{children:n.jsx(D,{})}),n.jsxs(Q,{children:[n.jsx(W,{value:"push",children:e("sync_section.push_label")}),n.jsx(W,{value:"pull",children:e("sync_section.pull_label")}),n.jsx(W,{value:"bidirectional",children:e("sync_section.bidirectional_label")})]})]})]}),n.jsxs("div",{className:"flex items-end gap-2",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(u,{htmlFor:"sync-cron",children:e("sync_section.cron_label")}),n.jsx(x,{id:"sync-cron",value:t.schedule.cron,onChange:e=>z("schedule",{...t.schedule,cron:e.target.value}),placeholder:"0 3 * * *"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",dangerouslySetInnerHTML:{__html:e("sync_section.cron_hint")}})]}),n.jsxs("div",{className:"flex items-center gap-2 pb-1.5",children:[n.jsx(fe,{checked:t.schedule.enabled,onCheckedChange:e=>z("schedule",{...t.schedule,enabled:e})}),n.jsx("span",{className:"text-xs text-muted-foreground",children:e("sync_section.enable_label")})]})]})]})]}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-sm font-semibold mb-3",children:e("sync_section.exclude_section")}),n.jsx("textarea",{value:F,onChange:e=>L(e.target.value),rows:6,className:"w-full font-mono text-xs p-2 rounded border border-input bg-background resize-y",placeholder:"node_modules/\n.git/objects/\n*.log"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",dangerouslySetInnerHTML:{__html:e("sync_section.exclude_hint")}})]}),n.jsxs("div",{className:"flex flex-wrap gap-2 pt-2 border-t",children:[n.jsxs(p,{onClick:()=>{(async()=>{if(t){r(!0);try{const s=F.split("\n").map(e=>e.trim()).filter(Boolean),n={host:t.host,port:t.port,user:t.user,authMethod:t.authMethod,keyPath:t.keyPath,remoteRoot:t.remoteRoot,direction:t.direction,defaultExcludes:s,schedule:t.schedule};P&&"__keep__"!==P&&(n.password=P);const c=await y(n);a(c),L(c.defaultExcludes.join("\n")),H(""),m.success(e("sync_section.saved"))}catch(s){m.error(e("sync_section.save_failed",{message:s.message}))}finally{r(!1)}}})()},disabled:i,children:[i?n.jsx(g,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):n.jsx(Z,{className:"h-3.5 w-3.5 mr-1.5"}),e("sync_section.save_button")]}),n.jsxs(p,{variant:"outline",onClick:()=>{(async()=>{N(!0);try{const s=await f();s.ok?m.success(s.message||e("sync_section.test_ok")):m.error(s.message||e("sync_section.test_failed"))}catch(s){m.error(e("sync_section.test_failed_with_reason",{message:s.message}))}finally{N(!1)}})()},disabled:k,children:[k?n.jsx(g,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):n.jsx(ie,{className:"h-3.5 w-3.5 mr-1.5"}),e("sync_section.test_button")]}),n.jsx("div",{className:"flex-1"}),w&&T&&n.jsx("span",{className:"text-xs text-muted-foreground self-center mr-1 tabular-nums",children:R>0?e("sync_section.syncing_with_files",{project:T,files:R}):e("sync_section.syncing_no_files",{project:T})}),n.jsxs(p,{variant:"outline",onClick:()=>{(async()=>{C(!0);try{const s=await _(),t=s.results.filter(e=>e.ok).length,a=s.results.filter(e=>e.skipped).length,n=s.results.filter(e=>"cancelled"===e.reason).length,c=s.total-t-a-n;n>0?m.info(e("sync_section.bulk_cancelled_toast",{ok:t,skipped:a,cancelled:n,failed:c})):m.success(e("sync_section.bulk_done_toast",{ok:t,skipped:a,failed:c}))}catch(s){m.error(e("sync_section.bulk_failed_toast",{message:s.message}))}finally{C(!1),M(!1),E(null),I(0)}})()},disabled:w,title:e("sync_section.sync_all_title"),children:[w?n.jsx(g,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):n.jsx($,{className:"h-3.5 w-3.5 mr-1.5"}),e("sync_section.sync_all_button")]}),w&&n.jsxs(p,{variant:"outline",onClick:()=>{(async()=>{if(w&&!S){M(!0);try{await v(),m.info(e("sync_section.cancel_requested"))}catch(s){m.error(e("sync_section.cancel_failed",{message:s.message})),M(!1)}}})()},disabled:S,title:e("sync_section.cancel_button_title"),children:[S?n.jsx(g,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):n.jsx(j,{className:"h-3.5 w-3.5 mr-1.5"}),e("sync_section.cancel_button")]})]}),n.jsxs("div",{className:"border-t pt-4 text-xs text-muted-foreground",children:["Per-project push/pull: from inside a project, click the ",n.jsx($,{className:"inline h-3 w-3"})," / ",n.jsx(b,{className:"inline h-3 w-3"})," buttons in the header. Or call ",n.jsx("code",{children:"POST /api/sync/project/:id"})," with body ",n.jsx("code",{children:'{ "direction": "push" }'}),"."]})]})}function ve(){const e=k(),[t,a]=s.useState(null),[c,l]=s.useState(!0),[i,r]=s.useState(""),[o,d]=s.useState(!1);s.useEffect(()=>{let e=!1;return N().then(s=>{e||a(s)}).catch(()=>{e||a({configured:!1,needsReset:!1})}).finally(()=>{e||l(!1)}),()=>{e=!0}},[]);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-sm font-semibold mb-1",children:"CCWeb Hub 直接提交"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:['配置你的 GitHub PAT 后,在 Quick Prompts / Agent Prompts 卡片右键选择"共享"时可一键直接提交 Issue 到 ',n.jsx("code",{children:"zbc0315/ccweb-hub"}),"。 ccweb 本身不自带 token —— 使用你自己的账号身份提交,归属清晰,互不影响。"]})]}),c?n.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-2",children:[n.jsx(g,{className:"h-4 w-4 animate-spin"}),"加载中…"]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"rounded-md border px-3 py-2.5 text-xs flex items-center gap-2",children:(null==t?void 0:t.configured)?n.jsxs(n.Fragment,{children:[n.jsx(se,{className:"h-4 w-4 text-green-500 shrink-0"}),n.jsx("span",{children:"已配置 token,可直接提交"}),n.jsx("div",{className:"flex-1"}),n.jsxs(p,{size:"sm",variant:"outline",onClick:()=>{(async()=>{if(await e({title:"清除 Hub Token",description:"清除后将无法直接提交到 ccweb-hub,需要重新配置 token。确认?",destructive:!0,confirmLabel:"清除"}))try{await C(),a({configured:!1,needsReset:!1}),m.success("已清除")}catch(s){m.error(`清除失败: ${s.message}`)}})()},children:[n.jsx(w,{className:"h-3.5 w-3.5 mr-1"}),"清除"]})]}):(null==t?void 0:t.needsReset)?n.jsxs(n.Fragment,{children:[n.jsx(ae,{className:"h-4 w-4 text-amber-500 shrink-0"}),n.jsx("span",{children:"之前的 token 已失效(服务端密钥可能已轮换),请重新设置"})]}):n.jsxs(n.Fragment,{children:[n.jsx(ae,{className:"h-4 w-4 text-muted-foreground shrink-0"}),n.jsx("span",{children:"尚未配置 token"})]})}),n.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2.5 text-xs space-y-2",children:[n.jsx("div",{className:"font-medium text-foreground",children:"如何获取 token"}),n.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-muted-foreground",children:[n.jsxs("li",{children:["打开"," ",n.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline inline-flex items-center gap-0.5",children:["GitHub fine-grained PAT",n.jsx(J,{className:"h-3 w-3"})]})," ","创建页"]}),n.jsxs("li",{children:[n.jsx("strong",{className:"text-foreground",children:"Repository access"}),':选 "Only select repositories",添加 ',n.jsx("code",{children:"zbc0315/ccweb-hub"})]}),n.jsxs("li",{children:[n.jsx("strong",{className:"text-foreground",children:"Repository permissions → Issues"}),':设置为 "Read and write"']}),n.jsx("li",{children:"其余权限保持默认(全部无访问)"}),n.jsx("li",{children:"生成后复制 token 粘贴到下方"})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs(u,{htmlFor:"hub-token",className:"text-xs",children:["GitHub Token ",(null==t?void 0:t.configured)&&n.jsx("span",{className:"text-muted-foreground",children:"(填写会覆盖现有 token)"})]}),n.jsx(x,{id:"hub-token",type:"password",placeholder:"github_pat_...",value:i,onChange:e=>r(e.target.value),autoComplete:"off",spellCheck:!1}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Token 以 AES-256-GCM 加密存储于 ",n.jsx("code",{children:"~/.ccweb/hub-auth/"}),";per-user 独立,不会被其他用户读到。"]})]}),n.jsx("div",{className:"flex gap-2 pt-2 border-t",children:n.jsxs(p,{onClick:()=>{(async()=>{const e=i.trim();if(e){d(!0);try{const s=await S(e);a(s),r(""),m.success("已保存")}catch(s){m.error(`保存失败: ${s.message}`)}finally{d(!1)}}else m.error("请输入 token")})()},disabled:o||!i.trim(),children:[o?n.jsx(g,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):n.jsx(Z,{className:"h-3.5 w-3.5 mr-1.5"}),"保存"]})})]})]})}function ke(){const{t:e,i18n:s}=o();return n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(le,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs(O,{value:s.language,onValueChange:async t=>{if(M.includes(t)){try{localStorage.setItem(T,t)}catch{}await s.changeLanguage(t);try{await E(t)}catch{m.error(e("language.switch_failed"))}}},children:[n.jsx(B,{className:"w-40",children:n.jsx(D,{})}),n.jsxs(Q,{children:[n.jsx(W,{value:"zh",children:e("language.zh")}),n.jsx(W,{value:"en",children:e("language.en")})]})]})]})}function Ne(){const{t:e}=o(),t=R(),[a]=I(),c=a.get("tab")||"sync",[l,i]=s.useState(()=>P()),[r,d]=s.useState(!1),[h,g]=s.useState({webhookEnabled:!1}),[j,b]=s.useState(""),[y,f]=s.useState(!1),[_,v]=s.useState(()=>H(F.usageMonitorTool,"claude"));s.useEffect(()=>{L().then(e=>{g(e),b(e.webhookUrl??"")}).catch(()=>{})},[]);const k=(e,s)=>{const t=parseInt(s,10);isNaN(t)||t<1||(i(s=>({...s,[e]:t})),d(!0))};return n.jsx("div",{className:"min-h-screen bg-background",children:n.jsxs("div",{className:"max-w-3xl mx-auto p-6",children:[n.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[n.jsxs(p,{variant:"ghost",size:"sm",onClick:()=>t("/"),children:[n.jsx(z,{className:"h-4 w-4 mr-1"}),e("common.back")]}),n.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:e("settings.title")})]}),n.jsxs(X,{defaultValue:c,children:[n.jsxs(K,{className:"mb-4",children:[n.jsxs(Y,{value:"sync",children:[n.jsx(re,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_sync")]}),n.jsxs(Y,{value:"hub",children:[n.jsx(ce,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_hub")]}),n.jsxs(Y,{value:"notifications",children:[n.jsx(ne,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_notifications")]}),n.jsxs(Y,{value:"pomodoro",children:[n.jsx(A,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_pomodoro")]}),n.jsxs(Y,{value:"usage",children:[n.jsx(te,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_usage")]}),n.jsxs(Y,{value:"language",children:[n.jsx(le,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_language")]})]}),n.jsx(ee,{value:"sync",children:n.jsx(_e,{})}),n.jsx(ee,{value:"hub",children:n.jsx(ve,{})}),n.jsx(ee,{value:"notifications",children:n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-2",children:[n.jsx("h3",{className:"text-sm font-medium",children:e("settings.browser_notify.title")}),n.jsx("p",{className:"text-xs text-muted-foreground",children:e("settings.browser_notify.description")})]}),n.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-3",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-sm font-medium",children:e("settings.webhook.title")}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("settings.webhook.description")})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(u,{className:"text-xs",children:"Webhook URL"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(x,{placeholder:"https://hooks.slack.com/...",value:j,onChange:e=>b(e.target.value),className:"font-mono text-xs"}),n.jsx(p,{size:"sm",onClick:()=>{(async()=>{f(!0);try{const s=await U({webhookEnabled:j.trim().length>0,webhookUrl:j.trim()||void 0});g(s),m.success(e("settings.webhook.saved"))}catch{m.error(e("settings.webhook.save_failed"))}finally{f(!1)}})()},disabled:y,children:e(y?"common.saving":"common.save")})]}),h.webhookEnabled&&h.webhookUrl&&n.jsxs("p",{className:"text-xs text-green-500",children:[e("settings.webhook.enabled_prefix")," ",h.webhookUrl]})]})]})]})}),n.jsx(ee,{value:"pomodoro",children:n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-sm font-medium",children:e("settings.pomodoro.section_title")}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("settings.pomodoro.section_desc")})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-6 max-w-xs",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(u,{className:"text-xs",children:e("settings.pomodoro.work_minutes")}),n.jsx(x,{type:"number",min:1,max:120,value:l.workMinutes,onChange:e=>k("workMinutes",e.target.value),className:"w-full"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(u,{className:"text-xs",children:e("settings.pomodoro.break_minutes")}),n.jsx(x,{type:"number",min:1,max:60,value:l.breakMinutes,onChange:e=>k("breakMinutes",e.target.value),className:"w-full"})]})]}),r&&n.jsxs(p,{size:"sm",onClick:()=>{q(F.pomodoroConfig,l,!0),d(!1),m.success(e("settings.pomodoro.saved"))},children:[n.jsx(Z,{className:"h-3.5 w-3.5 mr-1.5"}),e("common.save")]})]}),n.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-2",children:[n.jsx("h3",{className:"text-sm font-medium",children:e("settings.pomodoro.howto_title")}),n.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1 list-disc list-inside",children:[n.jsxs("li",{children:[n.jsx(A,{className:"h-3 w-3 inline-block mx-0.5"})," ",e("settings.pomodoro.howto_item_1")]}),n.jsx("li",{children:e("settings.pomodoro.howto_item_2")}),n.jsx("li",{children:e("settings.pomodoro.howto_item_3")}),n.jsx("li",{children:e("settings.pomodoro.howto_item_4")}),n.jsx("li",{children:e("settings.pomodoro.howto_item_5")})]})]})]})}),n.jsx(ee,{value:"usage",children:n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-sm font-medium",children:e("settings.usage.section_title")}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("settings.usage.section_desc")})]}),n.jsx("div",{className:"grid gap-3 max-w-md",children:[{key:"claude",label:"Claude Code",desc:e("settings.usage.tool_claude_desc")},{key:"codex",label:"Codex",desc:e("settings.usage.tool_codex_desc")},{key:"opencode",label:"OpenCode",desc:e("settings.usage.tool_opencode_desc")},{key:"qwen",label:"Qwen Code",desc:e("settings.usage.tool_qwen_desc")},{key:"gemini",label:"Gemini CLI",desc:e("settings.usage.tool_gemini_desc")}].map(s=>n.jsxs("label",{className:"flex items-start gap-3 rounded-md border p-3 cursor-pointer transition-colors "+(_===s.key?"border-blue-500/50 bg-blue-500/5":"border-border hover:bg-muted/30"),children:[n.jsx("input",{type:"radio",name:"usageTool",value:s.key,checked:_===s.key,onChange:()=>{v(s.key),q(F.usageMonitorTool,s.key),window.dispatchEvent(new Event("ccweb:usage-tool-change")),m.success(e("settings.usage.switched_toast",{tool:s.label}))},className:"mt-0.5"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium",children:s.label}),n.jsx("div",{className:"text-xs text-muted-foreground",children:s.desc})]})]},s.key))})]}),n.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-2",children:[n.jsx("h3",{className:"text-sm font-medium",children:e("settings.usage.info_title")}),n.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1 list-disc list-inside",children:[n.jsx("li",{children:e("settings.usage.info_item_1")}),n.jsx("li",{children:e("settings.usage.info_item_2")}),n.jsx("li",{children:e("settings.usage.info_item_3")}),n.jsx("li",{children:e("settings.usage.info_item_4")})]})]})]})}),n.jsx(ee,{value:"language",children:n.jsx("div",{className:"space-y-6",children:n.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-3",children:[n.jsx("div",{children:n.jsx("h3",{className:"text-sm font-medium",children:e("language.label")})}),n.jsx(ke,{})]})})})]})]})})}export{Ne as SettingsPage};
@@ -1,4 +1,4 @@
1
- import{c as e,aH as s,r as t,bl as a,bm as r,t as n,bn as l,bo as i,bp as c,ak as d,bq as o,j as m,B as x,aK as u,d as p,I as h,T as g,q as f,D as j,aD as b,aE as N,A as y,ap as v,av as k}from"./index-BnxUVJSG.js";import{S as w}from"./search-F_MnOHbB.js";import{C}from"./chevron-down-C53vkdK1.js";
1
+ import{c as e,aI as s,r as t,bl as a,bm as r,t as n,bn as l,bo as i,bp as c,ak as d,bq as o,j as m,B as x,aD as u,d as p,I as h,T as g,q as f,D as j,aE as b,aF as N,A as y,ap as v,av as k}from"./index-nYsy3LMF.js";import{S as w}from"./search-B9B3Cq4V.js";import{C}from"./chevron-down-B3q2CU-d.js";
2
2
  /**
3
3
  * @license lucide-react v0.309.0 - ISC
4
4
  *
@@ -10,4 +10,4 @@ import{c as e,aH as s,r as t,bl as a,bm as r,t as n,bn as l,bo as i,bp as c,ak a
10
10
  *
11
11
  * This source code is licensed under the ISC license.
12
12
  * See the LICENSE file in the root directory of this source tree.
13
- */function z(){const e=s(),[z,M]=t.useState("prompts"),[H,_]=t.useState(""),[F,Q]=t.useState([]),[W,D]=t.useState([]),[I,O]=t.useState(!1),[T,U]=t.useState(null);t.useEffect(()=>{"plugins"===z&&(O(!0),Promise.all([a().catch(()=>[]),fetch("/api/skillhub/plugins").then(e=>e.ok?e.json():[]).catch(()=>[])]).then(([e,s])=>{Q(e),D(s)}).finally(()=>O(!1)))},[z]);const Z=t.useCallback(async e=>{if(!T){U(e.id);try{await r(e.downloadUrl),n.success(`已安装 ${e.name}`);const s=await a().catch(()=>[]);Q(s)}catch(s){n.error(s instanceof Error?s.message:"安装失败")}finally{U(null)}}},[T]),B=t.useCallback(async e=>{try{await l(e),Q(s=>s.filter(s=>s.id!==e)),n.success("已卸载")}catch(s){n.error(s instanceof Error?s.message:"卸载失败")}},[]),K=t.useCallback(async(e,s)=>{try{await i(e,s),Q(t=>t.map(t=>t.id===e?{...t,enabled:s}:t))}catch(t){n.error(t instanceof Error?t.message:"操作失败")}},[]),[$,G]=t.useState([]),[J,R]=t.useState(!0),[V,X]=t.useState(null),[Y,ee]=t.useState("all"),[se,te]=t.useState(null),[ae,re]=t.useState(null),[ne,le]=t.useState(new Set),[ie,ce]=t.useState(null);t.useEffect(()=>{Promise.all([c(),d().catch(()=>[]),o().catch(()=>[])]).then(([e,s,t])=>{G(e);const a=new Set;for(const r of e)"quick-prompt"===r.kind?s.some(e=>e.label===r.label&&e.command===r.body)&&a.add(r.id):t.some(e=>e.label===r.label&&e.command===r.body)&&a.add(r.id);le(a)}).catch(e=>X(e instanceof Error?e.message:"Failed to load CCWeb Hub")).finally(()=>R(!1))},[]);const de=t.useMemo(()=>{const e=new Set;return $.forEach(s=>{var t;return null==(t=s.tags)?void 0:t.forEach(s=>e.add(s))}),[...e].sort()},[$]),oe=t.useMemo(()=>{let e=$;"all"!==Y&&(e=e.filter(e=>e.kind===Y)),"__untagged__"===se?e=e.filter(e=>!e.tags||0===e.tags.length):se&&(e=e.filter(e=>{var s;return null==(s=e.tags)?void 0:s.includes(se)}));const s=H.trim().toLowerCase();return s&&(e=e.filter(e=>e.label.toLowerCase().includes(s)||e.body.toLowerCase().includes(s)||(e.description??"").toLowerCase().includes(s)||(e.author??"").toLowerCase().includes(s)||(e.tags??[]).some(e=>e.toLowerCase().includes(s)))),e},[$,Y,se,H]);return m.jsxs("div",{className:"min-h-screen bg-background",children:[m.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:m.jsxs("div",{className:"max-w-4xl mx-auto px-4 h-14 flex items-center gap-4",children:[m.jsxs(x,{variant:"ghost",size:"sm",onClick:()=>e("/"),children:[m.jsx(u,{className:"h-4 w-4 mr-1"}),"返回"]}),m.jsx("h1",{className:"font-semibold text-lg",children:"CCWeb Hub"}),m.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[m.jsx("button",{onClick:()=>M("prompts"),className:p("px-3 py-1 rounded-md text-sm transition-colors","prompts"===z?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"),children:"Prompts"}),m.jsxs("button",{onClick:()=>M("plugins"),className:p("px-3 py-1 rounded-md text-sm transition-colors flex items-center gap-1","plugins"===z?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"),children:[m.jsx(P,{className:"h-3.5 w-3.5"}),"插件"]})]}),m.jsx("div",{className:"flex-1"}),m.jsxs("div",{className:"relative w-64",children:[m.jsx(w,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),m.jsx(h,{placeholder:"prompts"===z?"搜索 prompt...":"搜索插件...",value:H,onChange:e=>_(e.target.value),className:"pl-8 h-9"})]})]})}),m.jsxs("main",{className:"max-w-4xl mx-auto px-4 py-6",children:["plugins"===z&&m.jsxs("div",{children:[I&&m.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),!I&&m.jsxs(m.Fragment,{children:[F.length>0&&m.jsxs("div",{className:"mb-8",children:[m.jsx("h2",{className:"text-sm font-medium text-muted-foreground mb-3",children:"已安装"}),m.jsx("div",{className:"space-y-2",children:F.map(e=>m.jsxs("div",{className:"rounded-xl border bg-card p-4 flex items-center gap-4",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"font-medium text-sm",children:e.name}),m.jsxs("span",{className:"text-xs text-muted-foreground",children:["v",e.version]}),m.jsx("span",{className:p("text-xs px-1.5 py-0.5 rounded",e.enabled?"bg-green-500/10 text-green-500":"bg-muted text-muted-foreground"),children:e.enabled?"启用":"禁用"})]}),m.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:e.description}),e.permissions.length>0&&m.jsx("div",{className:"flex gap-1 mt-1 flex-wrap",children:e.permissions.map(e=>m.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400",children:e},e))})]}),m.jsx(x,{size:"sm",variant:"ghost",onClick:()=>K(e.id,!e.enabled),title:e.enabled?"禁用":"启用",children:m.jsx(S,{className:p("h-4 w-4",e.enabled?"text-green-500":"text-muted-foreground")})}),m.jsx(x,{size:"sm",variant:"ghost",onClick:()=>B(e.id),title:"卸载",children:m.jsx(g,{className:"h-4 w-4 text-red-400"})})]},e.id))})]}),m.jsxs("div",{children:[m.jsx("h2",{className:"text-sm font-medium text-muted-foreground mb-3",children:F.length>0?"更多插件":"可用插件"}),0===W.length&&m.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[m.jsx(P,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),m.jsx("p",{className:"text-sm",children:"Hub 暂无可用插件"})]}),m.jsx("div",{className:"space-y-2",children:W.filter(e=>!F.some(s=>s.id===e.id)).map((e,s)=>{const t=T===e.id;return m.jsxs(f.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25,delay:.03*s},className:"rounded-xl border bg-card p-4 flex items-center gap-4",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"font-medium text-sm",children:e.name}),m.jsxs("span",{className:"text-xs text-muted-foreground",children:["v",e.version]}),m.jsxs("span",{className:"text-xs text-muted-foreground",children:["by ",e.author]})]}),m.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.description}),e.permissions.length>0&&m.jsx("div",{className:"flex gap-1 mt-1 flex-wrap",children:e.permissions.map(e=>m.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400",children:e},e))})]}),m.jsxs(x,{size:"sm",disabled:t,onClick:()=>Z(e),children:[m.jsx(j,{className:"h-3.5 w-3.5 mr-1"}),t?"安装中...":"安装"]})]},e.id)})})]})]})]}),"prompts"===z&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[m.jsx(A,{active:"all"===Y,onClick:()=>ee("all"),children:"全部"}),m.jsxs(A,{active:"quick-prompt"===Y,onClick:()=>ee("quick-prompt"),children:[m.jsx(b,{className:"h-3 w-3"}),"Quick Prompts"]}),m.jsxs(A,{active:"agent-prompt"===Y,onClick:()=>ee("agent-prompt"),children:[m.jsx(N,{className:"h-3 w-3"}),"Agent Prompts"]})]}),de.length>0&&m.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[m.jsx(L,{active:null===se,onClick:()=>te(null),children:"全部标签"}),de.map(e=>m.jsx(L,{active:se===e,onClick:()=>te(se===e?null:e),children:e},e))]}),J&&m.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),V&&m.jsx("div",{className:"text-center text-destructive py-20",children:V}),!J&&!V&&0===$.length&&m.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[m.jsx("p",{className:"text-lg mb-2",children:"CCWeb Hub 还没有 prompt"}),m.jsx("p",{className:"text-sm",children:'在 Quick Prompts 或 Agent Prompts 卡片上右键选择"共享"来提交第一个吧!'})]}),!J&&!V&&$.length>0&&0===oe.length&&m.jsx("div",{className:"text-center text-muted-foreground py-20",children:"没有匹配的 prompt"}),m.jsx("div",{className:"space-y-3",children:oe.map((e,s)=>{var t;const a=ae===e.id,r=ne.has(e.id),l=ie===e.id;return m.jsxs(f.div,{layout:!0,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25,delay:.03*s,ease:"easeOut"},className:"rounded-xl border bg-card p-4 cursor-pointer hover:border-muted-foreground/30 transition-colors",onClick:()=>re(a?null:e.id),children:[m.jsxs("div",{className:"flex items-start justify-between gap-4",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[m.jsxs("span",{className:p("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium","quick-prompt"===e.kind?"bg-blue-500/15 text-blue-400":"bg-green-500/15 text-green-500"),children:["quick-prompt"===e.kind?m.jsx(b,{className:"h-2.5 w-2.5"}):m.jsx(N,{className:"h-2.5 w-2.5"}),"quick-prompt"===e.kind?"Quick":"Agent"]}),m.jsx("h3",{className:"font-medium text-sm truncate",children:e.label}),null==(t=e.tags)?void 0:t.map(e=>m.jsxs("span",{className:"inline-flex items-center gap-0.5 px-2 py-0.5 rounded-full text-xs bg-muted text-muted-foreground",children:[m.jsx(q,{className:"h-2.5 w-2.5"}),e]},e))]}),e.description&&m.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:e.description}),m.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.author&&m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx(E,{className:"h-3 w-3"}),e.author]}),m.jsx("code",{className:"text-[10px] opacity-60",children:e.file})]})]}),m.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m.jsxs(x,{size:"sm",variant:r?"ghost":"outline",disabled:l||r,onClick:s=>{(async(e,s)=>{if(s.stopPropagation(),!ie&&!ne.has(e.id)){ce(e.id);try{"quick-prompt"===e.kind?(await v({label:e.label,command:e.body}),n.success("已导入到全局快捷 Prompts")):(await k({label:e.label,command:e.body}),n.success("已导入到全局 Agent Prompts")),le(s=>new Set(s).add(e.id))}catch(t){n.error(t instanceof Error?t.message:"导入失败")}finally{ce(null)}}})(e,s)},title:"quick-prompt"===e.kind?"导入到全局快捷 Prompts":"导入到全局 Agent Prompts",children:[m.jsx(j,{className:"h-3.5 w-3.5 mr-1"}),r?"已导入":l?"导入中...":"导入"]}),m.jsx(f.span,{animate:{rotate:a?180:0},transition:{duration:.2},children:m.jsx(C,{className:"h-4 w-4 text-muted-foreground"})})]})]}),m.jsx(y,{children:a&&m.jsx(f.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:"overflow-hidden",children:m.jsx("div",{className:"mt-3 pt-3 border-t",children:m.jsx("pre",{className:"text-xs font-mono bg-muted rounded p-3 whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:e.body})})})})]},e.id)})})]})]})]})}function A({active:e,onClick:s,children:t}){return m.jsx("button",{onClick:s,className:p("flex items-center gap-1 px-3 py-1 rounded-full text-xs font-medium transition-colors",e?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),children:t})}function L({active:e,onClick:s,children:t}){return m.jsx("button",{onClick:s,className:p("px-3 py-1 rounded-full text-xs font-medium transition-colors",e?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),children:t})}export{z as SkillHubPage};
13
+ */function z(){const e=s(),[z,M]=t.useState("prompts"),[H,F]=t.useState(""),[_,I]=t.useState([]),[Q,W]=t.useState([]),[D,O]=t.useState(!1),[T,U]=t.useState(null);t.useEffect(()=>{"plugins"===z&&(O(!0),Promise.all([a().catch(()=>[]),fetch("/api/skillhub/plugins").then(e=>e.ok?e.json():[]).catch(()=>[])]).then(([e,s])=>{I(e),W(s)}).finally(()=>O(!1)))},[z]);const Z=t.useCallback(async e=>{if(!T){U(e.id);try{await r(e.downloadUrl),n.success(`已安装 ${e.name}`);const s=await a().catch(()=>[]);I(s)}catch(s){n.error(s instanceof Error?s.message:"安装失败")}finally{U(null)}}},[T]),B=t.useCallback(async e=>{try{await l(e),I(s=>s.filter(s=>s.id!==e)),n.success("已卸载")}catch(s){n.error(s instanceof Error?s.message:"卸载失败")}},[]),$=t.useCallback(async(e,s)=>{try{await i(e,s),I(t=>t.map(t=>t.id===e?{...t,enabled:s}:t))}catch(t){n.error(t instanceof Error?t.message:"操作失败")}},[]),[G,J]=t.useState([]),[K,R]=t.useState(!0),[V,X]=t.useState(null),[Y,ee]=t.useState("all"),[se,te]=t.useState(null),[ae,re]=t.useState(null),[ne,le]=t.useState(new Set),[ie,ce]=t.useState(null);t.useEffect(()=>{Promise.all([c(),d().catch(()=>[]),o().catch(()=>[])]).then(([e,s,t])=>{J(e);const a=new Set;for(const r of e)"quick-prompt"===r.kind?s.some(e=>e.label===r.label&&e.command===r.body)&&a.add(r.id):t.some(e=>e.label===r.label&&e.command===r.body)&&a.add(r.id);le(a)}).catch(e=>X(e instanceof Error?e.message:"Failed to load CCWeb Hub")).finally(()=>R(!1))},[]);const de=t.useMemo(()=>{const e=new Set;return G.forEach(s=>{var t;return null==(t=s.tags)?void 0:t.forEach(s=>e.add(s))}),[...e].sort()},[G]),oe=t.useMemo(()=>{let e=G;"all"!==Y&&(e=e.filter(e=>e.kind===Y)),"__untagged__"===se?e=e.filter(e=>!e.tags||0===e.tags.length):se&&(e=e.filter(e=>{var s;return null==(s=e.tags)?void 0:s.includes(se)}));const s=H.trim().toLowerCase();return s&&(e=e.filter(e=>e.label.toLowerCase().includes(s)||e.body.toLowerCase().includes(s)||(e.description??"").toLowerCase().includes(s)||(e.author??"").toLowerCase().includes(s)||(e.tags??[]).some(e=>e.toLowerCase().includes(s)))),e},[G,Y,se,H]);return m.jsxs("div",{className:"min-h-screen bg-background",children:[m.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:m.jsxs("div",{className:"max-w-4xl mx-auto px-4 h-14 flex items-center gap-4",children:[m.jsxs(x,{variant:"ghost",size:"sm",onClick:()=>e("/"),children:[m.jsx(u,{className:"h-4 w-4 mr-1"}),"返回"]}),m.jsx("h1",{className:"font-semibold text-lg",children:"CCWeb Hub"}),m.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[m.jsx("button",{onClick:()=>M("prompts"),className:p("px-3 py-1 rounded-md text-sm transition-colors","prompts"===z?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"),children:"Prompts"}),m.jsxs("button",{onClick:()=>M("plugins"),className:p("px-3 py-1 rounded-md text-sm transition-colors flex items-center gap-1","plugins"===z?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"),children:[m.jsx(P,{className:"h-3.5 w-3.5"}),"插件"]})]}),m.jsx("div",{className:"flex-1"}),m.jsxs("div",{className:"relative w-64",children:[m.jsx(w,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),m.jsx(h,{placeholder:"prompts"===z?"搜索 prompt...":"搜索插件...",value:H,onChange:e=>F(e.target.value),className:"pl-8 h-9"})]})]})}),m.jsxs("main",{className:"max-w-4xl mx-auto px-4 py-6",children:["plugins"===z&&m.jsxs("div",{children:[D&&m.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),!D&&m.jsxs(m.Fragment,{children:[_.length>0&&m.jsxs("div",{className:"mb-8",children:[m.jsx("h2",{className:"text-sm font-medium text-muted-foreground mb-3",children:"已安装"}),m.jsx("div",{className:"space-y-2",children:_.map(e=>m.jsxs("div",{className:"rounded-xl border bg-card p-4 flex items-center gap-4",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"font-medium text-sm",children:e.name}),m.jsxs("span",{className:"text-xs text-muted-foreground",children:["v",e.version]}),m.jsx("span",{className:p("text-xs px-1.5 py-0.5 rounded",e.enabled?"bg-green-500/10 text-green-500":"bg-muted text-muted-foreground"),children:e.enabled?"启用":"禁用"})]}),m.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:e.description}),e.permissions.length>0&&m.jsx("div",{className:"flex gap-1 mt-1 flex-wrap",children:e.permissions.map(e=>m.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400",children:e},e))})]}),m.jsx(x,{size:"sm",variant:"ghost",onClick:()=>$(e.id,!e.enabled),title:e.enabled?"禁用":"启用",children:m.jsx(S,{className:p("h-4 w-4",e.enabled?"text-green-500":"text-muted-foreground")})}),m.jsx(x,{size:"sm",variant:"ghost",onClick:()=>B(e.id),title:"卸载",children:m.jsx(g,{className:"h-4 w-4 text-red-400"})})]},e.id))})]}),m.jsxs("div",{children:[m.jsx("h2",{className:"text-sm font-medium text-muted-foreground mb-3",children:_.length>0?"更多插件":"可用插件"}),0===Q.length&&m.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[m.jsx(P,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),m.jsx("p",{className:"text-sm",children:"Hub 暂无可用插件"})]}),m.jsx("div",{className:"space-y-2",children:Q.filter(e=>!_.some(s=>s.id===e.id)).map((e,s)=>{const t=T===e.id;return m.jsxs(f.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25,delay:.03*s},className:"rounded-xl border bg-card p-4 flex items-center gap-4",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"font-medium text-sm",children:e.name}),m.jsxs("span",{className:"text-xs text-muted-foreground",children:["v",e.version]}),m.jsxs("span",{className:"text-xs text-muted-foreground",children:["by ",e.author]})]}),m.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.description}),e.permissions.length>0&&m.jsx("div",{className:"flex gap-1 mt-1 flex-wrap",children:e.permissions.map(e=>m.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400",children:e},e))})]}),m.jsxs(x,{size:"sm",disabled:t,onClick:()=>Z(e),children:[m.jsx(j,{className:"h-3.5 w-3.5 mr-1"}),t?"安装中...":"安装"]})]},e.id)})})]})]})]}),"prompts"===z&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[m.jsx(A,{active:"all"===Y,onClick:()=>ee("all"),children:"全部"}),m.jsxs(A,{active:"quick-prompt"===Y,onClick:()=>ee("quick-prompt"),children:[m.jsx(b,{className:"h-3 w-3"}),"Quick Prompts"]}),m.jsxs(A,{active:"agent-prompt"===Y,onClick:()=>ee("agent-prompt"),children:[m.jsx(N,{className:"h-3 w-3"}),"Agent Prompts"]})]}),de.length>0&&m.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[m.jsx(L,{active:null===se,onClick:()=>te(null),children:"全部标签"}),de.map(e=>m.jsx(L,{active:se===e,onClick:()=>te(se===e?null:e),children:e},e))]}),K&&m.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),V&&m.jsx("div",{className:"text-center text-destructive py-20",children:V}),!K&&!V&&0===G.length&&m.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[m.jsx("p",{className:"text-lg mb-2",children:"CCWeb Hub 还没有 prompt"}),m.jsx("p",{className:"text-sm",children:'在 Quick Prompts 或 Agent Prompts 卡片上右键选择"共享"来提交第一个吧!'})]}),!K&&!V&&G.length>0&&0===oe.length&&m.jsx("div",{className:"text-center text-muted-foreground py-20",children:"没有匹配的 prompt"}),m.jsx("div",{className:"space-y-3",children:oe.map((e,s)=>{var t;const a=ae===e.id,r=ne.has(e.id),l=ie===e.id;return m.jsxs(f.div,{layout:!0,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25,delay:.03*s,ease:"easeOut"},className:"rounded-xl border bg-card p-4 cursor-pointer hover:border-muted-foreground/30 transition-colors",onClick:()=>re(a?null:e.id),children:[m.jsxs("div",{className:"flex items-start justify-between gap-4",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[m.jsxs("span",{className:p("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium","quick-prompt"===e.kind?"bg-blue-500/15 text-blue-400":"bg-green-500/15 text-green-500"),children:["quick-prompt"===e.kind?m.jsx(b,{className:"h-2.5 w-2.5"}):m.jsx(N,{className:"h-2.5 w-2.5"}),"quick-prompt"===e.kind?"Quick":"Agent"]}),m.jsx("h3",{className:"font-medium text-sm truncate",children:e.label}),null==(t=e.tags)?void 0:t.map(e=>m.jsxs("span",{className:"inline-flex items-center gap-0.5 px-2 py-0.5 rounded-full text-xs bg-muted text-muted-foreground",children:[m.jsx(q,{className:"h-2.5 w-2.5"}),e]},e))]}),e.description&&m.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:e.description}),m.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.author&&m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx(E,{className:"h-3 w-3"}),e.author]}),m.jsx("code",{className:"text-[10px] opacity-60",children:e.file})]})]}),m.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m.jsxs(x,{size:"sm",variant:r?"ghost":"outline",disabled:l||r,onClick:s=>{(async(e,s)=>{if(s.stopPropagation(),!ie&&!ne.has(e.id)){ce(e.id);try{"quick-prompt"===e.kind?(await v({label:e.label,command:e.body}),n.success("已导入到全局快捷 Prompts")):(await k({label:e.label,command:e.body}),n.success("已导入到全局 Agent Prompts")),le(s=>new Set(s).add(e.id))}catch(t){n.error(t instanceof Error?t.message:"导入失败")}finally{ce(null)}}})(e,s)},title:"quick-prompt"===e.kind?"导入到全局快捷 Prompts":"导入到全局 Agent Prompts",children:[m.jsx(j,{className:"h-3.5 w-3.5 mr-1"}),r?"已导入":l?"导入中...":"导入"]}),m.jsx(f.span,{animate:{rotate:a?180:0},transition:{duration:.2},children:m.jsx(C,{className:"h-4 w-4 text-muted-foreground"})})]})]}),m.jsx(y,{children:a&&m.jsx(f.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:"overflow-hidden",children:m.jsx("div",{className:"mt-3 pt-3 border-t",children:m.jsx("pre",{className:"text-xs font-mono bg-muted rounded p-3 whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:e.body})})})})]},e.id)})})]})]})]})}function A({active:e,onClick:s,children:t}){return m.jsx("button",{onClick:s,className:p("flex items-center gap-1 px-3 py-1 rounded-full text-xs font-medium transition-colors",e?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),children:t})}function L({active:e,onClick:s,children:t}){return m.jsx("button",{onClick:s,className:p("px-3 py-1 rounded-full text-xs font-medium transition-colors",e?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),children:t})}export{z as SkillHubPage};
@@ -1,4 +1,4 @@
1
- import{c as o}from"./index-BnxUVJSG.js";
1
+ import{c as o}from"./index-nYsy3LMF.js";
2
2
  /**
3
3
  * @license lucide-react v0.309.0 - ISC
4
4
  *