index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <!--
  2. - Copyright (c) 2024 LangChat. TyCoding All Rights Reserved.
  3. -
  4. - Licensed under the GNU Affero General Public License, Version 3 (the "License");
  5. - you may not use this file except in compliance with the License.
  6. - You may obtain a copy of the License at
  7. -
  8. - https://www.gnu.org/licenses/agpl-3.0.html
  9. -
  10. - Unless required by applicable law or agreed to in writing, software
  11. - distributed under the License is distributed on an "AS IS" BASIS,
  12. - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. - See the License for the specific language governing permissions and
  14. - limitations under the License.
  15. -->
  16. <script lang="ts" setup>
  17. import Sider from './Sider.vue';
  18. import { onMounted, ref, watch } from 'vue';
  19. import { useBasicLayout } from '@/hooks/useBasicLayout';
  20. const { isMobile } = useBasicLayout();
  21. const collapsed = ref(false);
  22. watch(isMobile, (val) => {
  23. collapsed.value = val;
  24. });
  25. onMounted(() => {
  26. collapsed.value = isMobile.value;
  27. });
  28. </script>
  29. <template>
  30. <div class="h-screen w-full grid-mask">
  31. <n-layout class="h-full" has-sider>
  32. <n-layout-sider
  33. :collapsed="collapsed"
  34. :collapsed-width="0"
  35. :width="200"
  36. @collapse="collapsed = true"
  37. @expand="collapsed = false"
  38. >
  39. <div class="m-4 mr-2" style="height: calc(100vh - 33px)">
  40. <Sider />
  41. </div>
  42. </n-layout-sider>
  43. <n-layout-content>
  44. <RouterView v-slot="{ Component, route }">
  45. <keep-alive>
  46. <div
  47. class="h-full m-4 ml-2 border rounded-lg bg-white dark:bg-transparent dark:border-[#ffffff17]"
  48. style="height: calc(100vh - 33px)"
  49. >
  50. <component :is="Component" :key="route.fullPath" />
  51. </div>
  52. </keep-alive>
  53. </RouterView>
  54. </n-layout-content>
  55. </n-layout>
  56. </div>
  57. </template>