feat: 首页侧边抽屉调整

This commit is contained in:
duanshuwen
2025-11-09 18:14:53 +08:00
parent a7348c2002
commit a3087c09a8
2 changed files with 12 additions and 8 deletions

View File

@@ -36,7 +36,7 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted, defineEmits } from "vue"; import { ref, defineEmits, defineExpose } from "vue";
import { getLoginUserPhone } from "@/request/api/LoginApi"; import { getLoginUserPhone } from "@/request/api/LoginApi";
import { NOTICE_EVENT_LOGOUT } from "@/constant/constant"; import { NOTICE_EVENT_LOGOUT } from "@/constant/constant";
import { useAppStore } from "@/store"; import { useAppStore } from "@/store";
@@ -64,11 +64,6 @@ const menuList = ref([
// { label: "订阅消息", type: "action", action: "subscribeMessage" }, // { label: "订阅消息", type: "action", action: "subscribeMessage" },
]); ]);
// 组件挂载时调用
onMounted(() => {
getLoginUserPhoneInfo();
});
const getLoginUserPhoneInfo = async () => { const getLoginUserPhoneInfo = async () => {
const res = await getLoginUserPhone(); const res = await getLoginUserPhone();
@@ -113,6 +108,8 @@ const handleLogout = () => {
}, },
}); });
}; };
defineExpose({ getLoginUserPhoneInfo });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -12,19 +12,26 @@
<text class="title">我的</text> <text class="title">我的</text>
</view> </view>
<MineSetting @close="close" /> <MineSetting ref="mineSettingRef" @close="close" />
</view> </view>
</uni-drawer> </uni-drawer>
</template> </template>
<script setup> <script setup>
import { ref, defineExpose } from "vue"; import { ref, defineExpose } from "vue";
import { checkToken } from "@/hooks/useGoLogin";
import MineSetting from "./components/MineSetting/index.vue"; import MineSetting from "./components/MineSetting/index.vue";
const drawerRef = ref(null); const drawerRef = ref(null);
// 监听抽屉显示事件 // 监听抽屉显示事件
const open = () => drawerRef.value.open(); const mineSettingRef = ref(null);
const open = () => {
checkToken().then(async () => {
await mineSettingRef.value.getLoginUserPhoneInfo();
drawerRef.value.open();
});
};
// 监听抽屉隐藏事件 // 监听抽屉隐藏事件
const close = () => drawerRef.value.close(); const close = () => drawerRef.value.close();