first commit
This commit is contained in:
parent
5a13c949fa
commit
e074e1079d
@ -196,11 +196,7 @@
|
|||||||
getUnreadNotifications() {
|
getUnreadNotifications() {
|
||||||
let _ts = this;
|
let _ts = this;
|
||||||
if (_ts.isLogin) {
|
if (_ts.isLogin) {
|
||||||
_ts.$axios.$get('/api/v1/notification/unread', {
|
_ts.$axios.$get('/api/v1/notification/unread').then(function (res) {
|
||||||
headers: {
|
|
||||||
Authorization: _ts.$store.state.oauth?.accessToken
|
|
||||||
}
|
|
||||||
}).then(function (res) {
|
|
||||||
if (res) {
|
if (res) {
|
||||||
_ts.$set(_ts, 'notifications', res.data.notifications);
|
_ts.$set(_ts, 'notifications', res.data.notifications);
|
||||||
_ts.$set(_ts, 'notificationNumbers', res.data.notifications.length == 0 ? "" : res.data.notifications.length);
|
_ts.$set(_ts, 'notificationNumbers', res.data.notifications.length == 0 ? "" : res.data.notifications.length);
|
||||||
|
@ -52,6 +52,7 @@ export default {
|
|||||||
** https://nuxtjs.org/guide/plugins
|
** https://nuxtjs.org/guide/plugins
|
||||||
*/
|
*/
|
||||||
plugins: [
|
plugins: [
|
||||||
|
{src: '@/plugins/axios'},
|
||||||
{src: '@/plugins/element-ui'},
|
{src: '@/plugins/element-ui'},
|
||||||
{src: '@/plugins/vditor', ssr: false}
|
{src: '@/plugins/vditor', ssr: false}
|
||||||
],
|
],
|
||||||
|
@ -226,7 +226,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} 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) {
|
if (res) {
|
||||||
_ts.$set(_ts, 'shareData', res);
|
_ts.$set(_ts, 'shareData', res);
|
||||||
_ts.$set(_ts, 'isShare', true);
|
_ts.$set(_ts, 'isShare', true);
|
||||||
@ -241,8 +241,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.$store.commit('setActiveMenu', 'articleDetail')
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
this.$store.commit('setActiveMenu', 'articleDetail')
|
|
||||||
const previewElement = document.getElementById("articleContent");
|
const previewElement = document.getElementById("articleContent");
|
||||||
// //const outLineElement = document.getElementById("articleToC");
|
// //const outLineElement = document.getElementById("articleToC");
|
||||||
// VditorPreview.setContentTheme('light');
|
// VditorPreview.setContentTheme('light');
|
||||||
|
@ -87,16 +87,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ts.$axios.$post('/api/v1/console/login', data).then(function (res) {
|
_ts.$axios.$post('/api/v1/console/login', data).then(function (res) {
|
||||||
if (res.data) {
|
if (res) {
|
||||||
if (res.data.message) {
|
if (res.message) {
|
||||||
_ts.$message(res.data.message);
|
_ts.$message(res.message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let auth = {
|
let auth = {
|
||||||
accessToken: res.data.user.token,
|
accessToken: res.user.token,
|
||||||
nickname: res.data.user.nickname,
|
nickname: res.user.nickname,
|
||||||
avatarURL: res.data.user.avatarUrl,
|
avatarURL: res.user.avatarUrl,
|
||||||
role: res.data.user.weights
|
role: res.user.weights
|
||||||
}
|
}
|
||||||
_ts.$store.commit('setAuth', auth) // mutating to store for client rendering
|
_ts.$store.commit('setAuth', auth) // mutating to store for client rendering
|
||||||
Cookie.set('auth', auth)
|
Cookie.set('auth', auth)
|
||||||
@ -133,7 +133,7 @@
|
|||||||
let data = {
|
let data = {
|
||||||
email: email
|
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.loading = false;
|
||||||
_ts.forget = false;
|
_ts.forget = false;
|
||||||
if (res) {
|
if (res) {
|
||||||
|
@ -83,9 +83,9 @@
|
|||||||
code: _ts.user.code
|
code: _ts.user.code
|
||||||
}
|
}
|
||||||
_ts.$axios.$post('/api/v1/console/register', data).then(function (res) {
|
_ts.$axios.$post('/api/v1/console/register', data).then(function (res) {
|
||||||
if (res.data) {
|
if (res) {
|
||||||
_ts.$message(res.data.message);
|
_ts.$message(res.message);
|
||||||
if (res.data.flag && res.data.flag === 1) {
|
if (res.flag && res.flag === 1) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
_ts.$router.push(
|
_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})
|
.$get(`${ARTICLE_API_PATH}/articles`, {params})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
commit('updateListFetching', false)
|
commit('updateListFetching', false)
|
||||||
commit('updateListData', response.data)
|
commit('updateListData', response)
|
||||||
if (isBrowser) {
|
if (isBrowser) {
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
window.scrollTo(0,0);
|
window.scrollTo(0,0);
|
||||||
@ -92,7 +92,7 @@ export const actions = {
|
|||||||
.$get(`${ARTICLE_API_PATH}/article/${params.article_id}`)
|
.$get(`${ARTICLE_API_PATH}/article/${params.article_id}`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
commit('updateDetailData', response.data)
|
commit('updateDetailData', response)
|
||||||
commit('updateDetailFetching', false)
|
commit('updateDetailFetching', false)
|
||||||
resolve(response)
|
resolve(response)
|
||||||
// delay(() => {
|
// delay(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user