Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
Koishi Thirdeye
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
3rdeye
Koishi Thirdeye
Commits
195214d9
Commit
195214d9
authored
Feb 16, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more filter decorators and doc update
parent
effef813
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
0 deletions
+37
-0
README.md
README.md
+24
-0
src/decorators/common.ts
src/decorators/common.ts
+3
-0
src/registrar.ts
src/registrar.ts
+10
-0
No files found.
README.md
View file @
195214d9
...
...
@@ -760,6 +760,9 @@ export default class MyPlugin extends StarterPlugin(Config) {
-
`@OnPlatform(value)`
等价于
`ctx.platform(value)`
。
-
`@OnPrivate(value)`
等价于
`ctx.private(value)`
。
-
`@OnSelection(value)`
等价于
`ctx.select(value)`
。
-
`@OnUnion(value)`
等价于
`ctx.union(value)`
。
-
`@OnIntersect(value)`
等价于
`ctx.intersect(value)`
。
-
`@OnExclude(value)`
等价于
`ctx.exclude(value)`
。
## 插值定义
...
...
@@ -1159,6 +1162,27 @@ export class MyPluginBar extends FooPlugin(BarConfig) {
koishi-thirdeye 也提供了一些开箱即用的插件模板,这些模板可以帮助您简单地对各个子插件进行有效的组织。事实上,上面的
[
`StarterPlugin`
](
#插件基类
)
就是内置模板的一种。
#### HttpClientPlugin
HttpClientPlugin 是一个内置的模板,里面提供了一个
`http`
成员变量,可以用于发送 HTTP 请求。该模板内置了相关 http 的配置以让插件的用户定义
`this.http`
相关的行为。
```
ts
@
RegisterSchema
()
export
class
Config
{
@
SchemaProperty
()
foo
:
string
// 将被增加 headers, proxyAgent, timeout 等配置
}
@
DefinePlugin
()
export
class
MyPlugin
extends
HttpClientPlugin
(
Config
)
{
@
UseCommand
(
'
foo
'
)
onFoo
()
{
return
this
.
http
.
get
(
'
https://example.com
'
)
}
}
```
#### 组合插件
使用组合插件可以将多个插件组合成一个插件,并将子插件的配置映射到插件配置的某一个元素中。在父插件中可以使用
`getInstance(name)`
方法获取子插件的实例。
...
...
src/decorators/common.ts
View file @
195214d9
...
...
@@ -28,6 +28,9 @@ export const {
OnPlatform
,
OnPrivate
,
OnSelection
,
OnUnion
,
OnIntersect
,
OnExclude
,
}
=
koishiRegistrar
.
selectorDecorators
();
export
const
{
...
...
src/registrar.ts
View file @
195214d9
...
...
@@ -7,6 +7,7 @@ import {
Next
,
Session
,
Component
,
Filter
,
}
from
'
koishi
'
;
import
{
CanBeObserved
,
sessionRxToPromise
}
from
'
./utility/rxjs-session
'
;
import
{
...
...
@@ -250,6 +251,15 @@ export class KoishiRegistrar extends Registrar<Context> {
OnSelection
:
this
.
decorateTransformer
((
ctx
,
selection
:
Selection
)
=>
selectContext
(
ctx
,
selection
),
),
OnUnion
:
this
.
decorateTransformer
((
ctx
,
arg
:
Filter
|
Context
)
=>
ctx
.
union
(
arg
),
),
OnIntersect
:
this
.
decorateTransformer
((
ctx
,
arg
:
Filter
|
Context
)
=>
ctx
.
intersect
(
arg
),
),
OnExclude
:
this
.
decorateTransformer
((
ctx
,
arg
:
Filter
|
Context
)
=>
ctx
.
exclude
(
arg
),
),
};
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment