|
|
@ -1,6 +1,7 @@ |
|
|
|
import type { FilterType, SortType, ViewType, ViewTypes } from 'nocodb-sdk' |
|
|
|
import type { FilterType, SortType, ViewType, ViewTypes } from 'nocodb-sdk' |
|
|
|
import { acceptHMRUpdate, defineStore } from 'pinia' |
|
|
|
import { acceptHMRUpdate, defineStore } from 'pinia' |
|
|
|
import type { ViewPageType } from '~/lib' |
|
|
|
import type { ViewPageType } from '~/lib' |
|
|
|
|
|
|
|
import { navigateToBlankTargetOpenOption, useMagicKeys } from '#imports' |
|
|
|
|
|
|
|
|
|
|
|
export const useViewsStore = defineStore('viewsStore', () => { |
|
|
|
export const useViewsStore = defineStore('viewsStore', () => { |
|
|
|
const { $api } = useNuxtApp() |
|
|
|
const { $api } = useNuxtApp() |
|
|
@ -27,6 +28,8 @@ export const useViewsStore = defineStore('viewsStore', () => { |
|
|
|
|
|
|
|
|
|
|
|
const { activeWorkspaceId } = storeToRefs(useWorkspace()) |
|
|
|
const { activeWorkspaceId } = storeToRefs(useWorkspace()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { meta: metaKey, ctrlKey } = useMagicKeys() |
|
|
|
|
|
|
|
|
|
|
|
const recentViews = computed<RecentView[]>(() => |
|
|
|
const recentViews = computed<RecentView[]>(() => |
|
|
|
allRecentViews.value.filter((f) => f.workspaceId === activeWorkspaceId.value).splice(0, 10), |
|
|
|
allRecentViews.value.filter((f) => f.workspaceId === activeWorkspaceId.value).splice(0, 10), |
|
|
|
) |
|
|
|
) |
|
|
@ -216,6 +219,8 @@ export const useViewsStore = defineStore('viewsStore', () => { |
|
|
|
hardReload?: boolean |
|
|
|
hardReload?: boolean |
|
|
|
doNotSwitchTab?: boolean |
|
|
|
doNotSwitchTab?: boolean |
|
|
|
}) => { |
|
|
|
}) => { |
|
|
|
|
|
|
|
const cmdOrCtrl = isMac() ? metaKey.value : ctrlKey.value |
|
|
|
|
|
|
|
|
|
|
|
const routeName = 'index-typeOrId-baseId-index-index-viewId-viewTitle-slugs' |
|
|
|
const routeName = 'index-typeOrId-baseId-index-index-viewId-viewTitle-slugs' |
|
|
|
|
|
|
|
|
|
|
|
let baseIdOrBaseId = baseId |
|
|
|
let baseIdOrBaseId = baseId |
|
|
@ -231,29 +236,64 @@ export const useViewsStore = defineStore('viewsStore', () => { |
|
|
|
router.currentRoute.value.query.page && |
|
|
|
router.currentRoute.value.query.page && |
|
|
|
router.currentRoute.value.query.page === 'fields' |
|
|
|
router.currentRoute.value.query.page === 'fields' |
|
|
|
) { |
|
|
|
) { |
|
|
|
await router.push({ |
|
|
|
if (cmdOrCtrl) { |
|
|
|
name: routeName, |
|
|
|
await navigateTo( |
|
|
|
params: { |
|
|
|
router.resolve({ |
|
|
|
viewTitle: view.id || '', |
|
|
|
name: routeName, |
|
|
|
viewId: tableId, |
|
|
|
params: { |
|
|
|
baseId: baseIdOrBaseId, |
|
|
|
viewTitle: view.id || '', |
|
|
|
slugs, |
|
|
|
viewId: tableId, |
|
|
|
}, |
|
|
|
baseId: baseIdOrBaseId, |
|
|
|
query: router.currentRoute.value.query, |
|
|
|
slugs, |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
query: router.currentRoute.value.query, |
|
|
|
|
|
|
|
}).href, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
open: navigateToBlankTargetOpenOption, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
await router.push({ |
|
|
|
|
|
|
|
name: routeName, |
|
|
|
|
|
|
|
params: { |
|
|
|
|
|
|
|
viewTitle: view.id || '', |
|
|
|
|
|
|
|
viewId: tableId, |
|
|
|
|
|
|
|
baseId: baseIdOrBaseId, |
|
|
|
|
|
|
|
slugs, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
query: router.currentRoute.value.query, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
await router.push({ |
|
|
|
if (cmdOrCtrl) { |
|
|
|
name: routeName, |
|
|
|
await navigateTo( |
|
|
|
params: { |
|
|
|
router.resolve({ |
|
|
|
viewTitle: view.id || '', |
|
|
|
name: routeName, |
|
|
|
viewId: tableId, |
|
|
|
params: { |
|
|
|
baseId: baseIdOrBaseId, |
|
|
|
viewTitle: view.id || '', |
|
|
|
slugs, |
|
|
|
viewId: tableId, |
|
|
|
}, |
|
|
|
baseId: baseIdOrBaseId, |
|
|
|
}) |
|
|
|
slugs, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}).href, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
open: navigateToBlankTargetOpenOption, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
await router.push({ |
|
|
|
|
|
|
|
name: routeName, |
|
|
|
|
|
|
|
params: { |
|
|
|
|
|
|
|
viewTitle: view.id || '', |
|
|
|
|
|
|
|
viewId: tableId, |
|
|
|
|
|
|
|
baseId: baseIdOrBaseId, |
|
|
|
|
|
|
|
slugs, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (hardReload) { |
|
|
|
if (!cmdOrCtrl && hardReload) { |
|
|
|
await router |
|
|
|
await router |
|
|
|
.replace({ |
|
|
|
.replace({ |
|
|
|
name: routeName, |
|
|
|
name: routeName, |
|
|
|