@tom2012/cc-web 1.5.39 → 1.5.40
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/README.md +1 -1
- package/backend/dist/chat-process-manager.d.ts +43 -0
- package/backend/dist/chat-process-manager.d.ts.map +1 -0
- package/backend/dist/chat-process-manager.js +240 -0
- package/backend/dist/chat-process-manager.js.map +1 -0
- package/backend/dist/config.d.ts +2 -1
- package/backend/dist/config.d.ts.map +1 -1
- package/backend/dist/config.js +1 -0
- package/backend/dist/config.js.map +1 -1
- package/backend/dist/hooks-manager.d.ts +20 -0
- package/backend/dist/hooks-manager.d.ts.map +1 -0
- package/backend/dist/hooks-manager.js +139 -0
- package/backend/dist/hooks-manager.js.map +1 -0
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +113 -7
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/routes/hooks.d.ts +14 -0
- package/backend/dist/routes/hooks.d.ts.map +1 -0
- package/backend/dist/routes/hooks.js +62 -0
- package/backend/dist/routes/hooks.js.map +1 -0
- package/backend/dist/routes/projects.d.ts.map +1 -1
- package/backend/dist/routes/projects.js +46 -0
- package/backend/dist/routes/projects.js.map +1 -1
- package/backend/dist/routes/update.d.ts.map +1 -1
- package/backend/dist/routes/update.js +22 -13
- package/backend/dist/routes/update.js.map +1 -1
- package/backend/dist/session-manager.d.ts +9 -1
- package/backend/dist/session-manager.d.ts.map +1 -1
- package/backend/dist/session-manager.js +38 -12
- package/backend/dist/session-manager.js.map +1 -1
- package/backend/dist/types.d.ts +2 -0
- package/backend/dist/types.d.ts.map +1 -1
- package/frontend/dist/assets/ChatView-CmGXAs2a.js +11 -0
- package/frontend/dist/assets/{GraphPreview-N3E2cIAz.js → GraphPreview-0UgP3AnJ.js} +1 -1
- package/frontend/dist/assets/{OfficePreview-DU2Hm9q8.js → OfficePreview-DhY6Py9Y.js} +3 -3
- package/frontend/dist/assets/{ProjectPage-tQtkCa-F.js → ProjectPage-Ckxkh4Nr.js} +54 -54
- package/frontend/dist/assets/{SettingsPage-BOkP1J2E.js → SettingsPage-Dmb7V9a0.js} +3 -3
- package/frontend/dist/assets/{SkillHubPage-BCEiOqrp.js → SkillHubPage-C5zcxERj.js} +2 -2
- package/frontend/dist/assets/{chevron-down-3Iee9LeQ.js → chevron-down-BEvQLdWD.js} +1 -1
- package/frontend/dist/assets/{index-HZqCo2f1.js → index-C9_Mp1hE.js} +53 -48
- package/frontend/dist/assets/{index-DosNEafF.js → index-DEta9t2M.js} +1 -1
- package/frontend/dist/assets/{index-BoRMSxCU.css → index-DjgiG4hc.css} +1 -1
- package/frontend/dist/assets/{jszip.min-rijCkWTm.js → jszip.min-s-54SERU.js} +1 -1
- package/frontend/dist/assets/{select-CyT5wy3n.js → select-Cfjj__BG.js} +1 -1
- package/frontend/dist/assets/{user-DWfPqhZs.js → user-_adqQY3y.js} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/frontend/dist/assets/ChatView-DHceYEQu.js +0 -16
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as R,r,j as e,Y as ce,a0 as L,a1 as A,a4 as le,$ as Be,W as ie,
|
|
1
|
+
import{c as R,r,j as e,Y as ce,a0 as L,a1 as A,a4 as le,$ as Be,W as ie,av as Ge,a2 as ze,e as Q,aw as He,D as Ke,y as Ve,z as $e,B as Ue,H as Xe,K as I,L as P,I as z,J as Ye,ax as se,ay as q,az as qe,aA as Je,aB as Ze,ag as de,aC as Qe,l as ue,aD as We,ae as et,af as tt,v as st,A as at,o as nt,X as rt,aE as ot,aF as ct,aG as lt,aH as it,aI as dt,aJ as ut,aK as ae}from"./index-C9_Mp1hE.js";import{k as mt,u as me,d as xe,e as he,f as fe,g as pe,j as H,S as xt,b as ht}from"./select-Cfjj__BG.js";import"./chevron-down-BEvQLdWD.js";/**
|
|
2
2
|
* @license lucide-react v0.309.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -18,7 +18,7 @@ import{c as R,r,j as e,Y as ce,a0 as L,a1 as A,a4 as le,$ as Be,W as ie,at as Ge
|
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const J=R("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
|
|
22
22
|
* @license lucide-react v0.309.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
@@ -33,4 +33,4 @@ import{c as R,r,j as e,Y as ce,a0 as L,a1 as A,a4 as le,$ as Be,W as ie,at as Ge
|
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const yt=R("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var Y="rovingFocusGroup.onEntryFocus",jt={bubbles:!1,cancelable:!0},B="RovingFocusGroup",[J,ge,bt]=mt(B),[Nt,ve]=le(B,[bt]),[wt,Ct]=Nt(B),ye=r.forwardRef((t,n)=>e.jsx(J.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(J.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(St,{...t,ref:n})})}));ye.displayName=B;var St=r.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,orientation:a,loop:i=!1,dir:x,currentTabStopId:l,defaultCurrentTabStopId:m,onCurrentTabStopIdChange:p,onEntryFocus:y,preventScrollOnEntryFocus:d=!1,...u}=t,g=r.useRef(null),T=Be(n,g),k=me(x),[w,h]=ie({prop:l,defaultProp:m??null,onChange:p,caller:B}),[b,C]=r.useState(!1),v=Ge(y),f=ge(s),D=r.useRef(!1),[M,_]=r.useState(0);return r.useEffect(()=>{const j=g.current;if(j)return j.addEventListener(Y,v),()=>j.removeEventListener(Y,v)},[v]),e.jsx(wt,{scope:s,orientation:a,dir:k,loop:i,currentTabStopId:w,onItemFocus:r.useCallback(j=>h(j),[h]),onItemShiftTab:r.useCallback(()=>C(!0),[]),onFocusableItemAdd:r.useCallback(()=>_(j=>j+1),[]),onFocusableItemRemove:r.useCallback(()=>_(j=>j-1),[]),children:e.jsx(L.div,{tabIndex:b||M===0?-1:0,"data-orientation":a,...u,ref:T,style:{outline:"none",...t.style},onMouseDown:A(t.onMouseDown,()=>{D.current=!0}),onFocus:A(t.onFocus,j=>{const c=!D.current;if(j.target===j.currentTarget&&c&&!b){const S=new CustomEvent(Y,jt);if(j.currentTarget.dispatchEvent(S),!S.defaultPrevented){const F=f().filter(E=>E.focusable),G=F.find(E=>E.active),U=F.find(E=>E.id===w),X=[G,U,...F].filter(Boolean).map(E=>E.ref.current);Ne(X,d)}}D.current=!1}),onBlur:A(t.onBlur,()=>C(!1))})})}),je="RovingFocusGroupItem",be=r.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,focusable:a=!0,active:i=!1,tabStopId:x,children:l,...m}=t,p=ce(),y=x||p,d=Ct(je,s),u=d.currentTabStopId===y,g=ge(s),{onFocusableItemAdd:T,onFocusableItemRemove:k,currentTabStopId:w}=d;return r.useEffect(()=>{if(a)return T(),()=>k()},[a,T,k]),e.jsx(J.ItemSlot,{scope:s,id:y,focusable:a,active:i,children:e.jsx(L.span,{tabIndex:u?0:-1,"data-orientation":d.orientation,...m,ref:n,onMouseDown:A(t.onMouseDown,h=>{a?d.onItemFocus(y):h.preventDefault()}),onFocus:A(t.onFocus,()=>d.onItemFocus(y)),onKeyDown:A(t.onKeyDown,h=>{if(h.key==="Tab"&&h.shiftKey){d.onItemShiftTab();return}if(h.target!==h.currentTarget)return;const b=kt(h,d.orientation,d.dir);if(b!==void 0){if(h.metaKey||h.ctrlKey||h.altKey||h.shiftKey)return;h.preventDefault();let v=g().filter(f=>f.focusable).map(f=>f.ref.current);if(b==="last")v.reverse();else if(b==="prev"||b==="next"){b==="prev"&&v.reverse();const f=v.indexOf(h.currentTarget);v=d.loop?Dt(v,f+1):v.slice(f+1)}setTimeout(()=>Ne(v))}}),children:typeof l=="function"?l({isCurrentTabStop:u,hasTabStop:w!=null}):l})})});be.displayName=je;var Tt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function It(t,n){return n!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function kt(t,n,s){const a=It(t.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return Tt[a]}function Ne(t,n=!1){const s=document.activeElement;for(const a of t)if(a===s||(a.focus({preventScroll:n}),document.activeElement!==s))return}function Dt(t,n){return t.map((s,a)=>t[(n+a)%t.length])}var Et=ye,At=be,$="Tabs",[Ft]=le($,[ve]),we=ve(),[Rt,W]=Ft($),Ce=r.forwardRef((t,n)=>{const{__scopeTabs:s,value:a,onValueChange:i,defaultValue:x,orientation:l="horizontal",dir:m,activationMode:p="automatic",...y}=t,d=me(m),[u,g]=ie({prop:a,onChange:i,defaultProp:x??"",caller:$});return e.jsx(Rt,{scope:s,baseId:ce(),value:u,onValueChange:g,orientation:l,dir:d,activationMode:p,children:e.jsx(L.div,{dir:d,"data-orientation":l,...y,ref:n})})});Ce.displayName=$;var Se="TabsList",Te=r.forwardRef((t,n)=>{const{__scopeTabs:s,loop:a=!0,...i}=t,x=W(Se,s),l=we(s);return e.jsx(Et,{asChild:!0,...l,orientation:x.orientation,dir:x.dir,loop:a,children:e.jsx(L.div,{role:"tablist","aria-orientation":x.orientation,...i,ref:n})})});Te.displayName=Se;var Ie="TabsTrigger",ke=r.forwardRef((t,n)=>{const{__scopeTabs:s,value:a,disabled:i=!1,...x}=t,l=W(Ie,s),m=we(s),p=Ae(l.baseId,a),y=Fe(l.baseId,a),d=a===l.value;return e.jsx(At,{asChild:!0,...m,focusable:!i,active:d,children:e.jsx(L.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":y,"data-state":d?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:p,...x,ref:n,onMouseDown:A(t.onMouseDown,u=>{!i&&u.button===0&&u.ctrlKey===!1?l.onValueChange(a):u.preventDefault()}),onKeyDown:A(t.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&l.onValueChange(a)}),onFocus:A(t.onFocus,()=>{const u=l.activationMode!=="manual";!d&&!i&&u&&l.onValueChange(a)})})})});ke.displayName=Ie;var De="TabsContent",Ee=r.forwardRef((t,n)=>{const{__scopeTabs:s,value:a,forceMount:i,children:x,...l}=t,m=W(De,s),p=Ae(m.baseId,a),y=Fe(m.baseId,a),d=a===m.value,u=r.useRef(d);return r.useEffect(()=>{const g=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(g)},[]),e.jsx(ze,{present:i||d,children:({present:g})=>e.jsx(L.div,{"data-state":d?"active":"inactive","data-orientation":m.orientation,role:"tabpanel","aria-labelledby":p,hidden:!g,id:y,tabIndex:0,...l,ref:n,style:{...t.style,animationDuration:u.current?"0s":void 0},children:g&&x})})});Ee.displayName=De;function Ae(t,n){return`${t}-trigger-${n}`}function Fe(t,n){return`${t}-content-${n}`}var _t=Ce,Re=Te,_e=ke,Pe=Ee;const Pt=_t,Le=r.forwardRef(({className:t,...n},s)=>e.jsx(Re,{ref:s,className:Q("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...n}));Le.displayName=Re.displayName;const K=r.forwardRef(({className:t,...n},s)=>e.jsx(_e,{ref:s,className:Q("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...n}));K.displayName=_e.displayName;const V=r.forwardRef(({className:t,...n},s)=>e.jsx(Pe,{ref:s,className:Q("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...n}));V.displayName=Pe.displayName;const re={"google-drive":"Google Drive",onedrive:"OneDrive",dropbox:"Dropbox"};function Lt({open:t,onOpenChange:n,onAdded:s}){const[a,i]=r.useState([]),[x,l]=r.useState(!1),[m,p]=r.useState(null),[y,d]=r.useState(""),[u,g]=r.useState(""),[T,k]=r.useState(""),[w,h]=r.useState(""),[b,C]=r.useState(!1),[v,f]=r.useState(null);r.useEffect(()=>{t&&He().then(c=>i(c.available)).catch(()=>i([]))},[t]);const D=()=>{l(!1),p(null),d(""),g(""),k(""),h(""),C(!1),f(null)},M=async c=>{p(c),f(null);try{const{id:S}=await se({type:c,label:re[c]||c}),{url:F}=await q(S);window.open(F,"_blank"),D(),n(!1),s()}catch(S){f(S instanceof Error?S.message:"添加失败"),p(null)}},_=async()=>{if(!y||!u||!T||!w){f("请填写所有字段");return}C(!0),f(null);try{const{id:c}=await se({type:y,label:u,clientId:T,clientSecret:w}),{url:S}=await q(c);window.open(S,"_blank"),D(),n(!1),s()}catch(c){f(c instanceof Error?c.message:"添加失败")}finally{C(!1)}},j=a.length>0;return e.jsx(Ke,{open:t,onOpenChange:c=>{n(c),c||D()},children:e.jsxs(Ve,{className:"sm:max-w-md",children:[e.jsxs($e,{children:[e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-5 w-5"}),"添加云盘账号"]}),e.jsx(Xe,{children:x?"手动填写 OAuth 凭据连接云盘":"选择云盘类型,点击后跳转登录授权"})]}),x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"云盘类型"}),e.jsxs(xe,{value:y,onValueChange:d,children:[e.jsx(he,{children:e.jsx(fe,{placeholder:"选择云盘类型"})}),e.jsxs(pe,{children:[e.jsx(H,{value:"google-drive",children:"Google Drive"}),e.jsx(H,{value:"onedrive",children:"OneDrive"}),e.jsx(H,{value:"dropbox",children:"Dropbox"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"显示名称"}),e.jsx(z,{placeholder:"例如:我的 Google Drive",value:u,onChange:c=>g(c.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Client ID"}),e.jsx(z,{placeholder:"OAuth Client ID",value:T,onChange:c=>k(c.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Client Secret"}),e.jsx(z,{type:"password",placeholder:"OAuth Client Secret",value:w,onChange:c=>h(c.target.value)})]}),v&&e.jsx("p",{className:"text-sm text-destructive",children:v})]}),e.jsxs(Ye,{children:[e.jsx(I,{variant:"outline",onClick:()=>{l(!1),f(null)},children:"返回"}),e.jsx(I,{onClick:_,disabled:b,children:b?"添加中...":"添加并授权"})]})]}):e.jsxs("div",{className:"space-y-3 py-2",children:[j?e.jsx(e.Fragment,{children:a.map(c=>e.jsx(I,{variant:"outline",className:"w-full justify-start gap-3 h-12 text-base",onClick:()=>void M(c),disabled:m!==null,children:m===c?"连接中...":`连接 ${re[c]||c}`},c))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"暂无内置 OAuth 凭据,请使用手动模式添加"}),v&&e.jsx("p",{className:"text-sm text-destructive",children:v}),e.jsx("div",{className:"pt-2 border-t border-border",children:e.jsxs("button",{onClick:()=>{l(!0),f(null)},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(vt,{className:"h-3.5 w-3.5"}),"手动填写 OAuth 凭据"]})})]})]})})}const Mt={"google-drive":"Google Drive",onedrive:"OneDrive",dropbox:"Dropbox"};function Ot({type:t}){switch(t){case"google-drive":return e.jsx(ne,{className:"h-5 w-5 text-blue-500"});case"onedrive":return e.jsx(Z,{className:"h-5 w-5 text-sky-500"});case"dropbox":return e.jsx(ne,{className:"h-5 w-5 text-indigo-500"});default:return e.jsx(Z,{className:"h-5 w-5"})}}function Bt({provider:t,onDelete:n,onReauth:s}){var l;const[a,i]=r.useState(!1),x=()=>{a?(n(t.id),i(!1)):(i(!0),setTimeout(()=>i(!1),3e3))};return e.jsxs(qe,{children:[e.jsx(Ze,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ot,{type:t.type}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-base",children:t.label}),e.jsx("p",{className:"text-sm text-muted-foreground",children:Mt[t.type]||t.type})]})]}),e.jsx(de,{variant:t.authorized?"default":"destructive",className:t.authorized?"bg-green-600 hover:bg-green-700":"",children:t.authorized?"已授权":"未授权"})]})}),e.jsxs(Qe,{children:[t.authorized&&((l=t.tokens)==null?void 0:l.expiry)&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:["授权到期:",new Date(t.tokens.expiry).toLocaleDateString("zh-CN")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>s(t.id),children:[e.jsx(ue,{className:"h-3.5 w-3.5 mr-1"}),"重新授权"]}),e.jsxs(I,{variant:a?"destructive":"outline",size:"sm",onClick:x,children:[e.jsx(We,{className:"h-3.5 w-3.5 mr-1"}),a?"确认删除?":"删除"]})]})]})]})}const Gt={success:{label:"成功",icon:pt,className:"bg-green-600 hover:bg-green-700"},failed:{label:"失败",icon:yt,className:"bg-red-600 hover:bg-red-700"},partial:{label:"部分完成",icon:ft,className:"bg-yellow-600 hover:bg-yellow-700"}};function zt(t,n){const s=new Date(n).getTime()-new Date(t).getTime();if(s<1e3)return`${s}ms`;const a=Math.floor(s/1e3);if(a<60)return`${a}秒`;const i=Math.floor(a/60),x=a%60;return`${i}分${x}秒`}function Ht(t){return new Date(t).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Kt({history:t}){const n=t.slice(0,20);return n.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(gt,{className:"h-10 w-10 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm",children:"暂无备份记录"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"时间"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"项目"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"云盘"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"状态"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"文件数"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"耗时"})]})}),e.jsx("tbody",{children:n.map(s=>{const a=Gt[s.status],i=a.icon;return e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/50",children:[e.jsx("td",{className:"py-2.5 px-2 whitespace-nowrap",children:Ht(s.startTime)}),e.jsx("td",{className:"py-2.5 px-2",children:s.projectName}),e.jsx("td",{className:"py-2.5 px-2",children:s.providerLabel}),e.jsxs("td",{className:"py-2.5 px-2",children:[e.jsxs(de,{className:a.className,children:[e.jsx(i,{className:"h-3 w-3 mr-1"}),a.label]}),s.error&&e.jsx("p",{className:"text-xs text-destructive mt-1",children:s.error})]}),e.jsxs("td",{className:"py-2.5 px-2 whitespace-nowrap",children:[s.filesUploaded,"/",s.filesTotal]}),e.jsx("td",{className:"py-2.5 px-2 whitespace-nowrap",children:zt(s.startTime,s.endTime)})]},s.id)})})]})})}const oe=["node_modules",".git","dist","build","*.log",".DS_Store","*.tmp",".venv","__pycache__",".env"],Vt=[{value:"30",label:"30分钟"},{value:"60",label:"1小时"},{value:"360",label:"6小时"},{value:"720",label:"12小时"},{value:"1440",label:"24小时"}];function Yt(){const t=et(),[n,s]=r.useState([]),[a,i]=r.useState(!0),[x,l]=r.useState(!1),[m,p]=r.useState({enabled:!1,intervalMinutes:60}),[y,d]=r.useState(!0),[u,g]=r.useState([]),[T,k]=r.useState(!0),[w,h]=r.useState(""),[b,C]=r.useState(!1),[v,f]=r.useState(!1),[D,M]=r.useState([]),[_,j]=r.useState(!0),c=async()=>{try{const o=await ot();s(o)}catch{}finally{i(!1)}},S=async()=>{try{const o=await ct();p(o)}catch{}finally{d(!1)}},F=async()=>{try{const o=await lt();g(o.length>0?o:oe)}catch{g(oe)}finally{k(!1)}},G=async()=>{try{const o=await it();M(o)}catch{}finally{j(!1)}};r.useEffect(()=>{c(),S(),F(),G()},[]);const U=async o=>{try{await dt(o),s(N=>N.filter(O=>O.id!==o))}catch{}},ee=async o=>{try{const{url:N}=await q(o);window.open(N,"_blank")}catch{}},X=async o=>{const N={...m,enabled:o};p(N);try{await ae({enabled:o})}catch{p(m)}},E=async o=>{const N=parseInt(o,10),O={...m,intervalMinutes:N};p(O);try{await ae({intervalMinutes:N})}catch{p(m)}},te=()=>{const o=w.trim();!o||u.includes(o)||(g(N=>[...N,o]),h(""),C(!0))},Me=o=>{g(N=>N.filter(O=>O!==o)),C(!0)},Oe=async()=>{f(!0);try{await ut(u),C(!1)}catch{}finally{f(!1)}};return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"max-w-4xl mx-auto p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsxs(I,{variant:"ghost",size:"sm",onClick:()=>t("/"),children:[e.jsx(tt,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsx("h1",{className:"text-2xl font-bold",children:"设置"})]}),e.jsxs(Pt,{defaultValue:"providers",children:[e.jsxs(Le,{className:"mb-4",children:[e.jsx(K,{value:"providers",children:"云盘账号"}),e.jsx(K,{value:"strategy",children:"备份策略"}),e.jsx(K,{value:"history",children:"备份记录"})]}),e.jsxs(V,{value:"providers",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(I,{onClick:()=>l(!0),children:[e.jsx(st,{className:"h-4 w-4 mr-1"}),"添加云盘"]})}),a?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"加载中..."}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-12",children:"暂无云盘账号,点击上方按钮添加"}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:n.map(o=>e.jsx(Bt,{provider:o,onDelete:U,onReauth:ee},o.id))})]}),e.jsx(Lt,{open:x,onOpenChange:l,onAdded:()=>void c()})]}),e.jsx(V,{value:"strategy",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-medium",children:"排除规则"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"匹配这些模式的文件和目录将不会被备份"}),T?e.jsx("p",{className:"text-sm text-muted-foreground",children:"加载中..."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(at,{children:u.map(o=>e.jsxs(nt.span,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2},className:"inline-flex items-center gap-1 rounded-md bg-muted px-2.5 py-1 text-sm",children:[o,e.jsx("button",{onClick:()=>Me(o),className:"ml-0.5 rounded-sm hover:bg-muted-foreground/20 p-0.5",children:e.jsx(rt,{className:"h-3 w-3"})})]},o))})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(z,{placeholder:"输入排除模式,例如 *.log",value:w,onChange:o=>h(o.target.value),onKeyDown:o=>{o.key==="Enter"&&te()},className:"max-w-xs"}),e.jsx(I,{variant:"outline",size:"sm",onClick:te,children:"添加"})]}),b&&e.jsxs(I,{onClick:Oe,disabled:v,children:[e.jsx(xt,{className:"h-4 w-4 mr-1"}),v?"保存中...":"保存"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-medium",children:"定时备份"}),y?e.jsx("p",{className:"text-sm text-muted-foreground",children:"加载中..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ht,{checked:m.enabled,onCheckedChange:X}),e.jsx(P,{children:m.enabled?"已开启":"已关闭"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"备份间隔"}),e.jsxs(xe,{value:String(m.intervalMinutes),onValueChange:E,children:[e.jsx(he,{className:"w-48",children:e.jsx(fe,{})}),e.jsx(pe,{children:Vt.map(o=>e.jsx(H,{value:o.value,children:o.label},o.value))})]})]})]})]})]})}),e.jsx(V,{value:"history",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>{j(!0),G()},children:[e.jsx(ue,{className:"h-4 w-4 mr-1"}),"刷新"]})}),_?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"加载中..."}):e.jsx(Kt,{history:D})]})})]})]})})}export{Yt as SettingsPage};
|
|
36
|
+
*/const yt=R("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var Y="rovingFocusGroup.onEntryFocus",jt={bubbles:!1,cancelable:!0},B="RovingFocusGroup",[Z,ge,bt]=mt(B),[Nt,ve]=le(B,[bt]),[wt,Ct]=Nt(B),ye=r.forwardRef((t,n)=>e.jsx(Z.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Z.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(St,{...t,ref:n})})}));ye.displayName=B;var St=r.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,orientation:a,loop:i=!1,dir:x,currentTabStopId:l,defaultCurrentTabStopId:m,onCurrentTabStopIdChange:p,onEntryFocus:y,preventScrollOnEntryFocus:d=!1,...u}=t,g=r.useRef(null),T=Be(n,g),k=me(x),[w,h]=ie({prop:l,defaultProp:m??null,onChange:p,caller:B}),[b,C]=r.useState(!1),v=Ge(y),f=ge(s),D=r.useRef(!1),[M,_]=r.useState(0);return r.useEffect(()=>{const j=g.current;if(j)return j.addEventListener(Y,v),()=>j.removeEventListener(Y,v)},[v]),e.jsx(wt,{scope:s,orientation:a,dir:k,loop:i,currentTabStopId:w,onItemFocus:r.useCallback(j=>h(j),[h]),onItemShiftTab:r.useCallback(()=>C(!0),[]),onFocusableItemAdd:r.useCallback(()=>_(j=>j+1),[]),onFocusableItemRemove:r.useCallback(()=>_(j=>j-1),[]),children:e.jsx(L.div,{tabIndex:b||M===0?-1:0,"data-orientation":a,...u,ref:T,style:{outline:"none",...t.style},onMouseDown:A(t.onMouseDown,()=>{D.current=!0}),onFocus:A(t.onFocus,j=>{const c=!D.current;if(j.target===j.currentTarget&&c&&!b){const S=new CustomEvent(Y,jt);if(j.currentTarget.dispatchEvent(S),!S.defaultPrevented){const F=f().filter(E=>E.focusable),G=F.find(E=>E.active),U=F.find(E=>E.id===w),X=[G,U,...F].filter(Boolean).map(E=>E.ref.current);Ne(X,d)}}D.current=!1}),onBlur:A(t.onBlur,()=>C(!1))})})}),je="RovingFocusGroupItem",be=r.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,focusable:a=!0,active:i=!1,tabStopId:x,children:l,...m}=t,p=ce(),y=x||p,d=Ct(je,s),u=d.currentTabStopId===y,g=ge(s),{onFocusableItemAdd:T,onFocusableItemRemove:k,currentTabStopId:w}=d;return r.useEffect(()=>{if(a)return T(),()=>k()},[a,T,k]),e.jsx(Z.ItemSlot,{scope:s,id:y,focusable:a,active:i,children:e.jsx(L.span,{tabIndex:u?0:-1,"data-orientation":d.orientation,...m,ref:n,onMouseDown:A(t.onMouseDown,h=>{a?d.onItemFocus(y):h.preventDefault()}),onFocus:A(t.onFocus,()=>d.onItemFocus(y)),onKeyDown:A(t.onKeyDown,h=>{if(h.key==="Tab"&&h.shiftKey){d.onItemShiftTab();return}if(h.target!==h.currentTarget)return;const b=kt(h,d.orientation,d.dir);if(b!==void 0){if(h.metaKey||h.ctrlKey||h.altKey||h.shiftKey)return;h.preventDefault();let v=g().filter(f=>f.focusable).map(f=>f.ref.current);if(b==="last")v.reverse();else if(b==="prev"||b==="next"){b==="prev"&&v.reverse();const f=v.indexOf(h.currentTarget);v=d.loop?Dt(v,f+1):v.slice(f+1)}setTimeout(()=>Ne(v))}}),children:typeof l=="function"?l({isCurrentTabStop:u,hasTabStop:w!=null}):l})})});be.displayName=je;var Tt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function It(t,n){return n!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function kt(t,n,s){const a=It(t.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return Tt[a]}function Ne(t,n=!1){const s=document.activeElement;for(const a of t)if(a===s||(a.focus({preventScroll:n}),document.activeElement!==s))return}function Dt(t,n){return t.map((s,a)=>t[(n+a)%t.length])}var Et=ye,At=be,$="Tabs",[Ft]=le($,[ve]),we=ve(),[Rt,W]=Ft($),Ce=r.forwardRef((t,n)=>{const{__scopeTabs:s,value:a,onValueChange:i,defaultValue:x,orientation:l="horizontal",dir:m,activationMode:p="automatic",...y}=t,d=me(m),[u,g]=ie({prop:a,onChange:i,defaultProp:x??"",caller:$});return e.jsx(Rt,{scope:s,baseId:ce(),value:u,onValueChange:g,orientation:l,dir:d,activationMode:p,children:e.jsx(L.div,{dir:d,"data-orientation":l,...y,ref:n})})});Ce.displayName=$;var Se="TabsList",Te=r.forwardRef((t,n)=>{const{__scopeTabs:s,loop:a=!0,...i}=t,x=W(Se,s),l=we(s);return e.jsx(Et,{asChild:!0,...l,orientation:x.orientation,dir:x.dir,loop:a,children:e.jsx(L.div,{role:"tablist","aria-orientation":x.orientation,...i,ref:n})})});Te.displayName=Se;var Ie="TabsTrigger",ke=r.forwardRef((t,n)=>{const{__scopeTabs:s,value:a,disabled:i=!1,...x}=t,l=W(Ie,s),m=we(s),p=Ae(l.baseId,a),y=Fe(l.baseId,a),d=a===l.value;return e.jsx(At,{asChild:!0,...m,focusable:!i,active:d,children:e.jsx(L.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":y,"data-state":d?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:p,...x,ref:n,onMouseDown:A(t.onMouseDown,u=>{!i&&u.button===0&&u.ctrlKey===!1?l.onValueChange(a):u.preventDefault()}),onKeyDown:A(t.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&l.onValueChange(a)}),onFocus:A(t.onFocus,()=>{const u=l.activationMode!=="manual";!d&&!i&&u&&l.onValueChange(a)})})})});ke.displayName=Ie;var De="TabsContent",Ee=r.forwardRef((t,n)=>{const{__scopeTabs:s,value:a,forceMount:i,children:x,...l}=t,m=W(De,s),p=Ae(m.baseId,a),y=Fe(m.baseId,a),d=a===m.value,u=r.useRef(d);return r.useEffect(()=>{const g=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(g)},[]),e.jsx(ze,{present:i||d,children:({present:g})=>e.jsx(L.div,{"data-state":d?"active":"inactive","data-orientation":m.orientation,role:"tabpanel","aria-labelledby":p,hidden:!g,id:y,tabIndex:0,...l,ref:n,style:{...t.style,animationDuration:u.current?"0s":void 0},children:g&&x})})});Ee.displayName=De;function Ae(t,n){return`${t}-trigger-${n}`}function Fe(t,n){return`${t}-content-${n}`}var _t=Ce,Re=Te,_e=ke,Pe=Ee;const Pt=_t,Le=r.forwardRef(({className:t,...n},s)=>e.jsx(Re,{ref:s,className:Q("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...n}));Le.displayName=Re.displayName;const K=r.forwardRef(({className:t,...n},s)=>e.jsx(_e,{ref:s,className:Q("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...n}));K.displayName=_e.displayName;const V=r.forwardRef(({className:t,...n},s)=>e.jsx(Pe,{ref:s,className:Q("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...n}));V.displayName=Pe.displayName;const re={"google-drive":"Google Drive",onedrive:"OneDrive",dropbox:"Dropbox"};function Lt({open:t,onOpenChange:n,onAdded:s}){const[a,i]=r.useState([]),[x,l]=r.useState(!1),[m,p]=r.useState(null),[y,d]=r.useState(""),[u,g]=r.useState(""),[T,k]=r.useState(""),[w,h]=r.useState(""),[b,C]=r.useState(!1),[v,f]=r.useState(null);r.useEffect(()=>{t&&He().then(c=>i(c.available)).catch(()=>i([]))},[t]);const D=()=>{l(!1),p(null),d(""),g(""),k(""),h(""),C(!1),f(null)},M=async c=>{p(c),f(null);try{const{id:S}=await se({type:c,label:re[c]||c}),{url:F}=await q(S);window.open(F,"_blank"),D(),n(!1),s()}catch(S){f(S instanceof Error?S.message:"添加失败"),p(null)}},_=async()=>{if(!y||!u||!T||!w){f("请填写所有字段");return}C(!0),f(null);try{const{id:c}=await se({type:y,label:u,clientId:T,clientSecret:w}),{url:S}=await q(c);window.open(S,"_blank"),D(),n(!1),s()}catch(c){f(c instanceof Error?c.message:"添加失败")}finally{C(!1)}},j=a.length>0;return e.jsx(Ke,{open:t,onOpenChange:c=>{n(c),c||D()},children:e.jsxs(Ve,{className:"sm:max-w-md",children:[e.jsxs($e,{children:[e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"}),"添加云盘账号"]}),e.jsx(Xe,{children:x?"手动填写 OAuth 凭据连接云盘":"选择云盘类型,点击后跳转登录授权"})]}),x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"云盘类型"}),e.jsxs(xe,{value:y,onValueChange:d,children:[e.jsx(he,{children:e.jsx(fe,{placeholder:"选择云盘类型"})}),e.jsxs(pe,{children:[e.jsx(H,{value:"google-drive",children:"Google Drive"}),e.jsx(H,{value:"onedrive",children:"OneDrive"}),e.jsx(H,{value:"dropbox",children:"Dropbox"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"显示名称"}),e.jsx(z,{placeholder:"例如:我的 Google Drive",value:u,onChange:c=>g(c.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Client ID"}),e.jsx(z,{placeholder:"OAuth Client ID",value:T,onChange:c=>k(c.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Client Secret"}),e.jsx(z,{type:"password",placeholder:"OAuth Client Secret",value:w,onChange:c=>h(c.target.value)})]}),v&&e.jsx("p",{className:"text-sm text-destructive",children:v})]}),e.jsxs(Ye,{children:[e.jsx(I,{variant:"outline",onClick:()=>{l(!1),f(null)},children:"返回"}),e.jsx(I,{onClick:_,disabled:b,children:b?"添加中...":"添加并授权"})]})]}):e.jsxs("div",{className:"space-y-3 py-2",children:[j?e.jsx(e.Fragment,{children:a.map(c=>e.jsx(I,{variant:"outline",className:"w-full justify-start gap-3 h-12 text-base",onClick:()=>void M(c),disabled:m!==null,children:m===c?"连接中...":`连接 ${re[c]||c}`},c))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"暂无内置 OAuth 凭据,请使用手动模式添加"}),v&&e.jsx("p",{className:"text-sm text-destructive",children:v}),e.jsx("div",{className:"pt-2 border-t border-border",children:e.jsxs("button",{onClick:()=>{l(!0),f(null)},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(vt,{className:"h-3.5 w-3.5"}),"手动填写 OAuth 凭据"]})})]})]})})}const Mt={"google-drive":"Google Drive",onedrive:"OneDrive",dropbox:"Dropbox"};function Ot({type:t}){switch(t){case"google-drive":return e.jsx(ne,{className:"h-5 w-5 text-blue-500"});case"onedrive":return e.jsx(J,{className:"h-5 w-5 text-sky-500"});case"dropbox":return e.jsx(ne,{className:"h-5 w-5 text-indigo-500"});default:return e.jsx(J,{className:"h-5 w-5"})}}function Bt({provider:t,onDelete:n,onReauth:s}){var l;const[a,i]=r.useState(!1),x=()=>{a?(n(t.id),i(!1)):(i(!0),setTimeout(()=>i(!1),3e3))};return e.jsxs(qe,{children:[e.jsx(Je,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ot,{type:t.type}),e.jsxs("div",{children:[e.jsx(Ze,{className:"text-base",children:t.label}),e.jsx("p",{className:"text-sm text-muted-foreground",children:Mt[t.type]||t.type})]})]}),e.jsx(de,{variant:t.authorized?"default":"destructive",className:t.authorized?"bg-green-600 hover:bg-green-700":"",children:t.authorized?"已授权":"未授权"})]})}),e.jsxs(Qe,{children:[t.authorized&&((l=t.tokens)==null?void 0:l.expiry)&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:["授权到期:",new Date(t.tokens.expiry).toLocaleDateString("zh-CN")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>s(t.id),children:[e.jsx(ue,{className:"h-3.5 w-3.5 mr-1"}),"重新授权"]}),e.jsxs(I,{variant:a?"destructive":"outline",size:"sm",onClick:x,children:[e.jsx(We,{className:"h-3.5 w-3.5 mr-1"}),a?"确认删除?":"删除"]})]})]})]})}const Gt={success:{label:"成功",icon:pt,className:"bg-green-600 hover:bg-green-700"},failed:{label:"失败",icon:yt,className:"bg-red-600 hover:bg-red-700"},partial:{label:"部分完成",icon:ft,className:"bg-yellow-600 hover:bg-yellow-700"}};function zt(t,n){const s=new Date(n).getTime()-new Date(t).getTime();if(s<1e3)return`${s}ms`;const a=Math.floor(s/1e3);if(a<60)return`${a}秒`;const i=Math.floor(a/60),x=a%60;return`${i}分${x}秒`}function Ht(t){return new Date(t).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Kt({history:t}){const n=t.slice(0,20);return n.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(gt,{className:"h-10 w-10 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm",children:"暂无备份记录"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"时间"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"项目"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"云盘"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"状态"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"文件数"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"耗时"})]})}),e.jsx("tbody",{children:n.map(s=>{const a=Gt[s.status],i=a.icon;return e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/50",children:[e.jsx("td",{className:"py-2.5 px-2 whitespace-nowrap",children:Ht(s.startTime)}),e.jsx("td",{className:"py-2.5 px-2",children:s.projectName}),e.jsx("td",{className:"py-2.5 px-2",children:s.providerLabel}),e.jsxs("td",{className:"py-2.5 px-2",children:[e.jsxs(de,{className:a.className,children:[e.jsx(i,{className:"h-3 w-3 mr-1"}),a.label]}),s.error&&e.jsx("p",{className:"text-xs text-destructive mt-1",children:s.error})]}),e.jsxs("td",{className:"py-2.5 px-2 whitespace-nowrap",children:[s.filesUploaded,"/",s.filesTotal]}),e.jsx("td",{className:"py-2.5 px-2 whitespace-nowrap",children:zt(s.startTime,s.endTime)})]},s.id)})})]})})}const oe=["node_modules",".git","dist","build","*.log",".DS_Store","*.tmp",".venv","__pycache__",".env"],Vt=[{value:"30",label:"30分钟"},{value:"60",label:"1小时"},{value:"360",label:"6小时"},{value:"720",label:"12小时"},{value:"1440",label:"24小时"}];function Yt(){const t=et(),[n,s]=r.useState([]),[a,i]=r.useState(!0),[x,l]=r.useState(!1),[m,p]=r.useState({enabled:!1,intervalMinutes:60}),[y,d]=r.useState(!0),[u,g]=r.useState([]),[T,k]=r.useState(!0),[w,h]=r.useState(""),[b,C]=r.useState(!1),[v,f]=r.useState(!1),[D,M]=r.useState([]),[_,j]=r.useState(!0),c=async()=>{try{const o=await ot();s(o)}catch{}finally{i(!1)}},S=async()=>{try{const o=await ct();p(o)}catch{}finally{d(!1)}},F=async()=>{try{const o=await lt();g(o.length>0?o:oe)}catch{g(oe)}finally{k(!1)}},G=async()=>{try{const o=await it();M(o)}catch{}finally{j(!1)}};r.useEffect(()=>{c(),S(),F(),G()},[]);const U=async o=>{try{await dt(o),s(N=>N.filter(O=>O.id!==o))}catch{}},ee=async o=>{try{const{url:N}=await q(o);window.open(N,"_blank")}catch{}},X=async o=>{const N={...m,enabled:o};p(N);try{await ae({enabled:o})}catch{p(m)}},E=async o=>{const N=parseInt(o,10),O={...m,intervalMinutes:N};p(O);try{await ae({intervalMinutes:N})}catch{p(m)}},te=()=>{const o=w.trim();!o||u.includes(o)||(g(N=>[...N,o]),h(""),C(!0))},Me=o=>{g(N=>N.filter(O=>O!==o)),C(!0)},Oe=async()=>{f(!0);try{await ut(u),C(!1)}catch{}finally{f(!1)}};return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"max-w-4xl mx-auto p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsxs(I,{variant:"ghost",size:"sm",onClick:()=>t("/"),children:[e.jsx(tt,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsx("h1",{className:"text-2xl font-bold",children:"设置"})]}),e.jsxs(Pt,{defaultValue:"providers",children:[e.jsxs(Le,{className:"mb-4",children:[e.jsx(K,{value:"providers",children:"云盘账号"}),e.jsx(K,{value:"strategy",children:"备份策略"}),e.jsx(K,{value:"history",children:"备份记录"})]}),e.jsxs(V,{value:"providers",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(I,{onClick:()=>l(!0),children:[e.jsx(st,{className:"h-4 w-4 mr-1"}),"添加云盘"]})}),a?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"加载中..."}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-12",children:"暂无云盘账号,点击上方按钮添加"}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:n.map(o=>e.jsx(Bt,{provider:o,onDelete:U,onReauth:ee},o.id))})]}),e.jsx(Lt,{open:x,onOpenChange:l,onAdded:()=>void c()})]}),e.jsx(V,{value:"strategy",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-medium",children:"排除规则"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"匹配这些模式的文件和目录将不会被备份"}),T?e.jsx("p",{className:"text-sm text-muted-foreground",children:"加载中..."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(at,{children:u.map(o=>e.jsxs(nt.span,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2},className:"inline-flex items-center gap-1 rounded-md bg-muted px-2.5 py-1 text-sm",children:[o,e.jsx("button",{onClick:()=>Me(o),className:"ml-0.5 rounded-sm hover:bg-muted-foreground/20 p-0.5",children:e.jsx(rt,{className:"h-3 w-3"})})]},o))})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(z,{placeholder:"输入排除模式,例如 *.log",value:w,onChange:o=>h(o.target.value),onKeyDown:o=>{o.key==="Enter"&&te()},className:"max-w-xs"}),e.jsx(I,{variant:"outline",size:"sm",onClick:te,children:"添加"})]}),b&&e.jsxs(I,{onClick:Oe,disabled:v,children:[e.jsx(xt,{className:"h-4 w-4 mr-1"}),v?"保存中...":"保存"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-medium",children:"定时备份"}),y?e.jsx("p",{className:"text-sm text-muted-foreground",children:"加载中..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ht,{checked:m.enabled,onCheckedChange:X}),e.jsx(P,{children:m.enabled?"已开启":"已关闭"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"备份间隔"}),e.jsxs(xe,{value:String(m.intervalMinutes),onValueChange:E,children:[e.jsx(he,{className:"w-48",children:e.jsx(fe,{})}),e.jsx(pe,{children:Vt.map(o=>e.jsx(H,{value:o.value,children:o.label},o.value))})]})]})]})]})]})}),e.jsx(V,{value:"history",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>{j(!0),G()},children:[e.jsx(ue,{className:"h-4 w-4 mr-1"}),"刷新"]})}),_?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"加载中..."}):e.jsx(Kt,{history:D})]})})]})]})})}export{Yt as SettingsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as C,ae as
|
|
1
|
+
import{c as C,ae as P,r,aO as q,j as e,K as S,af as z,I as O,e as g,o as p,G as U,A as F,aP as G,t as B}from"./index-C9_Mp1hE.js";import{U as K,D as _}from"./user-_adqQY3y.js";import{C as R}from"./chevron-down-BEvQLdWD.js";/**
|
|
2
2
|
* @license lucide-react v0.309.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -8,4 +8,4 @@ import{c as C,ae as q,r,aM as z,j as e,K as S,af as P,I as U,e as g,o as p,G as
|
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const $=C("Tag",[["path",{d:"M12 2H2v10l9.29 9.29c.94.94 2.48.94 3.42 0l6.58-6.58c.94-.94.94-2.48 0-3.42L12 2Z",key:"14b2ls"}],["path",{d:"M7 7h.01",key:"7u93v4"}]]);function W(){const I=
|
|
11
|
+
*/const $=C("Tag",[["path",{d:"M12 2H2v10l9.29 9.29c.94.94 2.48.94 3.42 0l6.58-6.58c.94-.94.94-2.48 0-3.42L12 2Z",key:"14b2ls"}],["path",{d:"M7 7h.01",key:"7u93v4"}]]);function W(){const I=P(),[o,f]=r.useState([]),[x,E]=r.useState(!0),[i,L]=r.useState(null),[c,D]=r.useState(""),[d,h]=r.useState(null),[H,k]=r.useState(null),[j,w]=r.useState(null),[N,M]=r.useState(new Set);r.useEffect(()=>{q().then(f).catch(t=>L(t instanceof Error?t.message:"Failed to load SkillHub")).finally(()=>E(!1))},[]);const b=r.useMemo(()=>{const t=new Set;return o.forEach(a=>{var s;return(s=a.tags)==null?void 0:s.forEach(n=>t.add(n))}),Array.from(t).sort()},[o]),A=r.useMemo(()=>o.some(t=>!t.tags||t.tags.length===0),[o]),y=r.useMemo(()=>{let t=o;if(d==="__untagged__"?t=t.filter(a=>!a.tags||a.tags.length===0):d&&(t=t.filter(a=>{var s;return(s=a.tags)==null?void 0:s.includes(d)})),c.trim()){const a=c.toLowerCase();t=t.filter(s=>{var n;return s.label.toLowerCase().includes(a)||s.description.toLowerCase().includes(a)||s.command.toLowerCase().includes(a)||s.author.toLowerCase().includes(a)||((n=s.tags)==null?void 0:n.some(m=>m.toLowerCase().includes(a)))})}return t},[o,c,d]),T=async(t,a)=>{if(a.stopPropagation(),!(j||N.has(t.id))){w(t.id);try{await G(t.id),M(s=>new Set(s).add(t.id)),f(s=>s.map(n=>n.id===t.id?{...n,downloads:(n.downloads||0)+1}:n))}catch(s){B.error(s instanceof Error?s.message:"Download failed")}finally{w(null)}}};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 h-14 flex items-center gap-4",children:[e.jsxs(S,{variant:"ghost",size:"sm",onClick:()=>I("/"),children:[e.jsx(z,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsx("h1",{className:"font-semibold text-lg",children:"SkillHub"}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(Z,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(O,{placeholder:"搜索命令...",value:c,onChange:t=>D(t.target.value),className:"pl-8 h-9"})]})]})}),e.jsxs("main",{className:"max-w-4xl mx-auto px-4 py-6",children:[b.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx("button",{className:g("px-3 py-1 rounded-full text-xs font-medium transition-colors",d===null?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>h(null),children:"全部"}),b.map(t=>e.jsx("button",{className:g("px-3 py-1 rounded-full text-xs font-medium transition-colors",d===t?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>h(d===t?null:t),children:t},t)),A&&e.jsx("button",{className:g("px-3 py-1 rounded-full text-xs font-medium transition-colors",d==="__untagged__"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>h(d==="__untagged__"?null:"__untagged__"),children:"无标签"})]}),x&&e.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),i&&e.jsx("div",{className:"text-center text-destructive py-20",children:i}),!x&&!i&&o.length===0&&e.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[e.jsx("p",{className:"text-lg mb-2",children:"SkillHub 还没有命令"}),e.jsx("p",{className:"text-sm",children:"在快捷命令面板中点击分享按钮来提交第一个命令吧!"})]}),!x&&!i&&o.length>0&&y.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-20",children:"没有匹配的命令"}),e.jsx("div",{className:"space-y-3",children:y.map((t,a)=>{var v;const s=H===t.id,n=N.has(t.id),m=j===t.id,u=t.parentId?o.find(l=>l.id===t.parentId):void 0;return e.jsxs(p.div,{layout:!0,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25,delay:a*.03,ease:"easeOut"},className:"rounded-lg border bg-card p-4 cursor-pointer hover:border-muted-foreground/30 transition-colors",onClick:()=>k(s?null:t.id),children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-medium text-sm truncate",children:t.label}),(v=t.tags)==null?void 0:v.map(l=>e.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:[e.jsx($,{className:"h-2.5 w-2.5"}),l]},l))]}),u&&e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsx(U,{className:"h-3 w-3 text-muted-foreground"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["继承: ",u.label]})]}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:t.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(K,{className:"h-3 w-3"}),t.author]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_,{className:"h-3 w-3"}),t.downloads||0]}),e.jsx("span",{children:t.createdAt})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs(S,{size:"sm",variant:n?"outline":"default",disabled:m||n,onClick:l=>T(t,l),title:u?`将同时下载继承的「${u.label}」`:void 0,children:[e.jsx(_,{className:"h-3.5 w-3.5 mr-1"}),n?"已下载":m?"下载中...":"下载"]}),e.jsx(p.span,{animate:{rotate:s?180:0},transition:{duration:.2},children:e.jsx(R,{className:"h-4 w-4 text-muted-foreground"})})]})]}),e.jsx(F,{children:s&&e.jsx(p.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:e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsx("pre",{className:"text-xs font-mono bg-muted rounded p-3 whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:t.command})})})})]},t.id)})})]})]})}export{W as SkillHubPage};
|