Files
xiaozhi-admin-ui/src/layout/components/AppMain.vue
T

89 lines
2.0 KiB
Vue

<template>
<section class="app-main">
<router-view v-slot="{ Component, route }">
<transition :enter-active-class="animate" mode="out-in">
<keep-alive :include="tagsViewStore.cachedViews">
<component :is="Component" v-if="!route.meta.link" :key="route.path" />
</keep-alive>
</transition>
</router-view>
<iframe-toggle />
</section>
</template>
<script setup name="AppMain" lang="ts">
import { useSettingsStore } from '@/store/modules/settings';
import { useTagsViewStore } from '@/store/modules/tagsView';
import IframeToggle from './IframeToggle/index.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const route = useRoute();
const tagsViewStore = useTagsViewStore();
// 随机动画集合
const animate = ref<string>('');
watch(
() => useSettingsStore().animationEnable,
(val: boolean) => {
if (val) {
animate.value = proxy?.animate.animateList[Math.round(Math.random() * proxy?.animate.animateList.length)] as string;
} else {
animate.value = proxy?.animate.defaultAnimate as string;
}
},
{ immediate: true }
);
watchEffect(() => {
addIframe();
});
function addIframe() {
if (route.meta.link) {
useTagsViewStore().addIframeView(route);
}
}
</script>
<style lang="scss" scoped>
.app-main {
min-height: 100vh;
width: 100%;
position: relative;
overflow: hidden;
padding: 12px;
}
.app-main.with-fixed-header {
padding-top: 76px;
min-height: calc(100vh - 76px);
}
.app-main.with-fixed-header.with-tags-view {
min-height: calc(100vh - 111px);
padding-top: 111px;
}
</style>
<style lang="scss">
// fix css style bug in open el-dialog
.el-popup-parent--hidden {
.fixed-header {
padding-right: 6px;
}
}
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background-color: var(--el-fill-color-lighter);
}
::-webkit-scrollbar-thumb {
background-color: var(--el-text-color-placeholder);
border-radius: 999px;
}
</style>