feat(console): 新增浏览器应用(Chrome 风格多标签页 + iframe 智能混合加载) - #8
Open
wuxs wants to merge 2 commits into
Open
Conversation
后端 (pkg/console): - handlers_browser.go: 反向代理剥离 X-Frame-Options/CSP 等嵌套限制头并注入 <base>; /probe 端点 HEAD 检测目标能否被 iframe 直连(前端受同源策略限制无法自行检测) - browser_store.go: 书签/历史 JSON 原子持久化(RWMutex + tmp+rename) - server.go / config.go / main.go: 接入 Config 字段 + Server 字段 + 路由 前端 (console-ui): - pages/Browser.jsx: Chrome 风格 UI(多标签页 / 地址栏导航 / 书签 / 历史 / 新标签页) - 智能混合: 导航乐观 iframe 直连原始 URL,后台 probe 检测到拦截头才切代理 - hooks/useApi.js: useBookmarks/useHistory + 增删/probe helper 已知限制: 强反点击劫持的外部大站(frame-ancestors 'none' + JS 检测)即便走代理仍可能空白 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
工具条右侧加布局开关:合并成单行(默认,省垂直空间)或展开为两行(Chrome 标准)。 合并态 tabs 区限宽 42% + 横向滚动,多 tab 不挤掉地址栏。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
为 devbox 控制台桌面新增一个类似 Chrome 的「浏览器」应用,可在控制台内直接浏览网页,并带多标签页 / 地址栏导航 / 书签 / 历史。
核心设计是 iframe 智能混合加载:导航时先 iframe 直连目标 URL(快、无副作用),后端 probe 检测到目标设了
X-Frame-Options/frame-ancestors才自动切到后端代理(剥离嵌套限制头)。这等价于「先直连,不通走代理」——纯前端无法探测 iframe 是否被拒(同源策略),所以探测放后端 HEAD 做。改动
后端
pkg/consolehandlers_browser.go:反向代理 handler(白名单转发响应头,剥离X-Frame-Options/CSP/COOP/COEP/CORP/Content-Disposition,注入<base>+ fetch/XHR shim);/probe端点 HEAD 检测目标能否直连;SSRF 防护(禁云元数据 link-local、只允许 http/https、50MB 上限、重定向每跳重新校验)browser_store.go:书签 / 历史 JSON 原子持久化(RWMutex+tmp+rename,历史去重置顶 + 200 条上限)server.go/config.go/main.go:接入BrowserDataPath/BrowserInsecureTLS配置 + Server 字段 + 路由前端
console-uipages/Browser.jsx:Chrome 风格 UI(标签页 + 地址栏 + 前进/后退/刷新/主页 + 书签 ★ + 历史面板 + 新标签页空状态)mode字段,导航乐观直连,probe 决定是否切代理hooks/useApi.js:useBookmarks/useHistory+ 增删 /probeDirectEmbeddata/systemApps.js+AppShell.jsx:桌面图标 + 路由验证
go test ./pkg/console/全量通过(含新增handlers_browser_test.go/browser_store_test.go:URL 校验 / SSRF / header 白名单 / HTML 注入 / probe 各场景 / store 并发原子写)npm run build通过,已同步pkg/console/distexample.com→direct:true;github.com→direct:false (x-frame-options: deny);非法 scheme → 400已知限制(iframe 固有,非 bug)
frame-ancestors 'none'+ 站点自身 JS 检测)即便走代理仍可能空白document.title,tab 标题用 host 占位🤖 Generated with Claude Code