云下生产图片使用页面打开地址作为基础路径
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
import router from '@/router'
|
||||
import { MessageBox, } from 'element-ui'
|
||||
import { login, logout, getInfo } from '@/api/login'
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
import { isHttp, isEmpty } from "@/utils/validate"
|
||||
import {MessageBox,} from 'element-ui'
|
||||
import {getInfo, login, logout} from '@/api/login'
|
||||
import {getToken, removeToken, setToken} from '@/utils/auth'
|
||||
import {isEmpty, isHttp} from "@/utils/validate"
|
||||
import defAva from '@/assets/images/profile.jpg'
|
||||
|
||||
const user = {
|
||||
@ -42,7 +42,7 @@ const user = {
|
||||
|
||||
actions: {
|
||||
// 登录
|
||||
Login({ commit }, userInfo) {
|
||||
Login({commit}, userInfo) {
|
||||
const username = userInfo.username.trim()
|
||||
const password = userInfo.password
|
||||
const code = userInfo.code
|
||||
@ -59,13 +59,14 @@ const user = {
|
||||
},
|
||||
|
||||
// 获取用户信息
|
||||
GetInfo({ commit, state }) {
|
||||
GetInfo({commit, state}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getInfo().then(res => {
|
||||
const user = res.user
|
||||
let avatar = user.avatar || ""
|
||||
if (!isHttp(avatar)) {
|
||||
avatar = (isEmpty(avatar)) ? defAva : process.env.VUE_APP_IMG_URL + avatar
|
||||
const imgBase = process.env.NODE_ENV === 'production' ? window.location.origin : process.env.VUE_APP_IMG_URL
|
||||
avatar = (isEmpty(avatar)) ? defAva : imgBase + avatar
|
||||
}
|
||||
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
||||
commit('SET_ROLES', res.roles)
|
||||
@ -78,16 +79,26 @@ const user = {
|
||||
commit('SET_NICK_NAME', user.nickName)
|
||||
commit('SET_AVATAR', avatar)
|
||||
/* 初始密码提示 */
|
||||
if(res.isDefaultModifyPwd) {
|
||||
MessageBox.confirm('您的密码还是初始密码,请修改密码!', '安全提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => {
|
||||
router.push({ name: 'Profile', params: { activeTab: 'resetPwd' } })
|
||||
}).catch(() => {})
|
||||
if (res.isDefaultModifyPwd) {
|
||||
MessageBox.confirm('您的密码还是初始密码,请修改密码!', '安全提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
router.push({name: 'Profile', params: {activeTab: 'resetPwd'}})
|
||||
}).catch(() => {
|
||||
})
|
||||
}
|
||||
/* 过期密码提示 */
|
||||
if(!res.isDefaultModifyPwd && res.isPasswordExpired) {
|
||||
MessageBox.confirm('您的密码已过期,请尽快修改密码!', '安全提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => {
|
||||
router.push({ name: 'Profile', params: { activeTab: 'resetPwd' } })
|
||||
}).catch(() => {})
|
||||
if (!res.isDefaultModifyPwd && res.isPasswordExpired) {
|
||||
MessageBox.confirm('您的密码已过期,请尽快修改密码!', '安全提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
router.push({name: 'Profile', params: {activeTab: 'resetPwd'}})
|
||||
}).catch(() => {
|
||||
})
|
||||
}
|
||||
resolve(res)
|
||||
}).catch(error => {
|
||||
@ -97,7 +108,7 @@ const user = {
|
||||
},
|
||||
|
||||
// 退出系统
|
||||
LogOut({ commit, state }) {
|
||||
LogOut({commit, state}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
logout(state.token).then(() => {
|
||||
commit('SET_TOKEN', '')
|
||||
@ -112,7 +123,7 @@ const user = {
|
||||
},
|
||||
|
||||
// 前端 登出
|
||||
FedLogOut({ commit }) {
|
||||
FedLogOut({commit}) {
|
||||
return new Promise(resolve => {
|
||||
commit('SET_TOKEN', '')
|
||||
removeToken()
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="user-info-head" @click="editCropper()"><img v-bind:src="options.img" title="点击上传头像" class="img-circle img-lg" /></div>
|
||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog">
|
||||
<div class="user-info-head" @click="editCropper()"><img v-bind:src="options.img" title="点击上传头像"
|
||||
class="img-circle img-lg"/></div>
|
||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened"
|
||||
@close="closeDialog">
|
||||
<el-row>
|
||||
<el-col :xs="24" :md="12" :style="{height: '350px'}">
|
||||
<vue-cropper
|
||||
@ -19,11 +21,11 @@
|
||||
</el-col>
|
||||
<el-col :xs="24" :md="12" :style="{height: '350px'}">
|
||||
<div class="avatar-upload-preview">
|
||||
<img :src="previews.url" :style="previews.img" />
|
||||
<img :src="previews.url" :style="previews.img"/>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<br />
|
||||
<br/>
|
||||
<el-row>
|
||||
<el-col :lg="2" :sm="3" :xs="3">
|
||||
<el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload">
|
||||
@ -55,12 +57,12 @@
|
||||
|
||||
<script>
|
||||
import store from "@/store"
|
||||
import { VueCropper } from "vue-cropper"
|
||||
import { uploadAvatar } from "@/api/system/user"
|
||||
import { debounce } from '@/utils'
|
||||
import {VueCropper} from "vue-cropper"
|
||||
import {uploadAvatar} from "@/api/system/user"
|
||||
import {debounce} from '@/utils'
|
||||
|
||||
export default {
|
||||
components: { VueCropper },
|
||||
components: {VueCropper},
|
||||
data() {
|
||||
return {
|
||||
// 是否显示弹出层
|
||||
@ -75,7 +77,7 @@ export default {
|
||||
autoCropWidth: 200, // 默认生成截图框宽度
|
||||
autoCropHeight: 200, // 默认生成截图框高度
|
||||
fixedBox: true, // 固定截图框大小 不允许改变
|
||||
outputType:"png", // 默认生成截图为PNG格式
|
||||
outputType: "png", // 默认生成截图为PNG格式
|
||||
filename: 'avatar' // 文件名称
|
||||
},
|
||||
previews: {},
|
||||
@ -136,8 +138,9 @@ export default {
|
||||
let formData = new FormData()
|
||||
formData.append("avatarfile", data, this.options.filename)
|
||||
uploadAvatar(formData).then(response => {
|
||||
const imgBase = process.env.NODE_ENV === 'production' ? window.location.origin : process.env.VUE_APP_IMG_URL
|
||||
this.open = false
|
||||
this.options.img = process.env.VUE_APP_IMG_URL + response.imgUrl
|
||||
this.options.img = imgBase + response.imgUrl
|
||||
store.commit('SET_AVATAR', this.options.img)
|
||||
this.$modal.msgSuccess("修改成功")
|
||||
this.visible = false
|
||||
|
||||
Reference in New Issue
Block a user