Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
koishi-plugin-pics
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-plugin-pics
Commits
51d0715d
Commit
51d0715d
authored
Mar 20, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
put as default when 1 source
parent
bc83ac90
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
README.md
README.md
+15
-11
src/index.ts
src/index.ts
+1
-1
No files found.
README.md
View file @
51d0715d
...
...
@@ -95,23 +95,27 @@ export class PicSource {
```
ts
import
{
Context
}
from
"
koishi
"
;
import
{
PicSource
}
from
"
koishi-plugin-pics
"
;
import
{
DefinePlugin
,
Provide
}
from
"
koishi-thirdeye
"
;
import
{
PicSource
,
PicsContainer
}
from
"
koishi-plugin-pics
"
;
class
MyPicSource
extends
PicSource
{
constructor
(
ctx
:
Context
,
config
:
Config
)
{
@
DefinePlugin
({
name
:
'
my-picsource
'
,
schema
:
Config
})
export
default
class
MyPicSource
extends
PicSource
{
constructor
(
ctx
:
Context
,
config
:
Partial
<
Config
>
)
{
super
(
ctx
);
}
randomPic
(
tags
:
string
[])
{
return
{
url
:
'
https://1.1.1.1
'
,
description
:
'
图片介绍
'
}
}
}
@
Inject
(
true
)
private
pics
:
PicsContainer
;
export
const
using
=
[
'
pics
'
];
randomPic
(
tags
:
string
[])
{
return
{
url
:
'
https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/10000.jpg
'
,
description
:
'
图片介绍
'
}
}
export
function
apply
(
ctx
:
Context
,
config
:
PluginConfig
)
{
ctx
.
pics
.
addSource
(
new
MyPicSource
(
ctx
,
config
));
onApply
()
{
this
.
config
.
applyTo
(
this
);
this
.
pics
.
addSource
(
this
);
}
}
```
...
...
src/index.ts
View file @
51d0715d
...
...
@@ -111,7 +111,7 @@ export default class PicsContainer
sourceTags
.
some
((
exact
)
=>
s
.
name
===
exact
)
||
sourceTags
.
every
((
t
)
=>
s
.
tags
.
includes
(
t
)),
);
}
else
if
(
!
includeNonDefault
)
{
}
else
if
(
!
includeNonDefault
&&
sources
.
length
>
1
)
{
sources
=
sources
.
filter
((
s
)
=>
s
.
isDefault
);
}
return
sources
;
...
...
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