Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
koishi-plugin-picsource-localfs
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-picsource-localfs
Commits
84eff2b4
Commit
84eff2b4
authored
Oct 23, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first
parent
af9356cb
Pipeline
#6391
failed with stages
in 32 seconds
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
169 additions
and
427 deletions
+169
-427
README.md
README.md
+18
-1
package-lock.json
package-lock.json
+130
-410
package.json
package.json
+3
-3
src/LocalSource.ts
src/LocalSource.ts
+8
-6
src/config.ts
src/config.ts
+9
-7
webpack.config.js
webpack.config.js
+1
-0
No files found.
README.md
View file @
84eff2b4
# koishi-plugin-picsource-localfs
# koishi-plugin-picsource-localfs
Koishi 的本地图源插件
Koishi 的本地图源插件。
\ No newline at end of file
## 安装
### npm
```
bash
npm
install
koishi-plugin-picsource-localfs
```
## 配置
*
`sources`
图源实例列表。共通实例属性见
[
`koishi-plugin-pics`
](
https://code.mycard.moe/3rdeye/koishi-plugin-pics
)
的
`PicSourceInfo`
定义。
*
`name`
实例名称。
*
`path`
图片路径。必填。
*
`patterns`
允许的文件后缀。使用
`*`
表示当前目录,
`**`
表示递归所有子目录。
*
`exclude`
排除的路径。
*
`displayFilename`
是否显示文件名。默认
`true`
。
\ No newline at end of file
package-lock.json
View file @
84eff2b4
This source diff could not be displayed because it is too large. You can
view the blob
instead.
package.json
View file @
84eff2b4
...
@@ -26,11 +26,12 @@
...
@@ -26,11 +26,12 @@
},
},
"homepage"
:
"
https://code.mycard.moe/3rdeye/koishi-plugin-picsource-localfs
"
,
"homepage"
:
"
https://code.mycard.moe/3rdeye/koishi-plugin-picsource-localfs
"
,
"dependencies"
:
{
"dependencies"
:
{
"
koishi-utils-schemagen
"
:
"
^1.1.7
"
,
"
source-map-support
"
:
"
^0.5.20
"
"
source-map-support
"
:
"
^0.5.20
"
},
},
"peerDependencies"
:
{
"peerDependencies"
:
{
"
koishi
"
:
"
^4.0.0-alpha.11
"
,
"
koishi
"
:
"
^4.0.0-alpha.11
"
,
"
koishi-plugin-pics
"
:
"
^1.0.
0
"
"koishi-plugin-pics"
:
"
^1.0.
2
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"
@types/node
"
:
"
^16.11.4
"
,
"
@types/node
"
:
"
^16.11.4
"
,
...
@@ -40,8 +41,7 @@
...
@@ -40,8 +41,7 @@
"
eslint-config-prettier
"
:
"
^8.3.0
"
,
"
eslint-config-prettier
"
:
"
^8.3.0
"
,
"
eslint-plugin-prettier
"
:
"
^3.4.1
"
,
"
eslint-plugin-prettier
"
:
"
^3.4.1
"
,
"
koishi
"
:
"
^4.0.0-alpha.11
"
,
"
koishi
"
:
"
^4.0.0-alpha.11
"
,
"
koishi-plugin-pics
"
:
"
^1.0.0
"
,
"
koishi-plugin-pics
"
:
"
^1.0.4
"
,
"
koishi-utils-schemagen
"
:
"
^1.1.5
"
,
"
prettier
"
:
"
^2.4.1
"
,
"
prettier
"
:
"
^2.4.1
"
,
"
raw-loader
"
:
"
^4.0.2
"
,
"
raw-loader
"
:
"
^4.0.2
"
,
"
read-dir-deep
"
:
"
^7.0.1
"
,
"
read-dir-deep
"
:
"
^7.0.1
"
,
...
...
src/LocalSource.ts
View file @
84eff2b4
...
@@ -13,12 +13,14 @@ export class LocalSource extends PicSource {
...
@@ -13,12 +13,14 @@ export class LocalSource extends PicSource {
async
randomPic
(
picTags
:
string
[]):
Promise
<
PicResult
>
{
async
randomPic
(
picTags
:
string
[]):
Promise
<
PicResult
>
{
const
absolutePath
=
path
.
resolve
(
process
.
cwd
(),
this
.
config
.
path
);
const
absolutePath
=
path
.
resolve
(
process
.
cwd
(),
this
.
config
.
path
);
const
files
=
await
readDirDeep
(
absolutePath
,
{
const
files
=
(
await
readDirDeep
(
absolutePath
,
{
absolute
:
true
,
absolute
:
true
,
patterns
:
this
.
config
.
patterns
,
patterns
:
this
.
config
.
patterns
,
gitignore
:
false
,
gitignore
:
false
,
ignore
:
this
.
config
.
exclude
,
ignore
:
this
.
config
.
exclude
,
});
})
).
filter
((
f
)
=>
picTags
.
every
((
t
)
=>
f
.
includes
(
t
)));
if
(
!
files
.
length
)
{
if
(
!
files
.
length
)
{
return
null
;
return
null
;
}
}
...
...
src/config.ts
View file @
84eff2b4
import
'
source-map-support/register
'
;
import
'
source-map-support/register
'
;
import
{
DefineSchema
}
from
'
koishi-utils-schemagen
'
;
import
{
DefineSchema
,
schemaFromClass
}
from
'
koishi-utils-schemagen
'
;
import
{
import
{
PicSourceConfig
,
PicSourceInfo
}
from
'
koishi-plugin-pics
'
;
PicResult
,
PicSource
,
PicSourceConfig
,
PicSourceInfo
,
}
from
'
koishi-plugin-pics
'
;
import
{
Context
}
from
'
koishi
'
;
import
{
Context
}
from
'
koishi
'
;
import
{
LocalSource
}
from
'
./LocalSource
'
;
import
{
LocalSource
}
from
'
./LocalSource
'
;
...
@@ -45,8 +40,15 @@ export class LocalSourceConfig
...
@@ -45,8 +40,15 @@ export class LocalSourceConfig
registerInstance
(
ctx
:
Context
)
{
registerInstance
(
ctx
:
Context
)
{
const
instance
=
new
LocalSource
(
ctx
,
this
);
const
instance
=
new
LocalSource
(
ctx
,
this
);
ctx
.
logger
(
'
picsource-localfs
'
)
.
info
(
`Registered localfs pic source
${
instance
.
name
}
.`
);
if
(
ctx
.
pics
)
{
ctx
.
pics
.
addSource
(
instance
,
ctx
);
}
ctx
.
on
(
'
service/pics
'
,
()
=>
{
ctx
.
on
(
'
service/pics
'
,
()
=>
{
if
(
!
ctx
.
pics
)
{
if
(
!
ctx
.
pics
)
{
ctx
.
logger
(
'
picsource-localfs
'
).
warn
(
`Pics container not found.`
);
return
;
return
;
}
}
ctx
.
pics
.
addSource
(
instance
,
ctx
);
ctx
.
pics
.
addSource
(
instance
,
ctx
);
...
...
webpack.config.js
View file @
84eff2b4
...
@@ -28,5 +28,6 @@ module.exports = {
...
@@ -28,5 +28,6 @@ module.exports = {
externals
:
{
externals
:
{
koishi
:
'
koishi
'
,
koishi
:
'
koishi
'
,
'
koishi-plugin-pics
'
:
'
koishi-plugin-pics
'
,
'
koishi-plugin-pics
'
:
'
koishi-plugin-pics
'
,
'
koishi-utils-schemagen
'
:
'
koishi-utils-schemagen
'
,
},
},
};
};
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