@zhin.js/adapter-qq 1.0.84 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @zhin.js/adapter-qq
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 32049f5: fix: init publish
8
+ - Updated dependencies [32049f5]
9
+ - @zhin.js/console@3.0.1
10
+ - @zhin.js/http@1.0.75
11
+ - @zhin.js/logger@0.1.64
12
+ - @zhin.js/client@1.1.1
13
+ - zhin.js@1.0.82
14
+
15
+ ## 2.0.0
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+ - @zhin.js/client@1.1.0
21
+ - @zhin.js/console@3.0.0
22
+
3
23
  ## 1.0.84
4
24
 
5
25
  ### Patch Changes
@@ -1,4 +1,12 @@
1
1
  const TOKEN_KEY = "zhin_api_token";
2
+ const API_BASE_KEY = "zhin_api_base";
3
+
4
+ export function getApiBase(): string {
5
+ const stored = localStorage.getItem(API_BASE_KEY)?.trim();
6
+ if (stored) return stored.replace(/\/$/, "");
7
+ if (typeof window !== "undefined") return window.location.origin;
8
+ return "";
9
+ }
2
10
 
3
11
  export function getToken(): string | null {
4
12
  return localStorage.getItem(TOKEN_KEY);
@@ -8,7 +16,12 @@ export async function apiFetch(input: RequestInfo | URL, init?: RequestInit): Pr
8
16
  const token = getToken();
9
17
  const headers = new Headers(init?.headers);
10
18
  if (token) headers.set("Authorization", `Bearer ${token}`);
11
- const res = await fetch(input, { ...init, headers });
19
+
20
+ const base = getApiBase();
21
+ const url =
22
+ typeof input === "string" && input.startsWith("/") ? `${base}${input}` : input;
23
+
24
+ const res = await fetch(url, { ...init, headers });
12
25
  if (res.status === 401) {
13
26
  localStorage.removeItem(TOKEN_KEY);
14
27
  window.dispatchEvent(new CustomEvent("zhin:auth-required"));
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{useEffect as Se,useState as c,useCallback as ke}from"react";var Q="zhin_api_token";function ue(){return localStorage.getItem(Q)}async function k(t,o){let l=ue(),f=new Headers(o?.headers);l&&f.set("Authorization",`Bearer ${l}`);let n=await fetch(t,{...o,headers:f});return n.status===401&&(localStorage.removeItem(Q),window.dispatchEvent(new CustomEvent("zhin:auth-required"))),n}import{forwardRef as re,createElement as ie}from"react";var v=(...t)=>t.filter((o,l,f)=>!!o&&o.trim()!==""&&f.indexOf(o)===l).join(" ").trim();var J=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var _=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(o,l,f)=>f?f.toUpperCase():l.toLowerCase());var V=t=>{let o=_(t);return o.charAt(0).toUpperCase()+o.slice(1)};import{forwardRef as se,createElement as Y}from"react";var U={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var j=t=>{for(let o in t)if(o.startsWith("aria-")||o==="role"||o==="title")return!0;return!1};import{createContext as de,useContext as le,useMemo as Te,createElement as be}from"react";var fe=de({});var $=()=>le(fe);var ee=se(({color:t,size:o,strokeWidth:l,absoluteStrokeWidth:f,className:n="",children:s,iconNode:m,...L},R)=>{let{size:I=24,strokeWidth:x=2,absoluteStrokeWidth:O=!1,color:h="currentColor",className:q=""}=$()??{},g=f??O?Number(l??x)*24/Number(o??I):l??x;return Y("svg",{ref:R,...U,width:o??I??U.width,height:o??I??U.height,stroke:t??h,strokeWidth:g,className:v("lucide",q,n),...!s&&!j(L)&&{"aria-hidden":"true"},...L},[...m.map(([T,S])=>Y(T,S)),...Array.isArray(s)?s:[s]])});var d=(t,o)=>{let l=re(({className:f,...n},s)=>ie(ee,{ref:s,iconNode:o,className:v(`lucide-${J(V(t))}`,`lucide-${t}`,f),...n}));return l.displayName=V(t),l};var ce=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],w=d("chevron-down",ce);var ne=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],P=d("chevron-right",ne);var pe=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],C=d("hash",pe);var me=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],p=d("loader-circle",me);var Le=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],A=d("power-off",Le);var Ie=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],B=d("power",Ie);var xe=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],M=d("refresh-cw",xe);var Ce=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],F=d("server",Ce);var he=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],D=d("wifi-off",he);var ge=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],y=d("wifi",ge);import{Fragment as we,jsx as a,jsxs as u}from"react/jsx-runtime";function E(){let[t,o]=c([]),[l,f]=c(!0),[n,s]=c(""),[m,L]=c("overview"),[R,I]=c({}),[x,O]=c(""),[h,q]=c([]),[g,T]=c(!1),[S,H]=c(null),[G,z]=c({}),[ae,N]=c(null),b=ke(async()=>{f(!0),s("");try{let i=await(await k("/api/qq/bots")).json();i.success?o(i.data):s(i.error||"\u83B7\u53D6\u6570\u636E\u5931\u8D25")}catch{s("\u65E0\u6CD5\u8FDE\u63A5\u670D\u52A1\u5668")}finally{f(!1)}},[]);Se(()=>{b()},[b]);let te=async(e,i)=>{I(r=>({...r,[e]:!0}));try{let r=i?"disconnect":"connect",Z=await(await k(`/api/qq/bots/${encodeURIComponent(e)}/${r}`,{method:"POST"})).json();Z.success||s(Z.error||"\u64CD\u4F5C\u5931\u8D25"),await b()}catch{s("\u64CD\u4F5C\u5931\u8D25")}finally{I(r=>({...r,[e]:!1}))}},X=async e=>{O(e),T(!0),q([]),H(null),z({});try{let r=await(await k(`/api/qq/bots/${encodeURIComponent(e)}/guilds`)).json();r.success?q(r.data):s(r.error||"\u83B7\u53D6\u9891\u9053\u5931\u8D25")}catch{s("\u83B7\u53D6\u9891\u9053\u5931\u8D25")}finally{T(!1)}},oe=async e=>{if(S===e){H(null);return}if(H(e),!G[e]){N(e);try{let r=await(await k(`/api/qq/bots/${encodeURIComponent(x)}/guilds/${encodeURIComponent(e)}/channels`)).json();r.success&&z(K=>({...K,[e]:r.data}))}catch{}finally{N(null)}}},W=t.filter(e=>e.connected);return u("div",{className:"p-6 max-w-5xl mx-auto",children:[u("div",{className:"flex items-center justify-between mb-6",children:[u("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[a(F,{className:"w-6 h-6"})," QQ \u5B98\u65B9\u673A\u5668\u4EBA"]}),u("button",{onClick:b,disabled:l,className:"flex items-center gap-1 px-3 py-1.5 rounded bg-blue-500 text-white hover:bg-blue-600 disabled:opacity-50 text-sm",children:[a(M,{className:`w-4 h-4 ${l?"animate-spin":""}`})," \u5237\u65B0"]})]}),n&&a("div",{className:"mb-4 p-3 bg-red-50 text-red-600 rounded border border-red-200",children:n}),u("div",{className:"flex gap-1 mb-6 border-b",children:[a("button",{onClick:()=>L("overview"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${m==="overview"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"\u6982\u89C8"}),a("button",{onClick:()=>L("guilds"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${m==="guilds"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"\u9891\u9053\u6D4F\u89C8"})]}),m==="overview"&&u(we,{children:[!l&&!t.length&&!n&&a("div",{className:"text-center text-gray-500 py-12",children:"\u6682\u65E0 QQ \u673A\u5668\u4EBA\u5B9E\u4F8B"}),a("div",{className:"grid gap-4 md:grid-cols-2",children:t.map(e=>u("div",{className:"border rounded-lg p-4 bg-card shadow-sm",children:[u("div",{className:"flex items-center justify-between mb-3",children:[a("span",{className:"font-medium text-lg",children:e.name}),e.connected?u("span",{className:"flex items-center gap-1 text-green-600 text-sm",children:[a(y,{className:"w-4 h-4"})," \u5728\u7EBF"]}):u("span",{className:"flex items-center gap-1 text-gray-400 text-sm",children:[a(D,{className:"w-4 h-4"})," \u79BB\u7EBF"]})]}),a("div",{className:"grid grid-cols-1 gap-2 text-sm text-gray-600 mb-3",children:u("div",{className:"flex justify-between",children:[a("span",{children:"\u9891\u9053\u6570"}),a("span",{className:"font-mono",children:e.guildCount})]})}),u("div",{className:"flex gap-2",children:[u("button",{onClick:()=>te(e.name,e.connected),disabled:R[e.name],className:`flex items-center gap-1 px-3 py-1.5 rounded text-sm text-white ${e.connected?"bg-red-500 hover:bg-red-600":"bg-green-500 hover:bg-green-600"} disabled:opacity-50`,children:[R[e.name]?a(p,{className:"w-3.5 h-3.5 animate-spin"}):e.connected?a(A,{className:"w-3.5 h-3.5"}):a(B,{className:"w-3.5 h-3.5"}),e.connected?"\u65AD\u5F00":"\u8FDE\u63A5"]}),e.connected&&u("button",{onClick:()=>{L("guilds"),X(e.name)},className:"flex items-center gap-1 px-3 py-1.5 rounded text-sm bg-gray-100 hover:bg-gray-200 text-gray-700",children:[a(C,{className:"w-3.5 h-3.5"})," \u6D4F\u89C8\u9891\u9053"]})]})]},e.name))})]}),m==="guilds"&&u("div",{children:[W.length>0&&u("div",{className:"mb-4 flex items-center gap-2",children:[a("label",{className:"text-sm text-gray-500",children:"\u9009\u62E9\u673A\u5668\u4EBA\uFF1A"}),u("select",{value:x,onChange:e=>X(e.target.value),className:"border rounded px-2 py-1 text-sm",children:[a("option",{value:"",children:"--"}),W.map(e=>a("option",{value:e.name,children:e.name},e.name))]})]}),!W.length&&a("div",{className:"text-center text-gray-500 py-8",children:"\u6682\u65E0\u5728\u7EBF\u673A\u5668\u4EBA"}),g&&a("div",{className:"flex justify-center py-8",children:a(p,{className:"w-6 h-6 animate-spin text-blue-500"})}),!g&&h.length>0&&a("div",{className:"border rounded-lg bg-card shadow-sm divide-y",children:h.map(e=>u("div",{children:[u("button",{onClick:()=>oe(e.id),className:"w-full flex items-center gap-2 px-4 py-3 hover:bg-gray-50 text-left",children:[S===e.id?a(w,{className:"w-4 h-4 text-gray-400"}):a(P,{className:"w-4 h-4 text-gray-400"}),a("span",{className:"font-medium",children:e.name}),a("span",{className:"text-xs text-gray-400 ml-auto",children:e.id})]}),S===e.id&&a("div",{className:"px-4 pb-3",children:ae===e.id?u("div",{className:"flex items-center gap-2 text-gray-400 text-sm py-2 pl-6",children:[a(p,{className:"w-4 h-4 animate-spin"})," \u52A0\u8F7D\u4E2D\u2026"]}):G[e.id]?.length?a("div",{className:"pl-6 space-y-1",children:G[e.id].map(i=>u("div",{className:"flex items-center gap-2 text-sm text-gray-600 py-1",children:[a(C,{className:"w-3.5 h-3.5 text-gray-400"}),a("span",{children:i.name}),a("span",{className:"text-xs text-gray-400 ml-auto",children:i.id})]},i.id))}):a("div",{className:"pl-6 text-sm text-gray-400 py-1",children:"\u65E0\u5B50\u9891\u9053"})})]},e.id))}),!g&&x&&!h.length&&a("div",{className:"text-center text-gray-400 py-8",children:"\u8BE5\u673A\u5668\u4EBA\u672A\u52A0\u5165\u4EFB\u4F55\u9891\u9053"})]})]})}function Ra(t){t.addRoute({path:"/console/qq",name:"QQ\u5B98\u65B9",element:t.React.createElement(E,{hostReact:t.React})}),t.addTool({id:"qq",name:"QQ\u5B98\u65B9",path:"/console/qq"})}export{Ra as register};
1
+ import{useEffect as we,useState as c,useCallback as Pe}from"react";var Q="zhin_api_token",ue="zhin_api_base";function de(){let t=localStorage.getItem(ue)?.trim();return t?t.replace(/\/$/,""):typeof window<"u"?window.location.origin:""}function le(){return localStorage.getItem(Q)}async function k(t,o){let l=le(),s=new Headers(o?.headers);l&&s.set("Authorization",`Bearer ${l}`);let p=de(),f=typeof t=="string"&&t.startsWith("/")?`${p}${t}`:t,m=await fetch(f,{...o,headers:s});return m.status===401&&(localStorage.removeItem(Q),window.dispatchEvent(new CustomEvent("zhin:auth-required"))),m}import{forwardRef as ce,createElement as ne}from"react";var v=(...t)=>t.filter((o,l,s)=>!!o&&o.trim()!==""&&s.indexOf(o)===l).join(" ").trim();var J=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var _=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(o,l,s)=>s?s.toUpperCase():l.toLowerCase());var V=t=>{let o=_(t);return o.charAt(0).toUpperCase()+o.slice(1)};import{forwardRef as ie,createElement as Y}from"react";var U={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var j=t=>{for(let o in t)if(o.startsWith("aria-")||o==="role"||o==="title")return!0;return!1};import{createContext as fe,useContext as se,useMemo as ve,createElement as Ue}from"react";var re=fe({});var $=()=>se(re);var ee=ie(({color:t,size:o,strokeWidth:l,absoluteStrokeWidth:s,className:p="",children:f,iconNode:m,...L},R)=>{let{size:I=24,strokeWidth:x=2,absoluteStrokeWidth:O=!1,color:h="currentColor",className:q=""}=$()??{},g=s??O?Number(l??x)*24/Number(o??I):l??x;return Y("svg",{ref:R,...U,width:o??I??U.width,height:o??I??U.height,stroke:t??h,strokeWidth:g,className:v("lucide",q,p),...!f&&!j(L)&&{"aria-hidden":"true"},...L},[...m.map(([T,S])=>Y(T,S)),...Array.isArray(f)?f:[f]])});var d=(t,o)=>{let l=ce(({className:s,...p},f)=>ne(ee,{ref:f,iconNode:o,className:v(`lucide-${J(V(t))}`,`lucide-${t}`,s),...p}));return l.displayName=V(t),l};var pe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],w=d("chevron-down",pe);var me=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],P=d("chevron-right",me);var Le=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],C=d("hash",Le);var Ie=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],n=d("loader-circle",Ie);var xe=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],A=d("power-off",xe);var Ce=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],B=d("power",Ce);var he=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],M=d("refresh-cw",he);var ge=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],F=d("server",ge);var Se=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],D=d("wifi-off",Se);var ke=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],y=d("wifi",ke);import{Fragment as Ae,jsx as a,jsxs as u}from"react/jsx-runtime";function E(){let[t,o]=c([]),[l,s]=c(!0),[p,f]=c(""),[m,L]=c("overview"),[R,I]=c({}),[x,O]=c(""),[h,q]=c([]),[g,T]=c(!1),[S,H]=c(null),[G,z]=c({}),[ae,N]=c(null),b=Pe(async()=>{s(!0),f("");try{let i=await(await k("/api/qq/bots")).json();i.success?o(i.data):f(i.error||"\u83B7\u53D6\u6570\u636E\u5931\u8D25")}catch{f("\u65E0\u6CD5\u8FDE\u63A5\u670D\u52A1\u5668")}finally{s(!1)}},[]);we(()=>{b()},[b]);let te=async(e,i)=>{I(r=>({...r,[e]:!0}));try{let r=i?"disconnect":"connect",Z=await(await k(`/api/qq/bots/${encodeURIComponent(e)}/${r}`,{method:"POST"})).json();Z.success||f(Z.error||"\u64CD\u4F5C\u5931\u8D25"),await b()}catch{f("\u64CD\u4F5C\u5931\u8D25")}finally{I(r=>({...r,[e]:!1}))}},X=async e=>{O(e),T(!0),q([]),H(null),z({});try{let r=await(await k(`/api/qq/bots/${encodeURIComponent(e)}/guilds`)).json();r.success?q(r.data):f(r.error||"\u83B7\u53D6\u9891\u9053\u5931\u8D25")}catch{f("\u83B7\u53D6\u9891\u9053\u5931\u8D25")}finally{T(!1)}},oe=async e=>{if(S===e){H(null);return}if(H(e),!G[e]){N(e);try{let r=await(await k(`/api/qq/bots/${encodeURIComponent(x)}/guilds/${encodeURIComponent(e)}/channels`)).json();r.success&&z(K=>({...K,[e]:r.data}))}catch{}finally{N(null)}}},W=t.filter(e=>e.connected);return u("div",{className:"p-6 max-w-5xl mx-auto",children:[u("div",{className:"flex items-center justify-between mb-6",children:[u("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[a(F,{className:"w-6 h-6"})," QQ \u5B98\u65B9\u673A\u5668\u4EBA"]}),u("button",{onClick:b,disabled:l,className:"flex items-center gap-1 px-3 py-1.5 rounded bg-blue-500 text-white hover:bg-blue-600 disabled:opacity-50 text-sm",children:[a(M,{className:`w-4 h-4 ${l?"animate-spin":""}`})," \u5237\u65B0"]})]}),p&&a("div",{className:"mb-4 p-3 bg-red-50 text-red-600 rounded border border-red-200",children:p}),u("div",{className:"flex gap-1 mb-6 border-b",children:[a("button",{onClick:()=>L("overview"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${m==="overview"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"\u6982\u89C8"}),a("button",{onClick:()=>L("guilds"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${m==="guilds"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"\u9891\u9053\u6D4F\u89C8"})]}),m==="overview"&&u(Ae,{children:[!l&&!t.length&&!p&&a("div",{className:"text-center text-gray-500 py-12",children:"\u6682\u65E0 QQ \u673A\u5668\u4EBA\u5B9E\u4F8B"}),a("div",{className:"grid gap-4 md:grid-cols-2",children:t.map(e=>u("div",{className:"border rounded-lg p-4 bg-card shadow-sm",children:[u("div",{className:"flex items-center justify-between mb-3",children:[a("span",{className:"font-medium text-lg",children:e.name}),e.connected?u("span",{className:"flex items-center gap-1 text-green-600 text-sm",children:[a(y,{className:"w-4 h-4"})," \u5728\u7EBF"]}):u("span",{className:"flex items-center gap-1 text-gray-400 text-sm",children:[a(D,{className:"w-4 h-4"})," \u79BB\u7EBF"]})]}),a("div",{className:"grid grid-cols-1 gap-2 text-sm text-gray-600 mb-3",children:u("div",{className:"flex justify-between",children:[a("span",{children:"\u9891\u9053\u6570"}),a("span",{className:"font-mono",children:e.guildCount})]})}),u("div",{className:"flex gap-2",children:[u("button",{onClick:()=>te(e.name,e.connected),disabled:R[e.name],className:`flex items-center gap-1 px-3 py-1.5 rounded text-sm text-white ${e.connected?"bg-red-500 hover:bg-red-600":"bg-green-500 hover:bg-green-600"} disabled:opacity-50`,children:[R[e.name]?a(n,{className:"w-3.5 h-3.5 animate-spin"}):e.connected?a(A,{className:"w-3.5 h-3.5"}):a(B,{className:"w-3.5 h-3.5"}),e.connected?"\u65AD\u5F00":"\u8FDE\u63A5"]}),e.connected&&u("button",{onClick:()=>{L("guilds"),X(e.name)},className:"flex items-center gap-1 px-3 py-1.5 rounded text-sm bg-gray-100 hover:bg-gray-200 text-gray-700",children:[a(C,{className:"w-3.5 h-3.5"})," \u6D4F\u89C8\u9891\u9053"]})]})]},e.name))})]}),m==="guilds"&&u("div",{children:[W.length>0&&u("div",{className:"mb-4 flex items-center gap-2",children:[a("label",{className:"text-sm text-gray-500",children:"\u9009\u62E9\u673A\u5668\u4EBA\uFF1A"}),u("select",{value:x,onChange:e=>X(e.target.value),className:"border rounded px-2 py-1 text-sm",children:[a("option",{value:"",children:"--"}),W.map(e=>a("option",{value:e.name,children:e.name},e.name))]})]}),!W.length&&a("div",{className:"text-center text-gray-500 py-8",children:"\u6682\u65E0\u5728\u7EBF\u673A\u5668\u4EBA"}),g&&a("div",{className:"flex justify-center py-8",children:a(n,{className:"w-6 h-6 animate-spin text-blue-500"})}),!g&&h.length>0&&a("div",{className:"border rounded-lg bg-card shadow-sm divide-y",children:h.map(e=>u("div",{children:[u("button",{onClick:()=>oe(e.id),className:"w-full flex items-center gap-2 px-4 py-3 hover:bg-gray-50 text-left",children:[S===e.id?a(w,{className:"w-4 h-4 text-gray-400"}):a(P,{className:"w-4 h-4 text-gray-400"}),a("span",{className:"font-medium",children:e.name}),a("span",{className:"text-xs text-gray-400 ml-auto",children:e.id})]}),S===e.id&&a("div",{className:"px-4 pb-3",children:ae===e.id?u("div",{className:"flex items-center gap-2 text-gray-400 text-sm py-2 pl-6",children:[a(n,{className:"w-4 h-4 animate-spin"})," \u52A0\u8F7D\u4E2D\u2026"]}):G[e.id]?.length?a("div",{className:"pl-6 space-y-1",children:G[e.id].map(i=>u("div",{className:"flex items-center gap-2 text-sm text-gray-600 py-1",children:[a(C,{className:"w-3.5 h-3.5 text-gray-400"}),a("span",{children:i.name}),a("span",{className:"text-xs text-gray-400 ml-auto",children:i.id})]},i.id))}):a("div",{className:"pl-6 text-sm text-gray-400 py-1",children:"\u65E0\u5B50\u9891\u9053"})})]},e.id))}),!g&&x&&!h.length&&a("div",{className:"text-center text-gray-400 py-8",children:"\u8BE5\u673A\u5668\u4EBA\u672A\u52A0\u5165\u4EFB\u4F55\u9891\u9053"})]})]})}function Ta(t){t.addRoute({path:"/console/qq",name:"QQ\u5B98\u65B9",element:t.React.createElement(E,{hostReact:t.React})}),t.addTool({id:"qq",name:"QQ\u5B98\u65B9",path:"/console/qq"})}export{Ta as register};
2
2
  /*! Bundled license information:
3
3
 
4
4
  lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-qq",
3
- "version": "1.0.84",
3
+ "version": "2.0.1",
4
4
  "description": "Zhin.js adapter for QQ Official Bot",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -41,16 +41,16 @@
41
41
  "@types/react-dom": "^19.2.3",
42
42
  "lucide-react": "^1.16.0",
43
43
  "typescript": "^6.0.3",
44
- "@zhin.js/cli": "1.0.77",
45
- "@zhin.js/console": "2.0.24",
46
- "zhin.js": "1.0.81"
44
+ "@zhin.js/cli": "1.0.78",
45
+ "@zhin.js/console": "3.0.1",
46
+ "zhin.js": "1.0.82"
47
47
  },
48
48
  "peerDependencies": {
49
- "@zhin.js/client": "1.0.18",
50
- "@zhin.js/console": "2.0.24",
51
- "@zhin.js/http": "1.0.74",
52
- "@zhin.js/logger": "0.1.63",
53
- "zhin.js": "1.0.81"
49
+ "@zhin.js/client": "1.1.1",
50
+ "@zhin.js/console": "3.0.1",
51
+ "@zhin.js/http": "1.0.75",
52
+ "zhin.js": "1.0.82",
53
+ "@zhin.js/logger": "0.1.64"
54
54
  },
55
55
  "peerDependenciesMeta": {
56
56
  "@zhin.js/client": {