feat(app-switcher): читать конфиг из auth-portal вместо локального editor
CURRENT_APP_ID cfdm; настройка ссылок только на портале. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f1767b8a1f
commit
9d8c2aff86
9 files changed
+118
-155
No files matched your search
@@ -1,15 +1,28 @@
|
||||
import { queryOptions } from '@tanstack/react-query'
|
||||
import type { AppSwitcherConfig } from '@cfdm/shared'
|
||||
import { api } from '@/lib/api-client'
|
||||
import { ensureAuthConfig } from '@/lib/auth'
|
||||
import { DEFAULT_APP_SWITCHER_CONFIG } from '@/lib/app-switcher-config'
|
||||
|
||||
export const appSwitcherQueryKey = ['app-switcher'] as const
|
||||
export const appSwitcherQueryKey = ['app-switcher', 'portal'] as const
|
||||
|
||||
async function fetchPortalAppSwitcher(): Promise<AppSwitcherConfig> {
|
||||
const { portalUrl } = await ensureAuthConfig()
|
||||
const base = portalUrl.replace(/\/$/, '')
|
||||
const res = await fetch(`${base}/api/v1/app-switcher`, {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
if (!res.ok) {
|
||||
throw new Error(`app-switcher ${res.status}`)
|
||||
}
|
||||
return (await res.json()) as AppSwitcherConfig
|
||||
}
|
||||
|
||||
export function appSwitcherQueryOptions() {
|
||||
return queryOptions({
|
||||
queryKey: appSwitcherQueryKey,
|
||||
queryFn: () => api.get<AppSwitcherConfig>('/api/v1/settings/app-switcher'),
|
||||
queryFn: fetchPortalAppSwitcher,
|
||||
staleTime: 60_000,
|
||||
placeholderData: DEFAULT_APP_SWITCHER_CONFIG,
|
||||
retry: 1,
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user