放弃vuex改用pinia (#872)

Co-authored-by: bypanghu <bypanghu@163.com>
This commit is contained in:
奇淼(piexlmax
2022-01-07 12:29:32 +08:00
committed by GitHub
co-authored by bypanghu
parent eca5967b4d
commit 727caf3f4f
60 changed files with 681 additions and 918 deletions
+9 -10
View File
@@ -1,11 +1,11 @@
<template>
<span class="headerAvatar">
<template v-if="picType === 'avatar'">
<el-avatar v-if="userInfo.headerImg" :size="30" :src="avatar" />
<el-avatar v-if="userStore.userInfo.headerImg" :size="30" :src="avatar" />
<el-avatar v-else :size="30" :src="noAvatar" />
</template>
<template v-if="picType === 'img'">
<img v-if="userInfo.headerImg" :src="avatar" class="avatar">
<img v-if="userStore.userInfo.headerImg" :src="avatar" class="avatar">
<img v-else :src="noAvatar" class="avatar">
</template>
<template v-if="picType === 'file'">
@@ -22,10 +22,8 @@ export default {
<script setup>
import noAvatarPng from '@/assets/noBody.png'
import { useStore } from 'vuex'
import { computed, ref, defineProps } from 'vue'
const store = useStore()
import { useUserStore } from '@/pinia/modules/user'
import { computed, ref } from 'vue'
const props = defineProps({
picType: {
type: String,
@@ -41,14 +39,15 @@ const props = defineProps({
const path = ref(import.meta.env.VITE_BASE_API + '/')
const noAvatar = ref(noAvatarPng)
const userInfo = computed(() => store.getters['user/userInfo'])
const userStore = useUserStore()
const avatar = computed(() => {
if (props.picSrc === '') {
if (userInfo.value.headerImg !== '' && userInfo.value.headerImg.slice(0, 4) === 'http') {
return userInfo.value.headerImg
if (userStore.userInfo.headerImg !== '' && userStore.userInfo.headerImg.slice(0, 4) === 'http') {
return userStore.userInfo.headerImg
}
return path.value + userInfo.value.headerImg
return path.value + userStore.userInfo.headerImg
} else {
if (props.picSrc !== '' && props.picSrc.slice(0, 4) === 'http') {
return props.picSrc