mirror of
https://gitee.com/fantastic-admin/basic.git
synced 2024-12-05 13:37:45 +08:00
layout/ 目录下文件用 script setup 语法糖重写
This commit is contained in:
parent
516fcba5ed
commit
a88ebdfa89
@ -66,6 +66,7 @@ module.exports = {
|
||||
'after': true,
|
||||
'before': false
|
||||
}],
|
||||
'object-curly-spacing': [2, 'always'],
|
||||
// ES6
|
||||
'arrow-parens': [2, 'as-needed'],
|
||||
'arrow-spacing': [2, {
|
||||
|
@ -30,7 +30,7 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script setup>
|
||||
import Header from './components/Header/index.vue'
|
||||
import MainSidebar from './components/MainSidebar/index.vue'
|
||||
import SubSidebar from './components/SubSidebar/index.vue'
|
||||
@ -39,64 +39,48 @@ import Search from './components/Search/index.vue'
|
||||
import ThemeSetting from './components/ThemeSetting/index.vue'
|
||||
import BuyIt from './components/BuyIt/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'Layout',
|
||||
components: {
|
||||
Header,
|
||||
MainSidebar,
|
||||
SubSidebar,
|
||||
Topbar,
|
||||
Search,
|
||||
ThemeSetting,
|
||||
BuyIt
|
||||
},
|
||||
provide() {
|
||||
return {
|
||||
reload: this.reload,
|
||||
switchMenu: this.switchMenu
|
||||
import { provide, computed, watch, getCurrentInstance, onMounted } from 'vue'
|
||||
import { useStore } from 'vuex'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const store = useStore()
|
||||
const route = useRoute(), router = useRouter()
|
||||
|
||||
const showCopyright = computed(() => {
|
||||
return typeof route.meta.copyright !== 'undefined' ? route.meta.copyright : store.state.settings.showCopyright
|
||||
})
|
||||
|
||||
watch(() => store.state.settings.sidebarCollapse, val => {
|
||||
if (store.state.settings.mode === 'mobile') {
|
||||
if (!val) {
|
||||
document.querySelector('body').classList.add('hidden')
|
||||
} else {
|
||||
document.querySelector('body').classList.remove('hidden')
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
routePath: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
showCopyright() {
|
||||
return typeof this.$route.meta.copyright !== 'undefined' ? this.$route.meta.copyright : this.$store.state.settings.showCopyright
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$store.state.settings.sidebarCollapse'(val) {
|
||||
if (this.$store.state.settings.mode === 'mobile') {
|
||||
if (!val) {
|
||||
document.querySelector('body').classList.add('hidden')
|
||||
} else {
|
||||
document.querySelector('body').classList.remove('hidden')
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$hotkeys('f5', e => {
|
||||
if (this.$store.state.settings.enablePageReload) {
|
||||
e.preventDefault()
|
||||
this.reload()
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
reload() {
|
||||
this.$router.push({
|
||||
name: 'reload'
|
||||
})
|
||||
},
|
||||
switchMenu(index) {
|
||||
this.$store.commit('menu/switchHeaderActived', index)
|
||||
if (this.$store.state.settings.switchSidebarAndPageJump) {
|
||||
this.$router.push(this.$store.getters['menu/sidebarRoutes'][0].path)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
proxy.$hotkeys('f5', e => {
|
||||
if (store.state.settings.enablePageReload) {
|
||||
e.preventDefault()
|
||||
reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
provide('reload', reload)
|
||||
function reload() {
|
||||
router.push({
|
||||
name: 'reload'
|
||||
})
|
||||
}
|
||||
|
||||
provide('switchMenu', switchMenu)
|
||||
function switchMenu(index) {
|
||||
store.commit('menu/switchHeaderActived', index)
|
||||
if (store.state.settings.switchSidebarAndPageJump) {
|
||||
router.push(store.getters['menu/sidebarRoutes'][0].path)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user