diff --git a/pages/admin/tag/post/_tag_id.vue b/pages/admin/tag/post/_tag_id.vue new file mode 100644 index 0000000..3439fe0 --- /dev/null +++ b/pages/admin/tag/post/_tag_id.vue @@ -0,0 +1,284 @@ + + + + + diff --git a/pages/admin/tag.vue b/pages/admin/tags.vue similarity index 89% rename from pages/admin/tag.vue rename to pages/admin/tags.vue index 6a31ecc..84b7212 100644 --- a/pages/admin/tag.vue +++ b/pages/admin/tags.vue @@ -47,7 +47,7 @@ import {mapState} from 'vuex'; export default { - name: "tag", + name: "tags", fetch({store, params, error}) { return Promise.all([ store @@ -58,7 +58,7 @@ computed: { ...mapState({ tags: state => state.tag.list.data.tags, - pagination: state => state.topic.list.data.pagination + pagination: state => state.tag.list.data.pagination }) }, methods: { @@ -93,28 +93,19 @@ page: page }) }, - onRouter(item,data) { - this.$router.push({ - name: item, - params: data - }) - }, createTag() { this.$router.push({ - name: 'admin-tag-post' + path: '/admin/tag/post/' }) }, updateTag(id) { this.$router.push({ - name: 'admin-tag-post', - params: { - id: id - } + path: '/admin/tag/post/' + id }) } }, mounted() { - this.$store.commit("setActiveMenu", "admin-tag"); + this.$store.commit("setActiveMenu", "admin-tags"); } } diff --git a/store/tag.js b/store/tag.js index bbf68f5..253186b 100644 --- a/store/tag.js +++ b/store/tag.js @@ -1,3 +1,5 @@ +import {ARTICLE_API_PATH} from "@/store/article"; + /** * @file 分类数据状态 / ES module * @module store/category @@ -5,6 +7,7 @@ */ export const ADMIN_API_PATH = '/api/admin' +export const TAG_API_PATH = '/api/tag' const getDefaultListData = () => { return { @@ -12,6 +15,13 @@ const getDefaultListData = () => { pagination: {} } } +const getDefaultData = () => { + return { + tagIconPath: '', + tagStatus: '0', + tagReservation: '0' + } +} export const state = () => { return { @@ -20,6 +30,10 @@ export const state = () => { list: { fetching: false, data: getDefaultListData() + }, + detail: { + fetching: false, + data: getDefaultData() } } } @@ -34,8 +48,11 @@ export const mutations = { updateFetching(state, action) { state.fetching = action }, + updateDetailFetching(state, action) { + state.detail.fetching = action + }, updateDetailData(state, action) { - state.data = action + state.detail.data = action } } @@ -72,5 +89,40 @@ export const actions = { .catch(error => { commit('updateFetching', false) }) + }, + + // 获取文章详情 + fetchPostDetail({ commit }, params = {}) { + // const delay = fetchDelay( + // isBrowser + // ) + // if (isBrowser) { + // Vue.nextTick(() => { + // window.scrollTo(0, 300); + // }) + // } + + if (typeof params.tag_id === 'undefined') { + commit('updateDetailData', getDefaultData()) + return; + } + commit('updateDetailFetching', true) + // commit('updateDetailData', {}) + return this.$axios + .$get(`${ADMIN_API_PATH}/tag/detail/${params.tag_id}`) + .then(response => { + return new Promise(resolve => { + commit('updateDetailData', response) + commit('updateDetailFetching', false) + resolve(response) + // delay(() => { + // resolve(response) + // }) + }) + }) + .catch(error => { + commit('updateDetailFetching', false) + return Promise.reject(error) + }) } }