| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import Vue from 'vue'
- import http from '@/plugins/http'
- // mixin
- Vue.mixin({
- async fetch({ store, req }) {
- let headers = req && req.headers
- let res = await http.get('/api/user/getInfo', {}, { config: { headers }, neverLogout: true })
- if(res) {
- store.commit('updateUserinfo', { userinfo: res.data })
- }
- },
- components: {
- },
- data() {
- return {
- }
- },
- mounted() {},
- computed: {
- userinfo() {
- return this.$store.state.userinfo
- },
- hasLogined() {
- return !!this.userinfo.uid
- },
- },
- methods: {
- goLogin() {
- this.$alert('未登录, 前往登录', '提示', {
- confirmButtonText: '确定',
- callback: action => {
- location.href = `/?loginbox=show`
- }
- })
- },
- noCompetence(title = "没有权限") {
- this.$alert(title, '提示', {
- confirmButtonText: '确定',
- callback: action => {
- location.go(-1)
- }
- })
- },
- }
- })
|