Template
1
0
mirror of https://github.com/un-pany/v3-admin-vite.git synced 2025-04-21 11:29:20 +08:00

feat: add full screen in area feature (#30)

This commit is contained in:
Sunny-117 2022-11-12 10:17:05 +08:00 committed by GitHub
parent 907dc21d55
commit 9557c5679e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 2 deletions

View File

@ -3,17 +3,25 @@ import { ref, onUnmounted } from "vue"
import { ElMessage } from "element-plus"
import screenfull from "screenfull"
const props = defineProps({
areaScreenFull: {
type: Boolean,
required: false
}
})
type contentType = "全屏" | "退出全屏"
const content = ref<contentType>("全屏")
const isFullscreen = ref(false)
const click = () => {
const element = document.querySelector(".app-container") || undefined
if (!screenfull.isEnabled) {
ElMessage.warning("您的浏览器无法工作")
return
}
screenfull.toggle()
screenfull.toggle(props.areaScreenFull ? element : undefined)
}
const change = () => {

View File

@ -1,7 +1,11 @@
<script lang="ts" setup>
import { ref } from "vue"
import { computed, ref } from "vue"
import { ElScrollbar } from "element-plus"
import { ArrowLeft, ArrowRight } from "@element-plus/icons-vue"
import { useSettingsStore } from "@/store/modules/settings"
import Screenfull from "@/components/Screenfull/index.vue"
const settingsStore = useSettingsStore()
const scrollbarRef = ref<InstanceType<typeof ElScrollbar>>()
const scrollbarContentRef = ref<HTMLDivElement>()
@ -34,6 +38,9 @@ const scrollTo = (direction: "left" | "right") => {
}
scrollbarRef.value!.setScrollLeft(scrollLeft)
}
const showScreenfull = computed(() => {
return settingsStore.showScreenfull
})
</script>
<template>
@ -49,6 +56,7 @@ const scrollTo = (direction: "left" | "right") => {
<el-icon class="arrow right" @click="scrollTo('right')">
<ArrowRight />
</el-icon>
<Screenfull :areaScreenFull="true" v-if="showScreenfull" class="right-menu-item" />
</div>
</template>
@ -77,5 +85,23 @@ const scrollTo = (direction: "left" | "right") => {
display: inline-block;
}
}
.right-menu-item {
padding: 0 10px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
.right-menu-avatar {
display: flex;
align-items: center;
.el-avatar {
margin-right: 10px;
}
span {
font-size: 16px;
}
}
}
}
</style>