Skip to content

Commit

Permalink
Merge pull request #164 from linhaojun857/dev
Browse files Browse the repository at this point in the history
Fix bug of archive page not show private articles
  • Loading branch information
linhaojun857 authored Feb 10, 2024
2 parents ccdf197 + 8867051 commit 0ea7aa0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
6 changes: 4 additions & 2 deletions aurora-springboot/src/main/resources/mapper/ArticleMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,13 @@
<select id="listArchives" resultType="com.aurora.model.dto.ArticleCardDTO">
SELECT id,
article_title,
if(article_abstract is null or article_abstract = '', SUBSTR(article_content, 1, 500), article_abstract) AS article_content,
if(article_abstract is null or article_abstract = '', SUBSTR(article_content, 1, 500),
article_abstract) AS article_content,
status,
create_time
FROM t_article
WHERE is_delete = 0
and status = 1
and (status = 1 or status = 2)
ORDER BY create_time DESC
LIMIT #{current}, #{size}
</select>
Expand Down
39 changes: 34 additions & 5 deletions aurora-vue/aurora-blog/src/views/Archives.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
</div>
<div class="timeline-marker"></div>
<div class="timeline-content">
<router-link :to="'/articles/' + article.id">
<h3 class="timeline-title">{{ article.articleTitle }}</h3>
</router-link>
<h3 class="timeline-title" @click="toArticle(article)">
<span>{{ article.articleTitle }}</span>
<svg-icon v-if="article.status == 2" icon-class="lock" class="lock-svg" />
</h3>
<p>
{{ article.articleContent }}
</p>
Expand All @@ -49,19 +50,25 @@
<script lang="ts">
import { useArticleStore } from '@/stores/article'
import { useCommonStore } from '@/stores/common'
import { defineComponent, onMounted, onUnmounted, reactive, toRef } from 'vue'
import { useUserStore } from '@/stores/user'
import { defineComponent, onMounted, onUnmounted, reactive, toRef, getCurrentInstance } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router'
import Breadcrumb from '@/components/Breadcrumb.vue'
import Paginator from '@/components/Paginator.vue'
import api from '@/api/api'
import markdownToHtml from '@/utils/markdown'
import emitter from '@/utils/mitt'
export default defineComponent({
name: 'Archives',
components: { Breadcrumb, Paginator },
setup() {
const commonStore = useCommonStore()
const proxy: any = getCurrentInstance()?.appContext.config.globalProperties
const articleStore = useArticleStore()
const commonStore = useCommonStore()
const userStore = useUserStore()
const router = useRouter()
const { t } = useI18n()
const pagination = reactive({
current: 1,
Expand Down Expand Up @@ -105,8 +112,30 @@ export default defineComponent({
top: 0
})
}
const toArticle = (article: any) => {
let isAccess = false
userStore.accessArticles.forEach((item: any) => {
if (item == article.id) {
isAccess = true
}
})
if (article.status === 2 && isAccess === false) {
if (userStore.userInfo === '') {
proxy.$notify({
title: 'Warning',
message: '该文章受密码保护,请登录后访问',
type: 'warning'
})
} else {
emitter.emit('changeArticlePasswordDialogVisible', article.id)
}
} else {
router.push({ path: '/articles/' + article.id })
}
}
return {
pageChangeHanlder,
toArticle,
pagination,
archives: toRef(articleStore.$state, 'archives'),
t
Expand Down

0 comments on commit 0ea7aa0

Please sign in to comment.