@zhin.js/adapter-kook 1.0.69 → 1.0.71
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 +21 -0
- package/dist/index.js +1 -1
- package/package.json +8 -8
- package/LICENSE +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @zhin.js/adapter-kook
|
|
2
2
|
|
|
3
|
+
## 1.0.71
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4304825: fix: 重新发版
|
|
8
|
+
- Updated dependencies [4304825]
|
|
9
|
+
- @zhin.js/logger@0.1.53
|
|
10
|
+
- @zhin.js/client@1.0.17
|
|
11
|
+
- zhin.js@1.0.71
|
|
12
|
+
- @zhin.js/console@2.0.11
|
|
13
|
+
- @zhin.js/http@1.0.64
|
|
14
|
+
|
|
15
|
+
## 1.0.70
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- zhin.js@1.0.68
|
|
20
|
+
- @zhin.js/logger@0.1.52
|
|
21
|
+
- @zhin.js/console@2.0.10
|
|
22
|
+
- @zhin.js/http@1.0.63
|
|
23
|
+
|
|
3
24
|
## 1.0.69
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{addPage as e}from"@zhin.js/client";import{Headphones as t,Loader2 as n,Plus as r,Power as i,PowerOff as a,RefreshCw as o,Server as s,Shield as c,Trash2 as l,Wifi as u,WifiOff as d,X as f}from"lucide-react";import{useCallback as p,useEffect as m,useState as h}from"react";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";var y="zhin_api_token";function b(){return localStorage.getItem(y)}async function x(e2,t2){let n2=b(),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(y),window.dispatchEvent(new CustomEvent("zhin:auth-required"))),i2}function S(){let[e2,t2]=h([]),[y2,b2]=h(true),[S2,C]=h(""),[w,T]=h("overview"),[E,D]=h({}),[O,k]=h(""),[A,j]=h(""),[M,N]=h([]),[P,F]=h(false),[I,L]=h(""),[R,z]=h(false),[B,V]=h(null),H=p(async()=>{b2(true),C("");try{let e3=await(await x("/api/kook/bots")).json();e3.success?t2(e3.data):C(e3.error||"获取数据失败")}catch{C("无法连接服务器")}finally{b2(false)}},[]);m(()=>{H()},[H]);let U=async(e3,t3)=>{D(t4=>({...t4,[e3]:true}));try{let n2=
|
|
1
|
+
import{addPage as e}from"@zhin.js/client";import{Headphones as t,Loader2 as n,Plus as r,Power as i,PowerOff as a,RefreshCw as o,Server as s,Shield as c,Trash2 as l,Wifi as u,WifiOff as d,X as f}from"lucide-react";import{useCallback as p,useEffect as m,useState as h}from"react";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";var y="zhin_api_token";function b(){return localStorage.getItem(y)}async function x(e2,t2){let n2=b(),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(y),window.dispatchEvent(new CustomEvent("zhin:auth-required"))),i2}function S(){let[e2,t2]=h([]),[y2,b2]=h(true),[S2,C]=h(""),[w,T]=h("overview"),[E,D]=h({}),[O,k]=h(""),[A,j]=h(""),[M,N]=h([]),[P,F]=h(false),[I,L]=h(""),[R,z]=h(false),[B,V]=h(null),H=p(async()=>{b2(true),C("");try{let e3=await(await x("/api/kook/bots")).json();e3.success?t2(e3.data):C(e3.error||"获取数据失败")}catch{C("无法连接服务器")}finally{b2(false)}},[]);m(()=>{H()},[H]);let U=async(e3,t3)=>{D(t4=>({...t4,[e3]:true}));try{let n2=await(await x(`/api/kook/bots/${encodeURIComponent(e3)}/${t3?"disconnect":"connect"}`,{method:"POST"})).json();n2.success||C(n2.error||"操作失败"),await H()}catch{C("操作失败")}finally{D(t4=>({...t4,[e3]:false}))}},W=async()=>{if(!(!O||!A)){F(true),N([]);try{let e3=await(await x(`/api/kook/bots/${encodeURIComponent(O)}/guilds/${encodeURIComponent(A)}/roles`)).json();e3.success?N(e3.data):C(e3.error||"获取角色失败")}catch{C("获取角色失败")}finally{F(false)}}},G=async()=>{if(!(!O||!A||!I.trim())){z(true);try{let e3=await(await x(`/api/kook/bots/${encodeURIComponent(O)}/guilds/${encodeURIComponent(A)}/roles`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:I.trim()})})).json();e3.success?(L(""),await W()):C(e3.error||"创建角色失败")}catch{C("创建角色失败")}finally{z(false)}}},K=async e3=>{if(!(!O||!A)){V(e3);try{let t3=await(await x(`/api/kook/bots/${encodeURIComponent(O)}/guilds/${encodeURIComponent(A)}/roles/${encodeURIComponent(e3)}`,{method:"DELETE"})).json();t3.success?N(t4=>t4.filter(t5=>t5.id!==e3)):C(t3.error||"删除角色失败")}catch{C("删除角色失败")}finally{V(null)}}},q=e2.filter(e3=>e3.connected);return v("div",{className:"p-6 max-w-5xl mx-auto",children:[v("div",{className:"flex items-center justify-between mb-6",children:[v("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[_(s,{className:"w-6 h-6"})," KOOK 机器人"]}),v("button",{onClick:H,disabled:y2,className:"flex items-center gap-1 px-3 py-1.5 rounded bg-sky-500 text-white hover:bg-sky-600 disabled:opacity-50 text-sm",children:[_(o,{className:`w-4 h-4 ${y2?"animate-spin":""}`})," 刷新"]})]}),S2&&v("div",{className:"mb-4 p-3 bg-red-50 text-red-600 rounded border border-red-200 flex items-center justify-between",children:[_("span",{children:S2}),_("button",{onClick:()=>C(""),className:"text-red-400 hover:text-red-600",children:_(f,{className:"w-4 h-4"})})]}),v("div",{className:"flex gap-1 mb-6 border-b",children:[_("button",{onClick:()=>T("overview"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="overview"?"border-sky-500 text-sky-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"概览"}),_("button",{onClick:()=>T("roles"),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="roles"?"border-sky-500 text-sky-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:"角色管理"})]}),w==="overview"&&v(g,{children:[!y2&&!e2.length&&!S2&&_("div",{className:"text-center text-gray-500 py-12",children:"暂无 KOOK 机器人实例"}),_("div",{className:"grid gap-4 md:grid-cols-2",children:e2.map(e3=>v("div",{className:"border rounded-lg p-4 bg-card shadow-sm",children:[v("div",{className:"flex items-center justify-between mb-3",children:[_("span",{className:"font-medium text-lg",children:e3.name}),e3.connected?v("span",{className:"flex items-center gap-1 text-green-600 text-sm",children:[_(u,{className:"w-4 h-4"})," 在线"]}):v("span",{className:"flex items-center gap-1 text-gray-400 text-sm",children:[_(d,{className:"w-4 h-4"})," 离线"]})]}),_("div",{className:"text-sm text-gray-600 mb-3",children:v("div",{className:"flex justify-between",children:[_("span",{children:"服务器"}),_("span",{className:"font-mono",children:e3.guildCount})]})}),v("button",{onClick:()=>U(e3.name,e3.connected),disabled:E[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:[E[e3.name]?_(n,{className:"w-3.5 h-3.5 animate-spin"}):e3.connected?_(a,{className:"w-3.5 h-3.5"}):_(i,{className:"w-3.5 h-3.5"}),e3.connected?"断开":"连接"]})]},e3.name))})]}),w==="roles"&&v("div",{className:"space-y-4",children:[v("div",{className:"flex flex-wrap items-end gap-3",children:[v("div",{children:[_("label",{className:"block text-xs text-gray-500 mb-1",children:"机器人"}),v("select",{value:O,onChange:e3=>k(e3.target.value),className:"border rounded px-2 py-1.5 text-sm min-w-[140px]",children:[_("option",{value:"",children:"--"}),q.map(e3=>_("option",{value:e3.name,children:e3.name},e3.name))]})]}),v("div",{children:[_("label",{className:"block text-xs text-gray-500 mb-1",children:"服务器 ID"}),_("input",{value:A,onChange:e3=>j(e3.target.value),placeholder:"输入服务器 ID",className:"border rounded px-2 py-1.5 text-sm w-[180px]"})]}),v("button",{onClick:W,disabled:!O||!A||P,className:"px-3 py-1.5 rounded bg-sky-500 text-white text-sm hover:bg-sky-600 disabled:opacity-50 flex items-center gap-1",children:[P?_(n,{className:"w-3.5 h-3.5 animate-spin"}):_(c,{className:"w-3.5 h-3.5"})," 查询角色"]})]}),!q.length&&_("div",{className:"text-center text-gray-500 py-4",children:"暂无在线机器人"}),O&&A&&M.length>0&&v("div",{className:"flex items-center gap-2",children:[_("input",{value:I,onChange:e3=>L(e3.target.value),placeholder:"新角色名称",className:"border rounded px-2 py-1.5 text-sm flex-1 max-w-[240px]",onKeyDown:e3=>e3.key==="Enter"&&G()}),v("button",{onClick:G,disabled:R||!I.trim(),className:"px-3 py-1.5 rounded bg-green-500 text-white text-sm hover:bg-green-600 disabled:opacity-50 flex items-center gap-1",children:[R?_(n,{className:"w-3.5 h-3.5 animate-spin"}):_(r,{className:"w-3.5 h-3.5"})," 创建"]})]}),P&&_("div",{className:"flex justify-center py-8",children:_(n,{className:"w-6 h-6 animate-spin text-sky-500"})}),!P&&M.length>0&&_("div",{className:"border rounded-lg bg-card shadow-sm divide-y",children:M.map(e3=>v("div",{className:"flex items-center px-4 py-2.5 hover:bg-gray-50",children:[_("div",{className:"w-3 h-3 rounded-full mr-3",style:{backgroundColor:e3.color?`#${e3.color.toString(16).padStart(6,"0")}`:"#999"}}),_("span",{className:"font-medium text-sm flex-1",children:e3.name}),v("span",{className:"text-xs text-gray-400 mr-4",children:["ID: ",e3.id]}),_("button",{onClick:()=>K(e3.id),disabled:B===e3.id,className:"text-gray-400 hover:text-red-500 disabled:opacity-50",children:B===e3.id?_(n,{className:"w-4 h-4 animate-spin"}):_(l,{className:"w-4 h-4"})})]},e3.id))}),!P&&O&&A&&!M.length&&_("div",{className:"text-center text-gray-400 py-6",children:"暂无角色数据,请先查询"})]})]})}e({key:"kook-management",path:"/kook",title:"KOOK",icon:_(t,{className:"w-5 h-5"}),element:_(S,{})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-kook",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.71",
|
|
4
4
|
"description": "Zhin.js adapter for KOOK (开黑啦)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"@types/react-dom": "^19.2.1",
|
|
41
41
|
"lucide-react": "^0.469.0",
|
|
42
42
|
"typescript": "^6.0.0",
|
|
43
|
-
"@zhin.js/console": "2.0.
|
|
44
|
-
"zhin.js": "1.0.
|
|
43
|
+
"@zhin.js/console": "2.0.11",
|
|
44
|
+
"zhin.js": "1.0.71"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@zhin.js/client": "1.0.
|
|
48
|
-
"@zhin.js/console": "2.0.
|
|
49
|
-
"@zhin.js/http": "1.0.
|
|
50
|
-
"@zhin.js/logger": "0.1.
|
|
51
|
-
"zhin.js": "1.0.
|
|
47
|
+
"@zhin.js/client": "1.0.17",
|
|
48
|
+
"@zhin.js/console": "2.0.11",
|
|
49
|
+
"@zhin.js/http": "1.0.64",
|
|
50
|
+
"@zhin.js/logger": "0.1.53",
|
|
51
|
+
"zhin.js": "1.0.71"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"@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.
|