feat: Add support for slash commands, optimize command selector logic. (#24723)

This commit is contained in:
GuanMu 2025-08-28 21:13:18 +08:00 • committed by GitHub
commit 27d09d1783
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 274 additions and 32 deletions

View file

@ -7,6 +7,10 @@ import { useTheme } from 'next-themes'
import { setLocaleOnClient } from '@/i18n-config'
import { themeCommand } from './theme'
import { languageCommand } from './language'
import { feedbackCommand } from './feedback'
import { docCommand } from './doc'
import { communityCommand } from './community'
import { accountCommand } from './account'
import i18n from '@/i18n-config/i18next-config'
export const slashAction: ActionItem = {
@ -30,12 +34,20 @@ export const registerSlashCommands = (deps: Record<string, any>) => {
// Register command handlers to the registry system with their respective dependencies
slashCommandRegistry.register(themeCommand, { setTheme: deps.setTheme })
slashCommandRegistry.register(languageCommand, { setLocale: deps.setLocale })
slashCommandRegistry.register(feedbackCommand, {})
slashCommandRegistry.register(docCommand, {})
slashCommandRegistry.register(communityCommand, {})
slashCommandRegistry.register(accountCommand, {})
}
export const unregisterSlashCommands = () => {
// Remove command handlers from registry system (automatically calls each command's unregister method)
slashCommandRegistry.unregister('theme')
slashCommandRegistry.unregister('language')
slashCommandRegistry.unregister('feedback')
slashCommandRegistry.unregister('doc')
slashCommandRegistry.unregister('community')
slashCommandRegistry.unregister('account')
}
export const SlashCommandProvider = () => {