index.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <n-layout
  3. has-sider
  4. position="absolute"
  5. style="top: 0; right: 0; bottom: 0; left: 0"
  6. >
  7. <n-config-provider :theme="darkTheme">
  8. <n-layout-sider
  9. collapse-mode="transform"
  10. :collapsed-width="0"
  11. show-trigger="bar"
  12. :native-scrollbar="false"
  13. class="h-full"
  14. >
  15. <h2 class="text-center leading-[64px]">冷链验证报告生成系统</h2>
  16. <MenuComponent />
  17. </n-layout-sider>
  18. </n-config-provider>
  19. <n-layout>
  20. <n-layout-header class="h-16 px-6" bordered>
  21. <n-space justify="end" align="center" class="h-full">
  22. <n-dropdown trigger="hover" :options="options" @select="handleSelect">
  23. <n-avatar round class="cursor-pointer"> {{ username }} </n-avatar>
  24. </n-dropdown>
  25. </n-space>
  26. </n-layout-header>
  27. <n-layout-content
  28. content-style="padding: 24px; background-color: #f0f2f5"
  29. :native-scrollbar="false"
  30. >
  31. <n-card
  32. :bordered="false"
  33. style="height: calc(100vh - 112px); min-height: 600px"
  34. >
  35. <RouterView />
  36. </n-card>
  37. </n-layout-content>
  38. </n-layout>
  39. </n-layout>
  40. </template>
  41. <script setup>
  42. import { darkTheme, NIcon } from "naive-ui";
  43. import MenuComponent from "@/layout/components/menu/index.vue";
  44. import { removeToken } from "@/utils/storage/sessionToken";
  45. import { LogoutOutlined as LogoutIcon } from "@vicons/antd";
  46. const router = useRouter();
  47. const message = useMessage();
  48. const username = window.sessionStorage.getItem("username");
  49. const renderIcon = (icon) => {
  50. return () => {
  51. return h(NIcon, null, {
  52. default: () => h(icon),
  53. });
  54. };
  55. };
  56. // 下拉菜单传入的 options
  57. const options = [
  58. {
  59. label: "退出登录",
  60. key: "/logout",
  61. icon: renderIcon(LogoutIcon),
  62. },
  63. ];
  64. // select 选中时触发的回调函数
  65. const handleSelect = () => {
  66. removeToken();
  67. message.success("退出登录成功");
  68. router.replace("/login");
  69. };
  70. </script>
  71. <style scoped></style>