feat(custom-menu): 自定义菜单项支持选择打开方式(内嵌/跳转/新标签页)#3027
Open
bwliangc wants to merge 2 commits into
Open
Conversation
为每个自定义菜单项新增 open_mode 选项: - embed(默认):应用内 iframe 打开,保持原 /custom/:id 行为 - redirect:当前标签页直接跳转到该网址 - newtab:浏览器新标签页打开 Markdown 页面(md: 前缀)始终走应用内渲染,不受影响。 后端:CustomMenuItem 增加 OpenMode 字段并在保存时校验取值; 持久化与公开设置过滤均保留该字段。 前端:管理端设置页新增「打开方式」下拉选择与中英文案; 侧边栏对 redirect/newtab 的 http(s) 外链渲染为 <a>(携带 用户上下文参数,复用 buildEmbeddedUrl),按需带 target/rel。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
为每个自定义菜单项新增 with_user_params 开关,控制打开网址时 是否附加用户上下文参数(token、user_id、theme、lang 等): - 开启(默认):复用 buildEmbeddedUrl 附加参数,保持原有行为 - 关闭:使用原始网址打开 对三种打开方式(embed/redirect/newtab)均生效。后端 DTO 用 *bool, nil(旧数据)视为开启以保持向后兼容;前端管理端加载旧数据时归一化为 开启。管理端设置页以 Toggle 呈现,并补充中英文案。 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.
自定义菜单项支持选择打开方式(内嵌 / 跳转 / 新标签页)
背景 / Motivation
自定义菜单项此前固定以应用内 iframe 内嵌方式打开外部网址。但部分网址不允许被 iframe 嵌入(
X-Frame-Options/ CSPframe-ancestors),或本身更适合整页打开。本 PR为每个自定义菜单项增加「打开方式」选项,让管理员自行选择。
改动 / Changes
为
CustomMenuItem新增open_mode字段,三选一:embed(默认)/custom/:id行为redirectnewtabtarget="_blank"+rel="noopener noreferrer")后端
dto.CustomMenuItem新增OpenMode string(json:"open_mode,omitempty")。filterUserVisibleMenuItems经原始 JSON 透传)均完整保留该字段。前端
open_mode归一化为embed,保证<select>绑定有匹配项。redirect/newtab的 http(s) 外链渲染为<a>(复用buildEmbeddedUrl,携带token/user_id/theme/lang等用户上下文参数),其余仍为<router-link>。三处导航渲染块(管理员主菜单、管理员个人区、普通用户)统一通过<component :is>切换。兼容性 / Backward Compatibility
open_mode为可选字段,omitempty;存量菜单项无该字段时默认embed,行为与改动前完全一致。/api/v1/.../public)的 API 契约不变(字段新增且可选)。测试 / Testing
go build ./...通过;internal/handler/dto、internal/handler/admin包测试通过。vue-tsc --noEmit0 错误;SettingsView、AppSidebar、stores 等相关单测全部通过。已知边界 / Notes
直接访问
redirect/newtab菜单项的/custom/:id(如旧书签)仍会回退到 iframe 内嵌展示——这是合理兜底。主入口(侧边栏)已正确渲染为外链。截图 / Screenshots