You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
2.8 KiB
148 lines
2.8 KiB
<template>
|
|
<div ref="rightPanel" :class="{ show: show }" class="rightPanel-container">
|
|
<div class="rightPanel-background" @click="closeSidebar"/>
|
|
<div class="rightPanel">
|
|
<div class="rightPanel-items">
|
|
<div style="display: flex;align-items: center; justify-content:start;height: 40px;">
|
|
<el-icon style="font-size: 1.2rem;margin-left:10px;cursor: pointer;" @click="closeSidebar"><Close /></el-icon>
|
|
<span style="margin-left: 20px;">设置面板</span>
|
|
</div>
|
|
<slot />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { addClass, removeClass } from '@/utils'
|
|
import store from '@/stores'
|
|
|
|
export default {
|
|
name: 'RightPanel',
|
|
setup() {
|
|
const settingsStore = store.settingsStore()
|
|
return { settingsStore }
|
|
},
|
|
props: {
|
|
clickNotClose: {
|
|
default: false,
|
|
type: Boolean
|
|
},
|
|
buttonTop: {
|
|
default: 250,
|
|
type: Number
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
show: false
|
|
}
|
|
},
|
|
computed: {
|
|
theme() {
|
|
return this.settingsStore.theme
|
|
}
|
|
},
|
|
watch: {
|
|
show(value) {
|
|
if (value) {
|
|
addClass(document.body, 'showRightPanel')
|
|
} else {
|
|
removeClass(document.body, 'showRightPanel')
|
|
}
|
|
}
|
|
},
|
|
mounted() {
|
|
this.insertToBody()
|
|
},
|
|
beforeUnmount() {
|
|
const elx = this.$refs.rightPanel
|
|
elx.remove()
|
|
},
|
|
methods: {
|
|
closeSidebar() {
|
|
this.show = false
|
|
},
|
|
insertToBody() {
|
|
const elx = this.$refs.rightPanel
|
|
const body = document.querySelector('body')
|
|
body.insertBefore(elx, body.firstChild)
|
|
},
|
|
open() {
|
|
this.show = true
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.showRightPanel {
|
|
overflow: hidden;
|
|
position: relative;
|
|
}
|
|
</style>
|
|
|
|
<style lang="scss" scoped>
|
|
.rightPanel-background {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
opacity: 0;
|
|
transition: opacity 0.3s cubic-bezier(0.7, 0.3, 0.1, 1);
|
|
background: rgba(0, 0, 0, 0.2);
|
|
z-index: -1;
|
|
}
|
|
|
|
.rightPanel {
|
|
width: 100%;
|
|
max-width: 260px;
|
|
height: 100vh;
|
|
position: fixed;
|
|
top: 0;
|
|
right: 0;
|
|
box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 0.05);
|
|
transition: all 0.25s cubic-bezier(0.7, 0.3, 0.1, 1);
|
|
transform: translate(100%);
|
|
background: #fff;
|
|
z-index: 40000;
|
|
}
|
|
|
|
.dark .rightPanel{
|
|
background: #252526;
|
|
color: var(--el-menu-text-color);
|
|
}
|
|
|
|
.show {
|
|
transition: all 0.3s cubic-bezier(0.7, 0.3, 0.1, 1);
|
|
|
|
.rightPanel-background {
|
|
z-index: 20000;
|
|
opacity: 1;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.rightPanel {
|
|
transform: translate(0);
|
|
}
|
|
}
|
|
|
|
.handle-button {
|
|
width: 48px;
|
|
height: 48px;
|
|
position: absolute;
|
|
left: -48px;
|
|
text-align: center;
|
|
font-size: 24px;
|
|
border-radius: 6px 0 0 6px !important;
|
|
z-index: 0;
|
|
pointer-events: auto;
|
|
cursor: pointer;
|
|
color: #fff;
|
|
line-height: 48px;
|
|
i {
|
|
font-size: 24px;
|
|
line-height: 48px;
|
|
}
|
|
}
|
|
</style>
|
|
|