feat(视图): 添加大师详情页内容并优化姓名显示样式
在MastersDetail.vue中添加图片和内容展示区域 在Masters.vue中为姓名添加上标效果并调整字体大小
Showing
2 changed files
with
77 additions
and
7 deletions
| ... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
| 13 | </div> | 13 | </div> |
| 14 | <div class="item-caption"> | 14 | <div class="item-caption"> |
| 15 | <div class="item-role">{{ item.role }}</div> | 15 | <div class="item-role">{{ item.role }}</div> |
| 16 | - <div class="item-name">{{ item.name }}</div> | 16 | + <div class="item-name" v-html="formatNameWithSuperscript(item.name)"></div> |
| 17 | </div> | 17 | </div> |
| 18 | </div> | 18 | </div> |
| 19 | </section> | 19 | </section> |
| ... | @@ -31,7 +31,7 @@ | ... | @@ -31,7 +31,7 @@ |
| 31 | </div> | 31 | </div> |
| 32 | <div class="item-caption"> | 32 | <div class="item-caption"> |
| 33 | <div class="item-role">{{ item.role }}</div> | 33 | <div class="item-role">{{ item.role }}</div> |
| 34 | - <div class="item-name">{{ item.name }}</div> | 34 | + <div class="item-name small" v-html="formatNameWithSuperscript(item.name)"></div> |
| 35 | </div> | 35 | </div> |
| 36 | </div> | 36 | </div> |
| 37 | </section> | 37 | </section> |
| ... | @@ -116,6 +116,20 @@ const goDetail = (item) => { | ... | @@ -116,6 +116,20 @@ const goDetail = (item) => { |
| 116 | router.push(`/masters/${item.id}`) | 116 | router.push(`/masters/${item.id}`) |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | +/** | ||
| 120 | + * 为name字段的第一个文字添加上标效果 | ||
| 121 | + * @param {string} name - 原始姓名 | ||
| 122 | + * @returns {string} - 带上标的HTML字符串 | ||
| 123 | + */ | ||
| 124 | +const formatNameWithSuperscript = (name) => { | ||
| 125 | + if (!name || name.length === 0) return name | ||
| 126 | + | ||
| 127 | + const firstChar = name.charAt(0) | ||
| 128 | + const restChars = name.slice(1) | ||
| 129 | + | ||
| 130 | + return `<sup style="font-size: 0.6rem;">上</sup>${firstChar}<sup style="font-size: 0.6rem;">下</sup>${restChars}` | ||
| 131 | +} | ||
| 132 | + | ||
| 119 | const pid = ref(router.currentRoute.value.query.pid) | 133 | const pid = ref(router.currentRoute.value.query.pid) |
| 120 | 134 | ||
| 121 | onMounted(async () => { | 135 | onMounted(async () => { |
| ... | @@ -200,11 +214,16 @@ onMounted(async () => { | ... | @@ -200,11 +214,16 @@ onMounted(async () => { |
| 200 | } | 214 | } |
| 201 | 215 | ||
| 202 | .item-name { | 216 | .item-name { |
| 203 | - font-size: 0.875rem; | 217 | + font-size: 1.5rem; |
| 204 | font-weight: 600; | 218 | font-weight: 600; |
| 205 | margin-top: 0.25rem; | 219 | margin-top: 0.25rem; |
| 206 | } | 220 | } |
| 207 | 221 | ||
| 222 | +.item-name.small { | ||
| 223 | + font-size: 1.25rem; | ||
| 224 | +} | ||
| 225 | + | ||
| 226 | + | ||
| 208 | /* 响应式调整 */ | 227 | /* 响应式调整 */ |
| 209 | @media (max-width: 48rem) { | 228 | @media (max-width: 48rem) { |
| 210 | .item-caption { | 229 | .item-caption { |
| ... | @@ -222,7 +241,10 @@ onMounted(async () => { | ... | @@ -222,7 +241,10 @@ onMounted(async () => { |
| 222 | margin: 0.5rem; | 241 | margin: 0.5rem; |
| 223 | } | 242 | } |
| 224 | .item-name { | 243 | .item-name { |
| 225 | - font-size: 0.8125rem; | 244 | + font-size: 1.25rem; |
| 245 | + } | ||
| 246 | + .item-name.small { | ||
| 247 | + font-size: 1rem; | ||
| 226 | } | 248 | } |
| 227 | } | 249 | } |
| 228 | 250 | ||
| ... | @@ -235,7 +257,10 @@ onMounted(async () => { | ... | @@ -235,7 +257,10 @@ onMounted(async () => { |
| 235 | margin: 0.5rem; | 257 | margin: 0.5rem; |
| 236 | } | 258 | } |
| 237 | .item-name { | 259 | .item-name { |
| 238 | - font-size: 0.75rem; | 260 | + font-size: 1rem; |
| 261 | + } | ||
| 262 | + .item-name.small { | ||
| 263 | + font-size: 0.875rem; | ||
| 239 | } | 264 | } |
| 240 | } | 265 | } |
| 241 | </style> | 266 | </style> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-10-30 20:00:25 | 2 | * @Date: 2025-10-30 20:00:25 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-10-30 20:50:36 | 4 | + * @LastEditTime: 2025-10-31 14:50:05 |
| 5 | * @FilePath: /stdj_h5/src/views/MastersDetail.vue | 5 | * @FilePath: /stdj_h5/src/views/MastersDetail.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -9,7 +9,15 @@ | ... | @@ -9,7 +9,15 @@ |
| 9 | <div class="masters-detail-container"> | 9 | <div class="masters-detail-container"> |
| 10 | <section class="single-list"> | 10 | <section class="single-list"> |
| 11 | <div class="item-card"> | 11 | <div class="item-card"> |
| 12 | - | 12 | + <img |
| 13 | + :src="item.src" | ||
| 14 | + :alt="item.title" | ||
| 15 | + class="item-image" | ||
| 16 | + /> | ||
| 17 | + <div class="item-content"> | ||
| 18 | + <h3 class="item-title">{{ item.title }}</h3> | ||
| 19 | + <p class="item-text">{{ item.description }}</p> | ||
| 20 | + </div> | ||
| 13 | </div> | 21 | </div> |
| 14 | </section> | 22 | </section> |
| 15 | </div> | 23 | </div> |
| ... | @@ -20,6 +28,12 @@ import { ref } from 'vue' | ... | @@ -20,6 +28,12 @@ import { ref } from 'vue' |
| 20 | import { useTitle } from '@vueuse/core'; | 28 | import { useTitle } from '@vueuse/core'; |
| 21 | 29 | ||
| 22 | useTitle('三師七證 - 詳情') | 30 | useTitle('三師七證 - 詳情') |
| 31 | + | ||
| 32 | +const item = ref({ | ||
| 33 | + src: 'https://via.placeholder.com/300x400?text=三師七證', | ||
| 34 | + title: '三師七證 - 詳情', | ||
| 35 | + description: '三師七證是三師七證的詳情,包含三師七證的所有內容。' | ||
| 36 | +}) | ||
| 23 | </script> | 37 | </script> |
| 24 | 38 | ||
| 25 | 39 | ||
| ... | @@ -48,4 +62,35 @@ useTitle('三師七證 - 詳情') | ... | @@ -48,4 +62,35 @@ useTitle('三師七證 - 詳情') |
| 48 | padding: 0.5rem; | 62 | padding: 0.5rem; |
| 49 | } | 63 | } |
| 50 | 64 | ||
| 65 | +.item-image { | ||
| 66 | + width: 100%; | ||
| 67 | + height: auto; | ||
| 68 | + display: block; | ||
| 69 | +} | ||
| 70 | + | ||
| 71 | +.item-content { | ||
| 72 | + padding: 0.5rem; | ||
| 73 | +} | ||
| 74 | + | ||
| 75 | +.item-title { | ||
| 76 | + font-size: 1.2rem; | ||
| 77 | + font-weight: 600; | ||
| 78 | + color: #333; | ||
| 79 | + line-height: 1.4; | ||
| 80 | + margin-bottom: 0.5rem; | ||
| 81 | + overflow: hidden; | ||
| 82 | + text-overflow: ellipsis; | ||
| 83 | + white-space: nowrap; | ||
| 84 | +} | ||
| 85 | + | ||
| 86 | +.item-text { | ||
| 87 | + font-size: 1rem; | ||
| 88 | + color: #666; | ||
| 89 | + line-height: 1.4; | ||
| 90 | + overflow: hidden; | ||
| 91 | + text-overflow: ellipsis; | ||
| 92 | + display: -webkit-box; | ||
| 93 | + -webkit-line-clamp: 2; | ||
| 94 | + -webkit-box-orient: vertical; | ||
| 95 | +} | ||
| 51 | </style> | 96 | </style> | ... | ... |
-
Please register or login to post a comment