From afdb091a3e4994250d8228fd1238658b45a4e35e Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期三, 10 七月 2024 15:41:24 +0800
Subject: [PATCH] 教学资源增加分类
---
src/views/home/components/user-panel/index.vue | 56 +++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 37 insertions(+), 19 deletions(-)
diff --git a/src/views/home/components/user-panel/index.vue b/src/views/home/components/user-panel/index.vue
index 03c2294..0880ffc 100644
--- a/src/views/home/components/user-panel/index.vue
+++ b/src/views/home/components/user-panel/index.vue
@@ -3,24 +3,24 @@
<el-card class="card">
<div class="panel-content flex flex-col items-center">
<div class="avatar-container w-40 h-40 rounded-full overflow-hidden">
- <div class="avatar-content">
- <img src="@/assets/image/avatar/avatar.png" class="avatar-img" alt="">
+ <div class="avatar-content" v-if="userInfo.imagePath">
+ <img :src="userInfo.imagePath" class="avatar-img" alt="">
</div>
- <!-- <div class="avatar-content" :style="{backgroundColor: getColor}">
- <div class="name text-5xl font-bold text-white">寮�</div>
- </div> -->
+ <div class="avatar-content" :style="{backgroundColor: getColor}" v-else>
+ <div class="name text-5xl font-bold text-white">{{ getFirstName }}</div>
+ </div>
</div>
<div class="name-container text-lg font-bold mt-5 mb-2">
- 娴嬭瘯娴嬭瘯
+ {{ userInfo.realName }}
</div>
<div class="department-container text-base mb-10">
- 娴嬭瘯娴嬭瘯
+ {{ userInfo.userName }}
</div>
<div class="tool-container grid grid-cols-3 gap-10">
- <div class="tool-item text-center cursor-pointer" v-for="item in toolList">
+ <div class="tool-item text-center cursor-pointer" v-for="item in toolList" @click="toolClick(item)">
<div class="tool-icon mb-1">
<img :src="item.iconPath" class="width-img" alt="">
</div>
@@ -38,27 +38,35 @@
<script setup>
import { ref, computed } from 'vue';
import randomColor from '@/utils/randomColor.js';
+import { useRouter } from 'vue-router';
+import { storeToRefs } from 'pinia';
+import { useUserStore } from '@/store/index.js';
+
+const userStore = useUserStore();
+const { userInfo } = storeToRefs(userStore);
+
+
+
+const router = useRouter();
const toolList = ref([
{
id: 1,
- title: '璧勬簮鍏变韩',
- iconPath: new URL('@/assets/icons/icon1.png', import.meta.url).href
+ title: '鍦ㄧ嚎鍩硅',
+ iconPath: new URL('@/assets/icons/icon1.png', import.meta.url).href,
+ path: '/train'
},
{
id: 2,
- title: '鎴戠殑璇剧▼',
- iconPath: new URL('@/assets/icons/icon2.png', import.meta.url).href
+ title: '鎴戠殑鑰冭瘯',
+ iconPath: new URL('@/assets/icons/icon2.png', import.meta.url).href,
+ path: '/exam-list'
},
{
id: 3,
- title: '鎴戠殑璇剧▼',
- iconPath: new URL('@/assets/icons/icon2.png', import.meta.url).href
- },
- {
- id: 4,
- title: '鎴戠殑璇剧▼',
- iconPath: new URL('@/assets/icons/icon2.png', import.meta.url).href
+ title: '鎴戠殑鎴愮哗',
+ iconPath: new URL('@/assets/icons/icon2.png', import.meta.url).href,
+ path: '/grade-list'
},
]);
@@ -67,6 +75,16 @@
return randomColor();
});
+const getFirstName = computed(() => {
+ return userInfo.value.realName && userInfo.value.realName[0];
+});
+
+const toolClick = (item) => {
+ if (item.path) {
+ router.push(item.path);
+ }
+}
+
</script>
<style lang="scss" scoped>
--
Gitblit v1.8.0