index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div :class="classObj" class="app-wrapper" :style="{ '--current-color': theme }">
  3. <div v-if="device === 'mobile' && sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
  4. <sidebar v-if="!sidebar.hide" class="sidebar-container" />
  5. <div :class="{ hasTagsView: needTagsView, sidebarHide: sidebar.hide }" class="main-container">
  6. <div :class="{ 'fixed-header': fixedHeader }">
  7. <navbar @setLayout="setLayout" />
  8. <headerBar></headerBar>
  9. <tags-view v-if="needTagsView" />
  10. </div>
  11. <app-main />
  12. <settings ref="settingRef" />
  13. </div>
  14. </div>
  15. </template>
  16. <script setup>
  17. import { useWindowSize } from "@vueuse/core";
  18. import Sidebar from "./components/Sidebar/index.vue";
  19. import { AppMain, Navbar, Settings, TagsView } from "./components";
  20. import headerBar from "/src/components/headerBar/header-bar";
  21. import useAppStore from "/src/store/modules/app";
  22. import useSettingsStore from "/src/store/modules/settings";
  23. const { proxy } = getCurrentInstance();
  24. const settingsStore = useSettingsStore();
  25. const theme = computed(() => settingsStore.theme);
  26. const sidebar = computed(() => useAppStore().sidebar);
  27. const device = computed(() => useAppStore().device);
  28. const needTagsView = computed(() => settingsStore.tagsView);
  29. const fixedHeader = computed(() => settingsStore.fixedHeader);
  30. const classObj = computed(() => ({
  31. hideSidebar: !sidebar.value.opened,
  32. openSidebar: sidebar.value.opened,
  33. withoutAnimation: sidebar.value.withoutAnimation,
  34. mobile: device.value === "mobile",
  35. }));
  36. const { width, height } = useWindowSize();
  37. const WIDTH = 992; // refer to Bootstrap's responsive design
  38. watchEffect(() => {
  39. if (device.value === "mobile" && sidebar.value.opened) {
  40. useAppStore().closeSideBar({ withoutAnimation: false });
  41. }
  42. if (width.value - 1 < WIDTH) {
  43. useAppStore().toggleDevice("mobile");
  44. useAppStore().closeSideBar({ withoutAnimation: true });
  45. } else {
  46. useAppStore().toggleDevice("desktop");
  47. }
  48. });
  49. function handleClickOutside() {
  50. useAppStore().closeSideBar({ withoutAnimation: false });
  51. }
  52. const settingRef = ref(null);
  53. function setLayout() {
  54. settingRef.value.openSetting();
  55. }
  56. const getAllDict = () => {
  57. proxy
  58. .useUserStore()
  59. .allDictMap()
  60. .then(() => {})
  61. .catch(() => {});
  62. };
  63. getAllDict();
  64. </script>
  65. <style lang="scss" scoped>
  66. @import "@/assets/styles/mixin.scss";
  67. @import "@/assets/styles/variables.module.scss";
  68. .app-wrapper {
  69. @include clearfix;
  70. position: relative;
  71. height: 100%;
  72. width: 100%;
  73. &.mobile.openSidebar {
  74. position: fixed;
  75. top: 0;
  76. }
  77. }
  78. .drawer-bg {
  79. background: #000;
  80. opacity: 0.3;
  81. width: 100%;
  82. top: 0;
  83. height: 100%;
  84. position: absolute;
  85. z-index: 999;
  86. }
  87. .fixed-header {
  88. position: fixed;
  89. top: 0;
  90. right: 0;
  91. z-index: 9;
  92. width: calc(100% - #{$base-sidebar-width});
  93. transition: width 0.28s;
  94. }
  95. .hideSidebar .fixed-header {
  96. width: calc(100% - 54px);
  97. }
  98. .sidebarHide .fixed-header {
  99. width: 100%;
  100. }
  101. .mobile .fixed-header {
  102. width: 100%;
  103. }
  104. ::v-deep(.is-text) {
  105. outline: 0px !important;
  106. }
  107. ::v-deep(.el-button:focus-visible) {
  108. outline: 0px !important;
  109. }
  110. ::v-deep(.box-card) {
  111. height: calc(100vh - 120px);
  112. overflow-y: auto;
  113. overflow-x: hidden;
  114. }
  115. ::v-deep(.tableHeader th) {
  116. background-color: #edf0f5;
  117. height: 35px;
  118. padding: 0;
  119. }
  120. </style>