App.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <a-config-provider :theme="themeConfig">
  3. <router-view />
  4. </a-config-provider>
  5. </template>
  6. <script setup lang="ts">
  7. import { computed, onMounted } from 'vue'
  8. import { theme } from 'ant-design-vue'
  9. import { useThemeStore } from '@/stores/theme'
  10. import { useAuthStore } from '@/stores/auth'
  11. import { useWebSocketStore } from '@/stores/websocket'
  12. const themeStore = useThemeStore()
  13. const authStore = useAuthStore()
  14. const wsStore = useWebSocketStore()
  15. const themeConfig = computed(() => ({
  16. algorithm: themeStore.theme === 'dark' ? theme.darkAlgorithm : theme.defaultAlgorithm,
  17. token: {
  18. colorPrimary: '#1890ff',
  19. borderRadius: 6,
  20. colorBgContainer: themeStore.themeColors.cardBackground,
  21. colorBgElevated: themeStore.themeColors.cardBackground,
  22. colorBgLayout: themeStore.themeColors.surface,
  23. colorBorder: themeStore.themeColors.border,
  24. colorBorderSecondary: themeStore.themeColors.border,
  25. colorText: themeStore.themeColors.text,
  26. colorTextSecondary: themeStore.themeColors.textSecondary,
  27. }
  28. }))
  29. onMounted(async () => {
  30. themeStore.applyThemeToDom()
  31. await authStore.checkAuthStatus()
  32. if (authStore.isAuthenticated) {
  33. wsStore.initConnection()
  34. }
  35. })
  36. </script>
  37. <style>
  38. * {
  39. margin: 0;
  40. padding: 0;
  41. box-sizing: border-box;
  42. }
  43. body {
  44. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  45. -webkit-font-smoothing: antialiased;
  46. -moz-osx-font-smoothing: grayscale;
  47. background: var(--theme-background);
  48. color: var(--theme-text);
  49. transition: background-color 0.3s ease, color 0.3s ease;
  50. }
  51. :root {
  52. --theme-background: #ffffff;
  53. --theme-surface: #f0f2f5;
  54. --theme-primary: #1890ff;
  55. --theme-secondary: #52c41a;
  56. --theme-accent: #722ed1;
  57. --theme-text: rgba(0, 0, 0, 0.88);
  58. --theme-text-secondary: rgba(0, 0, 0, 0.45);
  59. --theme-border: #f0f0f0;
  60. --theme-shadow: rgba(0, 0, 0, 0.06);
  61. --theme-card-background: #ffffff;
  62. --theme-header-background: #ffffff;
  63. --theme-sidebar-background: #ffffff;
  64. --theme-success: #52c41a;
  65. --theme-warning: #faad14;
  66. --theme-error: #ff4d4f;
  67. --theme-info: #1890ff;
  68. }
  69. .dark-theme {
  70. --theme-background: #141414;
  71. --theme-surface: #1a1a1a;
  72. --theme-primary: #177ddc;
  73. --theme-secondary: #49aa19;
  74. --theme-accent: #531dab;
  75. --theme-text: rgba(255, 255, 255, 0.88);
  76. --theme-text-secondary: rgba(255, 255, 255, 0.45);
  77. --theme-border: #303030;
  78. --theme-shadow: rgba(0, 0, 0, 0.3);
  79. --theme-card-background: #1f1f1f;
  80. --theme-header-background: #1f1f1f;
  81. --theme-sidebar-background: #141414;
  82. --theme-success: #49aa19;
  83. --theme-warning: #d89614;
  84. --theme-error: #d32029;
  85. --theme-info: #177ddc;
  86. }
  87. #app {
  88. min-height: 100vh;
  89. }
  90. .ant-layout-sider {
  91. transition: width 0.2s cubic-bezier(0.645, 0.045, 0.355, 1), min-width 0.2s cubic-bezier(0.645, 0.045, 0.355, 1), max-width 0.2s cubic-bezier(0.645, 0.045, 0.355, 1) !important;
  92. }
  93. .ant-layout-sider .ant-layout-sider-children {
  94. transition: none !important;
  95. }
  96. .ant-card {
  97. border-radius: 8px !important;
  98. box-shadow: 0 1px 2px 0 var(--theme-shadow) !important;
  99. }
  100. .ant-menu-inline {
  101. border-inline-end: none !important;
  102. }
  103. .ant-drawer .ant-drawer-body {
  104. padding: 0 !important;
  105. }
  106. ::-webkit-scrollbar {
  107. width: 6px;
  108. height: 6px;
  109. }
  110. ::-webkit-scrollbar-track {
  111. background: transparent;
  112. }
  113. ::-webkit-scrollbar-thumb {
  114. background: rgba(0, 0, 0, 0.15);
  115. border-radius: 3px;
  116. }
  117. ::-webkit-scrollbar-thumb:hover {
  118. background: rgba(0, 0, 0, 0.25);
  119. }
  120. .dark-theme ::-webkit-scrollbar-thumb {
  121. background: rgba(255, 255, 255, 0.15);
  122. }
  123. .dark-theme ::-webkit-scrollbar-thumb:hover {
  124. background: rgba(255, 255, 255, 0.25);
  125. }
  126. </style>