From 5490ccf4f0b08bec46dde30c86bfd26bb82ef847 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Thu, 8 Aug 2024 20:09:49 -0400 Subject: [PATCH] Assign default category Others (#339) * Assign default category Others * nit --- src/stores/settingStore.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/stores/settingStore.ts b/src/stores/settingStore.ts index 1061a0dda..3e2067fef 100644 --- a/src/stores/settingStore.ts +++ b/src/stores/settingStore.ts @@ -30,9 +30,23 @@ export const useSettingStore = defineStore('setting', { }), getters: { settingTree(): SettingTreeNode { - return buildTree(Object.values(this.settings), (setting: SettingParams) => - setting.id.split('.') + const root = buildTree( + Object.values(this.settings), + (setting: SettingParams) => setting.id.split('.') ) + + const floatingSettings = root.children.filter((node) => node.leaf) + if (floatingSettings.length) { + root.children = root.children.filter((node) => !node.leaf) + root.children.push({ + key: 'Other', + label: 'Other', + leaf: false, + children: floatingSettings + }) + } + + return root } }, actions: {