index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <dv-full-screen-container style="position: unset;">
  3. <div class="app">
  4. <div :class="classObj" class="app-wrapper">
  5. <logo :collapse="isCollapse" class="fixed-header" />
  6. <app-main />
  7. <sidebar v-if="!sidebar.hide" class="fixed-bottom" />
  8. </div>
  9. </div>
  10. </dv-full-screen-container>
  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 isCollapse = ref(true)
  34. const { width, height } = useWindowSize();
  35. const WIDTH = 992; // refer to Bootstrap's responsive design
  36. watch(() => device.value, () => {
  37. if (device.value === 'mobile' && sidebar.value.opened) {
  38. useAppStore().closeSideBar({ withoutAnimation: false })
  39. }
  40. })
  41. watchEffect(() => {
  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. </script>
  57. <style lang="scss" scoped>
  58. @import "@/assets/styles/mixin.scss";
  59. @import "@/assets/styles/variables.module.scss";
  60. .app {
  61. position: relative;
  62. height: 100%;
  63. width: 100%;
  64. overflow: hidden;
  65. z-index: -2;
  66. background: radial-gradient(at 50% 50%, rgb(29, 52, 94) 1%, rgb(3, 22, 46) 60%);
  67. }
  68. .app-wrapper {
  69. @include clearfix;
  70. position: relative;
  71. height: 100%;
  72. width: 100%;
  73. display: flex;
  74. flex-direction: column;
  75. overflow: hidden;
  76. z-index: -2;
  77. background-image:
  78. repeating-linear-gradient(35deg, rgba(13, 28, 61, .5), rgba(13, 28, 61, .5) 1px, transparent 1px, transparent 70px),
  79. repeating-linear-gradient(-35deg, rgba(13, 28, 61, .5), rgba(13, 28, 61, .5) 1px, transparent 1px, transparent 70px),
  80. }
  81. .drawer-bg {
  82. background: #000;
  83. opacity: 0.3;
  84. width: 100%;
  85. top: 0;
  86. height: 100%;
  87. position: absolute;
  88. z-index: 999;
  89. }
  90. .fixed-header {
  91. position: fixed;
  92. top: 0;
  93. right: 0;
  94. left: 0;
  95. z-index: 9;
  96. width: 100%;
  97. transition: width 0.28s;
  98. }
  99. .fixed-bottom {
  100. position: fixed;
  101. bottom: 0;
  102. right: 0;
  103. left: 0;
  104. z-index: 9;
  105. width: 100%;
  106. transition: width 0.28s;
  107. }
  108. </style>