Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
504dce3
chore(local): init webui
Lipraty Apr 3, 2024
9460a67
Merge branch 'main' into local-webui
Lipraty Aug 14, 2024
134a891
Merge branch 'main' into local-webui
Lipraty Jul 28, 2025
c17344e
sync of main
Lipraty Jul 28, 2025
af29f7b
refactor(local): simplify
Lipraty Jul 29, 2025
9b2f027
fix(local): fail deps
Lipraty Jul 29, 2025
e23bf5a
docs(local): update
Lipraty Jul 29, 2025
04ee863
feat(local): refactor scraper. add author field and support for addit…
Lipraty Jul 29, 2025
a524708
feat(local): add proxy support.
Lipraty Jul 30, 2025
e8d4de3
feat(local): add user index management with load and save functionality
Lipraty Jul 31, 2025
a1af3d0
feat(local): add user index management and data provider
Lipraty Jul 31, 2025
0d6b340
chore(local): impl simple queue
Lipraty Aug 6, 2025
ce08c69
feat(local): simpiify entry and refactor file proxy server
Lipraty Aug 6, 2025
4d591cb
chore(local): move types
Lipraty Aug 6, 2025
efa4e7a
chore(local): add i18n support in notifier
Lipraty Aug 6, 2025
129119d
feat(local): update console events and manager, add i18n support
Lipraty Aug 7, 2025
bc2b788
fix(local): build index by condition
Lipraty Aug 7, 2025
c378bba
fix(local): use full path for image scanning and fix typo
Lipraty Aug 7, 2025
b6e50fe
fix(local): replace pipeline with streaming
Lipraty Aug 7, 2025
e614b89
chore(local): edge case check and bug fix
Lipraty Aug 7, 2025
3a37c4e
fix(local): add image titile parame
Lipraty Aug 7, 2025
6ec6e9c
feat(local): add image dimensions support and update types. fix conso…
Lipraty Aug 14, 2025
1729fd6
chore(local): update type definitions
Lipraty Aug 14, 2025
2ed38be
chore: change log message
Lipraty Jan 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 34 additions & 18 deletions docs/zh-CN/plugins/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@

图源文件夹,支持多个不同的文件夹

#### storage

- 类型: `ENUM`
- 选项: `file | database`
- 默认值: `file`

图源存数据存储方式,`file` 为文件存储,`database` 为数据库存储

#### reload
#### buildByReload

- 类型: `boolean`
- 默认值: `false`
Expand All @@ -46,6 +38,13 @@

图源支持的语言

#### proxy

- 类型: `boolean`
- 默认值: `false`

是否启用链接代理,如果启用,插件将使用代理的本地图片链接,而不是本地文件路径。

### 文件设置

#### scraper
Expand All @@ -72,15 +71,15 @@

### 使用

插件设置中 `scraper` 默认值可得出大致的使用方式:当 `scraper` 为 `{filename}-{tag}` 时,文件名为 `foo-[bar].jpg` 的图片将被刮削为 `{name: 'foo', tag: ['bar'], ...}`
插件设置中 `scraper` 默认值可得出大致的使用方式:当 `scraper` 为 `{filename}-{tag}` 时,文件名为 `foo-[bar].jpg` 的图片将被刮削为 `{name: 'foo', tags: ['bar'], ...}`

即:文件名为 `foo` 的图片,其拥有 `bar` 这个 tags
即:文件名为 `foo` 的图片,其拥有 `bar` 这个 tags

### 语法

#### `#...#`

- 类型: `string`
- 类型: `name | meta | index`
- 默认值: `name`
- 示例: `#name#{fliename}-{tag}`

Expand All @@ -90,6 +89,13 @@

1. `name`: 文件名模式
2. `meta`: 文件元信息模式(开发中)
3. `index`: 外部索引模式(开发中)

#### `{hidden}`

> 该语法应当在 `#...#` 语法后的第一个,否则将忽略

匹配 `.` 开头的隐藏文件,不设置的情况下将忽略隐藏文件

#### `{filename}`

Expand All @@ -105,17 +111,27 @@

指示标签所在的位置,标签将被刮削为 `tag`,并作为图片的 `tags` 属性

#### `{nsfw}`(WIP)
#### `{nsfw}`

- 类型: `boolean | 'furry' | 'guro' | 'shota' | 'bl'`
- 默认值: `nsfw=false`
- 默认值: `false`

指示图片是否为 nsfw,若为 `boolean` 类型,则直接将其作为 `nsfw` 属性开关,若为 `string` 类型,则将其作为 `nsfw` 属性的值,并且 `nsfw` 总是为 `true`

