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
85d4c653
Commit
85d4c653
authored
Nov 13, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add @InjectLogger
parent
2fba1157
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
0 deletions
+9
-0
README.md
README.md
+2
-0
src/decorators.ts
src/decorators.ts
+4
-0
src/register.ts
src/register.ts
+3
-0
No files found.
README.md
View file @
85d4c653
...
...
@@ -61,6 +61,8 @@ koishi-thirdeye 内建了对[`koishi-utils-schemagen`](https://github.com/koishi
*
`@InjectApp()`
注入 Koishi 实例对象。
*
`@InjectLogger(name: string)`
注入 Koishi 日志记录器。
### 声明周期钩子
下列方法是一些生命周期方法。这些方法会在插件特定生命周期中调用,便于注册方法等操作。
...
...
src/decorators.ts
View file @
85d4c653
...
...
@@ -222,3 +222,7 @@ export const InjectContext = (select?: Selection) =>
export
const
InjectApp
=
()
=>
InjectSystem
((
obj
)
=>
obj
.
__ctx
.
app
);
export
const
InjectConfig
=
(
raw
=
false
)
=>
InjectSystem
((
obj
)
=>
(
raw
?
obj
.
__rawConfig
:
obj
.
__config
));
export
const
InjectLogger
=
(
name
?:
string
)
=>
InjectSystem
((
obj
)
=>
obj
.
__ctx
.
logger
(
name
||
obj
.
__pluginOptions
?.
name
||
'
default
'
),
);
src/register.ts
View file @
85d4c653
...
...
@@ -28,6 +28,7 @@ export interface PluginClass<T = any> {
__ctx
:
Context
;
__config
:
T
;
__rawConfig
:
T
;
__pluginOptions
:
KoishiPluginRegistrationOptions
<
T
>
;
}
export
interface
OnApply
{
...
...
@@ -58,6 +59,7 @@ export function KoishiPlugin<T = any>(
__ctx
:
Context
;
__config
:
T
;
__rawConfig
:
T
;
__pluginOptions
:
KoishiPluginRegistrationOptions
<
T
>
;
_handleSystemInjections
()
{
// console.log('Handling system injection');
...
...
@@ -322,6 +324,7 @@ export function KoishiPlugin<T = any>(
this
.
__ctx
=
ctx
;
this
.
__rawConfig
=
rawConfig
;
this
.
__config
=
config
;
this
.
__pluginOptions
=
options
;
this
.
_initializePluginClass
().
then
();
}
};
...
...
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