feat(0.2.1): 合并 Windows 外壳 + 离线编辑, 版本 0.2.1, 正式域名 https://iboard.honor3.com
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<!-- 悬浮球 (W-SNP-02): 半圆形贴边图标, 圆弧朝屏幕内侧, 由 Rust 控制位置与主题 -->
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0; padding: 0; width: 100%; height: 100%;
|
||||
background: transparent; overflow: hidden; user-select: none;
|
||||
}
|
||||
#ball { position: fixed; inset: 0; cursor: pointer; transition: transform .12s ease; }
|
||||
/* 半圆: 直边贴屏幕边缘, 圆弧朝内 (四边方向) */
|
||||
.dock-left #ball { border-radius: 0 28px 28px 0; } /* 左缘 → 凸向右 */
|
||||
.dock-right #ball { border-radius: 28px 0 0 28px; } /* 右缘 → 凸向左 */
|
||||
.dock-top #ball { border-radius: 0 0 28px 28px; } /* 上缘 → 凸向下 */
|
||||
.dock-bottom #ball { border-radius: 28px 28px 0 0; } /* 下缘 → 凸向上 */
|
||||
/* 深浅色 (W-THE-01): 跟随系统应用模式 */
|
||||
.theme-light #ball { background: rgba(28, 28, 30, 0.92); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); }
|
||||
.theme-dark #ball { background: rgba(245, 245, 245, 0.95); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25); }
|
||||
#ball::after {
|
||||
content: ""; position: absolute; left: 50%; top: 50%;
|
||||
width: 8px; height: 8px; border-radius: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.theme-light #ball::after { background: rgba(255, 255, 255, 0.85); }
|
||||
.theme-dark #ball::after { background: rgba(30, 30, 30, 0.75); }
|
||||
#ball:hover { transform: scale(1.06); }
|
||||
</style>
|
||||
</head>
|
||||
<body class="dock-left theme-light">
|
||||
<div id="ball"></div>
|
||||
<script src="./dock.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,65 @@
|
||||
// 悬浮球交互 (W-SNP-04/05/12/13/14):
|
||||
// mouseenter/leave → hover 延时恢复 (Rust 侧计时 150ms)
|
||||
// 单击 (位移 ≤4px) → 立即恢复, 触屏点按等效
|
||||
// 拖动 → dock_drag_move 增量移动, 结束时按最近边停靠/换边/拖出
|
||||
const { invoke } = window.__TAURI__.core
|
||||
const ball = document.getElementById('ball')
|
||||
|
||||
let dragging = false
|
||||
let moved = 0
|
||||
let lastX = 0
|
||||
let lastY = 0
|
||||
|
||||
ball.addEventListener('mouseenter', () => invoke('dock_hover_start'))
|
||||
ball.addEventListener('mouseleave', () => invoke('dock_hover_end'))
|
||||
ball.addEventListener('contextmenu', (e) => e.preventDefault())
|
||||
|
||||
ball.addEventListener('pointerdown', (e) => {
|
||||
dragging = true
|
||||
moved = 0
|
||||
lastX = e.clientX
|
||||
lastY = e.clientY
|
||||
ball.setPointerCapture(e.pointerId)
|
||||
invoke('dock_drag_start')
|
||||
})
|
||||
|
||||
ball.addEventListener('pointermove', (e) => {
|
||||
if (!dragging) return
|
||||
const dx = e.clientX - lastX
|
||||
const dy = e.clientY - lastY
|
||||
if (dx === 0 && dy === 0) return
|
||||
lastX = e.clientX
|
||||
lastY = e.clientY
|
||||
moved += Math.abs(dx) + Math.abs(dy)
|
||||
if (moved > 4) {
|
||||
// clientX 为逻辑像素, 增量按 DPI 缩放换算成物理像素 (Rust 注入 __SCALE)
|
||||
const s = window.__SCALE || 1
|
||||
invoke('dock_drag_move', { dx: Math.round(dx * s), dy: Math.round(dy * s) })
|
||||
}
|
||||
})
|
||||
|
||||
ball.addEventListener('pointerup', (e) => {
|
||||
if (!dragging) return
|
||||
dragging = false
|
||||
try { ball.releasePointerCapture(e.pointerId) } catch { /* 已释放 */ }
|
||||
if (moved <= 4) {
|
||||
invoke('dock_click')
|
||||
} else {
|
||||
invoke('dock_drag_end')
|
||||
}
|
||||
})
|
||||
|
||||
ball.addEventListener('pointercancel', () => {
|
||||
dragging = false
|
||||
invoke('dock_drag_end')
|
||||
})
|
||||
|
||||
// Rust 在停靠/换边/主题变化时调用
|
||||
window.applyDock = (edge, theme) => {
|
||||
document.body.className = 'dock-' + edge + ' theme-' + theme
|
||||
}
|
||||
window.applyTheme = (theme) => {
|
||||
const edge = [...document.body.classList].find((c) => c.startsWith('dock-')) || 'dock-left'
|
||||
document.body.className = edge + ' theme-' + theme
|
||||
}
|
||||
window.__SCALE = 1
|
||||
Reference in New Issue
Block a user