From 122a01fe730e116fa3f54a3a791631b5987b72a2 Mon Sep 17 00:00:00 2001 From: Howard Date: Thu, 29 May 2025 23:56:33 +0800 Subject: [PATCH] Add basic simplify title in the navbar. --- pages/desktop.vue | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/pages/desktop.vue b/pages/desktop.vue index b6bf178..b7d339d 100644 --- a/pages/desktop.vue +++ b/pages/desktop.vue @@ -263,6 +263,22 @@ onMounted(async () => { } }); +const navBarDisplayText = (text: string) => { + if (!text) { + return; + } + const trimSpaces = text.trim(); + const regex = /.{0,7}/; + console.log("asdasda"); + if (trimSpaces.length <= 7) { + return text; + } + const maxStay = text.match(regex); + const filterToMax7Chars = maxStay[0] + "..." + return filterToMax7Chars; +} + + const findAndOpenWindow = (windowName: string, windowTitle?: string) => { const app = associAppWindow.find((app) => app.name === windowName); @@ -301,13 +317,13 @@ const findAndOpenWindow = (windowName: string, windowTitle?: string) => { // Add to navbar const windowNameVal2 = globalWindowVal.value.get(windowName).windowCount === 1 - ? app.title - : app.title + + ? navBarDisplayText(app.title) + : navBarDisplayText(app.title) + "(" + globalWindowVal.value.get(windowName).windowCount + ")"; currentNavBar.value.push({ - name: windowTitle || windowNameVal2, + name: navBarDisplayText(windowTitle) || windowNameVal2, icon: "anything", action: "idk", flash: true,