You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.3 KiB

  1. <template>
  2. <header class="title">
  3. <div class="title-text" :style="fontSize">
  4. <img
  5. v-if="props.colorBgc"
  6. src="@/assets/img/page/title-jn-left.png"
  7. alt=""
  8. class="title-text-img"
  9. />
  10. <div v-if="props.colorBgc">{{ translate(props.titleKey) }}</div>
  11. <img
  12. v-if="props.colorBgc"
  13. src="@/assets/img/page/title-jn-right.png"
  14. alt=""
  15. class="title-text-img"
  16. />
  17. <img
  18. v-if="!props.colorBgc"
  19. src="@/assets/img/page/title-left.png"
  20. alt=""
  21. class="title-text-img"
  22. />
  23. <div v-if="!props.colorBgc">{{ translate(props.titleKey) }}</div>
  24. <img
  25. v-if="!props.colorBgc"
  26. src="@/assets/img/page/title-right.png"
  27. alt=""
  28. class="title-text-img"
  29. />
  30. </div>
  31. <div class="title-line">
  32. <img src="@/assets/img/page/line.png" class="title-line-img" />
  33. </div>
  34. </header>
  35. </template>
  36. <script setup>
  37. import { useLanguage } from '@/utils/languageService'
  38. import { defineProps, computed } from 'vue'
  39. // 获取翻译函数和语言状态
  40. const { translate, t } = useLanguage()
  41. // 定义 props 接收传入的标题
  42. const props = defineProps({
  43. titleKey: {
  44. type: String,
  45. required: true
  46. },
  47. colorBgc: {
  48. type: String,
  49. required: true
  50. }
  51. })
  52. // 定义 fontSize 的类型,并确保 computed 返回正确的类型
  53. const fontSize = computed(() => {
  54. if (t.value?.suoxie === 'en' || t.value?.suoxie === 'th') {
  55. // 手机尺寸
  56. if (window.innerWidth < 768) {
  57. return { fontSize: '3vw' }
  58. } else {
  59. return { fontSize: '1.5vw' }
  60. }
  61. } else {
  62. // 简体或者繁体
  63. if (window.innerWidth < 768) {
  64. return { fontSize: '3.5vw' }
  65. } else {
  66. return { fontSize: '1.5vw' }
  67. }
  68. }
  69. })
  70. </script>
  71. <style scoped lang="less">
  72. .title {
  73. position: relative;
  74. .title-text {
  75. font-size: 3vw;
  76. display: flex;
  77. align-items: center;
  78. flex-wrap: wrap;
  79. justify-content: center;
  80. color: white;
  81. .title-text-img {
  82. width: 10%;
  83. }
  84. }
  85. .title-line {
  86. text-align: center;
  87. position: absolute;
  88. bottom: -1vw;
  89. left: 50%; /* 将左边距设置为 50% */
  90. transform: translateX(-50%); /* 使用 transform 来将元素水平居中 */
  91. width: 85%;
  92. .title-line-img {
  93. width: 100%;
  94. height: auto;
  95. }
  96. }
  97. }
  98. @media (min-width: 768px) {
  99. .title-text-img {
  100. width: 6% !important;
  101. }
  102. }
  103. </style>