mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-30 12:50:14 +08:00
feat(ux): toast 智能行动按钮 + 拓展 ⓘ 到 gateway/agents + sidebar 加术语表入口
延续上一轮小白 UX 改造的尾声三连:
## 1. toast 智能行动按钮(U2 收尾)
- humanizeError 输出新增 action 字段:{ label, route?, handler?, kind }
- 自动按错误 kind 给默认按钮:
· gatewayDown → [去启动 Gateway] → /services
· cmdMissing / permission → [打开设置] → /settings
· auth → [检查 API Key] → /models
· network / timeout / rateLimit / generic → 不给(重试由用户控制)
- toast 结构化分支渲染 .toast-action-btn 按钮,点击后用 navigate(route) 或调 handler,并自动关闭 toast
- common.js 加 errorAction.* 三个按钮文案 i18n(11 语言)
## 2. ⓘ 拓展到 gateway / agents
- gateway.js: token label 后加 ⓘ(apikey 术语),renderConfig 末尾 attachTermTooltips
- agents.js: addAgent 弹窗 workspace 字段 label 加 ⓘ,setTimeout 扫 document.body 绑定
- term-tooltip.js 精简表新增 4 个术语:workspace / provider / baseurl + scope(已有)
## 3. sidebar 加术语表入口
- 在两个引擎(OpenClaw + Hermes)的最后一个 section 加「术语」条目
- sidebar.js i18n 新增 glossary 键(11 语言)
- 之前只能从 dashboard quick-actions 进入,现在 sidebar 永久可达
## 4. 顺手 bug 修复
- gateway.js 文件末尾历史残留的多余 `}` (line 348) syntax 错误,删除
- 与之前 hermes/cron.js 同类问题,本次改 ⓘ 时被 node --check 暴露
## 累计变动
- 10 个文件修改
- 7 个新 i18n 键(11 语言)
- Build OK
This commit is contained in:
@@ -2,13 +2,15 @@
|
||||
* Toast 通知组件
|
||||
*
|
||||
* 入参 message 支持两种:
|
||||
* 1) string —— 原来的纯文本(向后兼容)
|
||||
* 2) { message, hint?, raw? } —— humanize-error.js 的友好错误对象:
|
||||
* 1) string —— 原来的纯文本(向后兼容)
|
||||
* 2) { message, hint?, raw?, action? } —— humanize-error.js 的友好错误对象:
|
||||
* - message: 主行(用户视角)
|
||||
* - hint: 副行小灰字(行动建议)
|
||||
* - raw: 折叠在「技术详情」里的原始错误字符串
|
||||
* - action: { label, route?, handler? } 智能行动按钮,点击跳转或调 handler
|
||||
*/
|
||||
import { t } from '../lib/i18n.js'
|
||||
import { navigate } from '../router.js'
|
||||
|
||||
let _container = null
|
||||
|
||||
@@ -51,6 +53,22 @@ export function toast(message, type = 'info', options = {}) {
|
||||
body.appendChild(hintRow)
|
||||
}
|
||||
|
||||
if (message.action && message.action.label) {
|
||||
const actionBtn = document.createElement('button')
|
||||
actionBtn.type = 'button'
|
||||
actionBtn.className = 'btn btn-xs btn-primary toast-action-btn'
|
||||
actionBtn.textContent = `${message.action.label} →`
|
||||
actionBtn.addEventListener('click', () => {
|
||||
try {
|
||||
if (typeof message.action.handler === 'function') message.action.handler()
|
||||
else if (message.action.route) navigate(message.action.route)
|
||||
} finally {
|
||||
el.remove()
|
||||
}
|
||||
})
|
||||
body.appendChild(actionBtn)
|
||||
}
|
||||
|
||||
if (message.raw) {
|
||||
const detail = document.createElement('details')
|
||||
detail.className = 'toast-raw'
|
||||
|
||||
Reference in New Issue
Block a user