Files
QLinker/frontend/src/components/ui/Tooltip.vue
T
xiaowang 27182fc7d2 feat: 交付任务005-021全量改动(自动化/AI/联系人中心、消息中心改造、运维与容器化)
- 自动化中心:规则引擎、流程画布与触发器(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 交付记录、设计画板导出、接口/数据库/架构文档同步
2026-11-17 17:29:06 +08:00

60 lines
1.6 KiB
Vue

<script setup>
import { nextTick, onBeforeUnmount, ref } from 'vue'
/**
* 轻量 Tooltip:替代原生 title 属性。鼠标悬停、键盘聚焦都会显示,位置自动翻转。
*/
const props = defineProps({
content: { type: String, default: '' },
placement: { type: String, default: 'top' },
delay: { type: Number, default: 120 },
disabled: Boolean
})
const rootRef = ref(null)
const visible = ref(false)
const style = ref({})
let timer = 0
const TEXT_WIDTH = 240
function measure() {
const anchor = rootRef.value
if (!anchor) return
const rect = anchor.getBoundingClientRect()
const place = props.placement === 'bottom' ? 'bottom' : 'top'
style.value = {
left: `${Math.max(8, Math.min(rect.left + rect.width / 2 - TEXT_WIDTH / 2, window.innerWidth - TEXT_WIDTH - 8))}px`,
minWidth: `${Math.min(rect.width, TEXT_WIDTH)}px`,
...(place === 'bottom'
? { top: `${rect.bottom + 6}px` }
: { bottom: `${window.innerHeight - rect.top + 6}px` })
}
}
function show() {
if (props.disabled || !props.content) return
window.clearTimeout(timer)
timer = window.setTimeout(() => {
visible.value = true
nextTick(measure)
}, props.delay)
}
function hide() {
window.clearTimeout(timer)
visible.value = false
}
onBeforeUnmount(() => window.clearTimeout(timer))
</script>
<template>
<span ref="rootRef" class="qk-tooltip" @mouseenter="show" @mouseleave="hide" @focusin="show" @focusout="hide">
<slot />
<Teleport to="body">
<span v-if="visible" class="qk-tooltip-pop" :style="style" role="tooltip">{{ content }}</span>
</Teleport>
</span>
</template>