专题模块功能

This commit is contained in:
x ronger 2020-08-01 00:41:54 +08:00
parent e15e3be1cc
commit 1b8ace45dc
7 changed files with 840 additions and 722 deletions

View File

@ -1,7 +1,7 @@
/**
* @file Comment box component / ES module
* @module components/common/comment
* @author Surmon <https://github.com/surmon-china>
* @author Ronger <https://github.com/ronger-x>
*/
import Comment from './main'

View File

@ -1,7 +1,7 @@
/**
* @file Environment / ES module
* @module environment
* @author Surmon <https://github.com/surmon-china>
* @author Ronger <https://github.com/ronger-x>
*/
export const environment = process.env

1507
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,8 +15,8 @@
"element-ui": "^2.13.2",
"express": "^4.17.1",
"js-cookie": "^2.2.1",
"nuxt": "^2.13.3",
"vditor": "^3.3.8"
"nuxt": "^2.14.0",
"vditor": "^3.4.0"
},
"devDependencies": {
"@nuxtjs/proxy": "^2.0.1",

View File

@ -1,8 +1,12 @@
// const Cookie = require('js-cookie')
export default function ({app, $axios, store, redirect}) {
$axios.onRequest(config => {
let token = store.state.oauth?.accessToken;
if (token) {
if (!(config.url.indexOf('console') > -1)) {
config.headers['Authorization'] = store.state.oauth?.accessToken
}
}
})
$axios.onResponse(response => {
return new Promise((resolve, reject) => {
@ -16,24 +20,17 @@ export default function ({app, $axios, store, redirect}) {
if (response.data.success) {
resolve(response.data);
} else {
if (response.data.code === 0) {
if (response.data.code === '0') {
app.$message(message);
} else if (response.data.code === 401) {
store.commit('logout');
app.$router.push({
name: 'login'
})
} else if (response.data.code === 402) {
store.commit('logout');
app.$router.push({
name: 'login',
query: {
historyUrl: window.location.href
}
})
} else if (response.data.code === 404) {
} else if (response.data.code === '401') {
// Cookie.remove('auth')
store.commit('setAuth', null);
} else if (response.data.code === '402') {
// Cookie.remove('auth')
store.commit('setAuth', null);
} else if (response.data.code === '404') {
app.$message('操作失败,请稍后再试......')
} else if (response.data.code === 500) {
} else if (response.data.code === '500') {
app.$message('服务器正在开小差,请稍后再试......')
}
}
@ -43,9 +40,9 @@ export default function ({app, $axios, store, redirect}) {
$axios.onError(error => {
const code = parseInt(error.response && error.response.status)
if (code === 400) {
redirect('/400')
redirect('/400');
} else {
console.log('网络异常')
console.log(error.data);
}
})
}

View File

@ -61,9 +61,15 @@ export const actions = {
// 清空已有数据
commit('updateListData', getDefaultListData())
commit('updateListFetching', true)
let data = {
page: params.page,
topicUri: params.topic_uri
}
return this.$axios
.$get(`${ARTICLE_API_PATH}/articles`, {params})
.$get(`${ARTICLE_API_PATH}/articles`, {
params: data
})
.then(response => {
commit('updateListFetching', false)
commit('updateListData', response)

View File

@ -1,7 +1,7 @@
/**
* @file 评论数据状态 / ES module
* @module store/comment
* @author Surmon <https://github.com/surmon-china>
* @author Ronger <https://github.com/ronger-x>
*/
export const COMMENT_API_PATH = '/api/article/'