#### `{author}`

指示图片是否为 nsfw,若为 `boolean` 类型,则直接将其作为 `nsfw` 属性,若为 `string` 类型,则将其作为 `nsfw` 属性的值
- 类型: `string`

指示图片作者名称,作者将被刮削为 `author`,并作为图片的 `author` 属性

#### `+`

忽略后续的内容不作为元信息处理
- 示例:`{filename}-{author}+{tag}`

#### `.`
忽略后续的内容不作为元信息处理,如示例所示,`{tag}` 将被忽略

匹配 `.` 开头的隐藏文件,不设置的情况下将忽略隐藏文件
## 外部索引

外部索引一般存储在 `./data/booru-local` 文件夹中,包含了所有图片的元信息索引。这个文件通常由插件在初次加载时生成,并且除非配置了 `buildByReload` 选项,否则不会在每次启动时重新生成。

索引文件名称为 `index.[plugin id].json`,其中 `[plugin id]` 是插件的唯一标识符。你不应该手动修改这个文件,因为插件提供了 WebUI 界面来方便的管理与编辑索引,经由 WebUI 管理的索引会保存为 `index.user.[plugin id].json`,该索引会覆盖基本索引的内容,如果因为特殊情况需要手动修改索引文件,请确保遵循正确的格式。
11 changes: 11 additions & 0 deletions packages/local/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Context } from '@koishijs/client'

import Main from './main.vue'

export default (ctx: Context) => {
ctx.page({
name: 'Local WebUI',
path: '/booru-local-ui',
component: Main,
})
}
17 changes: 17 additions & 0 deletions packages/local/client/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<k-layout>
<div class="flex flex-col h-full">
<k-content class="flex-1">

</k-content>
</div>
</k-layout>
</template>

<script setup lang="ts">

</script>

<style scoped>

</style>
11 changes: 11 additions & 0 deletions packages/local/client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"rootDir": ".",
"module": "esnext",
"moduleResolution": "node",
"types": [
"@koishijs/client/global",
],
},
"include": ["."],
}
29 changes: 26 additions & 3 deletions packages/local/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-plugin-booru-local",
"description": "Image service from local directories for Koishi",
"version": "1.2.1",
"version": "2.0.0",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down Expand Up @@ -40,18 +40,41 @@
},
"service": {
"require": [
"booru"
"booru",
"server",
"database"
],
"optional": [
"database"
"console",
"notifier"
]
}
},
"peerDependencies": {
"@koishijs/console": "^5.28.0",
"koishi": "^4.17.0",
"koishi-plugin-booru": "^1.2.0"
},
"peerDependenciesMeta": {
"@koishijs/plugin-console": {
"optional": true
},
"@koishijs/plugin-notifier": {
"optional": true
},
"koishi-plugin-booru": {
"optional": false
}
},
"devDependencies": {
"@koishijs/client": "^5.28.0",
"@koishijs/plugin-console": "^5.28.0",
"@koishijs/plugin-notifier": "^1.2.1"
},
"publishConfig": {
"provenance": true
},
"dependencies": {
"image-dimensions": "^2.3.0"
}
}
47 changes: 47 additions & 0 deletions packages/local/src/console.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { resolve } from 'node:path'

import { } from '@koishijs/console'
import { Context } from 'koishi'

import { Image } from './types'

declare module '@koishijs/console' {
namespace Console {
interface Services {

}
}

interface Events {
'booru-local/user-locale': (locale: string) => void
'booru-local/image-update': (metadata: Image) => Promise<void>
'booru-local/image-remove': (id: string) => Promise<void>
'booru-local/tags-update': (tags: string[]) => Promise<void>
'booru-local/tags-remove': (tags: number[]) => Promise<void>
}
}

export const inject = ['console']

export function apply(ctx: Context) {
ctx.console.addEntry({
dev: resolve(__dirname, '../client/index.ts'),
prod: resolve(__dirname, '../dist'),
})

ctx.console.addListener('booru-local/image-update', async (metadata) => {
await ctx.booruLocal.updateImage(metadata)
})

ctx.console.addListener('booru-local/image-remove', async (id) => {
await ctx.booruLocal.removeImage(id)
})

ctx.console.addListener('booru-local/tags-update', async (tags) => {
await ctx.booruLocal.updateTags(tags)
})

ctx.console.addListener('booru-local/tags-remove', async (tagIDs) => {
await ctx.booruLocal.removeTags(tagIDs)
})
}
Loading
Loading