feat: process extension settings

This commit is contained in:
Rizumu Ayaka
2025-11-17 17:27:28 +08:00
parent 6001600700
commit c985fff434
2 changed files with 20 additions and 0 deletions

View File

@@ -8,6 +8,8 @@ import type { Settings } from '@/schemas/apiSchema'
import { api } from '@/scripts/api'
import { app } from '@/scripts/app'
import type { TreeNode } from '@/types/treeExplorerTypes'
import { processExtensionSettings } from '@/extensions/dispatch'
import { useErrorHandling } from '@/composables/useErrorHandling'
export const getSettingInfo = (setting: SettingParams) => {
const parts = setting.category || setting.id.split('.')
@@ -46,6 +48,14 @@ export const useSettingStore = defineStore('setting', () => {
const settingValues = ref<Record<string, any>>({})
const settingsById = ref<Record<string, SettingParams>>({})
const { wrapWithErrorHandling } = useErrorHandling()
processExtensionSettings((settings) => {
const _addSetting = wrapWithErrorHandling(addSetting)
for (const setting of settings) {
_addSetting(setting)
}
})
/**
* Check if a setting's value exists, i.e. if the user has set it manually.
* @param key - The key of the setting to check.

View File

@@ -5,6 +5,8 @@ import { computed, ref, toRaw } from 'vue'
import { RESERVED_BY_TEXT_INPUT } from '@/constants/reservedKeyCombos'
import type { KeyCombo, Keybinding } from '@/schemas/keyBindingSchema'
import { processExtensionKeybindings } from '@/extensions/dispatch'
import { useErrorHandling } from '@/composables/useErrorHandling'
export class KeybindingImpl implements Keybinding {
commandId: string
@@ -171,6 +173,14 @@ export const useKeybindingStore = defineStore('keybinding', () => {
}
)
const { wrapWithErrorHandling } = useErrorHandling()
processExtensionKeybindings((keybindings) => {
const addKeybinding = wrapWithErrorHandling(addDefaultKeybinding)
for (const keybinding of keybindings) {
addKeybinding(new KeybindingImpl(keybinding))
}
})
function getKeybindingsByCommandId(commandId: string) {
return keybindingsByCommandId.value[commandId] ?? []
}