2025-08-05 23:30:00 +08:00
|
|
|
<script setup>
|
2025-08-09 23:32:55 +08:00
|
|
|
import { ref } from "vue";
|
2025-08-06 14:15:15 +08:00
|
|
|
import petGif from "./assets/pet.gif";
|
2025-08-09 23:32:55 +08:00
|
|
|
import { Howl } from "howler";
|
2025-08-06 07:44:19 +08:00
|
|
|
|
2025-08-06 14:15:15 +08:00
|
|
|
// 配置数据
|
2025-08-06 07:44:19 +08:00
|
|
|
const tooltips = [
|
2025-08-06 14:15:15 +08:00
|
|
|
"说的道理~",
|
|
|
|
|
"尊尼获加",
|
|
|
|
|
"为什么不开大!!",
|
|
|
|
|
"(凤鸣)",
|
|
|
|
|
];
|
2025-08-07 01:15:18 +08:00
|
|
|
const soundFiles = [
|
|
|
|
|
"cnmb.mp3",
|
|
|
|
|
"冲刺,冲.mp3",
|
|
|
|
|
"哎你怎么死了.mp3",
|
|
|
|
|
"哎,猪逼.mp3",
|
|
|
|
|
"啊啊啊我草你妈呀.mp3",
|
|
|
|
|
"嘟嘟嘟.mp3",
|
|
|
|
|
"韭菜盒子.mp3",
|
2025-08-09 23:32:55 +08:00
|
|
|
"哇袄.mp3",
|
2025-08-07 01:15:18 +08:00
|
|
|
];
|
2025-08-06 07:44:19 +08:00
|
|
|
|
2025-08-06 14:15:15 +08:00
|
|
|
// 状态管理
|
|
|
|
|
const showTooltip = ref(false);
|
|
|
|
|
const currentTooltip = ref("");
|
2025-08-06 07:44:19 +08:00
|
|
|
|
2025-08-06 14:15:15 +08:00
|
|
|
// 点击事件处理
|
2025-08-07 01:15:18 +08:00
|
|
|
const handleClick = async () => {
|
2025-08-09 23:32:55 +08:00
|
|
|
const randomSoundFile =
|
|
|
|
|
soundFiles[Math.floor(Math.random() * soundFiles.length)];
|
|
|
|
|
console.log("请求播放:", randomSoundFile);
|
|
|
|
|
|
2025-08-07 01:15:18 +08:00
|
|
|
try {
|
2025-08-08 20:06:52 +08:00
|
|
|
const audioUrl = await window.electronAPI?.getSoundPath(randomSoundFile);
|
|
|
|
|
|
|
|
|
|
if (audioUrl) {
|
|
|
|
|
const sound = new Howl({
|
|
|
|
|
src: [audioUrl],
|
2025-08-09 23:32:55 +08:00
|
|
|
format: ["mp3"],
|
2025-08-08 20:06:52 +08:00
|
|
|
});
|
|
|
|
|
sound.play();
|
|
|
|
|
} else {
|
2025-08-09 23:32:55 +08:00
|
|
|
console.error("无法获取音频路径:", randomSoundFile);
|
2025-08-08 20:06:52 +08:00
|
|
|
}
|
2025-08-07 01:15:18 +08:00
|
|
|
} catch (err) {
|
2025-08-09 23:32:55 +08:00
|
|
|
console.error("播放失败:", err);
|
2025-08-07 01:15:18 +08:00
|
|
|
}
|
2025-08-06 14:15:15 +08:00
|
|
|
|
|
|
|
|
currentTooltip.value = tooltips[Math.floor(Math.random() * tooltips.length)];
|
|
|
|
|
showTooltip.value = true;
|
|
|
|
|
setTimeout(() => (showTooltip.value = false), 2000);
|
|
|
|
|
};
|
2025-08-05 23:30:00 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-08-09 23:32:55 +08:00
|
|
|
<div class="pet-container">
|
2025-08-06 07:44:19 +08:00
|
|
|
<transition name="fade">
|
|
|
|
|
<div v-if="showTooltip" class="tooltip">
|
|
|
|
|
{{ currentTooltip }}
|
|
|
|
|
</div>
|
|
|
|
|
</transition>
|
2025-08-09 23:32:55 +08:00
|
|
|
<img :src="petGif" class="pet-gif" @click="handleClick" />
|
2025-08-05 23:30:00 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2025-08-09 23:32:55 +08:00
|
|
|
<style>
|
|
|
|
|
html, body, #app {
|
|
|
|
|
background-color: transparent !important;
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
overflow: hidden; /* 隐藏滚动条 */
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
2025-08-05 23:30:00 +08:00
|
|
|
<style scoped>
|
2025-08-06 14:15:15 +08:00
|
|
|
.pet-container {
|
|
|
|
|
width: 300px;
|
|
|
|
|
height: 300px;
|
2025-08-09 23:32:55 +08:00
|
|
|
/* 将整个容器设置为可拖拽区域 */
|
|
|
|
|
-webkit-app-region: drag;
|
2025-08-05 23:30:00 +08:00
|
|
|
}
|
2025-08-06 07:44:19 +08:00
|
|
|
|
2025-08-06 14:15:15 +08:00
|
|
|
.pet-gif {
|
2025-08-06 07:44:19 +08:00
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
cursor: pointer;
|
2025-08-06 14:15:15 +08:00
|
|
|
user-select: none;
|
2025-08-09 23:32:55 +08:00
|
|
|
/* 设置图片为不可拖拽,以便响应点击事件 */
|
|
|
|
|
-webkit-app-region: no-drag;
|
2025-08-06 07:44:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tooltip {
|
|
|
|
|
position: absolute;
|
2025-08-06 14:15:15 +08:00
|
|
|
bottom: -40px;
|
2025-08-06 07:44:19 +08:00
|
|
|
left: 50%;
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
background: rgba(0, 0, 0, 0.7);
|
|
|
|
|
color: white;
|
|
|
|
|
padding: 8px 16px;
|
|
|
|
|
border-radius: 20px;
|
|
|
|
|
font-size: 14px;
|
2025-08-06 14:15:15 +08:00
|
|
|
white-space: nowrap;
|
2025-08-09 23:32:55 +08:00
|
|
|
/* 确保提示框不会干扰拖拽 */
|
|
|
|
|
-webkit-app-region: no-drag;
|
2025-08-06 07:44:19 +08:00
|
|
|
}
|
|
|
|
|
|
2025-08-06 14:15:15 +08:00
|
|
|
.fade-enter-active,
|
|
|
|
|
.fade-leave-active {
|
|
|
|
|
transition: opacity 0.3s;
|
2025-08-05 23:30:00 +08:00
|
|
|
}
|
2025-08-06 14:15:15 +08:00
|
|
|
.fade-enter-from,
|
|
|
|
|
.fade-leave-to {
|
2025-08-06 07:44:19 +08:00
|
|
|
opacity: 0;
|
2025-08-05 23:30:00 +08:00
|
|
|
}
|
2025-08-09 23:32:55 +08:00
|
|
|
</style>
|