@zhin.js/adapter-discord 1.0.73 → 1.0.74

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,16 @@
1
1
  # @zhin.js/adapter-discord
2
2
 
3
+ ## 1.0.74
4
+
5
+ ### Patch Changes
6
+
7
+ - 4304825: fix: 重新发版
8
+ - Updated dependencies [4304825]
9
+ - @zhin.js/client@1.0.17
10
+ - zhin.js@1.0.71
11
+ - @zhin.js/console@2.0.11
12
+ - @zhin.js/http@1.0.64
13
+
3
14
  ## 1.0.73
4
15
 
5
16
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{addPage as e}from"@zhin.js/client";import{Gamepad2 as t,Globe as n,Loader2 as r,Power as i,PowerOff as a,RefreshCw as o,Server as s,Users as c,Wifi as l,WifiOff as u}from"lucide-react";import{useCallback as d,useEffect as f,useState as p}from"react";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";var _="zhin_api_token";function v(){return localStorage.getItem(_)}async function y(e2,t2){let n2=v(),r2=new Headers(t2?.headers);n2&&r2.set("Authorization",`Bearer ${n2}`);let i2=await fetch(e2,{...t2,headers:r2});return i2.status===401&&(localStorage.removeItem(_),window.dispatchEvent(new CustomEvent("zhin:auth-required"))),i2}function b(){let[e2,t2]=p([]),[_2,v2]=p(true),[b2,x]=p(""),[S,C]=p("overview"),[w,T]=p({}),[E,D]=p(""),[O,k]=p([]),[A,j]=p(false),M=d(async()=>{v2(true),x("");try{let e3=await(await y("/api/discord/bots")).json();e3.success?t2(e3.data):x(e3.error||"获取数据失败")}catch{x("无法连接服务器")}finally{v2(false)}},[]);f(()=>{M()},[M]);let N=async(e3,t3)=>{T(t4=>({...t4,[e3]:true}));try{let n2=t3?"disconnect":"connect",r2=await(await y(`/api/discord/bots/${encodeURIComponent(e3)}/${n2}`,{method:"POST"})).json();r2.success||x(r2.error||"操作失败"),await M()}catch{x("操作失败")}finally{T(t4=>({...t4,[e3]:false}))}},P=async e3=>{D(e3),j(true),k([]);try{let t3=await(await y(`/api/discord/bots/${encodeURIComponent(e3)}/guilds`)).json();t3.success?k(t3.data):x(t3.error||"获取服务器列表失败")}catch{x("获取服务器列表失败")}finally{j(false)}},F=e2.filter(e3=>e3.connected&&e3.mode==="gateway");return g("div",{className:"p-6 max-w-5xl mx-auto",children:[g("div",{className:"flex items-center justify-between mb-6",children:[g("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[h(s,{className:"w-6 h-6"})," Discord 机器人"]}),g("button",{onClick:M,disabled:_2,className:"flex items-center gap-1 px-3 py-1.5 rounded bg-indigo-500 text-white hover:bg-indigo-600 disabled:opacity-50 text-sm",children:[h(o,{className:`w-4 h-4 ${_2?"animate-spin":""}`})," 刷新"]})]}),b2&&h("div",{className:"mb-4 p-3 bg-red-50 text-red-600 rounded border border-red-200",children:b2}),g("div",{className:"flex gap-1 mb-6 border-b",children:[h("button",{onClick:()=>C("overview"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${S==="overview"?"border-indigo-500 text-indigo-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"概览"}),h("button",{onClick:()=>C("guilds"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${S==="guilds"?"border-indigo-500 text-indigo-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"服务器列表"})]}),S==="overview"&&g(m,{children:[!_2&&!e2.length&&!b2&&h("div",{className:"text-center text-gray-500 py-12",children:"暂无 Discord 机器人实例"}),h("div",{className:"grid gap-4 md:grid-cols-2",children:e2.map(e3=>g("div",{className:"border rounded-lg p-4 bg-card shadow-sm",children:[g("div",{className:"flex items-center justify-between mb-3",children:[h("span",{className:"font-medium text-lg",children:e3.name}),e3.connected?g("span",{className:"flex items-center gap-1 text-green-600 text-sm",children:[h(l,{className:"w-4 h-4"})," 在线"]}):g("span",{className:"flex items-center gap-1 text-gray-400 text-sm",children:[h(u,{className:"w-4 h-4"})," 离线"]})]}),e3.user&&g("div",{className:"text-sm text-gray-500 mb-2",children:["@",e3.user.tag]}),g("div",{className:"grid grid-cols-2 gap-2 text-sm text-gray-600 mb-3",children:[g("div",{className:"flex justify-between",children:[h("span",{children:"模式"}),h("span",{className:"font-mono",children:e3.mode})]}),g("div",{className:"flex justify-between",children:[h("span",{children:"服务器"}),h("span",{className:"font-mono",children:e3.guildCount})]}),g("div",{className:"flex justify-between",children:[h("span",{children:"频道"}),h("span",{className:"font-mono",children:e3.channelCount})]})]}),g("div",{className:"flex gap-2",children:[g("button",{onClick:()=>N(e3.name,e3.connected),disabled:w[e3.name],className:`flex items-center gap-1 px-3 py-1.5 rounded text-sm text-white ${e3.connected?"bg-red-500 hover:bg-red-600":"bg-green-500 hover:bg-green-600"} disabled:opacity-50`,children:[w[e3.name]?h(r,{className:"w-3.5 h-3.5 animate-spin"}):e3.connected?h(a,{className:"w-3.5 h-3.5"}):h(i,{className:"w-3.5 h-3.5"}),e3.connected?"断开":"连接"]}),e3.connected&&e3.mode==="gateway"&&g("button",{onClick:()=>{C("guilds"),P(e3.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:[h(n,{className:"w-3.5 h-3.5"})," 查看服务器"]})]})]},e3.name))})]}),S==="guilds"&&g("div",{children:[F.length>0&&g("div",{className:"mb-4 flex items-center gap-2",children:[h("label",{className:"text-sm text-gray-500",children:"选择机器人:"}),g("select",{value:E,onChange:e3=>P(e3.target.value),className:"border rounded px-2 py-1 text-sm",children:[h("option",{value:"",children:"--"}),F.map(e3=>h("option",{value:e3.name,children:e3.name},e3.name))]}),h("span",{className:"text-xs text-gray-400 ml-2",children:"仅 Gateway 模式支持"})]}),!F.length&&h("div",{className:"text-center text-gray-500 py-8",children:"暂无 Gateway 模式在线机器人"}),A&&h("div",{className:"flex justify-center py-8",children:h(r,{className:"w-6 h-6 animate-spin text-indigo-500"})}),!A&&O.length>0&&h("div",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-3",children:O.map(e3=>g("div",{className:"border rounded-lg p-3 bg-card shadow-sm flex items-center gap-3",children:[e3.icon?h("img",{src:e3.icon,alt:"",className:"w-10 h-10 rounded-full"}):h("div",{className:"w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-500 font-bold text-sm",children:e3.name[0]}),g("div",{className:"flex-1 min-w-0",children:[h("div",{className:"font-medium text-sm truncate",children:e3.name}),g("div",{className:"flex items-center gap-1 text-xs text-gray-400",children:[h(c,{className:"w-3 h-3"})," ",e3.memberCount," 成员"]})]})]},e3.id))}),!A&&E&&!O.length&&h("div",{className:"text-center text-gray-400 py-8",children:"该机器人未加入任何服务器"})]})]})}e({key:"discord-management",path:"/discord",title:"Discord",icon:h(t,{className:"w-5 h-5"}),element:h(b,{})});
1
+ import{addPage as e}from"@zhin.js/client";import{Gamepad2 as t,Globe as n,Loader2 as r,Power as i,PowerOff as a,RefreshCw as o,Server as s,Users as c,Wifi as l,WifiOff as u}from"lucide-react";import{useCallback as d,useEffect as f,useState as p}from"react";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";var _="zhin_api_token";function v(){return localStorage.getItem(_)}async function y(e2,t2){let n2=v(),r2=new Headers(t2?.headers);n2&&r2.set("Authorization",`Bearer ${n2}`);let i2=await fetch(e2,{...t2,headers:r2});return i2.status===401&&(localStorage.removeItem(_),window.dispatchEvent(new CustomEvent("zhin:auth-required"))),i2}function b(){let[e2,t2]=p([]),[_2,v2]=p(true),[b2,x]=p(""),[S,C]=p("overview"),[w,T]=p({}),[E,D]=p(""),[O,k]=p([]),[A,j]=p(false),M=d(async()=>{v2(true),x("");try{let e3=await(await y("/api/discord/bots")).json();e3.success?t2(e3.data):x(e3.error||"获取数据失败")}catch{x("无法连接服务器")}finally{v2(false)}},[]);f(()=>{M()},[M]);let N=async(e3,t3)=>{T(t4=>({...t4,[e3]:true}));try{let n2=await(await y(`/api/discord/bots/${encodeURIComponent(e3)}/${t3?"disconnect":"connect"}`,{method:"POST"})).json();n2.success||x(n2.error||"操作失败"),await M()}catch{x("操作失败")}finally{T(t4=>({...t4,[e3]:false}))}},P=async e3=>{D(e3),j(true),k([]);try{let t3=await(await y(`/api/discord/bots/${encodeURIComponent(e3)}/guilds`)).json();t3.success?k(t3.data):x(t3.error||"获取服务器列表失败")}catch{x("获取服务器列表失败")}finally{j(false)}},F=e2.filter(e3=>e3.connected&&e3.mode==="gateway");return g("div",{className:"p-6 max-w-5xl mx-auto",children:[g("div",{className:"flex items-center justify-between mb-6",children:[g("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[h(s,{className:"w-6 h-6"})," Discord 机器人"]}),g("button",{onClick:M,disabled:_2,className:"flex items-center gap-1 px-3 py-1.5 rounded bg-indigo-500 text-white hover:bg-indigo-600 disabled:opacity-50 text-sm",children:[h(o,{className:`w-4 h-4 ${_2?"animate-spin":""}`})," 刷新"]})]}),b2&&h("div",{className:"mb-4 p-3 bg-red-50 text-red-600 rounded border border-red-200",children:b2}),g("div",{className:"flex gap-1 mb-6 border-b",children:[h("button",{onClick:()=>C("overview"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${S==="overview"?"border-indigo-500 text-indigo-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"概览"}),h("button",{onClick:()=>C("guilds"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${S==="guilds"?"border-indigo-500 text-indigo-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"服务器列表"})]}),S==="overview"&&g(m,{children:[!_2&&!e2.length&&!b2&&h("div",{className:"text-center text-gray-500 py-12",children:"暂无 Discord 机器人实例"}),h("div",{className:"grid gap-4 md:grid-cols-2",children:e2.map(e3=>g("div",{className:"border rounded-lg p-4 bg-card shadow-sm",children:[g("div",{className:"flex items-center justify-between mb-3",children:[h("span",{className:"font-medium text-lg",children:e3.name}),e3.connected?g("span",{className:"flex items-center gap-1 text-green-600 text-sm",children:[h(l,{className:"w-4 h-4"})," 在线"]}):g("span",{className:"flex items-center gap-1 text-gray-400 text-sm",children:[h(u,{className:"w-4 h-4"})," 离线"]})]}),e3.user&&g("div",{className:"text-sm text-gray-500 mb-2",children:["@",e3.user.tag]}),g("div",{className:"grid grid-cols-2 gap-2 text-sm text-gray-600 mb-3",children:[g("div",{className:"flex justify-between",children:[h("span",{children:"模式"}),h("span",{className:"font-mono",children:e3.mode})]}),g("div",{className:"flex justify-between",children:[h("span",{children:"服务器"}),h("span",{className:"font-mono",children:e3.guildCount})]}),g("div",{className:"flex justify-between",children:[h("span",{children:"频道"}),h("span",{className:"font-mono",children:e3.channelCount})]})]}),g("div",{className:"flex gap-2",children:[g("button",{onClick:()=>N(e3.name,e3.connected),disabled:w[e3.name],className:`flex items-center gap-1 px-3 py-1.5 rounded text-sm text-white ${e3.connected?"bg-red-500 hover:bg-red-600":"bg-green-500 hover:bg-green-600"} disabled:opacity-50`,children:[w[e3.name]?h(r,{className:"w-3.5 h-3.5 animate-spin"}):e3.connected?h(a,{className:"w-3.5 h-3.5"}):h(i,{className:"w-3.5 h-3.5"}),e3.connected?"断开":"连接"]}),e3.connected&&e3.mode==="gateway"&&g("button",{onClick:()=>{C("guilds"),P(e3.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:[h(n,{className:"w-3.5 h-3.5"})," 查看服务器"]})]})]},e3.name))})]}),S==="guilds"&&g("div",{children:[F.length>0&&g("div",{className:"mb-4 flex items-center gap-2",children:[h("label",{className:"text-sm text-gray-500",children:"选择机器人:"}),g("select",{value:E,onChange:e3=>P(e3.target.value),className:"border rounded px-2 py-1 text-sm",children:[h("option",{value:"",children:"--"}),F.map(e3=>h("option",{value:e3.name,children:e3.name},e3.name))]}),h("span",{className:"text-xs text-gray-400 ml-2",children:"仅 Gateway 模式支持"})]}),!F.length&&h("div",{className:"text-center text-gray-500 py-8",children:"暂无 Gateway 模式在线机器人"}),A&&h("div",{className:"flex justify-center py-8",children:h(r,{className:"w-6 h-6 animate-spin text-indigo-500"})}),!A&&O.length>0&&h("div",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-3",children:O.map(e3=>g("div",{className:"border rounded-lg p-3 bg-card shadow-sm flex items-center gap-3",children:[e3.icon?h("img",{src:e3.icon,alt:"",className:"w-10 h-10 rounded-full"}):h("div",{className:"w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-500 font-bold text-sm",children:e3.name[0]}),g("div",{className:"flex-1 min-w-0",children:[h("div",{className:"font-medium text-sm truncate",children:e3.name}),g("div",{className:"flex items-center gap-1 text-xs text-gray-400",children:[h(c,{className:"w-3 h-3"})," ",e3.memberCount," 成员"]})]})]},e3.id))}),!A&&E&&!O.length&&h("div",{className:"text-center text-gray-400 py-8",children:"该机器人未加入任何服务器"})]})]})}e({key:"discord-management",path:"/discord",title:"Discord",icon:h(t,{className:"w-5 h-5"}),element:h(b,{})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-discord",
3
- "version": "1.0.73",
3
+ "version": "1.0.74",
4
4
  "description": "Zhin.js adapter for Discord",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -42,14 +42,14 @@
42
42
  "@types/react-dom": "^19.2.1",
43
43
  "lucide-react": "^0.469.0",
44
44
  "typescript": "^6.0.0",
45
- "@zhin.js/console": "2.0.10",
46
- "zhin.js": "1.0.68"
45
+ "@zhin.js/console": "2.0.11",
46
+ "zhin.js": "1.0.71"
47
47
  },
48
48
  "peerDependencies": {
49
- "@zhin.js/client": "1.0.16",
50
- "@zhin.js/console": "2.0.10",
51
- "@zhin.js/http": "1.0.63",
52
- "zhin.js": "1.0.68"
49
+ "@zhin.js/client": "1.0.17",
50
+ "@zhin.js/console": "2.0.11",
51
+ "@zhin.js/http": "1.0.64",
52
+ "zhin.js": "1.0.71"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@zhin.js/client": {
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 凉菜
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.