手机开屏动画改成动图

This commit is contained in:
zhcnyuyang 2025-05-21 15:21:31 +08:00
parent 70c4566771
commit 6f708d179a
4 changed files with 109 additions and 68 deletions

BIN
public/beginwepgif.gif (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,36 +1,86 @@
<script> <script lang="ts">
import {defineComponent} from 'vue' import { defineComponent, onMounted, ref } from 'vue';
import { useBootstrapBreakpoint } from './useBreakpoint.js';
const { breakpoint } = useBootstrapBreakpoint();
export default defineComponent({ export default defineComponent({
name: "HeaderVideo" name: 'HeaderVideo',
setup() {
// ref <video>
const startVideoRef = ref<HTMLVideoElement | null>(null);
onMounted(() => {
const videoElement = startVideoRef.value;
if (videoElement) {
// 1. (iOS autoplay )
videoElement.muted = true;
// 2.
const playPromise = videoElement.play();
if (playPromise !== undefined) {
playPromise
.then(() => {
//
console.log('视频已自动播放');
}) })
.catch((error) => {
//
// 便 muted playsinline
console.error('视频自动播放失败:', error);
//
//
// 'click' 'touchstart' document
// document.body.addEventListener('click', () => videoElement.play(), { once: true });
});
}
} else {
console.warn('在 onMounted 中未找到视频元素。');
}
});
// ref
return {
startVideoRef,
};
},
// $isMobile setup
// vue-is-mobile
});
</script> </script>
<template> <template>
<div id="beginroot" class="pageroot"> <div id="beginroot" class="pageroot">
<div id="videodiv"> <div id="videodiv">
<video v-if="$isMobile.phone" poster="/logobeginweppld.png" controls="controls" <img v-if="$isMobile.phone" src="/beginwepgif.gif" id="mobilebeginv"/>
id="wepstart" muted autoplay preload="auto" <video
playsinline webkit-playsinline v-else-if="$isMobile.tablet"
ref="startVideoRef"
poster="/logobeginPCpld.png"
id="pcstart"
muted
autoplay
preload="auto"
playsinline
webkit-playsinline
class="startvideo" class="startvideo"
x5-video-player-type="h5-page"> x5-video-player-type="h5-page"
<source src="/logobeginwep.mp4" type="video/mp4"></source> >
<source src="/logobeginPC.mp4" type="video/mp4" />
</video> </video>
<video v-else-if="$isMobile.tablet" poster="/logobeginPCpld.png" controls="controls" <video
id="pcstart" muted autoplay preload="auto" v-else
playsinline webkit-playsinline ref="startVideoRef"
poster="/logobeginPCpld.png"
id="pcstart_else"
muted
autoplay
preload="auto"
playsinline
webkit-playsinline
class="startvideo" class="startvideo"
x5-video-player-type="h5-page"> x5-video-player-type="h5-page"
<source src="/logobeginPC.mp4" type="video/mp4"></source> >
</video> <source src="/logobeginPC.mp4" type="video/mp4" />
<video v-else poster="/logobeginPCpld.png"
id="pcstart" muted autoplay preload="auto"
playsinline webkit-playsinline
class="startvideo"
x5-video-player-type="h5-page">
<source src="/logobeginPC.mp4" type="video/mp4"></source>
</video> </video>
</div> </div>
<div id="beginbottom"> <div id="beginbottom">
@ -47,6 +97,7 @@ name: "HeaderVideo"
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
/* 你的样式保持不变 */
@import "src/publicstyle.scss"; @import "src/publicstyle.scss";
#beginroot{ #beginroot{
height: 100vh; height: 100vh;
@ -56,35 +107,31 @@ name: "HeaderVideo"
#wepstart{ #wepstart{
@include media-breakpoint-between(xs, md) { @include media-breakpoint-between(xs, md) {
visibility: visible; visibility: visible;
//height: 100%!important;
} }
@include media-breakpoint-up(md) { @include media-breakpoint-up(md) {
visibility: collapse; visibility: collapse;
//height: 0!important;
} }
} }
#pcstart{ #pcstart, #pcstart_else { /* 同时应用到两个可能的桌面/平板视频ID */
@include media-breakpoint-between(xs, md) { @include media-breakpoint-between(xs, md) {
visibility: collapse; visibility: collapse;
//height: 0!important;
} }
@include media-breakpoint-up(md) { @include media-breakpoint-up(md) {
visibility: visible; visibility: visible;
//height: 100%!important;
} }
} }
#beginbottom { #beginbottom {
a { a {
text-decoration: none; text-decoration: none;
width: 100%; /* 确保链接占满整个宽度 */ width: 100%;
.normalcontenttitle { .normalcontenttitle {
transition: color 0.3s ease; transition: color 0.3s ease;
color: white; color: white;
text-align: center; /* 文本居中 */ text-align: center;
display: flex; display: flex;
justify-content: center; /* flex布局下的水平居中 */ justify-content: center;
align-items: center; /* 垂直居中对齐图标 */ align-items: center;
} }
#intoa{ #intoa{
@include media-breakpoint-between(xs, md) { @include media-breakpoint-between(xs, md) {
@ -108,28 +155,19 @@ name: "HeaderVideo"
height: 100%; height: 100%;
background-color: black; background-color: black;
overflow: hidden; overflow: hidden;
@include media-breakpoint-between(xs, md) {
}
@include media-breakpoint-up(md) {
}
} }
.startvideo{ .startvideo{
width: 100%; width: 100%;
height: 100%; height: 100%;
@include media-breakpoint-between(xs, md) {
object-fit: contain; object-fit: contain;
} }
@include media-breakpoint-up(md) { #mobilebeginv{
object-fit: contain; width: 100%;
}
}
#intopagesvg{
height: 100%; height: 100%;
width: auto; object-fit: contain;
max-width: 100%;
} }
#intopagesvg{ #intopagesvg{
height: 1em; height: 1em; /* 改为相对单位 */
width: auto; width: auto;
margin-left: 0.5em; margin-left: 0.5em;
} }
@ -140,8 +178,8 @@ name: "HeaderVideo"
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; /* 添加这一行使内容水平居中 */ align-items: center;
width: 100%; /* 确保宽度占满 */ width: 100%;
margin-left: 0!important; margin-left: 0!important;
margin-bottom: 10px; margin-bottom: 10px;
} }

View File

@ -6,7 +6,7 @@ import MobileToolbar from "@/components/Tools/MobileToolbar.vue";
<div id="toproot"> <div id="toproot">
<MobileToolbar></MobileToolbar> <MobileToolbar></MobileToolbar>
<div id="topbar"> <div id="topbar">
<a href="/Homepage"> <a href="/">
<img <img
id="toplogo" id="toplogo"
referrerpolicy="no-referrer" referrerpolicy="no-referrer"

View File

@ -6,7 +6,7 @@ import FooterContent from './FooterContent.vue'
<div id="mobilebarroot"> <div id="mobilebarroot">
<div id="barcontent"> <div id="barcontent">
<div id="weptoplogo" class="image-wrapper_2 flex-row justify-between"> <div id="weptoplogo" class="image-wrapper_2 flex-row justify-between">
<a href="/Homepage"> <a href="/">
<img <img
id="image_1" id="image_1"
referrerpolicy="no-referrer" referrerpolicy="no-referrer"