style: 新增背景,部分页面bbs适配移动端
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
@media (max-width: 720px) {
|
||||
.div-logo {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
background-color: #272162;
|
||||
/*background-color: #272162;*/
|
||||
}
|
||||
|
||||
.div-content
|
||||
|
||||
86
Yi.Bbs.Vue3/src/components/StarBackground.vue
Normal file
86
Yi.Bbs.Vue3/src/components/StarBackground.vue
Normal file
@@ -0,0 +1,86 @@
|
||||
|
||||
<template>
|
||||
<canvas id="starfield"></canvas>
|
||||
</template>
|
||||
<script setup>
|
||||
import {onMounted} from "vue";
|
||||
const props = defineProps(['speed','number'])
|
||||
|
||||
onMounted(()=>{
|
||||
startAnimate();
|
||||
})
|
||||
|
||||
|
||||
let canvas={};
|
||||
let ctx={};
|
||||
let stars = [];
|
||||
let centerX=0;
|
||||
let centerY=0;
|
||||
const startAnimate=()=>{
|
||||
canvas = document.getElementById('starfield');
|
||||
ctx = canvas.getContext('2d');
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
centerX = canvas.width / 2;
|
||||
centerY = canvas.height / 2;
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
});
|
||||
|
||||
createStars(props.number??1000);
|
||||
animate();
|
||||
}
|
||||
|
||||
function createStars(numStars) {
|
||||
for (let i = 0; i < numStars; i++) {
|
||||
stars.push({
|
||||
x: (Math.random() - 0.5) * canvas.width,
|
||||
y: (Math.random() - 0.5) * canvas.height,
|
||||
z: Math.random() * canvas.width
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function drawStars() {
|
||||
ctx.fillStyle = '#f0f2f5';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
ctx.fillStyle = 'black';
|
||||
stars.forEach(star => {
|
||||
const k = 128 / star.z;
|
||||
const px = star.x * k + centerX;
|
||||
const py = star.y * k + centerY;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.arc(px, py, 1.5 * k, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
star.z -=props.speed??0.1;
|
||||
|
||||
if (star.z <= 0) {
|
||||
star.z = canvas.width;
|
||||
star.x = (Math.random() - 0.5) * canvas.width;
|
||||
star.y = (Math.random() - 0.5) * canvas.height;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function animate() {
|
||||
drawStars();
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
#starfield {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: -1;
|
||||
}
|
||||
</style>
|
||||
@@ -1,9 +1,14 @@
|
||||
<template>
|
||||
<StarBackground :speed="0.2" :number="1000"/>
|
||||
<div class="content-main">
|
||||
<RouterView />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
</template>
|
||||
<script setup>
|
||||
import StarBackground from "@/components/StarBackground.vue";
|
||||
</script>
|
||||
<style scoped>
|
||||
.content-main {
|
||||
width: 100%;
|
||||
@@ -11,6 +16,6 @@
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
/* min-height: 1150px; */
|
||||
background-color: #f0f2f5;
|
||||
/*background-color: #f0f2f5;*/
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -68,7 +68,7 @@ const handleScroll = () => {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
min-height: 10rem;
|
||||
background-color: #f0f2f5;
|
||||
//background-color: #f0f2f5;
|
||||
}
|
||||
|
||||
.fixed {
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<StarBackground :speed="0.01" :number="4000"/>
|
||||
</template>
|
||||
<!-- <style src="@/assets/styles/login.scss" scoped></style> -->
|
||||
<script setup>
|
||||
|
||||
import StarBackground from "@/components/StarBackground.vue";
|
||||
import useConfigStore from "@/stores/config";
|
||||
const configStore=useConfigStore();
|
||||
const isIcp=import.meta.env.VITE_APP_ICP==="true";
|
||||
|
||||
@@ -128,7 +128,7 @@ const captcha = async () => {
|
||||
<div class="container">
|
||||
<!-- 找回密码 -->
|
||||
<div class="div-content">
|
||||
<div class="div-right-register">
|
||||
<div class="div-right-register div-logo">
|
||||
<img class="div-img" src="@/assets/login.png"/>
|
||||
</div>
|
||||
<div class="div-left-register">
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="div-right">
|
||||
<div class="div-right div-logo">
|
||||
<img class="div-img" src="@/assets/login.png" alt=""/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -150,4 +150,5 @@ window.addEventListener("message", async (e) => {
|
||||
});
|
||||
</script>
|
||||
<style src="@/assets/styles/login.css" scoped>
|
||||
|
||||
</style>
|
||||
@@ -139,7 +139,7 @@ const captcha = async () => {
|
||||
<div class="container">
|
||||
<!-- 注册 -->
|
||||
<div class="div-content">
|
||||
<div class="div-right-register">
|
||||
<div class="div-right-register div-logo">
|
||||
<img class="div-img" src="@/assets/login.png"/>
|
||||
</div>
|
||||
<div class="div-left-register">
|
||||
|
||||
Reference in New Issue
Block a user