mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 10:42:44 +00:00
[SettingUI] Group setting menu items (#3510)
This commit is contained in:
@@ -10,15 +10,21 @@
|
|||||||
/>
|
/>
|
||||||
<Listbox
|
<Listbox
|
||||||
v-model="activeCategory"
|
v-model="activeCategory"
|
||||||
:options="allCategories"
|
:options="groupedMenuTreeNodes"
|
||||||
option-label="translatedLabel"
|
option-label="translatedLabel"
|
||||||
|
option-group-label="label"
|
||||||
|
option-group-children="children"
|
||||||
scroll-height="100%"
|
scroll-height="100%"
|
||||||
:option-disabled="
|
:option-disabled="
|
||||||
(option: SettingTreeNode) =>
|
(option: SettingTreeNode) =>
|
||||||
!queryIsEmpty && !searchResultsCategories.has(option.label ?? '')
|
!queryIsEmpty && !searchResultsCategories.has(option.label ?? '')
|
||||||
"
|
"
|
||||||
class="border-none w-full"
|
class="border-none w-full"
|
||||||
/>
|
>
|
||||||
|
<template #optiongroup>
|
||||||
|
<Divider class="my-0" />
|
||||||
|
</template>
|
||||||
|
</Listbox>
|
||||||
</ScrollPanel>
|
</ScrollPanel>
|
||||||
<Divider layout="vertical" class="mx-1 2xl:mx-4 hidden md:flex" />
|
<Divider layout="vertical" class="mx-1 2xl:mx-4 hidden md:flex" />
|
||||||
<Divider layout="horizontal" class="flex md:hidden" />
|
<Divider layout="horizontal" class="flex md:hidden" />
|
||||||
@@ -103,8 +109,12 @@ const ServerConfigPanel = defineAsyncComponent(
|
|||||||
() => import('./setting/ServerConfigPanel.vue')
|
() => import('./setting/ServerConfigPanel.vue')
|
||||||
)
|
)
|
||||||
|
|
||||||
const { activeCategory, defaultCategory, allCategories, settingCategories } =
|
const {
|
||||||
useSettingUI(defaultPanel)
|
activeCategory,
|
||||||
|
defaultCategory,
|
||||||
|
settingCategories,
|
||||||
|
groupedMenuTreeNodes
|
||||||
|
} = useSettingUI(defaultPanel)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
searchQuery,
|
searchQuery,
|
||||||
@@ -183,14 +193,8 @@ watch(activeCategory, (_, oldValue) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show a separator line above the Keybinding tab */
|
/* Hide the first group separator */
|
||||||
/* This indicates the start of custom setting panels */
|
.settings-sidebar :deep(.p-listbox-option-group:nth-child(1)) {
|
||||||
.settings-sidebar :deep(.p-listbox-option[aria-label='Keybinding']) {
|
display: none;
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-sidebar :deep(.p-listbox-option[aria-label='Keybinding'])::before {
|
|
||||||
@apply content-[''] top-0 left-0 absolute w-full;
|
|
||||||
border-top: 1px solid var(--p-divider-border-color);
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -82,25 +82,34 @@ export function useSettingUI(
|
|||||||
: settingCategories.value[0]
|
: settingCategories.value[0]
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
const translateCategory = (node: SettingTreeNode) => ({
|
||||||
* Translated all categories with labels
|
...node,
|
||||||
*/
|
translatedLabel: t(
|
||||||
const translatedCategories = computed<SettingTreeNode[]>(() => {
|
`settingsCategories.${normalizeI18nKey(node.label)}`,
|
||||||
return [
|
node.label
|
||||||
...settingCategories.value,
|
)
|
||||||
keybindingPanelNode,
|
|
||||||
extensionPanelNode,
|
|
||||||
...serverConfigPanelNodeList.value,
|
|
||||||
aboutPanelNode
|
|
||||||
].map((node) => ({
|
|
||||||
...node,
|
|
||||||
translatedLabel: t(
|
|
||||||
`settingsCategories.${normalizeI18nKey(node.label)}`,
|
|
||||||
node.label
|
|
||||||
)
|
|
||||||
}))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const groupedMenuTreeNodes = computed<SettingTreeNode[]>(() => [
|
||||||
|
// Normal settings stored in the settingStore
|
||||||
|
{
|
||||||
|
key: 'settings',
|
||||||
|
label: 'Application Settings',
|
||||||
|
children: settingCategories.value.map(translateCategory)
|
||||||
|
},
|
||||||
|
// Special settings such as about, keybinding, extension, server-config
|
||||||
|
{
|
||||||
|
key: 'specialSettings',
|
||||||
|
label: 'Special Settings',
|
||||||
|
children: [
|
||||||
|
keybindingPanelNode,
|
||||||
|
extensionPanelNode,
|
||||||
|
aboutPanelNode,
|
||||||
|
...serverConfigPanelNodeList.value
|
||||||
|
].map(translateCategory)
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
activeCategory.value = defaultCategory.value
|
activeCategory.value = defaultCategory.value
|
||||||
})
|
})
|
||||||
@@ -108,7 +117,7 @@ export function useSettingUI(
|
|||||||
return {
|
return {
|
||||||
activeCategory,
|
activeCategory,
|
||||||
defaultCategory,
|
defaultCategory,
|
||||||
allCategories: translatedCategories,
|
groupedMenuTreeNodes,
|
||||||
settingCategories
|
settingCategories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user