index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="page-container">
  3. <slot name="search"></slot>
  4. <a-card :style="{ marginTop: hasSearchSlot ? '16px' : '0' }" class="page-card">
  5. <div v-if="hasActionsSlot">
  6. <slot name="actions"></slot>
  7. </div>
  8. <slot></slot>
  9. </a-card>
  10. </div>
  11. </template>
  12. <script setup>
  13. import {computed, useSlots} from 'vue';
  14. const slots = useSlots();
  15. const hasSearchSlot = computed(() => !!slots.search);
  16. const hasActionsSlot = computed(() => !!slots.actions);
  17. </script>
  18. <style scoped>
  19. .page-container {
  20. width: 100%;
  21. max-width: 100%;
  22. height: calc(100vh - 104px); /* 计算高度:64px(HeaderBar) + 40px(HistoryNav) = 104px */
  23. overflow-y: auto; /* 只允许垂直滚动 */
  24. overflow-x: hidden; /* 隐藏水平滚动条 */
  25. box-sizing: border-box;
  26. background: var(--bg-color);
  27. padding: 0 16px 0 0; /* 右侧不要padding,让滚动条贴近边缘 */
  28. margin: 0;
  29. scrollbar-gutter: stable; /* 保持布局稳定性 */
  30. }
  31. .page-card {
  32. width: 100%;
  33. max-width: 100%;
  34. box-sizing: border-box;
  35. background: var(--component-background);
  36. margin: 0 16px 16px 0; /* 右侧保持间距,但不影响滚动条位置 */
  37. }
  38. /* PageContainer级别滚动条美化 - 8px宽度 */
  39. .page-container::-webkit-scrollbar {
  40. width: 8px;
  41. }
  42. .page-container::-webkit-scrollbar-thumb {
  43. background: rgba(0, 0, 0, 0.15);
  44. border-radius: 4px;
  45. transition: background 0.3s ease;
  46. /* 确保滚动条贴近右边缘 */
  47. border: none;
  48. margin: 0;
  49. }
  50. .page-container::-webkit-scrollbar-thumb:hover {
  51. background: rgba(0, 0, 0, 0.25);
  52. }
  53. .page-container::-webkit-scrollbar-track {
  54. background: transparent;
  55. border-radius: 4px;
  56. /* 确保轨道贴近右边缘 */
  57. border: none;
  58. margin: 0;
  59. }
  60. .page-container::-webkit-scrollbar-corner {
  61. background: transparent;
  62. }
  63. /* 确保卡片内容区域正确处理溢出 */
  64. :deep(.ant-card-body) {
  65. padding: 16px;
  66. width: 100%;
  67. box-sizing: border-box;
  68. background: var(--component-background);
  69. color: var(--text-primary);
  70. overflow: visible; /* 确保内容可见 */
  71. }
  72. /* 表格容器滚动条 - 8px宽度,与页面滚动条保持一致 */
  73. :deep(.ant-table-wrapper) {
  74. overflow-x: auto;
  75. scrollbar-gutter: stable; /* 保持布局稳定性 */
  76. }
  77. :deep(.ant-table-wrapper)::-webkit-scrollbar {
  78. height: 8px;
  79. width: 8px;
  80. }
  81. :deep(.ant-table-wrapper)::-webkit-scrollbar-thumb {
  82. background: rgba(0, 0, 0, 0.15);
  83. border-radius: 4px;
  84. transition: background 0.3s ease;
  85. /* 确保滚动条贴近边缘 */
  86. border: none;
  87. margin: 0;
  88. }
  89. :deep(.ant-table-wrapper)::-webkit-scrollbar-thumb:hover {
  90. background: rgba(0, 0, 0, 0.25);
  91. }
  92. :deep(.ant-table-wrapper)::-webkit-scrollbar-track {
  93. background: transparent;
  94. border-radius: 4px;
  95. /* 确保轨道贴近边缘 */
  96. border: none;
  97. margin: 0;
  98. }
  99. :deep(.ant-table-wrapper)::-webkit-scrollbar-corner {
  100. background: transparent;
  101. }
  102. /* 暗黑模式滚动条适配 */
  103. :global(.dark-theme) .page-container::-webkit-scrollbar-thumb {
  104. background: rgba(255, 255, 255, 0.2);
  105. }
  106. :global(.dark-theme) .page-container::-webkit-scrollbar-thumb:hover {
  107. background: rgba(255, 255, 255, 0.3);
  108. }
  109. :global(.dark-theme) .page-container::-webkit-scrollbar-track {
  110. background: rgba(255, 255, 255, 0.05);
  111. }
  112. /* 暗黑模式表格滚动条 */
  113. :global(.dark-theme) :deep(.ant-table-wrapper)::-webkit-scrollbar-thumb {
  114. background: rgba(255, 255, 255, 0.2);
  115. }
  116. :global(.dark-theme) :deep(.ant-table-wrapper)::-webkit-scrollbar-thumb:hover {
  117. background: rgba(255, 255, 255, 0.3);
  118. }
  119. :global(.dark-theme) :deep(.ant-table-wrapper)::-webkit-scrollbar-track {
  120. background: rgba(255, 255, 255, 0.05);
  121. }
  122. </style>