mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:29:49 +08:00
Ship folder-based workspaces and data migration, daily practice, redesigned provider and model settings, and streaming conversation improvements. Synchronize README translations and document the archive/permanent-delete upgrade behavior in assets/releases/ver1-6-9.md. Reduce initial JavaScript by deduplicating English resources and loading animation features after hydration. Keep the existing route size budgets. Update regression fixtures and browser audits for scoped URLs and the new settings and learning interfaces.
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
'use client'
|
|
|
|
import { useEffect } from 'react'
|
|
import { useRouter } from 'next/navigation'
|
|
import { activeWorkspaceId, registerWorkspaceNavigator, selectWorkspace } from '@/lib/workspace-scope'
|
|
|
|
/** Cross-store navigation disposes client runtimes. Links own their scope explicitly. */
|
|
export function WorkspaceNavigation() {
|
|
const router = useRouter()
|
|
useEffect(() => registerWorkspaceNavigator(router.push), [router])
|
|
useEffect(() => {
|
|
const follow = (event: MouseEvent) => {
|
|
const anchor = (event.target as Element).closest?.('a[href]') as HTMLAnchorElement | null
|
|
if (!anchor || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey ||
|
|
event.button !== 0 || anchor.target === '_blank' || anchor.hasAttribute('download')) return
|
|
const url = new URL(anchor.href)
|
|
if (url.origin !== window.location.origin) return
|
|
const target = url.searchParams.get('dt_workspace') ?? url.searchParams.get('workspace') ?? ''
|
|
if (target !== activeWorkspaceId()) {
|
|
event.preventDefault()
|
|
event.stopImmediatePropagation()
|
|
void selectWorkspace(target, url.toString())
|
|
}
|
|
}
|
|
document.addEventListener('click', follow, true)
|
|
return () => document.removeEventListener('click', follow, true)
|
|
}, [])
|
|
return null
|
|
}
|