59 lines
1.2 KiB
Vue
59 lines
1.2 KiB
Vue
<template>
|
||
<view class="nav-bar">
|
||
<view class="nav-item" @click="showDrawer('showLeft')">
|
||
<uni-icons type="bars" size="24" color="#333"></uni-icons>
|
||
</view>
|
||
|
||
<uni-drawer ref="showLeft" mode="left" :width="320">
|
||
<DrawerHome @closeDrawer="closeDrawer('showLeft')" />
|
||
</uni-drawer>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref } from "vue";
|
||
import DrawerHome from "@/pages/drawer/DrawerHome.vue";
|
||
import { goLogin } from "@/hooks/useGoLogin";
|
||
import { useAppStore } from "@/store";
|
||
const appStore = useAppStore();
|
||
const showLeft = ref(false);
|
||
|
||
// 打开窗口
|
||
const showDrawer = (e) => {
|
||
if (!appStore.hasToken) {
|
||
console.log("没有token,跳转到登录页");
|
||
goLogin();
|
||
return;
|
||
}
|
||
|
||
showLeft.value.open();
|
||
// 发送抽屉显示事件
|
||
uni.$emit("drawerShow");
|
||
};
|
||
// 关闭窗口
|
||
const closeDrawer = (e) => {
|
||
showLeft.value.close();
|
||
// 发送抽屉隐藏事件
|
||
uni.$emit("drawerHide");
|
||
};
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.nav-bar {
|
||
display: flex;
|
||
align-items: center;
|
||
height: 44px;
|
||
padding: 0 15px;
|
||
|
||
.nav-item {
|
||
width: 24px;
|
||
height: 24px;
|
||
margin-right: 10px;
|
||
}
|
||
.nav-item-icon {
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
}
|
||
</style>
|