first commit
This commit is contained in:
parent
5a13c949fa
commit
e074e1079d
@ -196,11 +196,7 @@
|
||||
getUnreadNotifications() {
|
||||
let _ts = this;
|
||||
if (_ts.isLogin) {
|
||||
_ts.$axios.$get('/api/v1/notification/unread', {
|
||||
headers: {
|
||||
Authorization: _ts.$store.state.oauth?.accessToken
|
||||
}
|
||||
}).then(function (res) {
|
||||
_ts.$axios.$get('/api/v1/notification/unread').then(function (res) {
|
||||
if (res) {
|
||||
_ts.$set(_ts, 'notifications', res.data.notifications);
|
||||
_ts.$set(_ts, 'notificationNumbers', res.data.notifications.length == 0 ? "" : res.data.notifications.length);
|
||||
|
@ -52,6 +52,7 @@ export default {
|
||||
** https://nuxtjs.org/guide/plugins
|
||||
*/
|
||||
plugins: [
|
||||
{src: '@/plugins/axios'},
|
||||
{src: '@/plugins/element-ui'},
|
||||
{src: '@/plugins/vditor', ssr: false}
|
||||
],
|
||||
|
@ -226,7 +226,7 @@
|
||||
}
|
||||
})
|
||||
} else {
|
||||
_ts.axios.get('/article/' + _ts.article.idArticle + '/share').then(function (res) {
|
||||
_ts.$axios.$get('/api/v1/article/' + _ts.article.idArticle + '/share').then(function (res) {
|
||||
if (res) {
|
||||
_ts.$set(_ts, 'shareData', res);
|
||||
_ts.$set(_ts, 'isShare', true);
|
||||
@ -241,8 +241,8 @@
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
Vue.nextTick(() => {
|
||||
this.$store.commit('setActiveMenu', 'articleDetail')
|
||||
Vue.nextTick(() => {
|
||||
const previewElement = document.getElementById("articleContent");
|
||||
// //const outLineElement = document.getElementById("articleToC");
|
||||
// VditorPreview.setContentTheme('light');
|
||||
|
@ -87,16 +87,16 @@
|
||||
}
|
||||
|
||||
_ts.$axios.$post('/api/v1/console/login', data).then(function (res) {
|
||||
if (res.data) {
|
||||
if (res.data.message) {
|
||||
_ts.$message(res.data.message);
|
||||
if (res) {
|
||||
if (res.message) {
|
||||
_ts.$message(res.message);
|
||||
return false;
|
||||
}
|
||||
let auth = {
|
||||
accessToken: res.data.user.token,
|
||||
nickname: res.data.user.nickname,
|
||||
avatarURL: res.data.user.avatarUrl,
|
||||
role: res.data.user.weights
|
||||
accessToken: res.user.token,
|
||||
nickname: res.user.nickname,
|
||||
avatarURL: res.user.avatarUrl,
|
||||
role: res.user.weights
|
||||
}
|
||||
_ts.$store.commit('setAuth', auth) // mutating to store for client rendering
|
||||
Cookie.set('auth', auth)
|
||||
@ -133,7 +133,7 @@
|
||||
let data = {
|
||||
email: email
|
||||
};
|
||||
_ts.axios.post('/console/get-forget-password-email', _ts.qs.stringify(data)).then(function (res) {
|
||||
_ts.axios.post('/console/get-forget-password-email', data).then(function (res) {
|
||||
_ts.loading = false;
|
||||
_ts.forget = false;
|
||||
if (res) {
|
||||
|
@ -83,9 +83,9 @@
|
||||
code: _ts.user.code
|
||||
}
|
||||
_ts.$axios.$post('/api/v1/console/register', data).then(function (res) {
|
||||
if (res.data) {
|
||||
_ts.$message(res.data.message);
|
||||
if (res.data.flag && res.data.flag === 1) {
|
||||
if (res) {
|
||||
_ts.$message(res.message);
|
||||
if (res.flag && res.flag === 1) {
|
||||
setTimeout(function () {
|
||||
_ts.$router.push(
|
||||
{
|
||||
|
@ -1,2 +1,51 @@
|
||||
import apiConfig from '~/config/api.config'
|
||||
|
||||
export default function ({app, $axios, store, redirect}) {
|
||||
$axios.onRequest(config => {
|
||||
if (!(config.url.indexOf('console') > -1)) {
|
||||
config.headers['Authorization'] = store.state.oauth?.accessToken
|
||||
}
|
||||
})
|
||||
$axios.onResponse(response => {
|
||||
return new Promise((resolve, reject) => {
|
||||
//返回数据逻辑处理 比如:error_code错误处理
|
||||
let message;
|
||||
if (typeof (response.data.data) !== 'undefined') {
|
||||
message = response.data.data.message
|
||||
} else if (typeof (response.data) !== 'undefined') {
|
||||
message = response.data.message
|
||||
}
|
||||
if (response.data.success) {
|
||||
resolve(response.data);
|
||||
} else {
|
||||
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) {
|
||||
app.$message('操作失败,请稍后再试......')
|
||||
} else if (response.data.code === 500) {
|
||||
app.$message('服务器正在开小差,请稍后再试......')
|
||||
}
|
||||
}
|
||||
reject(response);
|
||||
})
|
||||
});
|
||||
$axios.onError(error => {
|
||||
const code = parseInt(error.response && error.response.status)
|
||||
if (code === 400) {
|
||||
redirect('/400')
|
||||
} else {
|
||||
console.log('网络异常')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ export const actions = {
|
||||
.$get(`${ARTICLE_API_PATH}/articles`, {params})
|
||||
.then(response => {
|
||||
commit('updateListFetching', false)
|
||||
commit('updateListData', response.data)
|
||||
commit('updateListData', response)
|
||||
if (isBrowser) {
|
||||
Vue.nextTick(() => {
|
||||
window.scrollTo(0,0);
|
||||
@ -92,7 +92,7 @@ export const actions = {
|
||||
.$get(`${ARTICLE_API_PATH}/article/${params.article_id}`)
|
||||
.then(response => {
|
||||
return new Promise(resolve => {
|
||||
commit('updateDetailData', response.data)
|
||||
commit('updateDetailData', response)
|
||||
commit('updateDetailFetching', false)
|
||||
resolve(response)
|
||||
// delay(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user