✨ 专题模块功能
This commit is contained in:
parent
06b908c45c
commit
64a69195d2
9
components/common/topic/index.js
Normal file
9
components/common/topic/index.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import TopicNav from './main'
|
||||||
|
|
||||||
|
export const topicNav = {
|
||||||
|
install(Vue) {
|
||||||
|
Vue.component('topic-nav', TopicNav)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default topicNav
|
43
components/common/topic/main.vue
Normal file
43
components/common/topic/main.vue
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<template>
|
||||||
|
<el-row class="wrapper">
|
||||||
|
<el-col style="margin-bottom: 1rem;">
|
||||||
|
<el-menu type="border-card" :default-active="currentTopic" style="margin-top: -2px;border: 0;" mode="horizontal"
|
||||||
|
@select="handleSelectTopic">
|
||||||
|
<el-menu-item index="news">最新</el-menu-item>
|
||||||
|
<el-menu-item v-for="topic in topicNavs" :key="topic.idTopic" :index="topic.topicUri">{{topic.topicTitle}}
|
||||||
|
</el-menu-item>
|
||||||
|
</el-menu>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {mapState} from 'vuex'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "topicNav",
|
||||||
|
props: {
|
||||||
|
currentTopic: {
|
||||||
|
type: String,
|
||||||
|
default: 'news'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
topicNavs: state => state.topic.data,
|
||||||
|
isFetching: state => state.topic.fetching
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleSelectTopic(item) {
|
||||||
|
this.$router.push({
|
||||||
|
path: '/topic/' + item
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="topic-archive-page">
|
<div class="topic-archive-page">
|
||||||
|
<topic-nav :currentTopic="defaultParams.topic_uri"></topic-nav>
|
||||||
<article-list :articles="articles" @currentChange="currentChangeArticle"/>
|
<article-list :articles="articles" @currentChange="currentChangeArticle"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -13,6 +14,9 @@
|
|||||||
ArticleList
|
ArticleList
|
||||||
},
|
},
|
||||||
validate({ params, store }) {
|
validate({ params, store }) {
|
||||||
|
if (params.topic_uri === 'news') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return params.topic_uri && store.state.topic.data.some(
|
return params.topic_uri && store.state.topic.data.some(
|
||||||
topic => topic.topicUri === params.topic_uri
|
topic => topic.topicUri === params.topic_uri
|
||||||
)
|
)
|
||||||
@ -25,6 +29,9 @@
|
|||||||
return this.$store.state.article.list.data
|
return this.$store.state.article.list.data
|
||||||
},
|
},
|
||||||
currentTopic() {
|
currentTopic() {
|
||||||
|
if (this.$route.params.topic_uri === 'news') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return this.$store.state.topic.data.find(
|
return this.$store.state.topic.data.find(
|
||||||
topic => topic.topicUri === this.$route.params.topic_uri
|
topic => topic.topicUri === this.$route.params.topic_uri
|
||||||
)
|
)
|
||||||
@ -42,6 +49,7 @@
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$store.commit('setActiveMenu', 'topic');
|
this.$store.commit('setActiveMenu', 'topic');
|
||||||
|
console.log(this.defaultParams)
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (!this.currentTopic) {
|
if (!this.currentTopic) {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import CommentBox from '~/components/common/comment'
|
import CommentBox from '~/components/common/comment'
|
||||||
|
import TopicNavBox from '~/components/common/topic'
|
||||||
Vue.use(CommentBox)
|
Vue.use(CommentBox)
|
||||||
|
Vue.use(TopicNavBox)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file 分类数据状态 / ES module
|
* @file 分类数据状态 / ES module
|
||||||
* @module store/category
|
* @module store/category
|
||||||
* @author Surmon <https://github.com/surmon-china>
|
* @author Ronger <https://github.com/ronger-x>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const TOPIC_API_PATH = '/api/topic'
|
export const TOPIC_API_PATH = '/api/topic'
|
||||||
@ -24,8 +24,7 @@ export const mutations = {
|
|||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
fetchList({ commit }, params) {
|
fetchList({ commit }, params) {
|
||||||
commit('updateFetching', true)
|
commit('updateFetching', true);
|
||||||
console.log(params)
|
|
||||||
return this.$axios
|
return this.$axios
|
||||||
.$get(`${TOPIC_API_PATH}/topic-nav`)
|
.$get(`${TOPIC_API_PATH}/topic-nav`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
Loading…
Reference in New Issue
Block a user