index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div class="app">
  3. <div :class="classObj" class="app-wrapper">
  4. <dv-full-screen-container>
  5. <logo :collapse="isCollapse" class="fixed-header" />
  6. <app-main />
  7. <sidebar v-if="!sidebar.hide" class="fixed-bottom" />
  8. </dv-full-screen-container>
  9. </div>
  10. </div>
  11. </template>
  12. <script setup>
  13. import { useWindowSize } from '@vueuse/core'
  14. import Sidebar from './components/Sidebar/index.vue'
  15. import { AppMain, Navbar, Settings, TagsView } from './components'
  16. import Logo from './components/Sidebar/Logo'
  17. import defaultSettings from '@/settings'
  18. import useAppStore from '@/store/modules/app'
  19. import useSettingsStore from '@/store/modules/settings'
  20. const settingsStore = useSettingsStore()
  21. const theme = computed(() => settingsStore.theme);
  22. const sideTheme = computed(() => settingsStore.sideTheme);
  23. const sidebar = computed(() => useAppStore().sidebar);
  24. const device = computed(() => useAppStore().device);
  25. const needTagsView = computed(() => settingsStore.tagsView);
  26. const fixedHeader = computed(() => settingsStore.fixedHeader);
  27. const classObj = computed(() => ({
  28. hideSidebar: !sidebar.value.opened,
  29. openSidebar: sidebar.value.opened,
  30. withoutAnimation: sidebar.value.withoutAnimation,
  31. mobile: device.value === 'mobile'
  32. }))
  33. const { width, height } = useWindowSize();
  34. const WIDTH = 992; // refer to Bootstrap's responsive design
  35. watch(() => device.value, () => {
  36. if (device.value === 'mobile' && sidebar.value.opened) {
  37. useAppStore().closeSideBar({ withoutAnimation: false })
  38. }
  39. })
  40. watchEffect(() => {
  41. if (width.value - 1 < WIDTH) {
  42. useAppStore().toggleDevice('mobile')
  43. useAppStore().closeSideBar({ withoutAnimation: true })
  44. } else {
  45. useAppStore().toggleDevice('desktop')
  46. }
  47. })
  48. function handleClickOutside() {
  49. useAppStore().closeSideBar({ withoutAnimation: false })
  50. }
  51. const settingRef = ref(null);
  52. function setLayout() {
  53. settingRef.value.openSetting();
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. @import "@/assets/styles/mixin.scss";
  58. @import "@/assets/styles/variables.module.scss";
  59. .app {
  60. position: relative;
  61. height: 100%;
  62. width: 100%;
  63. overflow: hidden;
  64. background: radial-gradient(at 50% 50%, rgb(29, 52, 94) 1%, rgb(3, 22, 46) 60%);
  65. }
  66. .app-wrapper {
  67. @include clearfix;
  68. position: relative;
  69. height: 100%;
  70. width: 100%;
  71. display: flex;
  72. flex-direction: column;
  73. overflow: hidden;
  74. background-image:
  75. repeating-linear-gradient(35deg, rgba(13, 28, 61, .5), rgba(13, 28, 61, .5) 1px, transparent 1px, transparent 70px),
  76. repeating-linear-gradient(-35deg, rgba(13, 28, 61, .5), rgba(13, 28, 61, .5) 1px, transparent 1px, transparent 70px),
  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. left: 0;
  92. z-index: 9;
  93. width: 100%;
  94. transition: width 0.28s;
  95. }
  96. .fixed-bottom {
  97. position: fixed;
  98. bottom: 0;
  99. right: 0;
  100. left: 0;
  101. z-index: 9;
  102. width: 100%;
  103. transition: width 0.28s;
  104. }
  105. </style>