diff --git a/.vscode/extensions.json b/.vscode/extensions.json index c0a6e5a..5701189 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,5 @@ { - "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] + "recommendations": [ + "Vue.volar" + ] } diff --git a/src/components/Tabs.vue b/src/components/Tabs.vue index cf90705..c8a536b 100644 --- a/src/components/Tabs.vue +++ b/src/components/Tabs.vue @@ -35,12 +35,14 @@ const props = withDefaults(defineProps<{ tabClass?: string bodyClass?: string url?:boolean + clearQuery?:boolean }>(), { id: 'tabs', param: 'tab', label: (tab:string) => humanize(tab), bodyClass: 'p-4', - url: true + url:true, + clearQuery:false, }) const tabNames = computed(() => Object.keys(props.tabs)) @@ -55,7 +57,7 @@ function select(tab:string) { selected.value = tab if (props.url) { const firstTab = tabNames.value[0] - pushState({ tab: tab === firstTab ? undefined : tab }) + pushState({ tab: tab === firstTab ? undefined : tab }, props.clearQuery) } } diff --git a/src/use/utils.ts b/src/use/utils.ts index 27e263c..1dde226 100644 --- a/src/use/utils.ts +++ b/src/use/utils.ts @@ -1,7 +1,7 @@ import type { Ref } from "vue" import { isRef, nextTick, unref } from "vue" import type { ApiRequest, IReturn, TransitionRules } from "@/types" -import { ApiResult, appendQueryString, dateFmt, enc, JsonServiceClient, nameOf, omit, setQueryString, toTime } from "@servicestack/client" +import { ApiResult, appendQueryString, dateFmt, enc, JsonServiceClient, lastLeftPart, nameOf, omit, setQueryString, toTime } from "@servicestack/client" import { assetsPathResolver } from "./config" import { Sole } from "./config" @@ -139,9 +139,11 @@ export function parseJson(json?:string|null) { return typeof json == 'string' ? JSON.parse(json) : null } -export function pushState(args:Record) { - if (typeof history != 'undefined') { - const url = setQueryString(location.href, args) +export function pushState(args:Record, clear?:boolean) { + if (typeof history != 'undefined') { + const url = clear + ? setQueryString(location.href, args) + : appendQueryString(lastLeftPart(location.href,'?'), args) history.pushState({}, '', url) } }