This commit is contained in:
weipengfei 2023-10-16 18:41:07 +08:00
parent 4428fdd00f
commit e831bb82de
3 changed files with 184 additions and 0 deletions

View File

@ -18,6 +18,11 @@ const routes: RouteRecordRaw[] = [
},
],
},
{
path: '/controller',
name: 'controller',
component: () => import('@/views/controller/index.vue'),
},
{
path: '/404',

View File

@ -0,0 +1,112 @@
//waves.vue
<template>
<div data-tname="WaveItem" style="overflow: hidden;">
<div class="main-container">
<div class="waves">
<div class="wave" v-for="(item, key) in waves" :key="key" :style="item">
<div
v-for="n in wavesConfig.total"
:key="n"
class="wave-item"
:style="{
transform: `scale(${0.1 * Math.sqrt(n - 1)})`, // 使
opacity: 0.4 * (1 / n), //
animationDelay: `${(n - 1) * 0.12}s`, //
animationDuration: `${0.6 +
n * 1 +
parseInt(item.width) * 0.002}s`, // 波纹动画时间渐增,表现波纹向外扩散渐慢的效果,波纹尺寸越大动画时间越长。
backgroundColor: wavesConfig.waveColor
}"
></div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "WaveItem",
props: ['cid'],
data() {
return {
waves: [],
wavesConfig: {
maxSize: 1200, // px
minSize: 600, // px
zIndexCount: 999, // z-index
waveColor: "#3E8CE3", //
total: 6 //
},
clear: {
delay: 8000,
timeoutId: null
}
};
},
mounted() {
document.getElementById(this.$props.cid||"app").onclick = e => {
this.createWave(e);
this.intervalClearWave();
};
},
methods: {
createWave(e) {
//
if (this.wavesConfig.zIndexCount > 99999) {
this.wavesConfig.zIndexCount = 999;
} else {
this.wavesConfig.zIndexCount++;
}
//
const waveSize = parseInt(
Math.random() * (this.wavesConfig.maxSize - this.wavesConfig.minSize) +
this.wavesConfig.minSize
);
//
this.waves.push({
left: `${e.clientX - waveSize / 2}px`,
top: `${e.clientY - waveSize / 2}px`,
zIndex: this.wavesConfig.zIndexCount,
width: `${waveSize}px`,
height: `${waveSize}px`
});
},
intervalClearWave() {
clearTimeout(this.clear.timeoutId);
this.clear.timeoutId = setTimeout(() => {
this.waves = [];
}, this.clear.delay);
}
}
};
</script>
<style lang="scss" scoped>
.waves {
.wave {
position: fixed;
pointer-events: none; // 穿使穿ie11
@keyframes wave {
to {
//
transform: scale(1);
opacity: 0;
}
}
.wave-item {
width: 100%;
height: 100%;
position: absolute;
border-radius: 100%;
animation: {
name: wave;
fill-mode: forwards; //
timing-function: ease-out; //
}
}
}
}
</style>

View File

@ -0,0 +1,67 @@
<script setup lang='ts'>
import water from "./components/water.vue"
import { NImage } from 'naive-ui'
</script>
<template>
<div class="w-full h-full white">
<div class="img-list w-full h-full">
<div id="img1" class="img-list-item">
<water cid="img1"/>
<n-image
style="width: 100%;height: 100%"
preview-disabled
src="https://ceshi-worker-task.lihaink.cn/uploads/images/20231016/20231016140328a27258835.jpg"
/>
</div>
<div id="img2" class="img-list-item">
<water cid="img2"/>
<n-image
style="width: 100%;height: 100%"
preview-disabled
src="https://ceshi-worker-task.lihaink.cn/uploads/images/20231016/20231016140328a27258835.jpg"
/>
</div>
<div id="img3" class="img-list-item">
<water cid="img3"/>
<n-image
style="width: 100%;height: 100%"
preview-disabled
src="https://ceshi-worker-task.lihaink.cn/uploads/images/20231016/20231016140328a27258835.jpg"
/>
</div>
<div id="img4" class="img-list-item">
<water cid="img4"/>
<n-image
style="width: 100%;height: 100%"
preview-disabled
src="https://ceshi-worker-task.lihaink.cn/uploads/images/20231016/20231016140328a27258835.jpg"
/>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.white{
background-color: #101014;
color: #fff;
.img-list{
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
padding: 10px;
.img-list-item{
box-sizing: border-box;
height: 50%;
width: 50%;
padding: 10px;
overflow: hidden;
/* border: 1px solid darkblue; */
/* background-color: aquamarine; */
}
}
}
</style>