index.vue 1.57 KB
<template>
  <div v-loading="isLoading" class="bg" :class="{dark: styleTheme=='dark',light: styleTheme=='light'}">
    <el-button v-if="styleTheme=='light'" class="theme-button dark-btn" @click="handleChangeTheme('dark')"></el-button>
    <el-button v-else-if="styleTheme=='dark'" class="theme-button light-btn" @click="handleChangeTheme('light')"></el-button>
<!--    <video id="video" autoplay loop muted src="/bg.mp4"></video>-->
    <app-header />
    <app-main :myTheme="styleTheme" />
  </div>
</template>

<script setup>
import {AppMain, AppHeader, AppBottom} from './components'

const styleTheme = ref('dark')
const isLoading = ref(false)

function handleChangeTheme(type) {
  styleTheme.value = type
  isLoading.value = true
  setTimeout(() => {
    isLoading.value = false
  }, 3000)
}

</script>

<style lang="scss">
#video {
  position: absolute;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bg {
  width: 100vw;
  height: 100vh;
  min-width: 1000px;
  overflow: hidden;
  //background: rgba(0,0,0,0.75)
  background-size: 100% 100%;
}

.dark {
  background: url("@/assets/image/bg@2x.png") no-repeat top center;
}

.light {
  background: url("@/assets/image/bg_light.png") no-repeat top center;
}

.theme-button {
  position: absolute;
  z-index: 2;
  width: 30px;
  height: 30px;
  border: none;
  top: 4vh;
  right: 20px;
}

.dark-btn {
  background: url("@/assets/image/dark@2x.png") no-repeat top center;
  background-size: contain;
}

.light-btn {
  background: url("@/assets/image/light@2x.png") no-repeat top center;
  background-size: contain;
}
</style>