78 lines
1.5 KiB
Vue
78 lines
1.5 KiB
Vue
|
|
<template>
|
||
|
|
<div class="bottom-menu">
|
||
|
|
<div
|
||
|
|
class="item"
|
||
|
|
@click="changeMenu(index)"
|
||
|
|
:style="{
|
||
|
|
'background-image':
|
||
|
|
'url(' +
|
||
|
|
(currentIndex == index
|
||
|
|
? getImage('icon-menu-checked')
|
||
|
|
: getImage('icon-menu')) +
|
||
|
|
')',
|
||
|
|
}"
|
||
|
|
v-for="(item, index) in menu"
|
||
|
|
:key="index"
|
||
|
|
>
|
||
|
|
<img />
|
||
|
|
<span>{{ item.name }}</span>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script lang='ts' setup>
|
||
|
|
import { menuStore } from "@/store/menu";
|
||
|
|
import { EventEnum } from "@/utils/eventEnum";
|
||
|
|
import { onMounted, ref } from "vue";
|
||
|
|
|
||
|
|
const userMenu = menuStore();
|
||
|
|
|
||
|
|
const currentIndex = ref(0);
|
||
|
|
const menu = ref([
|
||
|
|
{ name: "首页", icon: "" },
|
||
|
|
{ name: "数据统计", icon: "" },
|
||
|
|
]);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 切换菜单
|
||
|
|
*/
|
||
|
|
const changeMenu = (index: number) => {
|
||
|
|
currentIndex.value = index;
|
||
|
|
userMenu.setMenuType(index);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取图片
|
||
|
|
*/
|
||
|
|
const getImage = (name: string) => {
|
||
|
|
const path = `/src/assets/images/menu/${name}.png`;
|
||
|
|
const modules = import.meta.globEager("/src/assets/images/menu/*.png");
|
||
|
|
return modules[path].default;
|
||
|
|
};
|
||
|
|
|
||
|
|
onMounted(() => {});
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style lang="scss" scoped>
|
||
|
|
.bottom-menu {
|
||
|
|
position: fixed;
|
||
|
|
bottom: 20px;
|
||
|
|
left: $sideWidth;
|
||
|
|
right: $sideWidth;
|
||
|
|
margin: 0 1%;
|
||
|
|
display: flex;
|
||
|
|
flex-direction: row;
|
||
|
|
justify-content: center;
|
||
|
|
|
||
|
|
.item {
|
||
|
|
font-size: 18px;
|
||
|
|
font-family: PingFang-SC, PingFang-SC;
|
||
|
|
color: #ffffff;
|
||
|
|
padding: 10px 60px;
|
||
|
|
background-size: 100% 100%;
|
||
|
|
background-repeat: no-repeat;
|
||
|
|
cursor: pointer;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</style>
|