Browse Source

refactor/fixed url generation for swagger

pull/3166/head
Muhammed Mustafa 2 years ago
parent
commit
2a71202c72
  1. 4
      packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue
  2. 5
      packages/nc-gui-v2/utils/urlUtils.ts

4
packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue

@ -15,6 +15,8 @@ import { TabType } from '~/composables'
const route = useRoute()
const { appInfo } = useGlobal()
const { project, loadProject, loadTables, isSharedBase } = useProject()
const { addTab, clearTabs } = useTabs()
@ -152,7 +154,7 @@ const isHovered = useElementHover(sidebar)
v-if="isUIAllowed('apiDocs')"
v-t="['e:api-docs']"
class="nc-project-menu-item group"
@click.stop="openLink(`/api/v1/db/meta/projects/${route.params.projectId}/swagger`)"
@click.stop="openLink(`/api/v1/db/meta/projects/${route.params.projectId}/swagger`, appInfo.ncSiteUrl)"
>
<MdiApi class="group-hover:text-pink-500 nc-swagger-api-docs" />
Swagger: Rest APIs

5
packages/nc-gui-v2/utils/urlUtils.ts

@ -24,6 +24,7 @@ export const isValidURL = (str: string) => {
return !!pattern.test(str)
}
export const openLink = (url: string, target = '_blank') => {
window.open(url, target)
export const openLink = (path: string, baseURL: string, target = '_blank') => {
const url = new URL(path, baseURL)
window.open(url.href, target)
}

Loading…
Cancel
Save