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