20260822171825
This commit is contained in:
1 parent
c43b4c8364
commit
27a32b313d
187 files changed
+34869
-4741
No files matched your search
@@ -94,6 +94,45 @@ const barStyles = computed(() =>
|
||||
}),
|
||||
)
|
||||
|
||||
/* ---------- 拖拽移动(固定浮层可能遮挡顶栏操作,允许用户拖开) ---------- */
|
||||
const rootEl = ref(null)
|
||||
// 拖动后的 left/top 坐标;null 表示未拖过,使用默认定位(右上角)
|
||||
const pos = ref(null)
|
||||
let dragStart = null // { pointerX, pointerY, originX, originY, width, height }
|
||||
|
||||
function onPointerDown(e) {
|
||||
// 重置按钮的点击不触发拖拽
|
||||
if (e.target.closest('.fps-monitor__reset')) return
|
||||
const rect = rootEl.value.getBoundingClientRect()
|
||||
dragStart = {
|
||||
pointerX: e.clientX,
|
||||
pointerY: e.clientY,
|
||||
originX: pos.value ? pos.value.x : rect.left,
|
||||
originY: pos.value ? pos.value.y : rect.top,
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
}
|
||||
window.addEventListener('pointermove', onPointerMove)
|
||||
window.addEventListener('pointerup', onPointerUp)
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
function onPointerMove(e) {
|
||||
if (!dragStart) return
|
||||
const dx = e.clientX - dragStart.pointerX
|
||||
const dy = e.clientY - dragStart.pointerY
|
||||
// 边界限制:不拖出视口
|
||||
const x = Math.max(0, Math.min(dragStart.originX + dx, window.innerWidth - dragStart.width))
|
||||
const y = Math.max(0, Math.min(dragStart.originY + dy, window.innerHeight - dragStart.height))
|
||||
pos.value = { x, y }
|
||||
}
|
||||
|
||||
function onPointerUp() {
|
||||
dragStart = null
|
||||
window.removeEventListener('pointermove', onPointerMove)
|
||||
window.removeEventListener('pointerup', onPointerUp)
|
||||
}
|
||||
|
||||
/* ---------- 生命周期 ---------- */
|
||||
onMounted(() => {
|
||||
resetSampleWindow()
|
||||
@@ -108,7 +147,15 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside class="fps-monitor" aria-label="FPS 性能监控" v-bind="$attrs">
|
||||
<aside
|
||||
ref="rootEl"
|
||||
class="fps-monitor"
|
||||
:class="{ 'is-dragging': dragStart }"
|
||||
:style="pos ? { left: pos.x + 'px', top: pos.y + 'px' } : undefined"
|
||||
aria-label="FPS 性能监控"
|
||||
v-bind="$attrs"
|
||||
@pointerdown="onPointerDown"
|
||||
>
|
||||
<div class="fps-monitor__header">
|
||||
<span class="fps-monitor__label">FPS</span>
|
||||
<strong class="fps-monitor__current" :style="{ color: currentFpsColor }">
|
||||
@@ -156,10 +203,18 @@ onBeforeUnmount(() => {
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0;
|
||||
user-select: none;
|
||||
cursor: move;
|
||||
touch-action: none;
|
||||
background: var(--fms-card);
|
||||
border: 1px solid var(--fms-border);
|
||||
border-radius: var(--fms-control-radius);
|
||||
box-shadow: var(--fms-popover-shadow);
|
||||
transition: box-shadow 150ms ease;
|
||||
|
||||
&.is-dragging {
|
||||
cursor: grabbing;
|
||||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
|
||||
}
|
||||
}
|
||||
|
||||
.fps-monitor__header {
|
||||
|
||||
@@ -591,7 +591,6 @@ defineExpose({
|
||||
<template v-else #empty>
|
||||
<div class="fms-table__empty" role="status">
|
||||
<strong>暂无数据</strong>
|
||||
<span>当前没有可显示的内容</span>
|
||||
</div>
|
||||
</template>
|
||||
</StkTable>
|
||||
|
||||
@@ -206,6 +206,8 @@
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
/* 4px 内边距为聚焦外发光(box-shadow 3px)留出空间,避免被 overflow 裁剪 */
|
||||
padding: 4px;
|
||||
color: var(--fms-text);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user