index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <el-container direction="vertical" class="ng-public-layout" lang="en">
  3. <public-header v-if="showHeader" :login-route="loginRoute" />
  4. <el-main class="ng-public-main">
  5. <page-hero v-if="layout.hero" :hero="layout.hero" />
  6. <div class="ng-public-container ng-public-content">
  7. <router-view />
  8. </div>
  9. </el-main>
  10. <public-footer v-if="layout.showFooter !== false" />
  11. </el-container>
  12. </template>
  13. <script>
  14. import './styles/theme.scss'
  15. import PublicHeader from './layouts/PublicHeader.vue'
  16. import PageHero from './layouts/PageHero.vue'
  17. import PublicFooter from './layouts/PublicFooter.vue'
  18. import usersInfo from '@/utils/usersInfo'
  19. export default {
  20. name: 'PublicLayout',
  21. components: { PublicHeader, PageHero, PublicFooter },
  22. computed: {
  23. layout() {
  24. // 仅使用当前叶子路由的展示配置,不参与权限或认证判断。
  25. return this.$route.meta.publicLayout || {}
  26. },
  27. showHeader() {
  28. // 会话有效性沿用路由守卫;这里只读取现有登录状态来控制展示。
  29. return this.layout.showHeader === 'authenticated'
  30. ? Boolean(usersInfo.accessToken())
  31. : this.layout.showHeader !== false
  32. },
  33. loginRoute() {
  34. // 返回登录时保留 redirect 和来源等查询参数。
  35. return { path: '/login', query: this.$route.query }
  36. }
  37. }
  38. }
  39. </script>
  40. <style lang="scss" scoped>
  41. @font-face {
  42. font-family: 'Ng Public Montserrat';
  43. src: url('../assets/custom-theme/fonts/Montserrat-Regular.woff2') format('woff2');
  44. font-weight: 400;
  45. font-style: normal;
  46. font-display: swap;
  47. }
  48. @font-face {
  49. font-family: 'Ng Public Montserrat';
  50. src: url('../assets/custom-theme/fonts/Montserrat-Medium.woff2') format('woff2');
  51. font-weight: 500;
  52. font-style: normal;
  53. font-display: swap;
  54. }
  55. @font-face {
  56. font-family: 'Ng Public Montserrat';
  57. src: url('../assets/custom-theme/fonts/Montserrat-Bold.woff2') format('woff2');
  58. font-weight: 700;
  59. font-style: normal;
  60. font-display: swap;
  61. }
  62. .ng-public-layout {
  63. min-height: 100vh;
  64. font-family: 'Ng Public Montserrat', 'Helvetica Neue', Arial, sans-serif;
  65. color: #25292c;
  66. background: #f4f6f8;
  67. }
  68. .ng-public-layout .ng-public-main {
  69. flex: 1 0 auto;
  70. min-width: 0;
  71. padding: 0;
  72. overflow: visible;
  73. }
  74. .ng-public-layout ::v-deep .ng-public-container {
  75. width: calc(100% - 96px);
  76. max-width: 1408px;
  77. margin-right: auto;
  78. margin-left: auto;
  79. }
  80. .ng-public-layout ::v-deep .ng-public-container--chrome {
  81. max-width: 1605px;
  82. }
  83. .ng-public-layout .ng-public-content {
  84. padding-top: 48px;
  85. padding-bottom: 64px;
  86. }
  87. .ng-public-layout ::v-deep a:focus-visible {
  88. outline: 2px solid currentColor;
  89. outline-offset: 4px;
  90. }
  91. @media (max-width: 1199px) {
  92. .ng-public-layout ::v-deep .ng-public-container {
  93. width: calc(100% - 80px);
  94. }
  95. }
  96. @media (max-width: 767px) {
  97. .ng-public-layout ::v-deep .ng-public-container {
  98. width: calc(100% - 40px);
  99. }
  100. .ng-public-layout .ng-public-content {
  101. padding-top: 32px;
  102. padding-bottom: 40px;
  103. }
  104. }
  105. </style>