feat: add tab close menu actions (#24)

Co-authored-by: SuLe <sule@SuLedeMacBook-Air.local>
This commit is contained in:
SuLea-IT
2026-04-30 16:35:01 +08:00
committed by GitHub
co-authored by SuLe
parent 9ee31aa188
commit aea6bf3239
6 changed files with 133 additions and 22 deletions
+15
View File
@@ -2,6 +2,7 @@ import { defineStore } from "pinia";
import { ref } from "vue";
import type { QueryTab } from "@/types/database";
import { orderPinnedFirst } from "@/lib/pinnedItems";
import { closeAllTabsState, closeOtherTabsState } from "@/lib/tabCloseActions";
import * as api from "@/lib/tauri";
export const useQueryStore = defineStore("query", () => {
@@ -46,6 +47,18 @@ export const useQueryStore = defineStore("query", () => {
}
}
function closeOtherTabs(id: string) {
const next = closeOtherTabsState(tabs.value, activeTabId.value, id);
tabs.value = next.tabs;
activeTabId.value = next.activeTabId;
}
function closeAllTabs() {
const next = closeAllTabsState(tabs.value, activeTabId.value);
tabs.value = next.tabs;
activeTabId.value = next.activeTabId;
}
function updateSql(id: string, sql: string) {
const tab = tabs.value.find((t) => t.id === id);
if (tab) tab.sql = sql;
@@ -123,6 +136,8 @@ export const useQueryStore = defineStore("query", () => {
activeTabId,
createTab,
closeTab,
closeOtherTabs,
closeAllTabs,
updateSql,
togglePinnedTab,
updateDatabase,