feat: 登录后进入实时首页,并加密保存可刷新的登录凭证
This commit is contained in:
+18
-7
@@ -1,18 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { onMounted, onUnmounted, ref } from "vue";
|
||||
import { NButton, NIcon, NLayout, NLayoutSider, NMenu, NTooltip } from "naive-ui";
|
||||
import { LogOutOutline, MoonOutline, PersonOutline, SunnyOutline } from "@vicons/ionicons5";
|
||||
import { isDark, toggleTheme } from "../shared/theme";
|
||||
import { navOptions, type PageKey } from "./navigation";
|
||||
import AccountsView from "../features/accounts/AccountsView.vue";
|
||||
import HomeView from "../features/home/HomeView.vue";
|
||||
|
||||
const props = defineProps<{ employeeId: string }>();
|
||||
const emit = defineEmits<{ logout: [] }>();
|
||||
const page = ref<PageKey>("accounts");
|
||||
const collapsed = ref(false);
|
||||
const page = ref<PageKey>("home");
|
||||
const collapsed = ref(window.innerWidth < 800);
|
||||
|
||||
function onResize() {
|
||||
if (window.innerWidth < 800) collapsed.value = true;
|
||||
}
|
||||
|
||||
onMounted(() => window.addEventListener("resize", onResize));
|
||||
onUnmounted(() => window.removeEventListener("resize", onResize));
|
||||
|
||||
function onMenu(key: string) {
|
||||
if (key === "accounts") page.value = key;
|
||||
if (key === "home") page.value = key;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -31,6 +38,10 @@ function onMenu(key: string) {
|
||||
@expand="collapsed = false"
|
||||
>
|
||||
<div class="sider-body">
|
||||
<div class="sider-brand" :class="{ compact: collapsed }">
|
||||
<div class="brand-mark" aria-hidden="true">E</div>
|
||||
<strong v-if="!collapsed">EunivTools</strong>
|
||||
</div>
|
||||
<n-menu
|
||||
:collapsed="collapsed"
|
||||
:collapsed-width="64"
|
||||
@@ -55,7 +66,7 @@ function onMenu(key: string) {
|
||||
</n-tooltip>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button quaternary circle size="small" aria-label="退出" @click="emit('logout')">
|
||||
<n-button class="logout-btn" quaternary circle size="small" aria-label="退出" @click="emit('logout')">
|
||||
<template #icon><n-icon><LogOutOutline /></n-icon></template>
|
||||
</n-button>
|
||||
</template>
|
||||
@@ -65,7 +76,7 @@ function onMenu(key: string) {
|
||||
</div>
|
||||
</n-layout-sider>
|
||||
<n-layout class="content">
|
||||
<AccountsView v-if="page === 'accounts'" />
|
||||
<HomeView v-if="page === 'home'" :employee-id="props.employeeId" />
|
||||
</n-layout>
|
||||
</n-layout>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user