From 80476fae71f08bf4408c7509eff254031a4eeac6 Mon Sep 17 00:00:00 2001 From: inleft <inleft@qq.com> Date: Wed, 24 Aug 2022 18:47:09 +0800 Subject: [PATCH] 路由修正,常量提取 --- src/components/mini/box-new-article.vue | 139 +++++++++++++++++++++++----------------------- 1 files changed, 69 insertions(+), 70 deletions(-) diff --git a/src/components/mini/box-new-article.vue b/src/components/mini/box-new-article.vue index eee3b5c..af47074 100644 --- a/src/components/mini/box-new-article.vue +++ b/src/components/mini/box-new-article.vue @@ -3,97 +3,65 @@ <div class="recent-post-item"> <div class="miniTag" v-if="isTop==1">置顶</div> <div class="post_cover left_radius" v-if="index%2==0"> - - <router-link :to="{path:'videoDetail',query:{id:id,articleFileType:articleFileType,typeId:typeId}}" :title="title" - v-if="articleFileType==myConstant.fileTypeVideo"> + <a @click="routerJump(id,articleFileType,typeId)" :title="title" class="article-title"> <div class="block left_radius"></div> <img class="post_bg" :src="coverFileURL" :onerror="img404" :alt="title"> - </router-link> - <!-- <a :href="jumpURL" target="_blank" class="no-underline" - v-else-if="articleFileType==myConstant.fileTypeShort" @click="showMsg(articleFileType,jumpURL)"> - <div class="block left_radius"></div> - <img class="post_bg" :src="coverFileURL" :onerror="img404" :alt="title"> - </a> --> - <router-link :to="{path:'/mdDetail',query:{id:id,articleFileType:articleFileType,typeId:typeId}}" :title="title" - v-else> - <div class="block left_radius"></div> - <img class="post_bg" :src="coverFileURL" :onerror="img404" :alt="title"> - </router-link> + </a> </div> <div class="post_cover right_radius" v-else> - <router-link :to="{path:'videoDetail',query:{id:id,articleFileType:articleFileType,typeId:typeId}}" :title="title" - v-if="articleFileType==myConstant.fileTypeVideo"> - <div class="block left_radius"></div> - <img class="post_bg" :src="coverFileURL" :onerror="img404" :alt="title"> - </router-link> - <!-- <a :href="jumpURL" target="_blank" class="no-underline" - v-else-if="articleFileType==myConstant.fileTypeShort" @click="showMsg(articleFileType,jumpURL)"> - <div class="block left_radius"></div> - <img class="post_bg" :src="coverFileURL" :onerror="img404" :alt="title"> - </a> --> - <router-link :to="{path:'/mdDetail',query:{id:id,articleFileType:articleFileType,typeId:typeId}}" :title="title" - v-else> + <a @click="routerJump(id,articleFileType,typeId)" :title="title" class="article-title"> <div class="block right_radius"></div> <img class="post_bg" :src="coverFileURL" :onerror="img404" :alt="title"> - </router-link> + </a> </div> <div class="recent-post-info"> - <router-link :to="{path:'/videoDetail',query:{id:id,articleFileType:articleFileType,typeId:typeId}}" - class="article-title" v-if="articleFileType==myConstant.fileTypeVideo"> + <a @click="routerJump(id,articleFileType,typeId)" :title="title" class="article-title"> <a-icon type="lock" style="color:rgba(0,0,0,.25)" v-if="authStatus==3" /> <a-icon type="stop" style="color:rgba(0,0,0,.25)" v-if="authStatus==2" /> {{title}} <a-badge :count="1" dot v-if="isAnyUpdate==1" title="最近有更新"></a-badge> - </router-link> + </a> - <router-link :to="{path:'/mdDetail',query:{id:id,articleFileType:articleFileType,typeId:typeId}}" - class="article-title" v-else> - <a-icon type="lock" style="color:rgba(0,0,0,.25)" v-if="authStatus==3" /> - <a-icon type="stop" style="color:rgba(0,0,0,.25)" v-if="authStatus==2" /> - {{title}} - <a-badge :count="1" dot v-if="isAnyUpdate==1" title="最近有更新"></a-badge> - </router-link> - - <!-- <a class="article-title" href="/mdDetail" :title="title"> {{title}}</a> --> <div class="article-meta-wrap" style="display: flex;"> <span class="post-meta-date"> <a-icon type="calendar" /> <span class="article-meta-label"></span> - <time> {{publishDate}} </time> + <span class="article-meta__categories"> {{publishDate}} </span> </span> - <span class="article-meta__separator" style="margin: 0px 3px ;"> | </span> + <span class="article-meta__separator" style="margin: 0px 5px ;">|</span> <span class="article-meta"> <a-icon type="book" /> - <router-link :to="{path:'/articleList',query:{typeId:articleTypeId}}" - class="article-meta__categories"> {{articleTypeName}}</router-link> - <span v-if="articleFileType==myConstant.fileTypeShort"> - <span v-if="jumpURL !=null && jumpURL!=''"> - <span class="article-meta__separator" style="margin: 0px 3px ;"> | </span> - <span class="post-meta-date"> - <a-icon type="share-alt" /> - <a :href="jumpURL" target="_blank" class="no-underline"> 外链 </a> - </span> - </span> + <a @click="routerToTypeList(articleTypeId)" class="article-meta__categories"> + {{articleTypeName}} + </a> - <span v-else> - <span class="article-meta__separator" style="margin: 0px 3px ;"> | </span> + <span v-if="jumpURL !=null && jumpURL!=''"> + <span class="article-meta__separator" style="margin: 0px 3px 5px 0px ;">|</span> + <span class="post-meta-date"> + <a-icon type="share-alt" /> + <a :href="jumpURL" target="_blank" class="no-underline"> 外链 </a> + </span> + </span> + <span v-else-if="articleFileType==fileType.fileTypeTalking_9"> + <span> + <span class="article-meta__separator" style="margin: 0px 3px 5px 0px ;">|</span> <span class="post-meta-date"> <a-icon type="thunderbolt" />碎碎念 </span> </span> </span> - <span v-if="articleFileType==myConstant.fileTypeVideo"> + <span v-if="articleFileType==fileType.fileTypeVideo_3"> <span class="article-meta__separator" style="margin: 0px 3px ;"> | </span> <span class="post-meta-date"> <a-icon type="video-camera" /> - <router-link :to="{path:'/videoDetail',query:{id:id}}"> + <a @click="routerToPlatform()"> 视频 - </router-link> + </a> </span> </span> <!-- <a class="article-meta__categories" href="#"> {{tag}}</a> --> @@ -116,16 +84,49 @@ export default { - methods: { - showMsg(articleFileType, jumpURL) { - if (articleFileType == myConstant.fileTypeShort && (jumpURL == null || jumpURL == "")) { - this.$message.info('这只是一句碎碎念,没有更多内容啦', 3); - return - } - } - }, components: { NotificationOutlined + }, + data() { + return { + fileType: myConstant.fileType, + img404: "this.onerror='';this.src=\"http://t.inleft.com/share/media_photo/1.jpg\"", + } + }, + methods: { + routerJump(id, articleFileType, typeId) { + let routerName = "mdDetail"; + if (articleFileType == this.fileType.fileTypeVideo_3) { + routerName = "videoDetail"; + } + + this.$router.push({ + name: routerName, + query: { + id: id, + articleFileType: articleFileType, + typeId: typeId + }, + params: { + id: id, + articleFileType: articleFileType, + typeId: typeId + } + }) + }, + routerToPlatform() { + this.$router.push({ + name: "platformGroup" + }) + }, + routerToTypeList(typeId) { + this.$router.push({ + name: "articleList", + query: { + typeId: typeId, + } + }) + } }, props: { "index": { @@ -173,12 +174,6 @@ "jumpURL": { default: "", } - }, - data() { - return { - myConstant: myConstant, - img404: "this.onerror='';this.src=\"http://t.inleft.com/share/media_photo/1.jpg\"", - } } } </script> @@ -199,6 +194,10 @@ a { position: initial; } + + img { + user-select: none; + } } .miniTag { -- Gitblit v1.9.1