@koishi-ce/plugin-config 1.0.6 → 1.0.7
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 +79 -0
- package/dist/index.js +2 -2
- package/dist/style.css +1 -1
- package/package.json +4 -4
- package/src/__tests__/index.test.ts +4 -0
- package/src/browser/index.ts +4 -0
- package/src/browser/packages.ts +4 -0
- package/src/index.ts +4 -0
- package/src/node/index.ts +4 -0
- package/src/node/packages.ts +4 -0
- package/src/shared/index.ts +4 -0
- package/src/shared/packages.ts +4 -0
- package/src/shared/services.ts +4 -0
- package/src/shared/writer.ts +4 -0
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @koishi-ce/plugin-config
|
|
2
|
+
|
|
3
|
+
**简体中文** | [English](#english)
|
|
4
|
+
|
|
5
|
+
控制台的插件配置管理器,移植自上游 [koishijs/webui](https://github.com/koishijs/webui) 的 `plugins/config`。它把 koishi.yml / koishi.json 的完整配置树推送到浏览器,并在网页上完成插件与机器人配置的查看、修改、启停、增删——所有改动经 loader 写回配置文件。需要先启用 [`@koishi-ce/plugin-console`](https://github.com/Koishi-CE/koishi/tree/main/plugins/webui/console)。
|
|
6
|
+
|
|
7
|
+
## 功能与页面
|
|
8
|
+
|
|
9
|
+
- **插件配置页**(`/plugins/:name*`,权限 4):本机与工作区全部插件包的列表、运行时状态(schema / usage / inject / fork)与配置编辑;含一个「应用全局设置」条目;
|
|
10
|
+
- **配置树右键菜单**:停用 / 启用、保存 / 重载、重命名、移除、克隆、管理同一插件的多份配置(fork)、添加插件与分组;
|
|
11
|
+
- **服务数据**:`packages`(插件包列表)、`services`(服务名到提供者的映射)、`config`(整份配置流,均要求权限 4);
|
|
12
|
+
- **浏览器端编程接口**:其他控制台插件可经 `configWriter` 服务对配置做 ensure / remove / get 操作。
|
|
13
|
+
|
|
14
|
+
配置来源不可写(非文件型配置)时仅告警跳过。
|
|
15
|
+
|
|
16
|
+
## 配置项
|
|
17
|
+
|
|
18
|
+
本插件自身无需配置。
|
|
19
|
+
|
|
20
|
+
## 用法
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
bun add @koishi-ce/plugin-config
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```yaml
|
|
27
|
+
plugins:
|
|
28
|
+
console: {}
|
|
29
|
+
config: {}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## CE 相对上游的调整
|
|
33
|
+
|
|
34
|
+
- 工作区包收集额外遍历 loader 配置树,把「相对路径键」(`./plugins/...`)引用的 workspace 源码包也纳入插件列表——Bun 不会把未被依赖的 workspace 包链入 node_modules,不做这步它们会在配置页「消失」;
|
|
35
|
+
- 插件是否驻留内存的判定改用纯 fs 的 `isResidentInCache`,规避 Bun 解析快照缓存导致的安装瞬间 "failed to resolve" 假警。
|
|
36
|
+
|
|
37
|
+
## 许可证
|
|
38
|
+
|
|
39
|
+
[AGPL-3.0](https://github.com/Koishi-CE/koishi/blob/main/LICENSES/AGPL-3.0.txt)。本包是上游 koishijs/webui 的社区再分发,版权归 Shigma 及 Koishijs 贡献者(上游)与 Koishi-CE 贡献者,见 [NOTICE](https://github.com/Koishi-CE/koishi/blob/main/NOTICE)。
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## English
|
|
44
|
+
|
|
45
|
+
The plugin configuration manager for the console, ported from `plugins/config` of the upstream [koishijs/webui](https://github.com/koishijs/webui). It streams the full koishi.yml / koishi.json config tree to the browser and lets you view, edit, enable, disable, add and remove plugin and bot configurations on the web — every change is written back through the loader. Requires [`@koishi-ce/plugin-console`](https://github.com/Koishi-CE/koishi/tree/main/plugins/webui/console).
|
|
46
|
+
|
|
47
|
+
## Features and pages
|
|
48
|
+
|
|
49
|
+
- **Plugin config page** (`/plugins/:name*`, authority 4) — lists all local and workspace plugin packages with runtime state (schema / usage / inject / fork) and config editing, including an "app global settings" entry.
|
|
50
|
+
- **Config tree context menu** — disable / enable, save / reload, rename, remove, clone, manage multiple forks of a plugin, add plugins and groups.
|
|
51
|
+
- **Service data** — `packages`, `services` (service name to provider mapping) and `config` (the whole config stream), all requiring authority 4.
|
|
52
|
+
- **Browser-side API** — other console plugins may use the `configWriter` service (ensure / remove / get).
|
|
53
|
+
|
|
54
|
+
Skips with a warning when the config source is not writable.
|
|
55
|
+
|
|
56
|
+
## Configuration
|
|
57
|
+
|
|
58
|
+
None.
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
bun add @koishi-ce/plugin-config
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```yaml
|
|
67
|
+
plugins:
|
|
68
|
+
console: {}
|
|
69
|
+
config: {}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## CE adjustments
|
|
73
|
+
|
|
74
|
+
- Workspace package collection additionally walks the loader config tree so plugins referenced by relative-path keys (`./plugins/...`) appear in the list — Bun does not link undepended workspace packages into node_modules, and without this step they would vanish from the page.
|
|
75
|
+
- In-memory residency checks use the pure-fs `isResidentInCache`, avoiding the transient "failed to resolve" false alarm caused by Bun's resolution snapshot cache.
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
[AGPL-3.0](https://github.com/Koishi-CE/koishi/blob/main/LICENSES/AGPL-3.0.txt). Community redistribution of upstream koishijs/webui; copyright Shigma and Koishijs contributors (upstream) and Koishi-CE contributors — see [NOTICE](https://github.com/Koishi-CE/koishi/blob/main/NOTICE).
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{Schema as e,ScopeStatus as t,Service as n,clone as r,icons as i,message as a,router as o,send as s,store as c,useContext as l,useI18nText as u,useMenu as d}from"@koishi-ce/client";import{Fragment as f,computed as p,createBlock as m,createCommentVNode as h,createElementBlock as g,createElementVNode as _,createTextVNode as v,createVNode as y,defineComponent as b,h as x,inject as S,nextTick as C,normalizeClass as w,onActivated as T,openBlock as E,provide as D,ref as O,renderList as k,renderSlot as A,resolveComponent as j,toDisplayString as M,unref as N,watch as P,withCtx as F,withKeys as I,withModifiers as L}from"vue";import{useRoute as R,useRouter as z}from"vue-router";var B=O(),V=O(),H=[`@koishi-ce/plugin-console`,`@koishi-ce/plugin-config`,`@koishi-ce/plugin-server`];function U(e){if(e.name&&H.includes(q(e.name)??``))return!0;if(e.children)return e.children.some(U)}function W(e){function t(e,t){r.has(e)||e!==`console`&&(n.using[e]={required:t})}let n={impl:[],using:{},peer:{}},r=new Set,i=c.packages,a=i?.[e];if(!i||!a)return n;for(let e in a.package.peerDependencies??{}){if(!e.includes(`@koishi-ce/plugin-`)&&!e.includes(`@koishijs/plugin-`)&&!e.includes(`koishi-plugin-`)||H.includes(e))continue;let t=!a.package.peerDependenciesMeta?.[e]?.optional,o=!!i[e]?.runtime?.id;n.peer[e]={required:t,active:o};for(let t of i[e]?.manifest?.service.implements??[])r.add(t)}for(let e of a.manifest.service.implements)e!==`adapter`&&n.impl.push(e);for(let e of a.runtime?.required??[])t(e,!0);for(let e of a.runtime?.optional??[])t(e,!1);return a.runtime?.id&&!a.runtime?.forkable&&(n.warning=!0),a.runtime?.schema||(n.warning=!0),n}var G=p(()=>Object.fromEntries(Object.keys(c.packages??{}).filter(e=>e).map(e=>[e,W(e)]))),K=O();function q(e){if(!e)return e;if(e.startsWith(`./`))return Object.values(c.packages??{}).find(t=>t.paths?.includes(e))?.package?.name;if(e.includes(`/`)){let[t,n]=e.split(`/`);return[`${t}/koishi-plugin-${n}`].find(e=>e in(c.packages||{}))}return[`@koishi-ce/plugin-${e}`,`@koishijs/plugin-${e}`,`koishi-plugin-${e}`].find(e=>e in(c.packages||{}))}var J=p(()=>{if(K.value)return q(K.value.name)}),Y=p(()=>{let e=G.value[J.value??``];if(e){if(e.warning&&K.value?.disabled)return`warning`;for(let t in e.using)if(t in(c.services||{})){if(e.impl.includes(t))return`warning`}else if(e.using[t]?.required)return`warning`}});function ee(e,t){let n=[];if(!t)return n;for(let r in t){if(r.startsWith(`$`))continue;let i=t[r],a={config:i,parent:e};r.startsWith(`~`)&&(a.disabled=!0,r=r.slice(1)),a.name=r.split(`:`,1)[0]??``,a.id=r,a.path=r.slice(a.name.length+1);let o=i?.$label;o!==void 0&&(a.label=o),r.startsWith(`group:`)&&(a.children=ee(a,i)),n.push(a)}return n}var X=p(()=>{let e={name:``,id:``,path:``,label:`全局设置`,config:c.config,children:[]},t=[e],n=[],r={},i={"":e};for(let n of ee(e,c.config?.plugins))t.push(n),a(n);function a(e){!e.config?.$collapsed&&e.children&&n.push(e.path),(r[e.name]||=[]).push(e.path),i[e.path]=e,e.children?.forEach(a)}return{data:t,forks:r,paths:i,expanded:n}});function Z(e){switch(c.packages?.[q(e.name)??``]?.runtime?.forks?.[e.path]?.status){case t.PENDING:return`pending`;case t.LOADING:return`loading`;case t.ACTIVE:return`active`;case t.FAILED:return`failed`;case t.DISPOSED:return`disposed`;default:return`disabled`}}async function Q(e){let t=e.parent?.path??``;s(`manager/remove`,t,e.id),await o.replace(`/plugins/${t}`)}var te=[`id`],ne={class:`text-left`},re={class:`path`},ie={class:`text-right`},ae={class:`actions`},oe=[`onClick`],se=[`onClick`],ce={class:`left`},le={class:`right`},ue=b({__name:`forks`,setup(e){let t=p(()=>B.value?.replace(/(koishi-|^@koishijs\/)plugin-/,``)),n=p(()=>c.packages?.[B.value]);function r(e){return`${e.label?`${e.label} `:``}[${e.path}]`}function i(e){let t=[r(e)];for(;e.parent;)e=e.parent,t.unshift(r(e));return t.shift(),t.join(` > `)}async function a(e){let n=t.value;e||(e=Math.random().toString(36).slice(2,8),s(`manager/unload`,``,`${n}:${e}`,{})),await o.push(`/plugins/${e}`),B.value=null}return(e,r)=>{let o=j(`k-icon`),s=j(`el-button`),c=j(`el-dialog`);return E(),m(c,{"model-value":!!N(B),"onUpdate:modelValue":r[1]||=e=>B.value=null,class:`dialog-config-fork`,"destroy-on-close":``},{header:F(({titleId:e,titleClass:t})=>[_(`span`,{id:e,class:w(t)},M(N(B)+(n.value?.workspace?` (工作区)`:``)),11,te)]),footer:F(()=>[_(`div`,ce,[N(X).forks[t.value]?.length?(E(),g(f,{key:0},[v(` 此插件目前存在 `+M(N(X).forks[t.value]?.length)+` 份配置。 `,1)],64)):(E(),g(f,{key:1},[v(` 此插件尚未被配置。 `)],64))]),_(`div`,le,[y(s,{onClick:r[0]||=L(e=>a(),[`stop`])},{default:F(()=>[...r[2]||=[v(`添加新配置`,-1)]]),_:1})])]),default:F(()=>[_(`table`,null,[(E(!0),g(f,null,k(N(X).forks[t.value],e=>(E(),g(`tr`,{key:e},[_(`td`,ne,[_(`span`,{class:w([`status-light`,N(Z)(N(X).paths[e])])},null,2),_(`span`,re,M(i(N(X).paths[e])),1)]),_(`td`,ie,[_(`span`,ae,[_(`span`,{class:`action`,onClick:L(t=>a(e),[`stop`])},[y(o,{name:`arrow-right`})],8,oe),_(`span`,{class:`action`,onClick:L(t=>N(Q)(N(X).paths[e]),[`stop`])},[y(o,{name:`delete`})],8,se)])])]))),128))])]),_:1},8,[`model-value`])}}}),de=b({__name:`global`,props:{current:{},modelValue:{}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=p({get:()=>n.modelValue,set:e=>r(`update:modelValue`,e)});return(t,n)=>{let r=j(`k-form`);return E(),m(r,{schema:N(c).packages[``].runtime.schema,initial:e.current.config,modelValue:i.value,"onUpdate:modelValue":n[0]||=e=>i.value=e},null,8,[`schema`,`initial`,`modelValue`])}}}),fe={class:`modifier`},pe=b({__name:`modifier`,props:{modelValue:{}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=p({get:()=>n.modelValue?.$filter,set:e=>r(`update:modelValue`,{...n.modelValue,$filter:e})});return(e,t)=>{let n=j(`k-filter`);return E(),g(`div`,fe,[t[1]||=_(`h2`,{class:`k-schema-header`},`过滤器设置`,-1),y(n,{modelValue:i.value,"onUpdate:modelValue":t[0]||=e=>i.value=e},null,8,[`modelValue`])])}}}),me=b({__name:`group`,props:{current:{},modelValue:{}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=p({get:()=>n.modelValue,set:e=>r(`update:modelValue`,e)});return(e,t)=>(E(),m(pe,{modelValue:i.value,"onUpdate:modelValue":t[0]||=e=>i.value=e},null,8,[`modelValue`]))}}),$=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},he=$(me,[[`__scopeId`,`data-v-826f5ec2`]]),ge=b({__name:`plugin`,props:{current:{},modelValue:{}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=l(),a=p({get:()=>n.modelValue,set:e=>r(`update:modelValue`,e)}),o=p(()=>G.value[J.value]),u=p(()=>c.packages[J.value]),d=p(()=>u.value.workspace?`请检查插件源代码。`:`请联系插件作者并反馈此问题。`);return P(u,e=>{!e||e.runtime||s(`config/request-runtime`,e.name)},{immediate:!0}),D(`plugin:name`,J),D(`plugin:env`,o),D(`manager.settings.local`,u),D(`manager.settings.config`,a),D(`manager.settings.current`,p(()=>n.current)),(t,n)=>{let r=j(`k-comment`),s=j(`k-slot`),l=j(`k-slot-item`),p=j(`k-activity-link`),b=j(`k-markdown`),x=j(`k-form`);return N(J)?(E(),g(f,{key:0},[u.value.runtime?u.value.runtime.failed?(E(),m(r,{key:1,type:`danger`},{default:F(()=>[_(`p`,null,`插件加载失败,这可能是插件本身的问题所致。`+M(d.value),1)]),_:1})):(E(),m(s,{key:2,name:`plugin-details`},{default:F(()=>[h(` 依赖信息:peer 插件依赖与注入服务的加载状态提示 `),y(l,{order:800},{default:F(()=>[y(s,{name:`plugin-dependency`,single:``},{default:F(()=>[(E(!0),g(f,null,k(o.value.peer,({required:e,active:t},n)=>(E(),m(r,{key:n,type:t?`success`:e?`warning`:`primary`},{default:F(()=>[_(`p`,null,M(e?`必需`:`可选`)+`依赖:`+M(n)+` (`+M(t?`已加载`:`未加载`)+`) `,1)]),_:2},1032,[`type`]))),128)),(E(!0),g(f,null,k(o.value.using,({required:e},t)=>(E(),m(r,{key:t,type:t in N(c).services?`success`:e?`warning`:`primary`},{default:F(()=>[_(`p`,null,M(e?`必需`:`可选`)+`服务:`+M(t)+` (`+M(t in N(c).services?`已加载`:`未加载`)+`) `,1)]),_:2},1032,[`type`]))),128))]),_:1})]),_:1}),h(` 实现的服务:本插件将提供哪些服务 `),y(l,{order:600},{default:F(()=>[(E(!0),g(f,null,k(o.value.impl,t=>(E(),g(f,{key:t},[t in N(c).services&&e.current.disabled?(E(),m(r,{key:0,type:`warning`},{default:F(()=>[_(`p`,null,`此插件将会提供 `+M(t)+` 服务,但此服务已被其他插件实现。`,1)]),_:2},1024)):(E(),m(r,{key:1,type:e.current.disabled?`primary`:`success`},{default:F(()=>[_(`p`,null,`此插件`+M(e.current.disabled?`启用后将会提供`:`提供了`)+` `+M(t)+` 服务。`,1)]),_:2},1032,[`type`]))],64))),128))]),_:1}),h(` 可重用性:不可重用插件的重复启用警告与多份配置提示 `),y(l,{order:400},{default:F(()=>[u.value.runtime.id&&!u.value.runtime.forkable&&e.current.disabled?(E(),m(r,{key:0,type:`warning`},{default:F(()=>[...n[4]||=[_(`p`,null,`此插件已在运行且不可重用,启用可能会导致非预期的问题。`,-1)]]),_:1})):h(`v-if`,!0),N(X).forks[e.current.name]?.length>1?(E(),m(r,{key:1,type:`primary`},{default:F(()=>[_(`p`,null,[n[5]||=v(`此插件存在多份配置,`,-1),_(`span`,{class:`k-link`,onClick:n[0]||=L(e=>B.value=N(J),[`stop`])},`点击前往管理`),n[6]||=v(`。`,-1)])]),_:1})):h(`v-if`,!0)]),_:1}),h(` 提供的页面:本插件注册的控制台活动页 `),y(l,{order:300},{default:F(()=>[(E(!0),g(f,null,k(N(i).$router.pages,(t,i)=>(E(),g(f,{key:i},[t.ctx.extension?.paths.includes(e.current.path)&&!t.disabled()?(E(),m(r,{key:0,type:`success`},{default:F(()=>[_(`p`,null,[n[7]||=_(`span`,null,`此插件提供了页面:`,-1),y(p,{id:t.id},null,8,[`id`])])]),_:2},1024)):h(`v-if`,!0)],64))),128))]),_:1}),h(` 用法说明:插件自带的 Markdown 文档 `),u.value.runtime?.usage?(E(),m(l,{key:0,order:-200},{default:F(()=>[y(b,{unsafe:``,class:`usage`,source:u.value.runtime?.usage},null,8,[`source`])]),_:1})):h(`v-if`,!0),h(` 过滤器设置:编辑 $filter 上下文过滤条件 `),y(l,{order:-600},{default:F(()=>[u.value.runtime.filter===!1?h(`v-if`,!0):(E(),m(pe,{key:0,modelValue:a.value,"onUpdate:modelValue":n[1]||=e=>a.value=e},null,8,[`modelValue`]))]),_:1}),h(` 配置表单:按 schema 生成的设置项 `),y(l,{order:-1e3},{default:F(()=>[u.value.runtime.schema?(E(),m(x,{key:1,schema:u.value.runtime.schema,initial:e.current.config,modelValue:a.value,"onUpdate:modelValue":n[2]||=e=>a.value=e},{hint:F(()=>[v(M(d.value),1)]),_:1},8,[`schema`,`initial`,`modelValue`])):(E(),m(r,{key:0,type:`warning`},{default:F(()=>[_(`p`,null,`此插件未声明配置项,这可能并非预期行为。`+M(d.value),1)]),_:1}))]),_:1})]),_:1})):(E(),m(r,{key:0},{default:F(()=>[...n[3]||=[_(`p`,null,`正在加载插件配置……`,-1)]]),_:1}))],64)):(E(),m(s,{key:1,name:`plugin-missing`,single:``},{default:F(()=>[y(r,{type:`danger`},{default:F(()=>[...n[8]||=[_(`p`,null,`此插件尚未安装。`,-1)]]),_:1})]),_:1}))}}}),_e={class:`search`},ve=[`title`],ye={class:`right`},be=b({__name:`tree`,props:{modelValue:{}},emits:[`update:modelValue`],setup(e,{expose:t,emit:n}){let r=e,i=R(),a=d(`config.tree`),o=n,c=O(null),l=O(null),u=O(``);function f(e,t){return t.name.toLowerCase().includes(u.value.toLowerCase())}let p=O(!0);async function v(){await C();let e=c.value?.$el,t=e?.querySelector(`.el-tree-node.is-active`);!t||!t.offsetTop&&i.path.slice(9)||c.value.setScrollTop(t.offsetTop-(e.offsetHeight-t.offsetHeight)/2)}t({activate:v}),T(async()=>{v(),p.value=!1});function b(e){!e||p.value||v()}function x(e){return e.data.name===`group`?`分组:${e.label||e.data.path}`:e.label||e.data.name||`待添加`}function S(e){return e.data.path!==``}function D(e,t,n){return n===`inner`?t.data.id.startsWith(`group:`):t.data.path!==``||n===`next`}function k(e,t,n,r){o(`update:modelValue`,e.path),window.dispatchEvent(new MouseEvent(r.type,r))}function A(e,t,n){s(`manager/meta`,e.path,{$collapsed:null})}function I(e,t,n){s(`manager/meta`,e.path,{$collapsed:!0})}function L(e,t,n,r){let i=n===`inner`?t:t.parent,a=i.childNodes.findIndex(t=>t.data.path===e.data.path);i.data.path||--a,s(`manager/teleport`,e.data.parent?.path??``,e.data.id,i.data.path,a)}function z(e){let t=[];return e.children&&t.push(`is-group`),!e.children&&!q(e.name)&&t.push(`is-disabled`),e.path===r.modelValue&&t.push(`is-active`),t.join(` `)}return P(u,e=>{l.value.filter(e)}),(e,t)=>{let n=j(`k-icon`),r=j(`el-input`),i=j(`el-tree`),o=j(`el-scrollbar`);return E(),m(o,{class:`plugin-tree`,ref_key:`root`,ref:c},{default:F(()=>[_(`div`,_e,[y(r,{modelValue:u.value,"onUpdate:modelValue":t[0]||=e=>u.value=e},{suffix:F(()=>[y(n,{name:`search`})]),_:1},8,[`modelValue`])]),y(i,{ref_key:`tree`,ref:l,"node-key":`path`,data:N(X).data,draggable:!0,"auto-expand-parent":!1,"default-expanded-keys":N(X).expanded,"expand-on-click-node":!1,"filter-node-method":f,props:{class:z},"allow-drag":S,"allow-drop":D,onNodeClick:k,onNodeContextmenu:N(a),onNodeDrop:L,onNodeExpand:A,onNodeCollapse:I},{default:F(({node:e})=>[_(`div`,{class:`item`,ref:b},[_(`div`,{class:`label`,title:x(e)},M(x(e)),9,ve),_(`div`,ye,[N(q)(e.data.name)?(E(),g(`span`,{key:0,class:w([`status-light`,N(Z)(e.data)])},null,2)):h(`v-if`,!0)])],512)]),_:1},8,[`data`,`default-expanded-keys`,`props`,`onNodeContextmenu`])]),_:1},512)}}}),xe=b({__name:`index`,setup(t){let n=R(),i=z(),o=p({get(){let e=n.path.slice(9);return e in X.value.paths?e:``},set(e){e in X.value.paths||(e=``),i.replace(`/plugins/${e}`)}}),u=O(),d=O(``),_=O(),b=O();async function x(){await C(),_.value?.focus()}let S=O(),w=O(!1),T=O(),D=O(!1),k=O(null);P(S,e=>{e&&(w.value=!0)}),P(T,e=>{e&&(D.value=!0)}),P(()=>X.value.paths[o.value],e=>{K.value=e,u.value=r(e.config)},{immediate:!0});let A=l();A.define(`config.tree`,K),A.action(`config.tree.add-plugin`,{hidden:({config:e})=>e.tree.path&&!e.tree.children,action:({config:e})=>V.value=e.tree}),A.action(`config.tree.add-group`,{hidden:({config:e})=>e.tree.path&&!e.tree.children,action:({config:e})=>{k.value=e.tree.path}});function H(e){let t=Math.random().toString(36).slice(2,8);s(`manager/reload`,k.value,`group:${t}`,{$label:e}),i.replace(`/plugins/${t}`),k.value=null}A.action(`config.tree.clone`,{hidden:({config:e})=>!e.tree.path||!!e.tree.children,action:async({config:e})=>{let t=(e.tree.parent.path?e.tree.parent.children:X.value.data.slice(1)).findIndex(t=>t.path===e.tree.path),n=Math.random().toString(36).slice(2,8);s(`manager/unload`,e.tree.parent?.path??``,`${e.tree.name}:${n}`,e.tree.config,t+1),i.replace(`/plugins/${n}`)}}),A.action(`config.tree.manage`,{hidden:({config:e})=>!e.tree.path||!!e.tree.children,action:async({config:e})=>{B.value=e.tree.name}}),A.action(`config.tree.rename`,{disabled:({config:e})=>!e.tree.path,action:({config:e})=>{d.value=e.tree.label||(e.tree.name===`group`?e.tree.path:e.tree.name),T.value=e.tree}}),A.action(`config.tree.remove`,{disabled:({config:e})=>!e.tree.path||U(e.tree),action:({config:e})=>S.value=e.tree});function W(t){let n=c.packages[q(t)]?.runtime.schema;if(!n)return!0;try{return new e(n)(u.value),!0}catch{return a.error(`当前配置项不满足约束,请检查配置!`),!1}}A.action(`config.tree.save`,{shortcut:`ctrl+s`,disabled:e=>!e?.config?.tree||![`config`].includes(i.currentRoute.value?.meta?.activity.id),action:async({config:{tree:e}})=>{let{disabled:t,path:n}=e;if(!(!t&&!W(e.name))){if(!n)return s(`manager/app-reload`,u.value);try{await G(e,t?`unload`:`reload`),a.success(t?`配置已保存。`:`配置已重载。`)}catch{a.error(`操作失败,请检查日志!`)}}}}),A.action(`config.tree.toggle`,{disabled:({config:e})=>!e.tree.path||U(e.tree),action:async({config:{tree:e}})=>{let{disabled:t,name:n}=e;if(!(t&&!W(e.name)))try{await G(e,t?`reload`:`unload`),a.success((n===`group`?`分组`:`插件`)+(t?`已启用。`:`已停用。`))}catch{a.error(`操作失败,请检查日志!`)}}});async function G(e,t){return await s(`manager/${t}`,e.parent?.path??``,e.id,u.value)}function J(e,t){D.value=!1,e.label=t,s(`manager/meta`,e.path,{$label:t||null})}return(e,t)=>{let n=j(`k-content`),r=j(`el-button`),i=j(`el-dialog`),a=j(`el-input`),s=j(`k-layout`);return E(),m(s,{menu:`config.tree`,"menu-data":N(K)},{header:F(()=>[h(` 根节点:全局设置 `),N(K).path?N(K).children?(E(),g(f,{key:1},[h(` 分组节点 `),v(` 分组:`+M(N(K).label||N(K).id),1)],64)):(E(),g(f,{key:2},[h(` 普通插件节点 `),v(M(N(K).label||N(K).name)+` [`+M(N(K).path)+`] `,1)],64)):(E(),g(f,{key:0},[v(`全局设置`)],64))]),left:F(()=>[y(be,{ref_key:`tree`,ref:b,modelValue:o.value,"onUpdate:modelValue":t[0]||=e=>o.value=e},null,8,[`modelValue`])]),default:F(()=>[(E(),m(n,{class:`plugin-view`,key:o.value},{default:F(()=>[N(K).path?N(K).children?(E(),m(he,{key:1,modelValue:u.value,"onUpdate:modelValue":t[2]||=e=>u.value=e,current:N(K)},null,8,[`modelValue`,`current`])):(E(),m(ge,{key:2,current:N(K),modelValue:u.value,"onUpdate:modelValue":t[3]||=e=>u.value=e},null,8,[`current`,`modelValue`])):(E(),m(de,{key:0,current:N(K),modelValue:u.value,"onUpdate:modelValue":t[1]||=e=>u.value=e},null,8,[`current`,`modelValue`]))]),_:1})),y(i,{modelValue:w.value,"onUpdate:modelValue":t[6]||=e=>w.value=e,title:`确认移除`,"destroy-on-close":``,onClosed:t[7]||=e=>S.value=null},{footer:F(()=>[y(r,{onClick:t[4]||=e=>w.value=!1},{default:F(()=>[...t[19]||=[v(`取消`,-1)]]),_:1}),y(r,{type:`danger`,onClick:t[5]||=e=>(w.value=!1,N(Q)(S.value),b.value?.activate())},{default:F(()=>[...t[20]||=[v(`确定`,-1)]]),_:1})]),default:F(()=>[S.value?(E(),g(f,{key:0},[v(` 确定要移除`+M(S.value.children?`分组 ${S.value.label||S.value.path}`:`插件 ${S.value.label||S.value.name}`)+` 吗?此操作不可撤销! `,1)],64)):h(`v-if`,!0)]),_:1},8,[`modelValue`]),y(i,{modelValue:D.value,"onUpdate:modelValue":t[12]||=e=>D.value=e,title:`重命名`,"destroy-on-close":``,onOpen:x,onClosed:t[13]||=e=>T.value=null},{footer:F(()=>[y(r,{onClick:t[10]||=e=>D.value=!1},{default:F(()=>[...t[21]||=[v(`取消`,-1)]]),_:1}),y(r,{type:`primary`,onClick:t[11]||=e=>J(T.value,d.value)},{default:F(()=>[...t[22]||=[v(`确定`,-1)]]),_:1})]),default:F(()=>[T.value?(E(),m(a,{key:0,ref_key:`inputEl`,ref:_,modelValue:d.value,"onUpdate:modelValue":t[8]||=e=>d.value=e,onKeydown:t[9]||=I(L(e=>J(T.value,d.value),[`stop`,`prevent`]),[`enter`])},null,8,[`modelValue`])):h(`v-if`,!0)]),_:1},8,[`modelValue`]),y(i,{"model-value":k.value!==null,"onUpdate:modelValue":t[18]||=e=>k.value=null,title:`创建分组`,"destroy-on-close":``,onOpen:x},{footer:F(()=>[y(r,{onClick:t[16]||=e=>k.value=null},{default:F(()=>[...t[23]||=[v(`取消`,-1)]]),_:1}),y(r,{type:`primary`,onClick:t[17]||=e=>H(d.value)},{default:F(()=>[...t[24]||=[v(`确定`,-1)]]),_:1})]),default:F(()=>[y(a,{ref_key:`inputEl`,ref:_,modelValue:d.value,"onUpdate:modelValue":t[14]||=e=>d.value=e,onKeydown:t[15]||=I(L(e=>H(d.value),[`stop`,`prevent`]),[`enter`])},null,8,[`modelValue`])]),_:1},8,[`model-value`])]),_:1},8,[`menu-data`])}}}),Se={class:`content`},Ce=[`onClick`],we=b({__name:`select`,setup(e){let t=u(),n=O(``),r=O(),i=S(`plugin-select-filter`,e=>!0),a=p(()=>Object.values(c.packages).filter(({name:e,shortname:t})=>e&&t.includes(n.value.toLowerCase())&&i(c.packages[e])));function l(e){let t=V.value.path,r=Math.random().toString(36).slice(2,8);V.value=null,n.value=``,s(`manager/unload`,t,`${e}:${r}`,{}),o.push(`/plugins/${r}`)}return P(V,async e=>{e&&(await C(),await r.value.focus())},{flush:`post`}),(e,i)=>{let o=j(`k-icon`),s=j(`el-input`),u=j(`k-markdown`),d=j(`el-scrollbar`),p=j(`el-dialog`);return N(c).packages?(E(),m(p,{key:0,modelValue:!!N(V),"onUpdate:modelValue":i[1]||=e=>V.value=null,class:`plugin-select`},{header:F(()=>[A(e.$slots,`title`,{packages:a.value},()=>[i[2]||=_(`span`,{class:`title`},`选择插件`,-1)]),y(s,{ref_key:`input`,ref:r,modelValue:n.value,"onUpdate:modelValue":i[0]||=e=>n.value=e},{suffix:F(()=>[y(o,{name:`search`})]),_:1},8,[`modelValue`])]),default:F(()=>[A(e.$slots,`tabs`,{packages:a.value}),_(`div`,Se,[y(d,null,{default:F(()=>[(E(!0),g(f,null,k(a.value,({name:e,shortname:n,manifest:r})=>(E(),g(`div`,{class:`package`,key:e,onClick:L(e=>l(n),[`stop`])},[_(`h3`,null,M(n),1),y(u,{inline:``,class:`desc`,source:N(t)(r.description)},null,8,[`source`])],8,Ce))),128))]),_:1})])]),_:3},8,[`modelValue`])):h(`v-if`,!0)}}}),Te={},Ee={class:`k-icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`};function De(e,t){return E(),g(`svg`,Ee,[...t[0]||=[_(`path`,{fill:`currentColor`,d:`M452 60H488C499 60 508 68.95 508 80C508 91.05 499 100 488 100H452V136C452 147 443 156 432 156C420.1 156 412 147 412 136V100H376C364.1 100 356 91.05 356 80C356 68.95 364.1 60 376 60H412V24C412 12.95 420.1 4 432 4C443 4 452 12.95 452 24V60zM280.8 133.1L490.1 222.8C503.4 228.5 512 241.5 512 256C512 270.5 503.4 283.5 490.1 289.2L280.8 378.9C272.1 382.3 264.5 384 256 384C247.5 384 239 382.3 231.2 378.9L21.9 289.2C8.614 283.5 0 270.5 0 256C0 241.5 8.614 228.5 21.9 222.8L231.2 133.1C239 129.7 247.5 128 256 128C264.5 128 272.1 129.7 280.8 133.1V133.1zM66.26 256L250.1 334.8C251.1 335.6 253.1 336 256 336C258 336 260 335.6 261.9 334.8L445.7 256L261.9 177.2C260 176.4 258 176 256 176C253.1 176 251.1 176.4 250.1 177.2L66.26 256zM59.53 350.6C66.15 359.9 65.24 372.3 57.1 380.5L250.1 462.8C251.1 463.6 253.1 464 256 464C258 464 260 463.6 261.9 462.8L452 381.3C447.4 374.4 446.5 365.2 450.5 357.3C456.5 345.4 470.9 340.6 482.7 346.5L491.8 351.1C504.2 357.3 512 369.9 512 383.7C512 398.4 503.3 411.6 489.9 417.3L280.8 506.9C272.1 510.3 264.5 512 256 512C247.5 512 239 510.3 231.2 506.9L22.81 417.6C8.971 411.7 .001 398.1 .001 383C.001 370.9 5.87 359.5 15.76 352.4L26.05 345C36.84 337.3 51.83 339.8 59.53 350.6L59.53 350.6z`},null,-1)]])}var Oe=$(Te,[[`render`,De]]),ke={},Ae={class:`k-icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`};function je(e,t){return E(),g(`svg`,Ae,[...t[0]||=[_(`path`,{fill:`currentColor`,d:`M144,0c13.3,0,24,10.8,24,24v88h-48V24C120,10.8,130.8,0,144,0z M336,0c13.3,0,24,10.8,24,24v88h-48V24
|
|
1
|
+
import{Schema as e,ScopeStatus as t,Service as n,clone as r,icons as i,message as a,router as o,send as s,store as c,useContext as l,useI18nText as u,useMenu as d}from"@koishi-ce/client";import{Fragment as f,computed as p,createBlock as m,createCommentVNode as h,createElementBlock as g,createElementVNode as _,createTextVNode as v,createVNode as y,defineComponent as b,h as x,inject as S,nextTick as C,normalizeClass as w,onActivated as T,openBlock as E,provide as D,ref as O,renderList as k,renderSlot as A,resolveComponent as j,toDisplayString as M,unref as N,watch as P,withCtx as F,withKeys as I,withModifiers as L}from"vue";import{useRoute as R,useRouter as z}from"vue-router";var B=O(),V=O(),H=[`@koishi-ce/plugin-console`,`@koishi-ce/plugin-config`,`@koishi-ce/plugin-server`];function U(e){if(e.name&&H.includes(J(e.name)??``))return!0;if(e.children)return e.children.some(U)}function W(e,t){let n=e?.[t];if(n)return n;if(t.startsWith(`@koishijs/plugin-`))return e?.[`@koishi-ce/plugin-${t.slice(17)}`]}function G(e){function t(e,t){r.has(e)||e!==`console`&&(n.using[e]={required:t})}let n={impl:[],using:{},peer:{}},r=new Set,i=c.packages,a=i?.[e];if(!i||!a)return n;for(let e in a.package.peerDependencies??{}){if(!e.includes(`@koishi-ce/plugin-`)&&!e.includes(`@koishijs/plugin-`)&&!e.includes(`koishi-plugin-`))continue;let t=W(i,e);if(H.includes(t?.name??e))continue;let o=!a.package.peerDependenciesMeta?.[e]?.optional,s=!!t?.runtime?.id;n.peer[e]={required:o,active:s};for(let e of t?.manifest?.service.implements??[])r.add(e)}for(let e of a.manifest.service.implements)e!==`adapter`&&n.impl.push(e);for(let e of a.runtime?.required??[])t(e,!0);for(let e of a.runtime?.optional??[])t(e,!1);return a.runtime?.id&&!a.runtime?.forkable&&(n.warning=!0),a.runtime?.schema||(n.warning=!0),n}var K=p(()=>Object.fromEntries(Object.keys(c.packages??{}).filter(e=>e).map(e=>[e,G(e)]))),q=O();function J(e){if(!e)return e;if(e.startsWith(`./`))return Object.values(c.packages??{}).find(t=>t.paths?.includes(e))?.package?.name;if(e.includes(`/`)){let[t,n]=e.split(`/`);return[`${t}/koishi-plugin-${n}`].find(e=>e in(c.packages||{}))}return[`@koishi-ce/plugin-${e}`,`@koishijs/plugin-${e}`,`koishi-plugin-${e}`].find(e=>e in(c.packages||{}))}var Y=p(()=>{if(q.value)return J(q.value.name)}),ee=p(()=>{let e=K.value[Y.value??``];if(e){if(e.warning&&q.value?.disabled)return`warning`;for(let t in e.using)if(t in(c.services||{})){if(e.impl.includes(t))return`warning`}else if(e.using[t]?.required)return`warning`}});function te(e,t){let n=[];if(!t)return n;for(let r in t){if(r.startsWith(`$`))continue;let i=t[r],a={config:i,parent:e};r.startsWith(`~`)&&(a.disabled=!0,r=r.slice(1)),a.name=r.split(`:`,1)[0]??``,a.id=r,a.path=r.slice(a.name.length+1);let o=i?.$label;o!==void 0&&(a.label=o),r.startsWith(`group:`)&&(a.children=te(a,i)),n.push(a)}return n}var X=p(()=>{let e={name:``,id:``,path:``,label:`全局设置`,config:c.config,children:[]},t=[e],n=[],r={},i={"":e};for(let n of te(e,c.config?.plugins))t.push(n),a(n);function a(e){!e.config?.$collapsed&&e.children&&n.push(e.path),(r[e.name]||=[]).push(e.path),i[e.path]=e,e.children?.forEach(a)}return{data:t,forks:r,paths:i,expanded:n}});function Z(e){switch(c.packages?.[J(e.name)??``]?.runtime?.forks?.[e.path]?.status){case t.PENDING:return`pending`;case t.LOADING:return`loading`;case t.ACTIVE:return`active`;case t.FAILED:return`failed`;case t.DISPOSED:return`disposed`;default:return`disabled`}}async function Q(e){let t=e.parent?.path??``;s(`manager/remove`,t,e.id),await o.replace(`/plugins/${t}`)}var ne=[`id`],re={class:`text-left`},ie={class:`path`},ae={class:`text-right`},oe={class:`actions`},se=[`onClick`],ce=[`onClick`],le={class:`left`},ue={class:`right`},de=b({__name:`forks`,setup(e){let t=p(()=>B.value?.replace(/(koishi-|^@koishijs\/)plugin-/,``)),n=p(()=>c.packages?.[B.value]);function r(e){return`${e.label?`${e.label} `:``}[${e.path}]`}function i(e){let t=[r(e)];for(;e.parent;)e=e.parent,t.unshift(r(e));return t.shift(),t.join(` > `)}async function a(e){let n=t.value;e||(e=Math.random().toString(36).slice(2,8),s(`manager/unload`,``,`${n}:${e}`,{})),await o.push(`/plugins/${e}`),B.value=null}return(e,r)=>{let o=j(`k-icon`),s=j(`el-button`),c=j(`el-dialog`);return E(),m(c,{"model-value":!!N(B),"onUpdate:modelValue":r[1]||=e=>B.value=null,class:`dialog-config-fork`,"destroy-on-close":``},{header:F(({titleId:e,titleClass:t})=>[_(`span`,{id:e,class:w(t)},M(N(B)+(n.value?.workspace?` (工作区)`:``)),11,ne)]),footer:F(()=>[_(`div`,le,[N(X).forks[t.value]?.length?(E(),g(f,{key:0},[v(` 此插件目前存在 `+M(N(X).forks[t.value]?.length)+` 份配置。 `,1)],64)):(E(),g(f,{key:1},[v(` 此插件尚未被配置。 `)],64))]),_(`div`,ue,[y(s,{onClick:r[0]||=L(e=>a(),[`stop`])},{default:F(()=>[...r[2]||=[v(`添加新配置`,-1)]]),_:1})])]),default:F(()=>[_(`table`,null,[(E(!0),g(f,null,k(N(X).forks[t.value],e=>(E(),g(`tr`,{key:e},[_(`td`,re,[_(`span`,{class:w([`status-light`,N(Z)(N(X).paths[e])])},null,2),_(`span`,ie,M(i(N(X).paths[e])),1)]),_(`td`,ae,[_(`span`,oe,[_(`span`,{class:`action`,onClick:L(t=>a(e),[`stop`])},[y(o,{name:`arrow-right`})],8,se),_(`span`,{class:`action`,onClick:L(t=>N(Q)(N(X).paths[e]),[`stop`])},[y(o,{name:`delete`})],8,ce)])])]))),128))])]),_:1},8,[`model-value`])}}}),fe=b({__name:`global`,props:{current:{},modelValue:{}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=p({get:()=>n.modelValue,set:e=>r(`update:modelValue`,e)});return(t,n)=>{let r=j(`k-form`);return E(),m(r,{schema:N(c).packages[``].runtime.schema,initial:e.current.config,modelValue:i.value,"onUpdate:modelValue":n[0]||=e=>i.value=e},null,8,[`schema`,`initial`,`modelValue`])}}}),pe={class:`modifier`},me=b({__name:`modifier`,props:{modelValue:{}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=p({get:()=>n.modelValue?.$filter,set:e=>r(`update:modelValue`,{...n.modelValue,$filter:e})});return(e,t)=>{let n=j(`k-filter`);return E(),g(`div`,pe,[t[1]||=_(`h2`,{class:`k-schema-header`},`过滤器设置`,-1),y(n,{modelValue:i.value,"onUpdate:modelValue":t[0]||=e=>i.value=e},null,8,[`modelValue`])])}}}),he=b({__name:`group`,props:{current:{},modelValue:{}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=p({get:()=>n.modelValue,set:e=>r(`update:modelValue`,e)});return(e,t)=>(E(),m(me,{modelValue:i.value,"onUpdate:modelValue":t[0]||=e=>i.value=e},null,8,[`modelValue`]))}}),$=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},ge=$(he,[[`__scopeId`,`data-v-21d6aea8`]]),_e=b({__name:`plugin`,props:{current:{},modelValue:{}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=l(),a=p({get:()=>n.modelValue,set:e=>r(`update:modelValue`,e)}),o=p(()=>K.value[Y.value]),u=p(()=>c.packages[Y.value]),d=p(()=>u.value.workspace?`请检查插件源代码。`:`请联系插件作者并反馈此问题。`);return P(u,e=>{!e||e.runtime||s(`config/request-runtime`,e.name)},{immediate:!0}),D(`plugin:name`,Y),D(`plugin:env`,o),D(`manager.settings.local`,u),D(`manager.settings.config`,a),D(`manager.settings.current`,p(()=>n.current)),(t,n)=>{let r=j(`k-comment`),s=j(`k-slot`),l=j(`k-slot-item`),p=j(`k-activity-link`),b=j(`k-markdown`),x=j(`k-form`);return N(Y)?(E(),g(f,{key:0},[u.value.runtime?u.value.runtime.failed?(E(),m(r,{key:1,type:`danger`},{default:F(()=>[_(`p`,null,`插件加载失败,这可能是插件本身的问题所致。`+M(d.value),1)]),_:1})):(E(),m(s,{key:2,name:`plugin-details`},{default:F(()=>[h(` 依赖信息:peer 插件依赖与注入服务的加载状态提示 `),y(l,{order:800},{default:F(()=>[y(s,{name:`plugin-dependency`,single:``},{default:F(()=>[(E(!0),g(f,null,k(o.value.peer,({required:e,active:t},n)=>(E(),m(r,{key:n,type:t?`success`:e?`warning`:`primary`},{default:F(()=>[_(`p`,null,M(e?`必需`:`可选`)+`依赖:`+M(n)+` (`+M(t?`已加载`:`未加载`)+`) `,1)]),_:2},1032,[`type`]))),128)),(E(!0),g(f,null,k(o.value.using,({required:e},t)=>(E(),m(r,{key:t,type:t in N(c).services?`success`:e?`warning`:`primary`},{default:F(()=>[_(`p`,null,M(e?`必需`:`可选`)+`服务:`+M(t)+` (`+M(t in N(c).services?`已加载`:`未加载`)+`) `,1)]),_:2},1032,[`type`]))),128))]),_:1})]),_:1}),h(` 实现的服务:本插件将提供哪些服务 `),y(l,{order:600},{default:F(()=>[(E(!0),g(f,null,k(o.value.impl,t=>(E(),g(f,{key:t},[t in N(c).services&&e.current.disabled?(E(),m(r,{key:0,type:`warning`},{default:F(()=>[_(`p`,null,`此插件将会提供 `+M(t)+` 服务,但此服务已被其他插件实现。`,1)]),_:2},1024)):(E(),m(r,{key:1,type:e.current.disabled?`primary`:`success`},{default:F(()=>[_(`p`,null,`此插件`+M(e.current.disabled?`启用后将会提供`:`提供了`)+` `+M(t)+` 服务。`,1)]),_:2},1032,[`type`]))],64))),128))]),_:1}),h(` 可重用性:不可重用插件的重复启用警告与多份配置提示 `),y(l,{order:400},{default:F(()=>[u.value.runtime.id&&!u.value.runtime.forkable&&e.current.disabled?(E(),m(r,{key:0,type:`warning`},{default:F(()=>[...n[4]||=[_(`p`,null,`此插件已在运行且不可重用,启用可能会导致非预期的问题。`,-1)]]),_:1})):h(`v-if`,!0),N(X).forks[e.current.name]?.length>1?(E(),m(r,{key:1,type:`primary`},{default:F(()=>[_(`p`,null,[n[5]||=v(`此插件存在多份配置,`,-1),_(`span`,{class:`k-link`,onClick:n[0]||=L(e=>B.value=N(Y),[`stop`])},`点击前往管理`),n[6]||=v(`。`,-1)])]),_:1})):h(`v-if`,!0)]),_:1}),h(` 提供的页面:本插件注册的控制台活动页 `),y(l,{order:300},{default:F(()=>[(E(!0),g(f,null,k(N(i).$router.pages,(t,i)=>(E(),g(f,{key:i},[t.ctx.extension?.paths.includes(e.current.path)&&!t.disabled()?(E(),m(r,{key:0,type:`success`},{default:F(()=>[_(`p`,null,[n[7]||=_(`span`,null,`此插件提供了页面:`,-1),y(p,{id:t.id},null,8,[`id`])])]),_:2},1024)):h(`v-if`,!0)],64))),128))]),_:1}),h(` 用法说明:插件自带的 Markdown 文档 `),u.value.runtime?.usage?(E(),m(l,{key:0,order:-200},{default:F(()=>[y(b,{unsafe:``,class:`usage`,source:u.value.runtime?.usage},null,8,[`source`])]),_:1})):h(`v-if`,!0),h(` 过滤器设置:编辑 $filter 上下文过滤条件 `),y(l,{order:-600},{default:F(()=>[u.value.runtime.filter===!1?h(`v-if`,!0):(E(),m(me,{key:0,modelValue:a.value,"onUpdate:modelValue":n[1]||=e=>a.value=e},null,8,[`modelValue`]))]),_:1}),h(` 配置表单:按 schema 生成的设置项 `),y(l,{order:-1e3},{default:F(()=>[u.value.runtime.schema?(E(),m(x,{key:1,schema:u.value.runtime.schema,initial:e.current.config,modelValue:a.value,"onUpdate:modelValue":n[2]||=e=>a.value=e},{hint:F(()=>[v(M(d.value),1)]),_:1},8,[`schema`,`initial`,`modelValue`])):(E(),m(r,{key:0,type:`warning`},{default:F(()=>[_(`p`,null,`此插件未声明配置项,这可能并非预期行为。`+M(d.value),1)]),_:1}))]),_:1})]),_:1})):(E(),m(r,{key:0},{default:F(()=>[...n[3]||=[_(`p`,null,`正在加载插件配置……`,-1)]]),_:1}))],64)):(E(),m(s,{key:1,name:`plugin-missing`,single:``},{default:F(()=>[y(r,{type:`danger`},{default:F(()=>[...n[8]||=[_(`p`,null,`此插件尚未安装。`,-1)]]),_:1})]),_:1}))}}}),ve={class:`search`},ye=[`title`],be={class:`right`},xe=b({__name:`tree`,props:{modelValue:{}},emits:[`update:modelValue`],setup(e,{expose:t,emit:n}){let r=e,i=R(),a=d(`config.tree`),o=n,c=O(null),l=O(null),u=O(``);function f(e,t){return t.name.toLowerCase().includes(u.value.toLowerCase())}let p=O(!0);async function v(){await C();let e=c.value?.$el,t=e?.querySelector(`.el-tree-node.is-active`);!t||!t.offsetTop&&i.path.slice(9)||c.value.setScrollTop(t.offsetTop-(e.offsetHeight-t.offsetHeight)/2)}t({activate:v}),T(async()=>{v(),p.value=!1});function b(e){!e||p.value||v()}function x(e){return e.data.name===`group`?`分组:${e.label||e.data.path}`:e.label||e.data.name||`待添加`}function S(e){return e.data.path!==``}function D(e,t,n){return n===`inner`?t.data.id.startsWith(`group:`):t.data.path!==``||n===`next`}function k(e,t,n,r){o(`update:modelValue`,e.path),window.dispatchEvent(new MouseEvent(r.type,r))}function A(e,t,n){s(`manager/meta`,e.path,{$collapsed:null})}function I(e,t,n){s(`manager/meta`,e.path,{$collapsed:!0})}function L(e,t,n,r){let i=n===`inner`?t:t.parent,a=i.childNodes.findIndex(t=>t.data.path===e.data.path);i.data.path||--a,s(`manager/teleport`,e.data.parent?.path??``,e.data.id,i.data.path,a)}function z(e){let t=[];return e.children&&t.push(`is-group`),!e.children&&!J(e.name)&&t.push(`is-disabled`),e.path===r.modelValue&&t.push(`is-active`),t.join(` `)}return P(u,e=>{l.value.filter(e)}),(e,t)=>{let n=j(`k-icon`),r=j(`el-input`),i=j(`el-tree`),o=j(`el-scrollbar`);return E(),m(o,{class:`plugin-tree`,ref_key:`root`,ref:c},{default:F(()=>[_(`div`,ve,[y(r,{modelValue:u.value,"onUpdate:modelValue":t[0]||=e=>u.value=e},{suffix:F(()=>[y(n,{name:`search`})]),_:1},8,[`modelValue`])]),y(i,{ref_key:`tree`,ref:l,"node-key":`path`,data:N(X).data,draggable:!0,"auto-expand-parent":!1,"default-expanded-keys":N(X).expanded,"expand-on-click-node":!1,"filter-node-method":f,props:{class:z},"allow-drag":S,"allow-drop":D,onNodeClick:k,onNodeContextmenu:N(a),onNodeDrop:L,onNodeExpand:A,onNodeCollapse:I},{default:F(({node:e})=>[_(`div`,{class:`item`,ref:b},[_(`div`,{class:`label`,title:x(e)},M(x(e)),9,ye),_(`div`,be,[N(J)(e.data.name)?(E(),g(`span`,{key:0,class:w([`status-light`,N(Z)(e.data)])},null,2)):h(`v-if`,!0)])],512)]),_:1},8,[`data`,`default-expanded-keys`,`props`,`onNodeContextmenu`])]),_:1},512)}}}),Se=b({__name:`index`,setup(t){let n=R(),i=z(),o=p({get(){let e=n.path.slice(9);return e in X.value.paths?e:``},set(e){e in X.value.paths||(e=``),i.replace(`/plugins/${e}`)}}),u=O(),d=O(``),_=O(),b=O();async function x(){await C(),_.value?.focus()}let S=O(),w=O(!1),T=O(),D=O(!1),k=O(null);P(S,e=>{e&&(w.value=!0)}),P(T,e=>{e&&(D.value=!0)}),P(()=>X.value.paths[o.value],e=>{q.value=e,u.value=r(e.config)},{immediate:!0});let A=l();A.define(`config.tree`,q),A.action(`config.tree.add-plugin`,{hidden:({config:e})=>e.tree.path&&!e.tree.children,action:({config:e})=>V.value=e.tree}),A.action(`config.tree.add-group`,{hidden:({config:e})=>e.tree.path&&!e.tree.children,action:({config:e})=>{k.value=e.tree.path}});function H(e){let t=Math.random().toString(36).slice(2,8);s(`manager/reload`,k.value,`group:${t}`,{$label:e}),i.replace(`/plugins/${t}`),k.value=null}A.action(`config.tree.clone`,{hidden:({config:e})=>!e.tree.path||!!e.tree.children,action:async({config:e})=>{let t=(e.tree.parent.path?e.tree.parent.children:X.value.data.slice(1)).findIndex(t=>t.path===e.tree.path),n=Math.random().toString(36).slice(2,8);s(`manager/unload`,e.tree.parent?.path??``,`${e.tree.name}:${n}`,e.tree.config,t+1),i.replace(`/plugins/${n}`)}}),A.action(`config.tree.manage`,{hidden:({config:e})=>!e.tree.path||!!e.tree.children,action:async({config:e})=>{B.value=e.tree.name}}),A.action(`config.tree.rename`,{disabled:({config:e})=>!e.tree.path,action:({config:e})=>{d.value=e.tree.label||(e.tree.name===`group`?e.tree.path:e.tree.name),T.value=e.tree}}),A.action(`config.tree.remove`,{disabled:({config:e})=>!e.tree.path||U(e.tree),action:({config:e})=>S.value=e.tree});function W(t){let n=c.packages[J(t)]?.runtime.schema;if(!n)return!0;try{return new e(n)(u.value),!0}catch{return a.error(`当前配置项不满足约束,请检查配置!`),!1}}A.action(`config.tree.save`,{shortcut:`ctrl+s`,disabled:e=>!e?.config?.tree||![`config`].includes(i.currentRoute.value?.meta?.activity.id),action:async({config:{tree:e}})=>{let{disabled:t,path:n}=e;if(!(!t&&!W(e.name))){if(!n)return s(`manager/app-reload`,u.value);try{await G(e,t?`unload`:`reload`),a.success(t?`配置已保存。`:`配置已重载。`)}catch{a.error(`操作失败,请检查日志!`)}}}}),A.action(`config.tree.toggle`,{disabled:({config:e})=>!e.tree.path||U(e.tree),action:async({config:{tree:e}})=>{let{disabled:t,name:n}=e;if(!(t&&!W(e.name)))try{await G(e,t?`reload`:`unload`),a.success((n===`group`?`分组`:`插件`)+(t?`已启用。`:`已停用。`))}catch{a.error(`操作失败,请检查日志!`)}}});async function G(e,t){return await s(`manager/${t}`,e.parent?.path??``,e.id,u.value)}function K(e,t){D.value=!1,e.label=t,s(`manager/meta`,e.path,{$label:t||null})}return(e,t)=>{let n=j(`k-content`),r=j(`el-button`),i=j(`el-dialog`),a=j(`el-input`),s=j(`k-layout`);return E(),m(s,{menu:`config.tree`,"menu-data":N(q)},{header:F(()=>[h(` 根节点:全局设置 `),N(q).path?N(q).children?(E(),g(f,{key:1},[h(` 分组节点 `),v(` 分组:`+M(N(q).label||N(q).id),1)],64)):(E(),g(f,{key:2},[h(` 普通插件节点 `),v(M(N(q).label||N(q).name)+` [`+M(N(q).path)+`] `,1)],64)):(E(),g(f,{key:0},[v(`全局设置`)],64))]),left:F(()=>[y(xe,{ref_key:`tree`,ref:b,modelValue:o.value,"onUpdate:modelValue":t[0]||=e=>o.value=e},null,8,[`modelValue`])]),default:F(()=>[(E(),m(n,{class:`plugin-view`,key:o.value},{default:F(()=>[N(q).path?N(q).children?(E(),m(ge,{key:1,modelValue:u.value,"onUpdate:modelValue":t[2]||=e=>u.value=e,current:N(q)},null,8,[`modelValue`,`current`])):(E(),m(_e,{key:2,current:N(q),modelValue:u.value,"onUpdate:modelValue":t[3]||=e=>u.value=e},null,8,[`current`,`modelValue`])):(E(),m(fe,{key:0,current:N(q),modelValue:u.value,"onUpdate:modelValue":t[1]||=e=>u.value=e},null,8,[`current`,`modelValue`]))]),_:1})),y(i,{modelValue:w.value,"onUpdate:modelValue":t[6]||=e=>w.value=e,title:`确认移除`,"destroy-on-close":``,onClosed:t[7]||=e=>S.value=null},{footer:F(()=>[y(r,{onClick:t[4]||=e=>w.value=!1},{default:F(()=>[...t[19]||=[v(`取消`,-1)]]),_:1}),y(r,{type:`danger`,onClick:t[5]||=e=>(w.value=!1,N(Q)(S.value),b.value?.activate())},{default:F(()=>[...t[20]||=[v(`确定`,-1)]]),_:1})]),default:F(()=>[S.value?(E(),g(f,{key:0},[v(` 确定要移除`+M(S.value.children?`分组 ${S.value.label||S.value.path}`:`插件 ${S.value.label||S.value.name}`)+` 吗?此操作不可撤销! `,1)],64)):h(`v-if`,!0)]),_:1},8,[`modelValue`]),y(i,{modelValue:D.value,"onUpdate:modelValue":t[12]||=e=>D.value=e,title:`重命名`,"destroy-on-close":``,onOpen:x,onClosed:t[13]||=e=>T.value=null},{footer:F(()=>[y(r,{onClick:t[10]||=e=>D.value=!1},{default:F(()=>[...t[21]||=[v(`取消`,-1)]]),_:1}),y(r,{type:`primary`,onClick:t[11]||=e=>K(T.value,d.value)},{default:F(()=>[...t[22]||=[v(`确定`,-1)]]),_:1})]),default:F(()=>[T.value?(E(),m(a,{key:0,ref_key:`inputEl`,ref:_,modelValue:d.value,"onUpdate:modelValue":t[8]||=e=>d.value=e,onKeydown:t[9]||=I(L(e=>K(T.value,d.value),[`stop`,`prevent`]),[`enter`])},null,8,[`modelValue`])):h(`v-if`,!0)]),_:1},8,[`modelValue`]),y(i,{"model-value":k.value!==null,"onUpdate:modelValue":t[18]||=e=>k.value=null,title:`创建分组`,"destroy-on-close":``,onOpen:x},{footer:F(()=>[y(r,{onClick:t[16]||=e=>k.value=null},{default:F(()=>[...t[23]||=[v(`取消`,-1)]]),_:1}),y(r,{type:`primary`,onClick:t[17]||=e=>H(d.value)},{default:F(()=>[...t[24]||=[v(`确定`,-1)]]),_:1})]),default:F(()=>[y(a,{ref_key:`inputEl`,ref:_,modelValue:d.value,"onUpdate:modelValue":t[14]||=e=>d.value=e,onKeydown:t[15]||=I(L(e=>H(d.value),[`stop`,`prevent`]),[`enter`])},null,8,[`modelValue`])]),_:1},8,[`model-value`])]),_:1},8,[`menu-data`])}}}),Ce={class:`content`},we=[`onClick`],Te=b({__name:`select`,setup(e){let t=u(),n=O(``),r=O(),i=S(`plugin-select-filter`,e=>!0),a=p(()=>Object.values(c.packages).filter(({name:e,shortname:t})=>e&&t.includes(n.value.toLowerCase())&&i(c.packages[e])));function l(e){let t=V.value.path,r=Math.random().toString(36).slice(2,8);V.value=null,n.value=``,s(`manager/unload`,t,`${e}:${r}`,{}),o.push(`/plugins/${r}`)}return P(V,async e=>{e&&(await C(),await r.value.focus())},{flush:`post`}),(e,i)=>{let o=j(`k-icon`),s=j(`el-input`),u=j(`k-markdown`),d=j(`el-scrollbar`),p=j(`el-dialog`);return N(c).packages?(E(),m(p,{key:0,modelValue:!!N(V),"onUpdate:modelValue":i[1]||=e=>V.value=null,class:`plugin-select`},{header:F(()=>[A(e.$slots,`title`,{packages:a.value},()=>[i[2]||=_(`span`,{class:`title`},`选择插件`,-1)]),y(s,{ref_key:`input`,ref:r,modelValue:n.value,"onUpdate:modelValue":i[0]||=e=>n.value=e},{suffix:F(()=>[y(o,{name:`search`})]),_:1},8,[`modelValue`])]),default:F(()=>[A(e.$slots,`tabs`,{packages:a.value}),_(`div`,Ce,[y(d,null,{default:F(()=>[(E(!0),g(f,null,k(a.value,({name:e,shortname:n,manifest:r})=>(E(),g(`div`,{class:`package`,key:e,onClick:L(e=>l(n),[`stop`])},[_(`h3`,null,M(n),1),y(u,{inline:``,class:`desc`,source:N(t)(r.description)},null,8,[`source`])],8,we))),128))]),_:1})])]),_:3},8,[`modelValue`])):h(`v-if`,!0)}}}),Ee={},De={class:`k-icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`};function Oe(e,t){return E(),g(`svg`,De,[...t[0]||=[_(`path`,{fill:`currentColor`,d:`M452 60H488C499 60 508 68.95 508 80C508 91.05 499 100 488 100H452V136C452 147 443 156 432 156C420.1 156 412 147 412 136V100H376C364.1 100 356 91.05 356 80C356 68.95 364.1 60 376 60H412V24C412 12.95 420.1 4 432 4C443 4 452 12.95 452 24V60zM280.8 133.1L490.1 222.8C503.4 228.5 512 241.5 512 256C512 270.5 503.4 283.5 490.1 289.2L280.8 378.9C272.1 382.3 264.5 384 256 384C247.5 384 239 382.3 231.2 378.9L21.9 289.2C8.614 283.5 0 270.5 0 256C0 241.5 8.614 228.5 21.9 222.8L231.2 133.1C239 129.7 247.5 128 256 128C264.5 128 272.1 129.7 280.8 133.1V133.1zM66.26 256L250.1 334.8C251.1 335.6 253.1 336 256 336C258 336 260 335.6 261.9 334.8L445.7 256L261.9 177.2C260 176.4 258 176 256 176C253.1 176 251.1 176.4 250.1 177.2L66.26 256zM59.53 350.6C66.15 359.9 65.24 372.3 57.1 380.5L250.1 462.8C251.1 463.6 253.1 464 256 464C258 464 260 463.6 261.9 462.8L452 381.3C447.4 374.4 446.5 365.2 450.5 357.3C456.5 345.4 470.9 340.6 482.7 346.5L491.8 351.1C504.2 357.3 512 369.9 512 383.7C512 398.4 503.3 411.6 489.9 417.3L280.8 506.9C272.1 510.3 264.5 512 256 512C247.5 512 239 510.3 231.2 506.9L22.81 417.6C8.971 411.7 .001 398.1 .001 383C.001 370.9 5.87 359.5 15.76 352.4L26.05 345C36.84 337.3 51.83 339.8 59.53 350.6L59.53 350.6z`},null,-1)]])}var ke=$(Ee,[[`render`,Oe]]),Ae={},je={class:`k-icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`};function Me(e,t){return E(),g(`svg`,je,[...t[0]||=[_(`path`,{fill:`currentColor`,d:`M144,0c13.3,0,24,10.8,24,24v88h-48V24C120,10.8,130.8,0,144,0z M336,0c13.3,0,24,10.8,24,24v88h-48V24
|
|
2
2
|
C312,10.8,322.7,0,336,0z M408,144c13.3,0,24,10.7,24,24s-10.7,24-24,24h-8v64c0,80.2-59.9,146.6-136,158.2V512h-48v-97.8
|
|
3
3
|
c-77-11.6-136-78-136-158.2v-64h-8c-13.2,0-24-10.7-24-24s10.8-24,24-24H408z M240,368c61.9,0,112-50.1,112-112v-64H128v64
|
|
4
4
|
C128,317.9,178.1,368,240,368z`},null,-1),_(`path`,{fill:`currentColor`,d:`M444,416h36c11,0,20,9,20,20s-9,20-20,20h-36v36c0,11-9,20-20,20c-11.9,0-20-9-20-20v-36h-36c-11.9,0-20-9-20-20
|
|
5
|
-
s8.1-20,20-20h36v-36c0-11,8.1-20,20-20c11,0,20,9,20,20V416z`},null,-1)]])}var
|
|
5
|
+
s8.1-20,20-20h36v-36c0-11,8.1-20,20-20c11,0,20,9,20,20V416z`},null,-1)]])}var Ne=$(Ae,[[`render`,Me]]),Pe={},Fe={class:`k-icon check`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 448 512`};function Ie(e,t){return E(),g(`svg`,Fe,[...t[0]||=[_(`path`,{fill:`currentColor`,d:`M438.6 105.4C451.1 117.9 451.1 138.1 438.6 150.6L182.6 406.6C170.1 419.1 149.9 419.1 137.4 406.6L9.372 278.6C-3.124 266.1-3.124 245.9 9.372 233.4C21.87 220.9 42.13 220.9 54.63 233.4L159.1 338.7L393.4 105.4C405.9 92.88 426.1 92.88 438.6 105.4H438.6z`},null,-1)]])}var Le=$(Pe,[[`render`,Ie]]),Re={},ze={class:`k-icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`};function Be(e,t){return E(),g(`svg`,ze,[...t[0]||=[_(`path`,{fill:`currentColor`,d:`M64 464H288C296.8 464 304 456.8 304 448V384H352V448C352 483.3 323.3 512 288 512H64C28.65 512 0 483.3 0 448V224C0 188.7 28.65 160 64 160H128V208H64C55.16 208 48 215.2 48 224V448C48 456.8 55.16 464 64 464zM160 64C160 28.65 188.7 0 224 0H448C483.3 0 512 28.65 512 64V288C512 323.3 483.3 352 448 352H224C188.7 352 160 323.3 160 288V64zM224 304H448C456.8 304 464 296.8 464 288V64C464 55.16 456.8 48 448 48H224C215.2 48 208 55.16 208 64V288C208 296.8 215.2 304 224 304z`},null,-1)]])}var Ve=$(Re,[[`render`,Be]]),He={},Ue={class:`k-icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`};function We(e,t){return E(),g(`svg`,Ue,[...t[0]||=[_(`path`,{fill:`currentColor`,d:`M81.84 152.1C77.43 156.9 71.21 159.8 64.63 159.1C58.05 160.2 51.69 157.6 47.03 152.1L7.029 112.1C-2.343 103.6-2.343 88.4 7.029 79.03C16.4 69.66 31.6 69.66 40.97 79.03L63.08 101.1L118.2 39.94C127 30.09 142.2 29.29 152.1 38.16C161.9 47.03 162.7 62.2 153.8 72.06L81.84 152.1zM81.84 312.1C77.43 316.9 71.21 319.8 64.63 319.1C58.05 320.2 51.69 317.6 47.03 312.1L7.029 272.1C-2.343 263.6-2.343 248.4 7.029 239C16.4 229.7 31.6 229.7 40.97 239L63.08 261.1L118.2 199.9C127 190.1 142.2 189.3 152.1 198.2C161.9 207 162.7 222.2 153.8 232.1L81.84 312.1zM216 120C202.7 120 192 109.3 192 96C192 82.75 202.7 72 216 72H488C501.3 72 512 82.75 512 96C512 109.3 501.3 120 488 120H216zM192 256C192 242.7 202.7 232 216 232H488C501.3 232 512 242.7 512 256C512 269.3 501.3 280 488 280H216C202.7 280 192 269.3 192 256zM160 416C160 402.7 170.7 392 184 392H488C501.3 392 512 402.7 512 416C512 429.3 501.3 440 488 440H184C170.7 440 160 429.3 160 416zM64 448C46.33 448 32 433.7 32 416C32 398.3 46.33 384 64 384C81.67 384 96 398.3 96 416C96 433.7 81.67 448 64 448z`},null,-1)]])}var Ge=$(He,[[`render`,We]]),Ke={},qe={class:`k-icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 384 512`};function Je(e,t){return E(),g(`svg`,qe,[...t[0]||=[_(`path`,{fill:`currentColor`,d:`M24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13V38.13zM48 432L336 256L48 80V432z`},null,-1)]])}var Ye=$(Ke,[[`render`,Je]]),Xe={},Ze={class:`k-icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`};function Qe(e,t){return E(),g(`svg`,Ze,[...t[0]||=[_(`path`,{fill:`currentColor`,d:`M168 255.1C168 207.4 207.4 167.1 256 167.1C304.6 167.1 344 207.4 344 255.1C344 304.6 304.6 344 256 344C207.4 344 168 304.6 168 255.1zM256 199.1C225.1 199.1 200 225.1 200 255.1C200 286.9 225.1 311.1 256 311.1C286.9 311.1 312 286.9 312 255.1C312 225.1 286.9 199.1 256 199.1zM65.67 230.6L25.34 193.8C14.22 183.7 11.66 167.2 19.18 154.2L49.42 101.8C56.94 88.78 72.51 82.75 86.84 87.32L138.8 103.9C152.2 93.56 167 84.96 182.8 78.43L194.5 25.16C197.7 10.47 210.7 0 225.8 0H286.2C301.3 0 314.3 10.47 317.5 25.16L329.2 78.43C344.1 84.96 359.8 93.56 373.2 103.9L425.2 87.32C439.5 82.75 455.1 88.78 462.6 101.8L492.8 154.2C500.3 167.2 497.8 183.7 486.7 193.8L446.3 230.6C447.4 238.9 448 247.4 448 255.1C448 264.6 447.4 273.1 446.3 281.4L486.7 318.2C497.8 328.3 500.3 344.8 492.8 357.8L462.6 410.2C455.1 423.2 439.5 429.2 425.2 424.7L373.2 408.1C359.8 418.4 344.1 427 329.2 433.6L317.5 486.8C314.3 501.5 301.3 512 286.2 512H225.8C210.7 512 197.7 501.5 194.5 486.8L182.8 433.6C167 427 152.2 418.4 138.8 408.1L86.84 424.7C72.51 429.2 56.94 423.2 49.42 410.2L19.18 357.8C11.66 344.8 14.22 328.3 25.34 318.2L65.67 281.4C64.57 273.1 64 264.6 64 255.1C64 247.4 64.57 238.9 65.67 230.6V230.6zM158.4 129.2L145.1 139.5L77.13 117.8L46.89 170.2L99.58 218.2L97.39 234.8C96.47 241.7 96 248.8 96 255.1C96 263.2 96.47 270.3 97.39 277.2L99.58 293.8L46.89 341.8L77.13 394.2L145.1 372.5L158.4 382.8C169.5 391.4 181.9 398.6 195 403.1L210.5 410.4L225.8 480H286.2L301.5 410.4L316.1 403.1C330.1 398.6 342.5 391.4 353.6 382.8L366.9 372.5L434.9 394.2L465.1 341.8L412.4 293.8L414.6 277.2C415.5 270.3 416 263.2 416 256C416 248.8 415.5 241.7 414.6 234.8L412.4 218.2L465.1 170.2L434.9 117.8L366.9 139.5L353.6 129.2C342.5 120.6 330.1 113.4 316.1 108L301.5 101.6L286.2 32H225.8L210.5 101.6L195 108C181.9 113.4 169.5 120.6 158.4 129.2H158.4z`},null,-1)]])}var $e=$(Xe,[[`render`,Qe]]),et={},tt={class:`k-icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 448 512`};function nt(e,t){return E(),g(`svg`,tt,[...t[0]||=[_(`path`,{fill:`currentColor`,d:`M224 256c-35.2 0-64 28.8-64 64c0 35.2 28.8 64 64 64c35.2 0 64-28.8 64-64C288 284.8 259.2 256 224 256zM433.1 129.1l-83.9-83.9C341.1 37.06 328.8 32 316.1 32H64C28.65 32 0 60.65 0 96v320c0 35.35 28.65 64 64 64h320c35.35 0 64-28.65 64-64V163.9C448 151.2 442.9 138.9 433.1 129.1zM128 80h144V160H128V80zM400 416c0 8.836-7.164 16-16 16H64c-8.836 0-16-7.164-16-16V96c0-8.838 7.164-16 16-16h16v104c0 13.25 10.75 24 24 24h192C309.3 208 320 197.3 320 184V83.88l78.25 78.25C399.4 163.2 400 164.8 400 166.3V416z`},null,-1)]])}var rt=$(et,[[`render`,nt]]),it={},at={class:`k-icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 384 512`};function ot(e,t){return E(),g(`svg`,at,[...t[0]||=[_(`path`,{fill:`currentColor`,d:`M320 64H64c-35.35 0-64 28.65-64 64v255.1c0 35.35 28.65 64 64 64H320c35.35 0 64-28.65 64-64V128C384 92.65 355.3 64 320 64zM336 384c0 8.822-7.178 16-16 16H64c-8.822 0-16-7.178-16-16V128c0-8.822 7.178-16 16-16h256c8.822 0 16 7.178 16 16V384z`},null,-1)]])}var st=$(it,[[`render`,ot]]),ct={},lt={class:`k-icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 448 512`};function ut(e,t){return E(),g(`svg`,lt,[...t[0]||=[_(`path`,{fill:`currentColor`,d:`M160 400C160 408.8 152.8 416 144 416C135.2 416 128 408.8 128 400V192C128 183.2 135.2 176 144 176C152.8 176 160 183.2 160 192V400zM240 400C240 408.8 232.8 416 224 416C215.2 416 208 408.8 208 400V192C208 183.2 215.2 176 224 176C232.8 176 240 183.2 240 192V400zM320 400C320 408.8 312.8 416 304 416C295.2 416 288 408.8 288 400V192C288 183.2 295.2 176 304 176C312.8 176 320 183.2 320 192V400zM317.5 24.94L354.2 80H424C437.3 80 448 90.75 448 104C448 117.3 437.3 128 424 128H416V432C416 476.2 380.2 512 336 512H112C67.82 512 32 476.2 32 432V128H24C10.75 128 0 117.3 0 104C0 90.75 10.75 80 24 80H93.82L130.5 24.94C140.9 9.357 158.4 0 177.1 0H270.9C289.6 0 307.1 9.358 317.5 24.94H317.5zM151.5 80H296.5L277.5 51.56C276 49.34 273.5 48 270.9 48H177.1C174.5 48 171.1 49.34 170.5 51.56L151.5 80zM80 432C80 449.7 94.33 464 112 464H336C353.7 464 368 449.7 368 432V128H80V432z`},null,-1)]])}var dt=$(ct,[[`render`,ut]]);i.register(`activity:plugin`,$e),i.register(`add-group`,ke),i.register(`add-plugin`,Ne),i.register(`trash-can`,dt),i.register(`check`,Le),i.register(`clone`,Ve),i.register(`manage`,Ge),i.register(`play`,Ye),i.register(`stop`,st),i.register(`save`,rt);var ft=class extends n{constructor(e){super(e,`configWriter`,!0),e.slot({type:`global`,component:b(()=>()=>x(j(`k-slot`),{name:`plugin-select`,single:!0}))}),e.slot({type:`plugin-select-base`,component:Te,order:-1e3}),e.slot({type:`plugin-select`,component:Te,order:-1e3}),e.slot({type:`global`,component:de}),e.page({id:`config`,path:`/plugins/:name*`,name:`插件配置`,icon:`activity:plugin`,order:800,authority:4,fields:[`config`,`packages`,`services`],component:Se}),e.menu(`config.tree`,[{id:`config.tree.toggle`,type:({config:e})=>e.tree?.disabled?``:ee.value??``,icon:({config:e})=>e.tree?.disabled?`play`:`stop`,label:({config:e})=>(e.tree?.disabled?`启用`:`停用`)+(e.tree?.name===`group`?`分组`:`插件`)},{id:`.save`,icon:({config:e})=>e.tree?.disabled?`save`:`check`,label:({config:e})=>e.tree?.disabled?`保存配置`:`重载配置`},{id:`@separator`},{id:`.rename`,icon:`edit`,label:`重命名`},{id:`.remove`,type:`danger`,icon:`delete`,label:({config:e})=>e.tree?.children?`移除分组`:`移除插件`},{id:`@separator`},{id:`.clone`,icon:`clone`,label:`克隆配置`},{id:`.manage`,icon:`manage`,label:`管理多份配置`},{id:`.add-plugin`,icon:`add-plugin`,label:`添加插件`},{id:`.add-group`,icon:`add-group`,label:`添加分组`}])}ensure(e,t){let n=e.replace(/(koishi-|^@koishijs\/)plugin-/,``),r=X.value.forks[n];if(r?.length)r.length===1?t||o.push(`/plugins/${r[0]}`):t||(B.value=e);else{let e=Math.random().toString(36).slice(2,8);s(`manager/unload`,``,`${n}:${e}`,{}),t||o.push(`/plugins/${e}`)}}remove(e){let t=e.replace(/(koishi-|^@koishijs\/)plugin-/,``),n=X.value.forks[t];for(let e of n??[]){let t=X.value.paths[e];t&&s(`manager/remove`,t.parent?.path??``,t.id)}}get(e){let t=e.replace(/(koishi-|^@koishijs\/)plugin-/,``);return X.value.forks[t]?.map(e=>X.value.paths[e])}};export{H as coreDeps,q as current,ft as default,B as dialogFork,V as dialogSelect,K as envMap,J as getFullName,Z as getStatus,U as hasCoreDeps,Y as name,X as plugins,Q as removeItem,W as resolveProvider,ee as type};
|
package/dist/style.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.dialog-config-fork .el-dialog__header .el-dialog__title{color:var(--fg1);flex:none;margin-right:.5rem;font-weight:500}.dialog-config-fork .status-light{margin-right:.75rem}.dialog-config-fork .actions{justify-content:flex-end;align-items:center;gap:0 .5rem;display:flex}.dialog-config-fork .action{cursor:pointer;width:1.25rem;color:var(--fg2);transition:var(--color-transition);justify-content:center;display:inline-flex}.dialog-config-fork .action:hover{color:var(--fg1)}.dialog-config-fork .el-dialog__footer{justify-content:space-between;align-items:center;font-size:.9em;display:flex}.modifier{margin-bottom:2rem}h2[data-v-
|
|
1
|
+
.dialog-config-fork .el-dialog__header .el-dialog__title{color:var(--fg1);flex:none;margin-right:.5rem;font-weight:500}.dialog-config-fork .status-light{margin-right:.75rem}.dialog-config-fork .actions{justify-content:flex-end;align-items:center;gap:0 .5rem;display:flex}.dialog-config-fork .action{cursor:pointer;width:1.25rem;color:var(--fg2);transition:var(--color-transition);justify-content:center;display:inline-flex}.dialog-config-fork .action:hover{color:var(--fg1)}.dialog-config-fork .el-dialog__footer{justify-content:space-between;align-items:center;font-size:.9em;display:flex}.modifier{margin-bottom:2rem}h2[data-v-21d6aea8]{font-size:1.25rem}.plugin-view .markdown.usage{margin-bottom:2rem}.plugin-view .markdown.usage h2{font-size:1.25rem}.plugin-tree{width:100%;height:100%;overflow:auto}.plugin-tree .el-scrollbar__view{padding:1rem 0;line-height:2.25rem}.plugin-tree .search{padding:0 1.5rem}.plugin-tree .k-icon-filter{height:15px}.plugin-tree .el-tree-node.is-group>.el-tree-node__content{font-weight:700}.plugin-tree .el-tree-node__content .item{flex:1;justify-content:space-between;align-items:center;height:100%;display:flex;overflow:hidden}.plugin-tree .el-tree-node__content .label{text-overflow:ellipsis;transition:var(--color-transition);overflow:hidden}.plugin-tree .el-tree-node__content .right{height:100%;margin:0 1.5rem 0 .5rem}.end{margin-right:.5rem}.config-header{margin:0 0 2rem;font-size:1.375rem;line-height:2rem}.config-header .k-button{float:right}.plugin-view .k-content>:first-child{margin-top:0}.plugin-select .el-dialog__header{border-bottom:1px solid var(--k-color-divider);justify-content:space-between;align-items:center;margin-right:0;padding:12px 20px;display:flex}.plugin-select .el-dialog__header button{top:2px}.plugin-select .el-dialog__header .title{flex:none}.plugin-select .el-dialog__header .el-input{width:220px;height:2rem;display:inline-block}.plugin-select .el-dialog__body{height:50vh;padding:0;display:flex}.plugin-select .el-dialog__body .tabs{border-right:1px solid var(--k-color-divider);flex:none;width:7.5rem;font-size:15px}@media screen and (width<=768px){.plugin-select .el-dialog__body .tabs{width:3rem}}.plugin-select .el-dialog__body .tabs .el-scrollbar__view{padding:.5rem 0}.plugin-select .el-dialog__body .tabs .tab-item{cursor:pointer;height:2rem;transition:var(--color-transition);justify-content:center;align-items:center;padding:0 1rem;font-size:.875rem;display:flex}.plugin-select .el-dialog__body .tabs .tab-item:hover{background-color:var(--k-hover-bg)}@media screen and (width<=768px){.plugin-select .el-dialog__body .tabs .tab-item{padding:0}}.plugin-select .el-dialog__body .tabs .tab-item .market-icon{width:1.25rem;height:1rem}.plugin-select .el-dialog__body .tabs .tab-item.active{color:var(--primary)}.plugin-select .el-dialog__body .tabs .tab-item .title{width:3.5rem;margin-left:.5rem}@media screen and (width<=768px){.plugin-select .el-dialog__body .tabs .tab-item .title{display:none}}.plugin-select .el-dialog__body .content{flex:auto}.plugin-select .el-dialog__body .content .package{cursor:pointer;transition:var(--color-transition);padding:.5rem 1rem}.plugin-select .el-dialog__body .content .package h3{margin:0 0 .25rem;font-size:16px}.plugin-select .el-dialog__body .content .package p{margin:0;font-size:14px}.plugin-select .el-dialog__body .content .package:hover{background-color:var(--k-hover-bg)}.inline{display:inline}.inline-block{display:inline-block}.hidden{display:none}.h2{height:.5rem}.h3{height:.75rem}.flex{display:flex}.inline-flex{display:inline-flex}.text-left{text-align:left}.text-right{text-align:right}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter,backdrop-filter;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.dialog-config-fork .status-light,.plugin-tree .status-light{width:.625rem;height:.625rem;transition:var(--color-transition);border-radius:100%;display:inline-block}.dialog-config-fork .status-light.active,.plugin-tree .status-light.active{background-color:var(--k-color-success)}.dialog-config-fork .status-light.pending,.plugin-tree .status-light.pending{background-color:var(--k-color-warning)}.dialog-config-fork .status-light.loading,.plugin-tree .status-light.loading{background-color:var(--k-color-warning);animation:1s infinite status-flash}.dialog-config-fork .status-light.failed,.plugin-tree .status-light.failed{background-color:var(--k-color-danger)}.dialog-config-fork .status-light.disabled:not(.ignore-disabled),.plugin-tree .status-light.disabled:not(.ignore-disabled){opacity:.5;background-color:var(--k-color-disabled)}@keyframes status-flash{0%,to{opacity:0}50%{opacity:1}}
|
|
2
2
|
/*$vite$:1*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koishi-ce/plugin-config",
|
|
3
3
|
"description": "Manage your bots and plugins with console",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.mjs",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@
|
|
66
|
-
"@
|
|
67
|
-
"koishi": "^
|
|
65
|
+
"@koishi-ce/loader": "^1.0.0",
|
|
66
|
+
"@koishi-ce/plugin-console": "^1.0.0",
|
|
67
|
+
"@koishi-ce/koishi": "^1.0.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@koishi-ce/client": "^1.0.2",
|
package/src/browser/index.ts
CHANGED
package/src/browser/packages.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2019-present Shigma and Koishijs contributors.
|
|
3
|
+
// Copyright (c) 2026-present Koishi-CE contributors.
|
|
4
|
+
|
|
1
5
|
import * as shared from "../shared/index.ts";
|
|
2
6
|
|
|
3
7
|
export class PackageProvider extends shared.PackageProvider {
|
package/src/index.ts
CHANGED
package/src/node/index.ts
CHANGED
package/src/node/packages.ts
CHANGED
package/src/shared/index.ts
CHANGED
package/src/shared/packages.ts
CHANGED
package/src/shared/services.ts
CHANGED