|
@@ -1,13 +1,16 @@
|
|
|
<template>
|
|
|
<div class="logo">
|
|
|
- <img src="~@/assets/images/admin.png" alt="" />
|
|
|
- <h2 v-show="!collapsed" class="title">{{userInfo.name}}</h2>
|
|
|
+ <img v-if="!avtImageUrl" src="~@/assets/images/admin.png" alt=""/>
|
|
|
+ <img v-else :src="avtImageUrl" alt="" style="border-radius: 50%"/>
|
|
|
+ <h2 v-show="!collapsed" class="title">{{ userInfo.name }}</h2>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import {reactive, ref, toRef} from 'vue';
|
|
|
+import {onMounted, reactive, ref, toRef} from 'vue';
|
|
|
import { useUserStore } from '@/store/modules/user';
|
|
|
+import {getFileBase64, getList} from "@/api/system/file";
|
|
|
+import {base64ToBlob} from "@/utils/imageUtils";
|
|
|
|
|
|
defineProps({
|
|
|
collapsed: {
|
|
@@ -16,10 +19,28 @@ import { useUserStore } from '@/store/modules/user';
|
|
|
});
|
|
|
|
|
|
const userStore = useUserStore();
|
|
|
-
|
|
|
const userInfo=reactive(userStore.getUserInfo);
|
|
|
|
|
|
+const avtImageUrl = ref<any>("")
|
|
|
+
|
|
|
+function getAvtImag(fileRefID) {
|
|
|
+ getList({fileRefID}).then((res) => {
|
|
|
+ if (!res) {
|
|
|
+ avtImageUrl.value = false;
|
|
|
+ } else {
|
|
|
+ // 获取图片
|
|
|
+ getFileBase64({fileId: res[0].fileId}).then(data => {
|
|
|
+ if (data) {
|
|
|
+ avtImageUrl.value = URL.createObjectURL(base64ToBlob("data:image/png;base64," + data));
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
+onMounted(() => {
|
|
|
+ getAvtImag(userInfo.userID);
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
@@ -31,6 +52,7 @@ const userInfo=reactive(userStore.getUserInfo);
|
|
|
line-height: 84px;
|
|
|
|
|
|
img {
|
|
|
+ width: 32px;
|
|
|
height: 32px;
|
|
|
margin-right: 8px;
|
|
|
}
|