✨ nuxt/auth
This commit is contained in:
parent
7c243e7d67
commit
7222753d0a
@ -76,7 +76,7 @@ export default {
|
|||||||
redirect: {
|
redirect: {
|
||||||
login: '/login',
|
login: '/login',
|
||||||
logout: false,
|
logout: false,
|
||||||
home: false
|
home: '/'
|
||||||
},
|
},
|
||||||
strategies: {
|
strategies: {
|
||||||
local: {
|
local: {
|
||||||
|
@ -194,7 +194,7 @@ export default {
|
|||||||
isMobile: state => state.global.isMobile,
|
isMobile: state => state.global.isMobile,
|
||||||
loggedIn: state => state.auth.loggedIn,
|
loggedIn: state => state.auth.loggedIn,
|
||||||
user: state => state.auth.user,
|
user: state => state.auth.user,
|
||||||
avatar: state => state.auth.user.avatarUrl
|
avatar: state => state.auth.user?.avatarUrl
|
||||||
}),
|
}),
|
||||||
hasPermissions() {
|
hasPermissions() {
|
||||||
let account = this.$store.state.auth.user?.nickname;
|
let account = this.$store.state.auth.user?.nickname;
|
||||||
|
@ -91,7 +91,7 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.$auth.hasScope('blog_admin');
|
return this.$auth.hasScope('blog_admin') || this.$auth.hasScope('admin');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -57,6 +57,7 @@ import {mapState} from 'vuex';
|
|||||||
export default {
|
export default {
|
||||||
name: "login",
|
name: "login",
|
||||||
middleware: 'auth',
|
middleware: 'auth',
|
||||||
|
auth: 'guest',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
user: {
|
user: {
|
||||||
@ -93,10 +94,6 @@ export default {
|
|||||||
_ts.$auth.setUserToken(response.data.token, response.data.refreshToken);
|
_ts.$auth.setUserToken(response.data.token, response.data.refreshToken);
|
||||||
if (_ts.historyUrl) {
|
if (_ts.historyUrl) {
|
||||||
window.location.href = _ts.historyUrl
|
window.location.href = _ts.historyUrl
|
||||||
} else {
|
|
||||||
_ts.$router.push({
|
|
||||||
name: 'index'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ts.$set(_ts, 'loginLoading', false);
|
_ts.$set(_ts, 'loginLoading', false);
|
||||||
@ -144,8 +141,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$store.commit('setActiveMenu', 'login');
|
let _ts = this
|
||||||
this.$set(this, 'historyUrl', this.$route.query.historyUrl || '');
|
_ts.$store.commit('setActiveMenu', 'login');
|
||||||
|
_ts.$set(_ts, 'historyUrl', _ts.$route.query.historyUrl || '');
|
||||||
|
// if (_ts.$auth.loggedIn) {
|
||||||
|
// _ts.$router.push({
|
||||||
|
// name: 'index'
|
||||||
|
// })
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -22,7 +22,8 @@ export default {
|
|||||||
topic => topic.topicUri === params.topic_uri
|
topic => topic.topicUri === params.topic_uri
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
fetch({store, params, query}) {
|
fetch() {
|
||||||
|
let {store, params, query} = this.$nuxt.context
|
||||||
params.page = query.page || 1
|
params.page = query.page || 1
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
store.dispatch('article/fetchList', params)
|
store.dispatch('article/fetchList', params)
|
||||||
|
@ -8,7 +8,8 @@ export const OPEN_DATA_API_PATH = '/api/open-data'
|
|||||||
|
|
||||||
const getDefaultDashboardData = () => {
|
const getDefaultDashboardData = () => {
|
||||||
return {
|
return {
|
||||||
dashboard: {}
|
countUserNum: 0,
|
||||||
|
countArticleNum: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user