|
| 1 | +# 图标和菜单结构修复 - 更新说明 |
| 2 | + |
| 3 | +## 修复内容 |
| 4 | + |
| 5 | +### 1. 图标显示问题 ✅ |
| 6 | + |
| 7 | +**问题:** 菜单项不显示图标 |
| 8 | + |
| 9 | +**原因:** 使用了 Ant Design 的图标组件,但 `ManageButtonItemLabel` 需要项目自带的 SVG React 组件。 |
| 10 | + |
| 11 | +**修复:** |
| 12 | +```typescript |
| 13 | +// 修改前(错误) |
| 14 | +import { CopyOutlined, LinkOutlined } from '@ant-design/icons'; |
| 15 | + |
| 16 | +// 修改后(正确) |
| 17 | +import { ReactComponent as LinkIcon } from '../../../assets/svg/link.svg'; |
| 18 | +import { ReactComponent as CopyIcon } from '../../../assets/svg/icon-copy.svg'; |
| 19 | +``` |
| 20 | + |
| 21 | +**使用的图标:** |
| 22 | +- 🔗 `link.svg` - 用于"复制名称链接" |
| 23 | +- 📋 `icon-copy.svg` - 用于"复制永久链接" |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +### 2. 菜单结构调整 ✅ |
| 28 | + |
| 29 | +**问题:** 子菜单不显示 |
| 30 | + |
| 31 | +**原因:** Ant Design Menu 的 `children` 属性在与 `ManageButtonItemLabel` 组合使用时可能不兼容。 |
| 32 | + |
| 33 | +**修复:** 将两个链接选项直接展开到主菜单顶部,用分隔符与其他选项区分。 |
| 34 | + |
| 35 | +**修改前的结构(子菜单方式 - 不工作):** |
| 36 | +```typescript |
| 37 | +{ |
| 38 | + label: '复制链接', |
| 39 | + children: [ |
| 40 | + { label: '复制名称链接', ... }, |
| 41 | + { label: '复制永久链接', ... } |
| 42 | + ] |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +**修改后的结构(平铺方式 - 工作):** |
| 47 | +```typescript |
| 48 | +[ |
| 49 | + { label: '复制名称链接', ... }, |
| 50 | + { label: '复制永久链接', ... }, |
| 51 | + { type: 'divider' }, |
| 52 | + // 其他菜单项... |
| 53 | +] |
| 54 | +``` |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +### 3. 最终 UI 效果 |
| 59 | + |
| 60 | +**Manage 下拉菜单(从上到下):** |
| 61 | + |
| 62 | +``` |
| 63 | +┌──────────────────────────────────────────────┐ |
| 64 | +│ 🔗 Copy Name-based Link │ |
| 65 | +│ Copy link with the term's full name. │ |
| 66 | +│ URL is readable and shows hierarchy... │ |
| 67 | +├──────────────────────────────────────────────┤ |
| 68 | +│ 📋 Copy Permanent Link │ |
| 69 | +│ Copy stable ID-based link. URL doesn't │ |
| 70 | +│ include name but remains valid... │ |
| 71 | +├──────────────────────────────────────────────┤ ← 分隔线 |
| 72 | +│ 📤 Export (如果是 Glossary) │ |
| 73 | +│ 📥 Import (如果是 Glossary) │ |
| 74 | +│ ✏️ Rename │ |
| 75 | +│ 🎨 Style (如果是 Term) │ |
| 76 | +│ 🔄 Change Parent (如果是 Term) │ |
| 77 | +│ 🗑️ Delete │ |
| 78 | +└──────────────────────────────────────────────┘ |
| 79 | +``` |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## 代码变更总结 |
| 84 | + |
| 85 | +### 文件:GlossaryHeader.component.tsx |
| 86 | + |
| 87 | +**导入变更:** |
| 88 | +```diff |
| 89 | +- import Icon, { CopyOutlined, DownOutlined, LinkOutlined } from '@ant-design/icons'; |
| 90 | ++ import Icon, { DownOutlined } from '@ant-design/icons'; |
| 91 | ++ import { ReactComponent as LinkIcon } from '../../../assets/svg/link.svg'; |
| 92 | ++ import { ReactComponent as CopyIcon } from '../../../assets/svg/icon-copy.svg'; |
| 93 | +``` |
| 94 | + |
| 95 | +**图标使用:** |
| 96 | +```diff |
| 97 | +- icon={LinkOutlined} |
| 98 | ++ icon={LinkIcon} |
| 99 | + |
| 100 | +- icon={CopyOutlined} |
| 101 | ++ icon={CopyIcon} |
| 102 | +``` |
| 103 | + |
| 104 | +**菜单结构:** |
| 105 | +```diff |
| 106 | + const manageButtonContent: ItemType[] = [ |
| 107 | +- { |
| 108 | +- label: t('label.copy-link'), |
| 109 | +- key: 'copy-link-menu', |
| 110 | +- icon: <Icon component={LinkIcon} />, |
| 111 | +- children: copyLinkMenuItems, |
| 112 | +- }, |
| 113 | ++ ...copyLinkMenuItems, |
| 114 | ++ { |
| 115 | ++ type: 'divider', |
| 116 | ++ }, |
| 117 | + ...(isGlossary && importExportPermissions |
| 118 | +``` |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +## 验证步骤 |
| 123 | + |
| 124 | +### 构建前端 |
| 125 | +```bash |
| 126 | +cd /workspace/openmetadata-ui/src/main/resources/ui |
| 127 | +yarn build |
| 128 | +``` |
| 129 | + |
| 130 | +### 启动服务 |
| 131 | +```bash |
| 132 | +cd /workspace |
| 133 | +./bin/openmetadata-server-start.sh |
| 134 | +``` |
| 135 | + |
| 136 | +### 测试点击路径 |
| 137 | +1. 打开任意词汇表术语页面(如 `/glossary/MyGlossary.MyTerm`) |
| 138 | +2. 点击页面右上角的 **Manage** 按钮(三点图标 `⋮`) |
| 139 | +3. 查看下拉菜单顶部是否有: |
| 140 | + - ✅ "Copy Name-based Link" 带链接图标 |
| 141 | + - ✅ "Copy Permanent Link" 带复制图标 |
| 142 | + - ✅ 分隔线 |
| 143 | +4. 点击任一选项,验证: |
| 144 | + - ✅ 显示成功 Toast 提示 |
| 145 | + - ✅ 链接已复制到剪贴板 |
| 146 | + - ✅ 菜单自动关闭 |
| 147 | + |
| 148 | +### 功能测试 |
| 149 | +```bash |
| 150 | +# 测试 1:复制并访问永久链接 |
| 151 | +1. 点击 "Copy Permanent Link" |
| 152 | +2. 在新标签页粘贴访问 |
| 153 | +3. 预期:成功打开术语页面,URL 格式为 /glossary/{uuid} |
| 154 | + |
| 155 | +# 测试 2:复制并访问名称链接 |
| 156 | +1. 点击 "Copy Name-based Link" |
| 157 | +2. 在新标签页粘贴访问 |
| 158 | +3. 预期:成功打开术语页面,URL 格式为 /glossary/{fqn} |
| 159 | + |
| 160 | +# 测试 3:重命名后的链接稳定性 |
| 161 | +1. 复制术语的永久链接 |
| 162 | +2. 重命名术语(如 "TestTerm" → "RenamedTerm") |
| 163 | +3. 访问之前复制的永久链接 |
| 164 | +4. 预期:仍然能正常访问,显示重命名后的内容 |
| 165 | +``` |
| 166 | + |
| 167 | +--- |
| 168 | + |
| 169 | +## 问题排查 |
| 170 | + |
| 171 | +### 如果图标仍不显示 |
| 172 | + |
| 173 | +**检查点 1:** 确认 SVG 文件存在 |
| 174 | +```bash |
| 175 | +ls -la /workspace/openmetadata-ui/src/main/resources/ui/src/assets/svg/link.svg |
| 176 | +ls -la /workspace/openmetadata-ui/src/main/resources/ui/src/assets/svg/icon-copy.svg |
| 177 | +``` |
| 178 | + |
| 179 | +**检查点 2:** 查看浏览器控制台是否有导入错误 |
| 180 | +``` |
| 181 | +F12 → Console → 查找 "Failed to load" 或 "Cannot find module" |
| 182 | +``` |
| 183 | + |
| 184 | +**检查点 3:** 清除构建缓存 |
| 185 | +```bash |
| 186 | +cd /workspace/openmetadata-ui/src/main/resources/ui |
| 187 | +rm -rf node_modules/.cache |
| 188 | +yarn build |
| 189 | +``` |
| 190 | + |
| 191 | +### 如果菜单项不显示 |
| 192 | + |
| 193 | +**检查点 1:** 验证翻译文件是否正确 |
| 194 | +```bash |
| 195 | +# 英文 |
| 196 | +grep "copy-fqn-link" /workspace/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json |
| 197 | + |
| 198 | +# 中文 |
| 199 | +grep "copy-fqn-link" /workspace/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json |
| 200 | +``` |
| 201 | + |
| 202 | +**检查点 2:** 查看浏览器 Network 标签,确认翻译文件已加载 |
| 203 | + |
| 204 | +**检查点 3:** 检查 `manageButtonContent` 数组长度 |
| 205 | +```typescript |
| 206 | +// 在浏览器 Console 中 |
| 207 | +// 应该至少包含 2 个链接选项 + 1 个分隔符 = 长度 >= 3 |
| 208 | +console.log('manageButtonContent length:', manageButtonContent.length); |
| 209 | +``` |
| 210 | + |
| 211 | +--- |
| 212 | + |
| 213 | +## 已知限制 |
| 214 | + |
| 215 | +1. **菜单宽度:** 固定为 350px(`overlayStyle={{ width: '350px' }}`) |
| 216 | + - 如果描述文本过长可能会换行 |
| 217 | + |
| 218 | +2. **图标大小:** 由 `ManageButtonItemLabel` 组件控制,固定为 18px |
| 219 | + |
| 220 | +3. **版本页面:** 在版本历史页面(`isVersionView = true`)不显示 Manage 按钮 |
| 221 | + |
| 222 | +--- |
| 223 | + |
| 224 | +## 完成状态 |
| 225 | + |
| 226 | +✅ 图标显示问题已修复 |
| 227 | +✅ 菜单结构已调整为平铺方式 |
| 228 | +✅ 分隔符已添加以区分功能组 |
| 229 | +✅ 国际化文本已完整添加(中英文) |
| 230 | +✅ 代码符合项目规范(使用项目自带 SVG 图标) |
| 231 | + |
| 232 | +--- |
| 233 | + |
| 234 | +**更新日期:** 2025-10-28 |
| 235 | +**状态:** ✅ 已修复,待测试验证 |
0 commit comments