From 8a4f2b4dae3fa5b247f5869f96143e3edf13619a Mon Sep 17 00:00:00 2001 From: CyanSalt Date: Fri, 22 Nov 2024 11:04:59 +0800 Subject: [PATCH] fix(addon-manager): order --- .../src/renderer/AddonManagerPane.vue | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/addons/addon-manager/src/renderer/AddonManagerPane.vue b/addons/addon-manager/src/renderer/AddonManagerPane.vue index e4af8921..c5f553e9 100644 --- a/addons/addon-manager/src/renderer/AddonManagerPane.vue +++ b/addons/addon-manager/src/renderer/AddonManagerPane.vue @@ -3,6 +3,7 @@ import { ipcRenderer } from '@commas/electron-ipc' import type { AddonInfo } from '@commas/types/addon' import type { TerminalTab } from '@commas/types/terminal' import * as commas from 'commas:api/renderer' +import { sortBy } from 'lodash' import { onMounted, watchEffect } from 'vue' import { useDiscoveredAddons } from './compositions' @@ -34,16 +35,23 @@ watchEffect(() => { }) const addonList = $computed(() => { - return discoveredAddons - .filter(addon => { - if (!isBuiltinAddonsVisible && addon.type === 'builtin') return false - return true - }) - .map(addon => ({ - addon, - manifest: commas.remote.getI18nManifest(addon.manifest), - enabled: enabledAddons.includes(addon.name), - })) + return sortBy( + discoveredAddons + .filter(addon => { + if (!isBuiltinAddonsVisible && addon.type === 'builtin') return false + return true + }) + .map(addon => ({ + addon, + manifest: commas.remote.getI18nManifest(addon.manifest), + enabled: enabledAddons.includes(addon.name), + })), + [ + ({ enabled }) => (enabled ? 0 : 1), + ({ addon }) => (addon.type === 'builtin' ? 1 : 0), + ({ addon }) => addon.name, + ], + ) }) function toggle(addon: AddonInfo, enabled: boolean) {