- 自动化中心:规则引擎、流程画布与触发器(V7/V10/V12/V18/V21)、测试全流程、安全边界、执行记录 - AI 中心:服务商/模型/调用与工具授权/治理(V8/V17)及配套前端页面 - 联系人中心:联系人目录、分组/标签、同步幂等(V19)与实装页面 - 消息中心:三栏布局重做、头像昵称服务端抓取与缓存(V16 conversation_profile)、出站归属修复 - 接入管理:NapCat 反向 WS/HTTP 回调多通道发送传输、连接状态统一口径 - 运维中心:备份保留与恢复确认(V13/V22/V24)、监控告警(V23)、日志与审计 - 全局:账号上下文切换(V20 account_profile)、统一 UI 基础组件、分页样式、Flyway 增量迁移护栏 - 部署:Dockerfile/docker-compose/Nginx 容器化编排与 CI 校验脚本 - 文档:任务 005-021 交付记录、设计画板导出、接口/数据库/架构文档同步
91 lines
2.9 KiB
JavaScript
91 lines
2.9 KiB
JavaScript
/**
|
|
* v-tooltip 指令:批量替代原生 title 属性,不改变既有 DOM 结构与布局。
|
|
* 用法:v-tooltip="'说明文字'" 或 v-tooltip="{ content: '说明', placement: 'bottom' }"
|
|
* 与 <Tooltip> 组件共用 .qk-tooltip-pop 样式。
|
|
*/
|
|
const state = new WeakMap()
|
|
const DELAY = 120
|
|
|
|
function clearTimer(record) {
|
|
if (record?.timer) window.clearTimeout(record.timer)
|
|
}
|
|
|
|
function removeTip(record) {
|
|
if (record?.tip?.parentNode) record.tip.parentNode.removeChild(record.tip)
|
|
if (record) record.tip = null
|
|
}
|
|
|
|
function hide(el) {
|
|
const record = state.get(el)
|
|
if (!record) return
|
|
clearTimer(record)
|
|
removeTip(record)
|
|
}
|
|
|
|
function place(el, text, placement) {
|
|
const tip = document.createElement('div')
|
|
tip.className = 'qk-tooltip-pop'
|
|
tip.setAttribute('role', 'tooltip')
|
|
tip.textContent = text
|
|
document.body.appendChild(tip)
|
|
const rect = el.getBoundingClientRect()
|
|
const width = Math.min(tip.offsetWidth || 0, 240)
|
|
const left = Math.max(8, Math.min(rect.left + rect.width / 2 - width / 2, window.innerWidth - width - 8))
|
|
tip.style.left = `${left}px`
|
|
if (placement === 'bottom') tip.style.top = `${rect.bottom + 6}px`
|
|
else tip.style.bottom = `${window.innerHeight - rect.top + 6}px`
|
|
return tip
|
|
}
|
|
|
|
function show(el, binding) {
|
|
const raw = binding.value
|
|
const text = typeof raw === 'string' ? raw : raw?.content
|
|
const placement = typeof raw === 'object' && raw?.placement ? raw.placement : 'top'
|
|
if (!text) return
|
|
hide(el)
|
|
const record = state.get(el) || {}
|
|
record.timer = window.setTimeout(() => {
|
|
removeTip(record)
|
|
record.tip = place(el, text, placement)
|
|
state.set(el, record)
|
|
}, DELAY)
|
|
state.set(el, record)
|
|
}
|
|
|
|
function normalize(el, binding) {
|
|
// 原生 title 会与自绘提示重复,移除它,但保留 aria-label 语义。
|
|
if (el.hasAttribute('title')) el.removeAttribute('title')
|
|
show(el, binding)
|
|
}
|
|
|
|
export const vTooltip = {
|
|
mounted(el, binding) {
|
|
el.__qkTooltipShow = () => normalize(el, binding)
|
|
el.__qkTooltipHide = () => hide(el)
|
|
el.addEventListener('mouseenter', el.__qkTooltipShow)
|
|
el.addEventListener('focusin', el.__qkTooltipShow)
|
|
el.addEventListener('mouseleave', el.__qkTooltipHide)
|
|
el.addEventListener('focusout', el.__qkTooltipHide)
|
|
el.addEventListener('click', el.__qkTooltipHide)
|
|
},
|
|
updated(el, binding) {
|
|
if (el.hasAttribute('title')) el.removeAttribute('title')
|
|
if (binding.value !== binding.oldValue) {
|
|
hide(el)
|
|
el.__qkTooltipShow = () => normalize(el, binding)
|
|
}
|
|
},
|
|
unmounted(el) {
|
|
hide(el)
|
|
el.removeEventListener('mouseenter', el.__qkTooltipShow)
|
|
el.removeEventListener('focusin', el.__qkTooltipShow)
|
|
el.removeEventListener('mouseleave', el.__qkTooltipHide)
|
|
el.removeEventListener('focusout', el.__qkTooltipHide)
|
|
el.removeEventListener('click', el.__qkTooltipHide)
|
|
}
|
|
}
|
|
|
|
export function installTooltip(app) {
|
|
app.directive('tooltip', vTooltip)
|
|
}
|