diff --git a/plugins/frontend/chat/client/chat.vue b/plugins/frontend/chat/client/chat.vue index 5a5b225a74..015dcad7af 100644 --- a/plugins/frontend/chat/client/chat.vue +++ b/plugins/frontend/chat/client/chat.vue @@ -18,7 +18,7 @@ @@ -46,7 +46,6 @@ import ChatMessage from './message.vue' const pinned = ref(true) const index = ref() -const activeMessage = ref() const messages = storage.create('chat', []) const current = ref('') @@ -93,15 +92,10 @@ function isSuccessive({ quote, userId, channelId }: Message, index: number) { return !quote && !!prev && prev.userId === userId && prev.channelId === channelId } -function handleClick(message: Message) { - activeMessage.value = message -} - function handleSend(content: string) { - if (!activeMessage.value) return - pinned.value = false - const { platform, selfId, channelId, guildId } = activeMessage.value - send('chat', { content, platform, selfId, channelId, guildId }) + if (!current.value) return + const [platform, guildId, channelId] = current.value.split(':') + send('chat', { content, platform, channelId, guildId }) } diff --git a/plugins/frontend/chat/src/index.ts b/plugins/frontend/chat/src/index.ts index e455957dd0..f639a02b94 100644 --- a/plugins/frontend/chat/src/index.ts +++ b/plugins/frontend/chat/src/index.ts @@ -15,7 +15,6 @@ declare module 'koishi' { interface ChatPayload { content: string platform: string - selfId: string channelId: string guildId: string } @@ -44,6 +43,8 @@ const defaultOptions: Config = { export const name = 'chat' +export const using = ['database'] as const + export interface Config extends ClientExtension { refresh?: RefreshConfig logLevel?: number @@ -90,9 +91,11 @@ export function apply(ctx: Context, options: Config = {}) { prod: resolve(__dirname, '../dist'), }) - ctx.console.addListener('chat', async ({ content, platform, selfId, channelId, guildId }) => { + ctx.console.addListener('chat', async ({ content, platform, channelId, guildId }) => { if (ctx.assets) content = await ctx.assets.transform(content) - ctx.bots.get(`${platform}:${selfId}`)?.sendMessage(channelId, content, guildId) + const channel = await ctx.database.getChannel(platform, channelId, ['assignee']) + if (!channel || !channel.assignee) return + ctx.bots.get(`${platform}:${channel.assignee}`)?.sendMessage(channelId, content, guildId) }, { authority: 3 }) ctx.on('chat/receive', async (message) => { diff --git a/plugins/frontend/client/client/components/index.ts b/plugins/frontend/client/client/components/index.ts index e411c4f94d..b861d60f19 100644 --- a/plugins/frontend/client/client/components/index.ts +++ b/plugins/frontend/client/client/components/index.ts @@ -64,8 +64,7 @@ export * from './form' export * from './layout' export * from './notice' -export * from '@satorijs/ui-chat' -export * from '@satorijs/ui-virtual' +export * from '@satorijs/components' export { icons, ChatImage } diff --git a/plugins/frontend/client/package.json b/plugins/frontend/client/package.json index 6bb99f3c13..f1b93630e6 100644 --- a/plugins/frontend/client/package.json +++ b/plugins/frontend/client/package.json @@ -34,8 +34,7 @@ ], "dependencies": { "@koishijs/segment": "^1.1.1", - "@satorijs/ui-chat": "^0.3.0", - "@satorijs/ui-virtual": "^0.3.0", + "@satorijs/components": "^0.3.0", "@types/marked": "^4.0.3", "@vitejs/plugin-vue": "^2.3.1", "@vueuse/core": "^7.7.1", diff --git a/plugins/messages/package.json b/plugins/messages/package.json deleted file mode 100644 index 4753f55485..0000000000 --- a/plugins/messages/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "@koishijs/plugin-messages", - "version":"0.0.1", - "main": "lib/index.js", - "typings": "lib/index.d.ts", - "peerDependencies": { - "koishi": "^4.4.2" - } -} \ No newline at end of file diff --git a/plugins/messages/src/types.ts b/plugins/messages/src/types.ts deleted file mode 100644 index 1eb87402e8..0000000000 --- a/plugins/messages/src/types.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface Message { - id?: number - content: string - messageId: string - platform: string - guildId: string - userId: string - timestamp: Date - quoteId?: string - username: string - nickname: string - channelId: string - selfId: string - lastUpdated?: Date - deleted?: number -} diff --git a/plugins/messages/tsconfig.json b/plugins/messages/tsconfig.json deleted file mode 100644 index e193a11f31..0000000000 --- a/plugins/messages/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.base", - "compilerOptions": { - "rootDir": "src", - "outDir": "lib", - }, - "include": [ - "src", - ], -} \ No newline at end of file