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
33427980
Commit
33427980
authored
Jul 25, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adapt Koishi 4.8.2
parent
f1683fa1
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1259 additions
and
529 deletions
+1259
-529
dev/index.ts
dev/index.ts
+2
-5
package-lock.json
package-lock.json
+1231
-504
package.json
package.json
+7
-6
src/config.ts
src/config.ts
+2
-2
src/index.ts
src/index.ts
+5
-8
src/middleware.ts
src/middleware.ts
+3
-3
src/picsource.ts
src/picsource.ts
+1
-1
webpack.config.js
webpack.config.js
+8
-0
No files found.
dev/index.ts
View file @
33427980
...
@@ -2,15 +2,13 @@ import { App } from 'koishi';
...
@@ -2,15 +2,13 @@ import { App } from 'koishi';
import
TargetPlugin
from
'
../src
'
;
import
TargetPlugin
from
'
../src
'
;
import
ConsolePlugin
from
'
@koishijs/plugin-console
'
;
import
ConsolePlugin
from
'
@koishijs/plugin-console
'
;
import
SandboxPlugin
from
'
@koishijs/plugin-sandbox
'
;
import
SandboxPlugin
from
'
@koishijs/plugin-sandbox
'
;
import
*
as
DatabasePlugin
from
'
@koishijs/plugin-database-memory
'
;
import
DatabasePlugin
from
'
@koishijs/plugin-database-memory
'
;
import
CachePlugin
from
'
@koishijs/plugin-cache-lru
'
;
import
ExtrasInDev
from
'
./extras
'
;
import
ExtrasInDev
from
'
./extras
'
;
const
app
=
new
App
({
const
app
=
new
App
({
port
:
14514
,
port
:
14514
,
host
:
'
localhost
'
,
host
:
'
localhost
'
,
prefix
:
'
.
'
,
prefix
:
'
.
'
,
locale
:
'
en
'
,
});
});
// Console and sandbox
// Console and sandbox
...
@@ -19,8 +17,7 @@ app.plugin(ConsolePlugin, {
...
@@ -19,8 +17,7 @@ app.plugin(ConsolePlugin, {
open
:
false
,
open
:
false
,
});
});
// Some services
// Database
app
.
plugin
(
CachePlugin
);
app
.
plugin
(
DatabasePlugin
);
app
.
plugin
(
DatabasePlugin
);
// Some extras
// Some extras
...
...
package-lock.json
View file @
33427980
This source diff could not be displayed because it is too large. You can
view the blob
instead.
package.json
View file @
33427980
...
@@ -27,19 +27,20 @@
...
@@ -27,19 +27,20 @@
},
},
"homepage"
:
"
https://github.com/koishijs/koishi-plugin-pics
"
,
"homepage"
:
"
https://github.com/koishijs/koishi-plugin-pics
"
,
"dependencies"
:
{
"dependencies"
:
{
"
koishi-thirdeye
"
:
"
^1
0.3.2
"
,
"
koishi-thirdeye
"
:
"
^1
1.0.6
"
,
"
lodash
"
:
"
^4.17.21
"
"
lodash
"
:
"
^4.17.21
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"
@koishijs/plugin-cache-lru
"
:
"
^1.0.0-rc.0
"
,
"
@koishijs/plugin-console
"
:
"
^4.1.1
"
,
"
@koishijs/plugin-console
"
:
"
^3.3.2
"
,
"
@koishijs/plugin-database-memory
"
:
"
^1.4.1
"
,
"
@koishijs/plugin-database-memory
"
:
"
^1.3.0
"
,
"
@koishijs/plugin-sandbox
"
:
"
^2.0.1
"
,
"
@koishijs/plugin-sandbox
"
:
"
^1.1.3
"
,
"
@types/jest
"
:
"
^27.4.0
"
,
"
@types/jest
"
:
"
^27.4.0
"
,
"
@types/lodash
"
:
"
^4.14.176
"
,
"
@types/lodash
"
:
"
^4.14.176
"
,
"
@types/node
"
:
"
^16.11.4
"
,
"
@types/node
"
:
"
^16.11.4
"
,
"
@typescript-eslint/eslint-plugin
"
:
"
^4.33.0
"
,
"
@typescript-eslint/eslint-plugin
"
:
"
^4.33.0
"
,
"
@typescript-eslint/parser
"
:
"
^4.33.0
"
,
"
@typescript-eslint/parser
"
:
"
^4.33.0
"
,
"
axios
"
:
"
0.24.0
"
,
"
esbuild-loader
"
:
"
^2.19.0
"
,
"
eslint
"
:
"
^7.32.0
"
,
"
eslint
"
:
"
^7.32.0
"
,
"
eslint-config-prettier
"
:
"
^8.3.0
"
,
"
eslint-config-prettier
"
:
"
^8.3.0
"
,
"
eslint-plugin-prettier
"
:
"
^3.4.1
"
,
"
eslint-plugin-prettier
"
:
"
^3.4.1
"
,
...
@@ -55,7 +56,7 @@
...
@@ -55,7 +56,7 @@
"
ws
"
:
"
^8.3.0
"
"
ws
"
:
"
^8.3.0
"
},
},
"peerDependencies"
:
{
"peerDependencies"
:
{
"koishi"
:
"^4.
7.5
"
"koishi"
:
"^4.
8.2
"
},
},
"jest"
:
{
"jest"
:
{
"moduleFileExtensions"
:
[
"moduleFileExtensions"
:
[
...
...
src/config.ts
View file @
33427980
// import 'source-map-support/register';
// import 'source-map-support/register';
import
{
SchemaProperty
,
RegisterSchema
,
SchemaClass
}
from
'
koishi-thirdeye
'
;
import
{
SchemaProperty
,
RegisterSchema
,
SchemaClass
}
from
'
koishi-thirdeye
'
;
import
{
Quester
}
from
'
koishi
'
;
import
{
Quester
,
Schema
}
from
'
koishi
'
;
import
{
PicMiddleware
,
PicMiddlewareInfo
,
PicSourceInfo
}
from
'
./def
'
;
import
{
PicMiddleware
,
PicMiddlewareInfo
,
PicSourceInfo
}
from
'
./def
'
;
@
RegisterSchema
()
@
RegisterSchema
()
...
@@ -18,7 +18,7 @@ export class PicsPluginConfig {
...
@@ -18,7 +18,7 @@ export class PicsPluginConfig {
@
SchemaProperty
({
description
:
'
使用 Base64 发送图片结果。
'
,
default
:
false
})
@
SchemaProperty
({
description
:
'
使用 Base64 发送图片结果。
'
,
default
:
false
})
useBase64
:
boolean
;
useBase64
:
boolean
;
@
SchemaProperty
({
type
:
Quester
.
createSchema
(
),
default
:
{}
})
@
SchemaProperty
({
type
:
Schema
.
object
({}
),
default
:
{}
})
httpConfig
:
Quester
.
Config
;
httpConfig
:
Quester
.
Config
;
@
SchemaProperty
({
@
SchemaProperty
({
...
...
src/index.ts
View file @
33427980
...
@@ -4,7 +4,7 @@ import { PicsPluginConfig } from './config';
...
@@ -4,7 +4,7 @@ import { PicsPluginConfig } from './config';
import
_
from
'
lodash
'
;
import
_
from
'
lodash
'
;
import
{
segment
,
Quester
}
from
'
koishi
'
;
import
{
segment
,
Quester
}
from
'
koishi
'
;
import
{
import
{
Base
Plugin
,
Starter
Plugin
,
Caller
,
Caller
,
CommandExample
,
CommandExample
,
CommandLocale
,
CommandLocale
,
...
@@ -31,18 +31,15 @@ export * from './picsource';
...
@@ -31,18 +31,15 @@ export * from './picsource';
export
*
from
'
./def
'
;
export
*
from
'
./def
'
;
declare
module
'
koishi
'
{
declare
module
'
koishi
'
{
// eslint-disable-next-line @typescript-eslint/no-namespace
interface
Context
{
namespace
Context
{
interface
Services
{
pics
:
PicsContainer
;
pics
:
PicsContainer
;
}
}
}
}
}
@
Provide
(
'
pics
'
,
{
immediate
:
true
})
@
Provide
(
'
pics
'
,
{
immediate
:
true
})
@
DefinePlugin
({
name
:
'
pics
'
,
schema
:
PicsPluginConfig
})
@
DefinePlugin
({
name
:
'
pics
'
})
export
default
class
PicsContainer
export
default
class
PicsContainer
extends
BasePlugin
<
PicsPluginConfig
>
extends
StarterPlugin
(
PicsPluginConfig
)
implements
LifecycleEvents
implements
LifecycleEvents
{
{
private
sources
=
new
Map
<
PicSource
,
()
=>
boolean
>
();
private
sources
=
new
Map
<
PicSource
,
()
=>
boolean
>
();
...
...
src/middleware.ts
View file @
33427980
import
{
Awaitable
,
Context
,
Logger
,
Schema
}
from
'
koishi
'
;
import
{
Awaitable
,
Context
,
Logger
,
Schema
}
from
'
koishi
'
;
import
{
PicMiddlewareConfig
}
from
'
./config
'
;
import
{
PicMiddlewareConfig
}
from
'
./config
'
;
import
{
import
{
BasePlugin
,
CreatePluginFactory
,
CreatePluginFactory
,
Inject
,
Inject
,
InjectLogger
,
InjectLogger
,
...
@@ -9,13 +8,14 @@ import {
...
@@ -9,13 +8,14 @@ import {
PartialDeep
,
PartialDeep
,
Reusable
,
Reusable
,
schemaFromClass
,
schemaFromClass
,
StarterPlugin
,
}
from
'
koishi-thirdeye
'
;
}
from
'
koishi-thirdeye
'
;
import
PicsContainer
,
{
PicMiddlewareInfo
}
from
'
./index
'
;
import
PicsContainer
,
{
PicMiddlewareInfo
}
from
'
./index
'
;
import
{
PicMiddleware
,
PicNext
}
from
'
./def
'
;
import
{
PicMiddleware
,
PicNext
}
from
'
./def
'
;
@
Reusable
()
@
Reusable
()
export
class
BasePicMiddlewarePlugin
export
class
BasePicMiddlewarePlugin
extends
BasePlugin
<
PicMiddlewareConfig
>
extends
StarterPlugin
(
PicMiddlewareConfig
)
implements
PicMiddleware
,
LifecycleEvents
implements
PicMiddleware
,
LifecycleEvents
{
{
@
Inject
(
true
)
@
Inject
(
true
)
...
@@ -42,7 +42,7 @@ export const PicMiddlewarePlugin = CreatePluginFactory(
...
@@ -42,7 +42,7 @@ export const PicMiddlewarePlugin = CreatePluginFactory(
export
function
PlainPicMiddlewarePlugin
<
C
>
(
dict
:
{
export
function
PlainPicMiddlewarePlugin
<
C
>
(
dict
:
{
[
K
in
keyof
C
]:
Schema
<
C
[
K
]
>
;
[
K
in
keyof
C
]:
Schema
<
C
[
K
]
>
;
})
{
})
{
const
Config
=
schemaFromClass
(
PicMiddlewareConfig
)
as
Schema
<
const
Config
=
schemaFromClass
(
PicMiddlewareConfig
)
as
unknown
as
Schema
<
PartialDeep
<
PicMiddlewareConfig
&
C
>
,
PartialDeep
<
PicMiddlewareConfig
&
C
>
,
PicMiddlewareConfig
&
C
PicMiddlewareConfig
&
C
>
;
>
;
...
...
src/picsource.ts
View file @
33427980
...
@@ -82,7 +82,7 @@ export const PicSourcePlugin = CreatePluginFactory(
...
@@ -82,7 +82,7 @@ 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
=
schemaFromClass
(
PicSourceConfig
)
as
Schema
<
const
Config
=
schemaFromClass
(
PicSourceConfig
)
as
unknown
as
Schema
<
PartialDeep
<
PicSourceConfig
&
C
>
,
PartialDeep
<
PicSourceConfig
&
C
>
,
PicSourceConfig
&
C
PicSourceConfig
&
C
>
;
>
;
...
...
webpack.config.js
View file @
33427980
const
path
=
require
(
'
path
'
);
const
path
=
require
(
'
path
'
);
const
packgeInfo
=
require
(
'
./package.json
'
);
const
packgeInfo
=
require
(
'
./package.json
'
);
const
{
ESBuildMinifyPlugin
}
=
require
(
'
esbuild-loader
'
);
function
externalsFromDep
()
{
function
externalsFromDep
()
{
return
Object
.
fromEntries
(
return
Object
.
fromEntries
(
...
@@ -43,4 +44,11 @@ module.exports = {
...
@@ -43,4 +44,11 @@ module.exports = {
koishi
:
'
koishi
'
,
koishi
:
'
koishi
'
,
...(
packAll
?
{}
:
externalsFromDep
()),
...(
packAll
?
{}
:
externalsFromDep
()),
},
},
optimization
:
{
minimizer
:
[
new
ESBuildMinifyPlugin
({
keepNames
:
true
,
}),
],
},
};
};
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