|
2 | 2 | import { defineComponent, h, ref, watch } from 'vue' |
3 | 3 | import miniProgramIconUrl from '~/assets/images/wechat/mini-program.svg' |
4 | 4 |
|
| 5 | +const finderLogoUrl = '/assets/images/wechat/channels-logo.svg' |
| 6 | +
|
5 | 7 | export default defineComponent({ |
6 | 8 | name: 'LinkCard', |
7 | 9 | props: { |
@@ -51,7 +53,11 @@ export default defineComponent({ |
51 | 53 | return text ? (Array.from(text)[0] || '') : '' |
52 | 54 | })() |
53 | 55 | const fromAvatarUrl = String(props.fromAvatar || '').trim() |
| 56 | + const headingText = String(props.heading || href || '').trim() |
| 57 | + let abstractText = String(props.abstract || '').trim() |
| 58 | + if (abstractText && headingText && abstractText === headingText) abstractText = '' |
54 | 59 | const isMiniProgram = String(props.linkType || '').trim() === 'mini_program' |
| 60 | + const isFinder = String(props.linkType || '').trim() === 'finder' |
55 | 61 | const isCoverVariant = !isMiniProgram && String(props.variant || '').trim() === 'cover' |
56 | 62 | const Tag = canNavigate ? 'a' : 'div' |
57 | 63 |
|
@@ -140,9 +146,68 @@ export default defineComponent({ |
140 | 146 | ) |
141 | 147 | } |
142 | 148 |
|
143 | | - const headingText = String(props.heading || href || '').trim() |
144 | | - let abstractText = String(props.abstract || '').trim() |
145 | | - if (abstractText && headingText && abstractText === headingText) abstractText = '' |
| 149 | + if (isFinder) { |
| 150 | + return h( |
| 151 | + Tag, |
| 152 | + { |
| 153 | + ...(canNavigate ? { href, target: '_blank', rel: 'noreferrer' } : { role: 'group', 'aria-disabled': 'true' }), |
| 154 | + class: [ |
| 155 | + 'wechat-link-card-finder', |
| 156 | + !canNavigate ? 'wechat-link-card--disabled' : '', |
| 157 | + 'wechat-special-card', |
| 158 | + 'msg-radius', |
| 159 | + props.isSent ? 'wechat-special-sent-side' : '' |
| 160 | + ].filter(Boolean).join(' '), |
| 161 | + style: { |
| 162 | + width: '135px', |
| 163 | + minWidth: '135px', |
| 164 | + maxWidth: '135px', |
| 165 | + display: 'flex', |
| 166 | + flexDirection: 'column', |
| 167 | + boxSizing: 'border-box', |
| 168 | + flex: '0 0 auto', |
| 169 | + border: 'none', |
| 170 | + boxShadow: 'none', |
| 171 | + textDecoration: 'none', |
| 172 | + outline: 'none' |
| 173 | + } |
| 174 | + }, |
| 175 | + [ |
| 176 | + h('div', { class: ['wechat-link-finder-cover', !props.preview ? 'wechat-link-finder-cover--empty' : ''].filter(Boolean).join(' ') }, [ |
| 177 | + props.preview |
| 178 | + ? h('img', { |
| 179 | + src: props.preview, |
| 180 | + alt: props.heading || '视频号封面', |
| 181 | + class: 'wechat-link-finder-cover-img', |
| 182 | + referrerpolicy: 'no-referrer' |
| 183 | + }) |
| 184 | + : h('div', { class: 'wechat-link-finder-cover-placeholder', 'aria-hidden': 'true' }, [ |
| 185 | + h('svg', { viewBox: '0 0 24 24', fill: 'currentColor' }, [ |
| 186 | + h('path', { d: 'M8 5v14l11-7z' }) |
| 187 | + ]) |
| 188 | + ]), |
| 189 | + h('div', { class: 'wechat-link-finder-cover-shade', 'aria-hidden': 'true' }), |
| 190 | + h('div', { class: 'wechat-link-finder-play', 'aria-hidden': 'true' }, [ |
| 191 | + h('svg', { viewBox: '0 0 24 24', fill: 'currentColor' }, [ |
| 192 | + h('path', { d: 'M8 5v14l11-7z' }) |
| 193 | + ]) |
| 194 | + ]), |
| 195 | + h('div', { class: 'wechat-link-finder-meta' }, [ |
| 196 | + h('div', { class: 'wechat-link-finder-author' }, [ |
| 197 | + h('div', { class: 'wechat-link-finder-author-avatar', 'aria-hidden': 'true' }, [ |
| 198 | + h('img', { |
| 199 | + src: finderLogoUrl, |
| 200 | + alt: '', |
| 201 | + class: 'wechat-link-finder-author-avatar-img' |
| 202 | + }) |
| 203 | + ]), |
| 204 | + h('div', { class: 'wechat-link-finder-author-name' }, fromText || '视频号') |
| 205 | + ]) |
| 206 | + ]) |
| 207 | + ]) |
| 208 | + ] |
| 209 | + ) |
| 210 | + } |
146 | 211 |
|
147 | 212 | if (isMiniProgram) { |
148 | 213 | return h( |
|
0 commit comments