test123

发布时间:2026/10/5 14:38:56

test123
templatediv classcontainer!-- div覆盖 iframe --divrefdragDivclassdrag-div:style{left: position.x px,top: position.y px,backgroundColor: isDragging ? #ff6b6b : rgba(0, 0, 0, 0.3),pointerEvents: isDragging ? auto : none}拖拽/div!-- iframe下层被 div 覆盖 --iframe refiframeRef srcabout:blank classiframe-content/iframe/div/templatescript setupimport { ref, onMounted, onUnmounted, nextTick } from vue;const dragDiv ref(null);const iframeRef ref(null);const isDragging ref(false);const position ref({ x: 0, y: 0 });const dragOffset ref({ x: 0, y: 0 });// 检测鼠标是否在 iframe 的 .checkarea 区域的按钮上const isOnIframeButton (e) {const iframe iframeRef.value;if (!iframe) return false;try {// 获取 iframe 的内部文档const iframeDoc iframe.contentDocument || iframe.contentWindow?.document;if (!iframeDoc) return false;// 找到 .checkarea 区域const checkarea iframeDoc.querySelector(.checkarea);if (!checkarea) return false;// 获取 .checkarea 的边界矩形相对于视口const checkareaRect checkarea.getBoundingClientRect();// 如果鼠标不在 .checkarea 区域内直接返回 falseif (e.clientX checkareaRect.left || e.clientX checkareaRect.right ||e.clientY checkareaRect.top || e.clientY checkareaRect.bottom) {return false;}// 在 .checkarea 内部查找所有按钮const buttons checkarea.querySelectorAll(button);for (const btn of buttons) {const rect btn.getBoundingClientRect();if (e.clientX rect.left e.clientX rect.right e.clientY rect.top e.clientY rect.bottom) {return true;}}return false;} catch (error) {// 跨域 iframe 会报错此时无法检测console.warn(无法访问 iframe 内容可能跨域:, error);return false;}};// 检测鼠标是否在 div 上const isOnDiv (e) {const div dragDiv.value;if (!div) return false;const rect div.getBoundingClientRect();return e.clientX rect.left e.clientX rect.right e.clientY rect.top e.clientY rect.bottom;};// 全局鼠标按下const onMouseDown (e) {if (e.button ! 0) return;if (isOnDiv(e)) {// 如果点击在 iframe 的 .checkarea 按钮上不启动拖拽if (isOnIframeButton(e)) return;const div dragDiv.value;const rect div.getBoundingClientRect();isDragging.value true;dragOffset.value {x: e.clientX - rect.left,y: e.clientY - rect.top};e.preventDefault();}};// 全局鼠标移动const onMouseMove (e) {if (!isDragging.value) return;const div dragDiv.value;if (!div) return;let newX e.clientX - dragOffset.value.x;let newY e.clientY - dragOffset.value.y;newX Math.max(0, Math.min(newX, window.innerWidth - div.offsetWidth));newY Math.max(0, Math.min(newY, window.innerHeight - div.offsetHeight));position.value { x: newX, y: newY };};// 全局鼠标释放const onMouseUp () {if (isDragging.value) {isDragging.value false;}};// 初始化位置const initPosition () {const div dragDiv.value;if (!div) return;position.value {x: (window.innerWidth - div.offsetWidth) / 2,y: (window.innerHeight - div.offsetHeight) / 2};};onMounted(() {initPosition();document.addEventListener(mousedown, onMouseDown);document.addEventListener(mousemove, onMouseMove);document.addEventListener(mouseup, onMouseUp);});onUnmounted(() {document.removeEventListener(mousedown, onMouseDown);document.removeEventListener(mousemove, onMouseMove);document.removeEventListener(mouseup, onMouseUp);});/scriptstyle scoped* {margin: 0;padding: 0;box-sizing: border-box;}.container {width: 100vw;height: 100vh;position: relative;background: #f0f0f0;}.iframe-content {width: 100%;height: 100%;border: none;z-index: 1;position: relative;}.drag-div {position: absolute;width: 300px;height: 200px;background: rgba(0, 0, 0, 0.3);backdrop-filter: blur(8px);border-radius: 16px;border: 2px solid rgba(255, 255, 255, 0.1);z-index: 2;cursor: grab;display: flex;align-items: center;justify-content: center;color: white;font-size: 18px;font-weight: 500;user-select: none;transition: background-color 0.2s ease;pointer-events: none;}.drag-div.dragging {cursor: grabbing;}/style

相关新闻

Navicat for Mac终极破解指南:三种简单方法永久重置14天试用期

Navicat for Mac终极破解指南:三种简单方法永久重置14天试用期

2026/9/8 10:47:20

Navicat for Mac终极破解指南:三种简单方法永久重置14天试用期 【免费下载链接】navicat_reset_mac navicat mac版无限重置试用期脚本 Navicat Mac Version Unlimited Trial Reset Script 项目地址: https://gitcode.com/gh_mirrors/na/navicat_reset_mac 还…

TranslucentTB:5分钟打造Windows任务栏透明化专业桌面

TranslucentTB:5分钟打造Windows任务栏透明化专业桌面

2026/9/1 0:48:32

TranslucentTB:5分钟打造Windows任务栏透明化专业桌面 【免费下载链接】TranslucentTB A lightweight utility that makes the Windows taskbar translucent/transparent. 项目地址: https://gitcode.com/gh_mirrors/tr/TranslucentTB TranslucentTB是一款专…

D3KeyHelper暗黑3按键助手:终极免费自动化游戏工具完全指南

D3KeyHelper暗黑3按键助手:终极免费自动化游戏工具完全指南

2026/9/4 10:09:49

D3KeyHelper暗黑3按键助手:终极免费自动化游戏工具完全指南 【免费下载链接】D3keyHelper D3KeyHelper是一个有图形界面,可自定义配置的暗黑3鼠标宏工具。 项目地址: https://gitcode.com/gh_mirrors/d3/D3keyHelper 还在为暗黑破坏神3中频繁的技…

CANN/GE ACL数据集缓冲区添加函数

CANN/GE ACL数据集缓冲区添加函数

2026/10/5 14:25:36

aclmdlAddDatasetBuffer 【免费下载链接】ge GE(Graph Engine)是面向昇腾的图编译器和执行器,提供了计算图优化、多流并行、内存复用和模型下沉等技术手段,加速模型执行效率,减少模型内存占用。 GE 提供对 PyTorch、Te…

用ffmpeg高效批量调整图片尺寸的实战指南

用ffmpeg高效批量调整图片尺寸的实战指南

2026/10/4 10:54:41

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

Transformers 音频特征提取工具库 audio_utils 全解析:从 Mel 刻度换算到对数 Mel 频谱

Transformers 音频特征提取工具库 audio_utils 全解析:从 Mel 刻度换算到对数 Mel 频谱

2026/10/5 11:17:40

Transformers 音频特征提取工具库 audio_utils 全解析:从 Mel 刻度换算到对数 Mel 频谱 【免费下载链接】transformers 🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and mu…

RustFS 多节点集群重启与滚动升级实战:Readiness、Quorum 与 Degraded 模式完全指南

RustFS 多节点集群重启与滚动升级实战:Readiness、Quorum 与 Degraded 模式完全指南

2026/10/4 17:30:40

RustFS 多节点集群重启与滚动升级实战:Readiness、Quorum 与 Degraded 模式完全指南 【免费下载链接】rustfs 🚀2.3x faster than MinIO for 4KB object payloads. RustFS is an open-source, S3-compatible high-performance object storage system sup…

Java Integer缓存揭秘:128陷阱原理、避坑与面试全解

Java Integer缓存揭秘:128陷阱原理、避坑与面试全解

2026/10/4 5:19:11

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

RustFS Scanner 数据用量发布权威性决策:配额准入如何获得可用的权威依据

RustFS Scanner 数据用量发布权威性决策:配额准入如何获得可用的权威依据

2026/10/4 10:55:30

RustFS Scanner 数据用量发布权威性决策:配额准入如何获得可用的权威依据 【免费下载链接】rustfs 🚀2.3x faster than MinIO for 4KB object payloads. RustFS is an open-source, S3-compatible high-performance object storage system supporting mi…