remember
This commit is contained in:
parent
a25088e723
commit
51f347a544
|
|
@ -1,9 +1,15 @@
|
|||
import type { App } from '../../shared/types'
|
||||
import { apps, selectedTab, setSelectedTab } from '../state'
|
||||
import { apps, selectedApp, selectedTab, setSelectedTab } from '../state'
|
||||
import { Tab, TabBar } from '../styles'
|
||||
import { resetToolIframe } from '../tool-iframes'
|
||||
|
||||
export function Nav({ app, render }: { app: App; render: () => void }) {
|
||||
const handleTabClick = (tab: string) => {
|
||||
// If clicking already-selected tool tab, reset to home
|
||||
if (tab === selectedTab && tab !== 'overview') {
|
||||
resetToolIframe(tab, selectedApp)
|
||||
return
|
||||
}
|
||||
setSelectedTab(tab)
|
||||
render()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ function setupMessageListener() {
|
|||
for (const [, cached] of iframes) {
|
||||
if (cached.iframe.contentWindow === event.source) {
|
||||
cached.contentHeight = height
|
||||
cached.iframe.style.height = `100vh`
|
||||
cached.iframe.style.height = `${height}px`
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
@ -85,6 +85,19 @@ function buildCacheKey(toolName: string, params: Record<string, string>): string
|
|||
return parts.join(':')
|
||||
}
|
||||
|
||||
// Reset a tool iframe to its home page
|
||||
export function resetToolIframe(toolName: string, selectedApp: string | null) {
|
||||
const params: Record<string, string> = {}
|
||||
if (selectedApp) params.app = selectedApp
|
||||
const cacheKey = buildCacheKey(toolName, params)
|
||||
const cached = iframes.get(cacheKey)
|
||||
if (cached) {
|
||||
// For code app, include empty file param to clear its localStorage
|
||||
const urlParams = toolName === 'code' ? { ...params, file: '' } : params
|
||||
cached.iframe.src = buildToolUrl(cached.port, urlParams)
|
||||
}
|
||||
}
|
||||
|
||||
// Update which iframe is visible based on selected tab and tool state
|
||||
export function updateToolIframes(
|
||||
selectedTab: string,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user