From 04753c61960ece9cd83fa0111fba113038a0d6b1 Mon Sep 17 00:00:00 2001 From: grml Date: Mon, 8 Jun 2026 00:53:00 +0800 Subject: [PATCH 1/2] fix: corrected handling and resolution of theme colors for tab instead of using the hardcoded items --- src/components/TabSystem/TabSystem.vue | 12 ++++++++++-- src/libs/project/BedrockProject.ts | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/components/TabSystem/TabSystem.vue b/src/components/TabSystem/TabSystem.vue index 7aea14d71..fdd820868 100644 --- a/src/components/TabSystem/TabSystem.vue +++ b/src/components/TabSystem/TabSystem.vue @@ -55,6 +55,13 @@ const contextMenu: Ref = ref(null) const contextMenuTab: ShallowRef = shallowRef(null) const contextMenuTabActions: Ref = ref([]) +function tabColor(tab: Tab): string { + if (!(tab instanceof FileTab)) return 'text' + if (!(ProjectManager.currentProject instanceof BedrockProject)) return 'text' + + return ProjectManager.currentProject.getPackFromPath(tab.path)?.color ?? 'text' +} + function getTabFromTarget(target: HTMLElement): HTMLElement | null { if (target.dataset.tab === 'tab') return target @@ -204,8 +211,9 @@ function dragEnd(event: DragEvent) {
- +

bestLength) { + bestPackId = packId + bestLength = packPath.length + } + } + + if (bestPackId === null) return null + + return this.packDefinitions.find((packDefinition) => packDefinition.id === bestPackId) ?? null + } } From cfefcd53b861f377020927efb1ddba7a5cef594f Mon Sep 17 00:00:00 2001 From: Outer Cloud Date: Sat, 27 Jun 2026 19:46:10 -0400 Subject: [PATCH 2/2] cleanup tab coloring --- src/components/TabSystem/TabSystem.vue | 38 +++++++++++++++++++------- src/libs/project/BedrockProject.ts | 19 ------------- src/libs/project/Project.ts | 12 ++++++++ 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/components/TabSystem/TabSystem.vue b/src/components/TabSystem/TabSystem.vue index fdd820868..83806bd16 100644 --- a/src/components/TabSystem/TabSystem.vue +++ b/src/components/TabSystem/TabSystem.vue @@ -13,12 +13,13 @@ import { FileTab } from './FileTab' import { Settings } from '@/libs/settings/Settings' import { TabManager } from './TabManager' import { computed, ComputedRef, Ref, ref, ShallowRef, shallowRef } from 'vue' -import { ProjectManager } from '@/libs/project/ProjectManager' +import { ProjectManager, useCurrentProject } from '@/libs/project/ProjectManager' import { BedrockProject } from '@/libs/project/BedrockProject' import { useTabActions } from '@/libs/actions/tab/TabActionManager' import { ActionManager } from '@/libs/actions/ActionManager' import { useTranslate } from '@/libs/locales/Locales' import { Tab } from './Tab' +import { IPackType } from 'mc-project-core' const props = defineProps({ instance: { @@ -55,13 +56,6 @@ const contextMenu: Ref = ref(null) const contextMenuTab: ShallowRef = shallowRef(null) const contextMenuTabActions: Ref = ref([]) -function tabColor(tab: Tab): string { - if (!(tab instanceof FileTab)) return 'text' - if (!(ProjectManager.currentProject instanceof BedrockProject)) return 'text' - - return ProjectManager.currentProject.getPackFromPath(tab.path)?.color ?? 'text' -} - function getTabFromTarget(target: HTMLElement): HTMLElement | null { if (target.dataset.tab === 'tab') return target @@ -144,6 +138,30 @@ function dragEnd(event: DragEvent) { TabSystem.draggingTab.value = null dragLevel = 0 } + +const currentProject = useCurrentProject() + +const currentProjectPackDefinitions: Ref = computed(() => { + if (!currentProject.value) return [] + if (!(currentProject.value instanceof BedrockProject)) return [] + + return currentProject.value.packDefinitions.filter((pack: IPackType) => { + if (!currentProject.value) return false + if (!currentProject.value.config) return false + + return Object.keys(currentProject.value.config.packs).includes(pack.id) + }) +}) + +function useTabColor(path: string | null) { + return computed(() => { + if(!currentProject.value) return 'text' + + const packId = currentProject.value.getPackFromPath(path) + + return currentProjectPackDefinitions.value.find(pack => pack.id === packId)?.color ?? 'text' + }) +}