Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
3 changes: 3 additions & 0 deletions astrbot/core/config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -3248,4 +3248,7 @@ class ChatProviderTemplate(TypedDict):
"list": [],
"object": {},
"template_list": [],
"palette": "",
"palette_rgb": "",
"palette_hsv": "",
}
4 changes: 3 additions & 1 deletion astrbot/dashboard/routes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ def validate(data: dict, metadata: dict = schema, path=""):
errors.append(
f"错误的类型 {path}{key}: 期望是 bool, 得到了 {type(value).__name__}",
)
elif meta["type"] in ["string", "text"] and not isinstance(value, str):
elif meta["type"] in ["string", "text", "palette", "palette_rgb", "palette_hsv"] and not isinstance(
value, str
):
errors.append(
f"错误的类型 {path}{key}: 期望是 string, 得到了 {type(value).__name__}",
)
Expand Down
15 changes: 15 additions & 0 deletions dashboard/src/components/shared/ConfigItemRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@
class="config-field"
/>

<PaletteEditor
v-else-if="itemMeta?.type === 'palette' || itemMeta?.type === 'palette_rgb' || itemMeta?.type === 'palette_hsv'"
:model-value="modelValue"
@update:model-value="emitUpdate"
:format="getPaletteFormat(itemMeta?.type)"
class="config-field"
/>

<ObjectEditor
v-else-if="itemMeta?.type === 'dict'"
:model-value="modelValue"
Expand Down Expand Up @@ -214,6 +222,7 @@ import PersonaSelector from './PersonaSelector.vue'
import KnowledgeBaseSelector from './KnowledgeBaseSelector.vue'
import PluginSetSelector from './PluginSetSelector.vue'
import T2ITemplateEditor from './T2ITemplateEditor.vue'
import PaletteEditor from './PaletteEditor.vue'
import { useI18n, useModuleI18n } from '@/i18n/composables'

const props = defineProps({
Expand Down Expand Up @@ -296,6 +305,12 @@ function getSpecialName(value) {
function getSpecialSubtype(value) {
return parseSpecialValue(value).subtype
}

function getPaletteFormat(type) {
if (type === 'palette_rgb') return 'rgb'
if (type === 'palette_hsv') return 'hsv'
return 'hex'
}
</script>

<style scoped>
Expand Down
Loading