feat: 按 NqiTools 的方案生成登录页和侧栏

This commit is contained in:
2026-10-26 17:06:04 +08:00
parent 419c40b740
commit eaad01d5a8
74 changed files with 21165 additions and 175 deletions
+71
View File
@@ -0,0 +1,71 @@
<script setup lang="ts">
import { 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";
const props = defineProps<{ employeeId: string }>();
const emit = defineEmits<{ logout: [] }>();
const page = ref<PageKey>("accounts");
const collapsed = ref(false);
function onMenu(key: string) {
if (key === "accounts") page.value = key;
}
</script>
<template>
<n-layout has-sider class="shell">
<n-layout-sider
bordered
collapse-mode="width"
:collapsed-width="64"
:width="220"
:collapsed="collapsed"
show-trigger
:native-scrollbar="false"
:content-style="{ height: '100%', display: 'flex', flexDirection: 'column' }"
@collapse="collapsed = true"
@expand="collapsed = false"
>
<div class="sider-body">
<n-menu
:collapsed="collapsed"
:collapsed-width="64"
:collapsed-icon-size="22"
:value="page"
:options="navOptions"
@update:value="onMenu"
/>
<div class="sider-user" :class="{ compact: collapsed }">
<n-icon :size="18"><PersonOutline /></n-icon>
<div v-if="!collapsed" class="who">
<strong>{{ props.employeeId }}</strong>
<span>已登录</span>
</div>
<n-tooltip>
<template #trigger>
<n-button quaternary circle size="small" :aria-label="isDark ? '切换到日间' : '切换到夜间'" @click="toggleTheme">
<template #icon><n-icon><MoonOutline v-if="!isDark" /><SunnyOutline v-else /></n-icon></template>
</n-button>
</template>
{{ isDark ? "切换到日间" : "切换到夜间" }}
</n-tooltip>
<n-tooltip>
<template #trigger>
<n-button quaternary circle size="small" aria-label="退出" @click="emit('logout')">
<template #icon><n-icon><LogOutOutline /></n-icon></template>
</n-button>
</template>
退出
</n-tooltip>
</div>
</div>
</n-layout-sider>
<n-layout class="content">
<AccountsView v-if="page === 'accounts'" />
</n-layout>
</n-layout>
</template>