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
4abc27e9
Commit
4abc27e9
authored
Dec 20, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add http settings
parent
ef3e5a2e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
6 deletions
+22
-6
dev/extras.ts
dev/extras.ts
+1
-1
src/config.ts
src/config.ts
+10
-0
src/picsource.ts
src/picsource.ts
+11
-5
No files found.
dev/extras.ts
View file @
4abc27e9
...
@@ -60,7 +60,7 @@ export class TestMultiPicSourcePlugin extends MultiInstancePlugin(
...
@@ -60,7 +60,7 @@ export class TestMultiPicSourcePlugin extends MultiInstancePlugin(
export
default
class
ExtrasInDev
{
export
default
class
ExtrasInDev
{
constructor
(
ctx
:
Context
)
{
constructor
(
ctx
:
Context
)
{
ctx
.
plugin
(
TestPicSourcePlugin
,
{
ctx
.
plugin
(
TestP
lainP
icSourcePlugin
,
{
// name: 'zh-CN',
// name: 'zh-CN',
isDefault
:
true
,
isDefault
:
true
,
// endpoint: 'https://cdn02.moecube.com:444',
// endpoint: 'https://cdn02.moecube.com:444',
...
...
src/config.ts
View file @
4abc27e9
...
@@ -32,6 +32,9 @@ export type PicsPluginConfigLike = Partial<PicsPluginConfig>;
...
@@ -32,6 +32,9 @@ export type PicsPluginConfigLike = Partial<PicsPluginConfig>;
// For convenience of plugins
// For convenience of plugins
const
questerConfigDict
=
{
...
Quester
.
Config
.
dict
};
delete
questerConfigDict
.
endpoint
;
export
class
PicSourceConfig
implements
PicSourceInfo
{
export
class
PicSourceConfig
implements
PicSourceInfo
{
@
SchemaProperty
({
type
:
'
string
'
,
default
:
[],
description
:
'
图源标签
'
})
@
SchemaProperty
({
type
:
'
string
'
,
default
:
[],
description
:
'
图源标签
'
})
tags
:
string
[];
tags
:
string
[];
...
@@ -44,6 +47,13 @@ export class PicSourceConfig implements PicSourceInfo {
...
@@ -44,6 +47,13 @@ export class PicSourceConfig implements PicSourceInfo {
@
SchemaProperty
({
description
:
'
是否为默认图源
'
})
@
SchemaProperty
({
description
:
'
是否为默认图源
'
})
isDefault
?:
boolean
;
isDefault
?:
boolean
;
@
SchemaProperty
({
type
:
Schema
.
object
(
questerConfigDict
),
description
:
'
请求设置
'
,
default
:
{},
})
http
:
Omit
<
Quester
.
Config
,
'
endpoint
'
>
;
// 给目标对象注入上述对象。
// 给目标对象注入上述对象。
applyTo
(
target
:
PicSourceInfo
)
{
applyTo
(
target
:
PicSourceInfo
)
{
target
.
tags
=
this
.
tags
;
target
.
tags
=
this
.
tags
;
...
...
src/picsource.ts
View file @
4abc27e9
import
{
Context
,
Awaitable
,
Logger
,
Schema
}
from
'
koishi
'
;
import
{
Context
,
Awaitable
,
Logger
,
Schema
,
Quester
}
from
'
koishi
'
;
import
{
import
{
PartialDeep
,
PartialDeep
,
InjectConfig
,
InjectConfig
,
...
@@ -8,6 +8,7 @@ import {
...
@@ -8,6 +8,7 @@ import {
schemaFromClass
,
schemaFromClass
,
Apply
,
Apply
,
Reusable
,
Reusable
,
SchemaClass
,
}
from
'
koishi-thirdeye
'
;
}
from
'
koishi-thirdeye
'
;
import
PicsContainer
from
'
.
'
;
import
PicsContainer
from
'
.
'
;
import
{
PicSourceConfig
}
from
'
./config
'
;
import
{
PicSourceConfig
}
from
'
./config
'
;
...
@@ -58,6 +59,8 @@ export class BasePicSourcePlugin extends PicSource {
...
@@ -58,6 +59,8 @@ export class BasePicSourcePlugin extends PicSource {
super
(
ctx
);
super
(
ctx
);
}
}
http
:
Quester
;
@
InjectConfig
()
@
InjectConfig
()
config
:
PicSourceConfig
;
config
:
PicSourceConfig
;
...
@@ -69,6 +72,7 @@ export class BasePicSourcePlugin extends PicSource {
...
@@ -69,6 +72,7 @@ export class BasePicSourcePlugin extends PicSource {
@
Apply
()
@
Apply
()
initializeSource
()
{
initializeSource
()
{
this
.
http
=
this
.
ctx
.
http
.
extend
(
this
.
config
.
httpConfig
||
{});
this
.
config
.
applyTo
(
this
);
this
.
config
.
applyTo
(
this
);
this
.
pics
.
addSource
(
this
);
this
.
pics
.
addSource
(
this
);
}
}
...
@@ -82,16 +86,18 @@ export const PicSourcePlugin = CreatePluginFactory(
...
@@ -82,16 +86,18 @@ export const PicSourcePlugin = CreatePluginFactory(
export
function
PlainPicSourcePlugin
<
C
>
(
dict
:
{
export
function
PlainPicSourcePlugin
<
C
>
(
dict
:
{
[
K
in
keyof
C
]:
Schema
<
C
[
K
]
>
;
[
K
in
keyof
C
]:
Schema
<
C
[
K
]
>
;
})
{
})
{
const
Config
=
schemaFrom
Class
(
PicSourceConfig
)
as
unknown
as
Schema
<
const
Config
=
Schema
Class
(
PicSourceConfig
)
as
unknown
as
Schema
<
PartialDeep
<
PicSourceConfig
&
C
>
,
PartialDeep
<
PicSourceConfig
&
C
>
,
PicSourceConfig
&
C
PicSourceConfig
&
C
>
;
>
;
Object
.
assign
(
Config
.
dict
,
dict
);
Object
.
assign
(
Config
.
dict
,
dict
);
return
class
PlainPicSourcePluginBase
extends
PicSource
{
return
class
PlainPicSourcePluginBase
extends
PicSource
{
config
:
PicSourceInfo
&
C
;
http
:
Quester
;
constructor
(
ctx
:
Context
,
config
:
PartialDeep
<
C
&
PicSourceInfo
>
)
{
config
:
PicSourceConfig
&
C
;
constructor
(
ctx
:
Context
,
config
:
PartialDeep
<
C
&
PicSourceConfig
>
)
{
super
(
ctx
);
super
(
ctx
);
this
.
config
=
config
as
PicSourceInfo
&
C
;
this
.
config
=
config
as
PicSourceConfig
&
C
;
this
.
http
=
this
.
ctx
.
http
.
extend
(
this
.
config
.
httpConfig
||
{});
this
.
applyConfig
(
config
);
this
.
applyConfig
(
config
);
ctx
.
pics
.
addSource
(
this
);
ctx
.
pics
.
addSource
(
this
);
}
}
...
...
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