feat(Screenfull): 全屏组件引入
This commit is contained in:
@@ -1,86 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="screenfull">
|
<div>
|
||||||
<div
|
<svg-icon :icon-class="isFullscreen ? 'exit-fullscreen' : 'fullscreen'" @click="toggle" />
|
||||||
v-if="isFullscreen"
|
|
||||||
@click="click"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
class="icon"
|
|
||||||
aria-hidden="true"
|
|
||||||
font-size="40px"
|
|
||||||
>
|
|
||||||
<use xlink:href="#iconshiliangzhinengduixiang1" />
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
@click="click"
|
|
||||||
v-else
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
class="icon"
|
|
||||||
aria-hidden="true"
|
|
||||||
font-size="40px"
|
|
||||||
>
|
|
||||||
<use xlink:href="#iconshiliangzhinengduixiang1" />
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import screenfull from 'screenfull'
|
import { useFullscreen } from '@vueuse/core'
|
||||||
import { ElMessage } from 'element-plus'
|
import SvgIcon from '@/components/SvgIcon/index.vue'
|
||||||
import {defineComponent,onBeforeUnmount,onMounted,reactive,toRefs} from "vue";
|
|
||||||
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
|
|
||||||
setup(){
|
|
||||||
const state =reactive({
|
|
||||||
isFullscreen: false,
|
|
||||||
click:()=>{
|
|
||||||
if (!screenfull.isEnabled) {
|
|
||||||
ElMessage({
|
|
||||||
message: 'you browser can not work',
|
|
||||||
type: 'warning'
|
|
||||||
})
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
screenfull.toggle()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const change=()=>{
|
|
||||||
if(screenfull.isEnabled){
|
|
||||||
this.isFullscreen = screenfull.isFullscreen
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
if (screenfull.isEnabled) {
|
|
||||||
screenfull.on('change', change)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
if (screenfull.isEnabled) {
|
|
||||||
screenfull.off('change', change)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
|
||||||
...toRefs(state)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
const { isFullscreen, enter, exit, toggle } = useFullscreen();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style lang='scss' scoped>
|
||||||
.screenfull-svg {
|
.screenfull-svg {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
fill: #5a5e66;;
|
fill: #5a5e66;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
vertical-align: 10px;
|
vertical-align: 10px;
|
||||||
|
|||||||
Reference in New Issue
Block a user