index.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 { SvgIcon } from '@/components/common';
  19. import { onMounted, ref, watch } from 'vue';
  20. import { useBasicLayout } from '@/hooks/useBasicLayout';
  21. import Login from '@/layout/login/Login.vue';
  22. const { isMobile } = useBasicLayout();
  23. const collapsed = ref(false);
  24. watch(isMobile, (val) => {
  25. collapsed.value = val;
  26. });
  27. onMounted(() => {
  28. collapsed.value = isMobile.value;
  29. });
  30. </script>
  31. <template>
  32. <div class="h-screen w-full grid-mask">
  33. <Login />
  34. <div
  35. v-if="isMobile"
  36. class="p-2 py-3 mb-0 bg-[#fafafa] border dark:border-[#ffffff17] bottom-b grid grid-cols-3"
  37. >
  38. <n-button class="flex !justify-start" text type="primary" @click="collapsed = !collapsed">
  39. <SvgIcon class="text-2xl" icon="solar:list-linear" />
  40. </n-button>
  41. <div class="text-xl font-bold flex justify-center">LangChat</div>
  42. <div class="flex justify-end"></div>
  43. </div>
  44. <n-layout class="h-full" has-sider>
  45. <n-layout-sider
  46. :collapsed="collapsed"
  47. :collapsed-width="0"
  48. :width="200"
  49. @collapse="collapsed = true"
  50. @expand="collapsed = false"
  51. >
  52. <div class="m-4 mr-2" style="height: calc(100vh - 33px)">
  53. <Sider />
  54. </div>
  55. </n-layout-sider>
  56. <n-layout-content>
  57. <RouterView v-slot="{ Component, route }">
  58. <keep-alive>
  59. <div
  60. class="h-full m-4 ml-2 border rounded-lg overflow-hidden bg-white dark:bg-transparent dark:border-[#ffffff17]"
  61. style="height: calc(100vh - 33px)"
  62. >
  63. <component :is="Component" :key="route.fullPath" />
  64. </div>
  65. </keep-alive>
  66. </RouterView>
  67. </n-layout-content>
  68. </n-layout>
  69. </div>
  70. </template>