koishi-plugin-adapter-onebot-multi 0.0.8 → 0.0.9

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/client/page.vue CHANGED
@@ -22,7 +22,7 @@ import { send } from '@koishijs/client'
22
22
  interface PanelConfig {
23
23
  basePath: string
24
24
  enabled: boolean
25
- adminUrl: string
25
+ port: number | null
26
26
  }
27
27
 
28
28
  const loading = ref(true)
@@ -30,8 +30,16 @@ const panelConfig = ref<PanelConfig | null>(null)
30
30
 
31
31
  const panelEnabled = computed(() => panelConfig.value?.enabled ?? false)
32
32
 
33
- // 使用服务端返回的完整 URL
34
- const adminUrl = computed(() => panelConfig.value?.adminUrl || '')
33
+ // 根据当前页面 hostname 动态构建 URL
34
+ const adminUrl = computed(() => {
35
+ if (!panelConfig.value) return ''
36
+ const { basePath, port } = panelConfig.value
37
+ if (port) {
38
+ // 使用当前页面的 hostname,支持服务器部署
39
+ return `${window.location.protocol}//${window.location.hostname}:${port}${basePath}/admin`
40
+ }
41
+ return `${basePath}/admin`
42
+ })
35
43
 
36
44
  onMounted(async () => {
37
45
  try {
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{send as p,icons as f}from"@koishijs/client";import{defineComponent as v,ref as u,computed as d,onMounted as g,resolveComponent as y,createBlock as k,openBlock as r,withCtx as x,createElementBlock as s,createElementVNode as l}from"vue";const h={key:0,class:"loading-state"},w={key:1,class:"disabled-state"},b=["src"],B=v({__name:"page",setup(n){const t=u(true),o=u(null),a=d(()=>{var e;return((e=o.value)==null?void 0:e.enabled)??false}),i=d(()=>{var e;return((e=o.value)==null?void 0:e.adminUrl)||""});return g(async()=>{try{o.value=await p("onebot-multi/config")}catch(e){console.error("Failed to get panel config:",e)}finally{t.value=false}}),(e,c)=>{const m=y("k-layout");return r(),k(m,null,{default:x(()=>[t.value?(r(),s("div",h,[...c[0]||(c[0]=[l("span",null,"加载中...",-1)])])):a.value?(r(),s("iframe",{key:2,src:i.value,class:"admin-iframe"},null,8,b)):(r(),s("div",w,[...c[1]||(c[1]=[l("h2",null,"面板未启用",-1),l("p",null,"请在插件配置中启用「展示面板」功能",-1)])]))]),_:1})}}}),_=(n,t)=>{const o=n.__vccOpts||n;for(const[a,i]of t)o[a]=i;return o},C=_(B,[["__scopeId","data-v-c05bc3f0"]]),E={},I={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function M(n,t){return r(),s("svg",I,[...t[0]||(t[0]=[l("rect",{x:"2",y:"4",width:"20",height:"18",rx:"3"},null,-1),l("circle",{cx:"8",cy:"13",r:"2.5"},null,-1),l("circle",{cx:"16",cy:"13",r:"2.5"},null,-1)])])}const O=_(E,[["render",M]]);f.register("activity:onebot-multi",O);const j=n=>{n.page({name:"OneBot Multi",path:"/onebot-multi",component:C,icon:"activity:onebot-multi",order:600})};export{j as default};
1
+ import{send as _,icons as f}from"@koishijs/client";import{defineComponent as v,ref as u,computed as d,onMounted as g,resolveComponent as y,createBlock as k,openBlock as a,withCtx as w,createElementBlock as s,createElementVNode as r}from"vue";const x={key:0,class:"loading-state"},h={key:1,class:"disabled-state"},b=["src"],$=v({__name:"page",setup(l){const t=u(true),n=u(null),c=d(()=>{var e;return((e=n.value)==null?void 0:e.enabled)??false}),i=d(()=>{if(!n.value)return"";const{basePath:e,port:o}=n.value;return o?`${window.location.protocol}//${window.location.hostname}:${o}${e}/admin`:`${e}/admin`});return g(async()=>{try{n.value=await _("onebot-multi/config")}catch(e){console.error("Failed to get panel config:",e)}finally{t.value=false}}),(e,o)=>{const p=y("k-layout");return a(),k(p,null,{default:w(()=>[t.value?(a(),s("div",x,[...o[0]||(o[0]=[r("span",null,"加载中...",-1)])])):c.value?(a(),s("iframe",{key:2,src:i.value,class:"admin-iframe"},null,8,b)):(a(),s("div",h,[...o[1]||(o[1]=[r("h2",null,"面板未启用",-1),r("p",null,"请在插件配置中启用「展示面板」功能",-1)])]))]),_:1})}}}),m=(l,t)=>{const n=l.__vccOpts||l;for(const[c,i]of t)n[c]=i;return n},B=m($,[["__scopeId","data-v-b3b2932d"]]),C={},E={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function I(l,t){return a(),s("svg",E,[...t[0]||(t[0]=[r("rect",{x:"2",y:"4",width:"20",height:"18",rx:"3"},null,-1),r("circle",{cx:"8",cy:"13",r:"2.5"},null,-1),r("circle",{cx:"16",cy:"13",r:"2.5"},null,-1)])])}const M=m(C,[["render",I]]);f.register("activity:onebot-multi",M);const j=l=>{l.page({name:"OneBot Multi",path:"/onebot-multi",component:B,icon:"activity:onebot-multi",order:600})};export{j as default};
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- @charset "UTF-8";[data-v-c05bc3f0] .k-layout{background:transparent!important;padding:0!important;margin:0!important}[data-v-c05bc3f0] .k-layout__main{background:transparent!important;padding:0!important;margin:0!important;overflow:hidden!important}[data-v-c05bc3f0] .k-layout__header,[data-v-c05bc3f0] .k-layout__left,[data-v-c05bc3f0] .k-layout__right{display:none!important}.admin-iframe[data-v-c05bc3f0]{width:100%;height:100%;border:none;display:block}.loading-state[data-v-c05bc3f0],.disabled-state[data-v-c05bc3f0]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--k-text-light)}.disabled-state h2[data-v-c05bc3f0]{margin-bottom:.5rem;color:var(--k-text-dark)}.disabled-state p[data-v-c05bc3f0]{color:var(--k-text-light)}
1
+ @charset "UTF-8";[data-v-b3b2932d] .k-layout{background:transparent!important;padding:0!important;margin:0!important}[data-v-b3b2932d] .k-layout__main{background:transparent!important;padding:0!important;margin:0!important;overflow:hidden!important}[data-v-b3b2932d] .k-layout__header,[data-v-b3b2932d] .k-layout__left,[data-v-b3b2932d] .k-layout__right{display:none!important}.admin-iframe[data-v-b3b2932d]{width:100%;height:100%;border:none;display:block}.loading-state[data-v-b3b2932d],.disabled-state[data-v-b3b2932d]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--k-text-light)}.disabled-state h2[data-v-b3b2932d]{margin-bottom:.5rem;color:var(--k-text-dark)}.disabled-state p[data-v-b3b2932d]{color:var(--k-text-light)}
package/lib/index.d.ts CHANGED
@@ -8,7 +8,7 @@ declare module '@koishijs/console' {
8
8
  'onebot-multi/config'(): {
9
9
  basePath: string;
10
10
  enabled: boolean;
11
- adminUrl: string;
11
+ port: number | null;
12
12
  };
13
13
  }
14
14
  }
package/lib/index.js CHANGED
@@ -2701,11 +2701,10 @@ function apply(ctx, config) {
2701
2701
  ctx2.console.addListener("onebot-multi/config", () => {
2702
2702
  const basePath = config.panel?.basePath || "/status";
2703
2703
  const port = config.panel?.port;
2704
- const adminUrl = port ? `http://localhost:${port}${basePath}/admin` : `${basePath}/admin`;
2705
2704
  return {
2706
2705
  basePath,
2707
2706
  enabled: config.panel?.enabled || false,
2708
- adminUrl
2707
+ port: port || null
2709
2708
  };
2710
2709
  });
2711
2710
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-adapter-onebot-multi",
3
3
  "description": "奶龙bot定制版onebot适配器,支持自动负载均衡,适配器级黑名单/白名单,提供webui,可指定端口",
4
- "version": "0.0.8",
4
+ "version": "0.0.9",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [