Skip to content

Commit 3189c9a

Browse files
committed
feat: floating button dnd & click
1 parent a8ad206 commit 3189c9a

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

electron.vite.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ export default defineConfig({
7575
}),
7676
vue(),
7777
svgLoader(),
78-
vueDevTools({
79-
// use export LAUNCH_EDITOR=cursor instead
80-
// launchEditor: 'cursor'
81-
})
78+
// vueDevTools({
79+
// // use export LAUNCH_EDITOR=cursor instead
80+
// // launchEditor: 'cursor'
81+
// })
8282
],
8383
build: {
8484
minify: 'esbuild',

src/renderer/floating/FloatingButton.vue

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
<template>
2-
<div class="w-screen h-screen bg-transparent overflow-hidden select-none flex items-center justify-center">
2+
<div class="w-screen h-screen bg-transparent overflow-hidden select-none flex items-center justify-center drag-region">
33
<div
44
ref="floatingButton"
5-
class="w-15 h-15 rounded-full border-2 border-white/30 flex items-center justify-center cursor-pointer transition-all duration-300 relative overflow-hidden select-none floating-button"
5+
class="w-15 h-15 rounded-full border-2 border-white/30 flex items-center justify-center cursor-pointer transition-all duration-300 relative overflow-hidden select-none floating-button no-drag"
66
:class="{ 'floating-button-pulse': isPulsing }"
77
@click="handleClick"
88
@mouseenter="handleMouseEnter"
99
@mouseleave="handleMouseLeave"
1010
>
11-
<svg class="w-6 h-6 fill-white z-1 relative" viewBox="0 0 24 24">
12-
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
13-
</svg>
14-
<div class="absolute bottom-full left-1/2 transform -translate-x-1/2 bg-black/80 text-white px-3 py-2 rounded-md text-xs whitespace-nowrap opacity-0 invisible transition-all duration-300 pointer-events-none mb-2 tooltip">
15-
点击打开 DeepChat
16-
</div>
11+
<img src="@/assets/logo.png" alt="Floating Button Icon" class="w-10 h-10 pointer-events-none" />
1712
</div>
1813
</div>
1914
</template>
@@ -83,9 +78,28 @@ onUnmounted(() => {
8378
</script>
8479

8580
<style scoped>
81+
/* 拖拽区域 */
82+
.drag-region {
83+
-webkit-app-region: drag;
84+
}
85+
86+
/* 禁用拖拽的元素 */
87+
.no-drag {
88+
-webkit-app-region: no-drag;
89+
}
90+
91+
/* 确保图片不会阻止点击事件 */
92+
.pointer-events-none {
93+
pointer-events: none;
94+
}
95+
8696
/* 悬浮按钮基础样式 */
8797
.floating-button {
8898
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
99+
/* 按钮本身不可拖拽,只响应点击 */
100+
-webkit-app-region: no-drag;
101+
/* 确保按钮可以接收鼠标事件 */
102+
pointer-events: auto;
89103
}
90104
91105
/* 悬浮按钮悬停效果 */

0 commit comments

Comments
 (0)