|
1 | 1 | <script lang="ts" setup>
|
2 | 2 | import { computed } from 'vue'
|
3 | 3 | import { LanguageKey } from '/@/language'
|
| 4 | + import { UNDEFINED } from '/@/constants/value' |
4 | 5 | import { Article, ArticleLangI18n } from '/@/interfaces/article'
|
5 | 6 | import { useEnhancer } from '/@/app/enhancer'
|
6 | 7 | import { useIdentityStore } from '/@/stores/identity'
|
7 | 8 | import { getArticleDetailRoute } from '/@/transforms/route'
|
8 | 9 | import { getImgProxyPath, ImgProxyFormat } from '/@/transforms/imgproxy'
|
9 | 10 | import { getImgProxyURL, getStaticPath, isOriginalStaticURL } from '/@/transforms/url'
|
10 | 11 | import { isOriginalType, isHybridType, isReprintType } from '/@/transforms/state'
|
11 |
| - import { openNewWindow } from '/@/utils/opener' |
12 | 12 | import { numberSplit } from '/@/transforms/text'
|
13 | 13 |
|
14 | 14 | const props = defineProps<{
|
15 | 15 | article: Article
|
16 | 16 | }>()
|
17 | 17 |
|
18 |
| - const { router, cdnDomain, gState } = useEnhancer() |
| 18 | + const { cdnDomain, gState } = useEnhancer() |
19 | 19 | const identityStore = useIdentityStore()
|
20 | 20 | const isLiked = computed(() => identityStore.isLikedPage(props.article.id))
|
21 | 21 | const isHybrid = computed(() => isHybridType(props.article.origin))
|
22 | 22 | const isReprint = computed(() => isReprintType(props.article.origin))
|
23 | 23 | const isOriginal = computed(() => isOriginalType(props.article.origin))
|
24 |
| -
|
25 |
| - const handleClick = () => { |
26 |
| - if (gState.userAgent.isWechat) { |
27 |
| - router.push(getArticleDetailRoute(props.article.id)) |
28 |
| - } else { |
29 |
| - openNewWindow(getArticleDetailRoute(props.article.id)) |
30 |
| - } |
31 |
| - } |
| 24 | + const detailRoutePath = getArticleDetailRoute(props.article.id) |
32 | 25 |
|
33 | 26 | const getThumbnailURL = (url: string, format?: ImgProxyFormat) => {
|
34 | 27 | if (!isOriginalStaticURL(url)) {
|
35 | 28 | return url
|
36 | 29 | }
|
| 30 | +
|
37 | 31 | return getImgProxyURL(
|
38 | 32 | cdnDomain,
|
39 | 33 | getImgProxyPath(getStaticPath(url), {
|
|
48 | 42 | </script>
|
49 | 43 |
|
50 | 44 | <template>
|
51 |
| - <div class="article-item" @click="handleClick"> |
| 45 | + <ulink |
| 46 | + class="article-item" |
| 47 | + :to="gState.userAgent.isWechat ? detailRoutePath : UNDEFINED" |
| 48 | + :href="!gState.userAgent.isWechat ? detailRoutePath : UNDEFINED" |
| 49 | + :blank="!gState.userAgent.isWechat" |
| 50 | + :external="false" |
| 51 | + > |
52 | 52 | <div class="thumbnail">
|
53 | 53 | <span
|
54 | 54 | class="origin"
|
|
83 | 83 | <div class="content">
|
84 | 84 | <div class="body">
|
85 | 85 | <h4 class="title">
|
86 |
| - <router-link class="link" :title="article.title" :to="getArticleDetailRoute(article.id)"> |
87 |
| - {{ article.title }} |
88 |
| - </router-link> |
| 86 | + <span class="text" :title="article.title">{{ article.title }}</span> |
89 | 87 | <span class="language">
|
90 | 88 | <i18n v-bind="ArticleLangI18n[article.lang]" />
|
91 | 89 | </span>
|
|
111 | 109 | </span>
|
112 | 110 | </div>
|
113 | 111 | </div>
|
114 |
| - </div> |
| 112 | + </ulink> |
115 | 113 | </template>
|
116 | 114 |
|
117 | 115 | <style lang="scss" scoped>
|
|
198 | 196 | display: flex;
|
199 | 197 | justify-content: space-between;
|
200 | 198 |
|
201 |
| - .link { |
202 |
| - text-decoration: none; |
| 199 | + .text { |
203 | 200 | max-width: calc(100% - 3em);
|
204 | 201 | @include text-overflow();
|
205 | 202 | }
|
|
0 commit comments