fix:默认头像问题; #228
|
@ -5,7 +5,7 @@
|
||||||
<el-popover ref="popoverRef" placement="right" trigger="hover" popper-class="popoverStyle" :tabindex="999" >
|
<el-popover ref="popoverRef" placement="right" trigger="hover" popper-class="popoverStyle" :tabindex="999" >
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<el-image class="user-img" :src="userStore.user.avatar ==='/img/avatar-default.jpg' || userStore.user.avatar ==='/images/img-avatar.png' ? defaultUserImg : dev_api + userStore.user.avatar" />
|
<el-image class="user-img" :src="img" />
|
||||||
<span>{{ userStore.user.nickName }}</span>
|
<span>{{ userStore.user.nickName }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -75,6 +75,9 @@ const activeId = ref('/home')
|
||||||
const version = ref(pkc.version)
|
const version = ref(pkc.version)
|
||||||
|
|
||||||
const popoverRef = ref('')
|
const popoverRef = ref('')
|
||||||
|
// 默认图片
|
||||||
|
const img = ref('')
|
||||||
|
const defaultImg = ['/img/avatar-default.jpg','/images/img-avatar.png','/src/assets/images/img-avatar.png']
|
||||||
|
|
||||||
//是否是基地人员
|
//是否是基地人员
|
||||||
const isStadium = () => {
|
const isStadium = () => {
|
||||||
|
@ -224,6 +227,11 @@ const logout = () => {
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
userStore.getDeptInfo()
|
userStore.getDeptInfo()
|
||||||
// getregisterinfo()
|
// getregisterinfo()
|
||||||
|
if(defaultImg.includes(userStore.user.avatar)){
|
||||||
|
img.value = defaultUserImg
|
||||||
|
}else{
|
||||||
|
img.value = dev_api.value + userStore.user.avatar
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {ref, reactive} from 'vue'
|
import {ref, reactive, onMounted} from 'vue'
|
||||||
import { uploadAvatar } from '@/api/system/user'
|
import { uploadAvatar } from '@/api/system/user'
|
||||||
import useUserStore from '@/store/modules/user'
|
import useUserStore from '@/store/modules/user'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
|
@ -31,10 +31,11 @@ const userStore = useUserStore()
|
||||||
const open = ref(false)
|
const open = ref(false)
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
|
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
|
||||||
|
const defaultImg = ['/img/avatar-default.jpg','/images/img-avatar.png','/src/assets/images/img-avatar.png']
|
||||||
|
|
||||||
//图片裁剪数据
|
//图片裁剪数据
|
||||||
const options = reactive({
|
const options = reactive({
|
||||||
img: userStore.user.avatar ==='/img/avatar-default.jpg' || userStore.user.avatar ==='/images/img-avatar.png' ? defaultUserImg : dev_api.value + userStore.user.avatar, // 裁剪图片的地址
|
img: '', // 裁剪图片的地址
|
||||||
autoCrop: true, // 是否默认生成截图框
|
autoCrop: true, // 是否默认生成截图框
|
||||||
autoCropWidth: 400, // 默认生成截图框宽度
|
autoCropWidth: 400, // 默认生成截图框宽度
|
||||||
autoCropHeight: 400, // 默认生成截图框高度
|
autoCropHeight: 400, // 默认生成截图框高度
|
||||||
|
@ -70,12 +71,19 @@ function uploadImg(data) {
|
||||||
|
|
||||||
/** 关闭窗口 */
|
/** 关闭窗口 */
|
||||||
function closeDialog() {
|
function closeDialog() {
|
||||||
options.img = userStore.user.avatar ==='/img/avatar-default.jpg' || userStore.user.avatar ==='/images/img-avatar.png' ? defaultUserImg : dev_api.value + userStore.user.avatar
|
// options.img = userStore.user.avatar ==='/img/avatar-default.jpg' || userStore.user.avatar ==='/images/img-avatar.png' ? defaultUserImg : dev_api.value + userStore.user.avatar
|
||||||
options.visible = false
|
options.visible = false
|
||||||
}
|
}
|
||||||
const cancle = () => {
|
const cancle = () => {
|
||||||
open.value = false
|
open.value = false
|
||||||
}
|
}
|
||||||
|
onMounted(() => {
|
||||||
|
if(defaultImg.includes(userStore.user.avatar)){
|
||||||
|
options.img = defaultUserImg
|
||||||
|
}else{
|
||||||
|
options.img = dev_api.value + userStore.user.avatar
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang='scss' scoped>
|
<style lang='scss' scoped>
|
||||||
|
|
Loading…
Reference in New Issue