增加头部名称

This commit is contained in:
zrh050423 2024-12-21 14:02:12 +08:00
parent 34d84fa02f
commit 6f6e2d5200
3 changed files with 21 additions and 24 deletions

View File

@ -11,7 +11,7 @@
<el-avatar :size="32" class="user-avatar">
<el-icon><User /></el-icon>
</el-avatar>
<span class="username">{{ userInfo.name }}</span>
<span class="username">{{ userInfo.username }}</span>
<el-icon><CaretBottom /></el-icon>
</span>
<template #dropdown>
@ -39,9 +39,7 @@ import { ref } from 'vue'
import { User, CaretBottom, UserFilled, Setting, SwitchButton } from '@element-plus/icons-vue'
const userInfo = ref({
name: '张医生',
role: '主治医师',
department: '内科'
username: sessionStorage.getItem('username') || '未登录',
})
</script>

View File

@ -7,37 +7,33 @@
<el-table-column prop="talkUser" label="使用者身份" width="180" />
</el-table>
</template>
<script lang="ts">
import { defineComponent, ref, onMounted } from 'vue';
<script>
import axiosInstance from '@/utils/axiosInstance'; // axios
const BASE_URL = '/talk/record/all'; // 使 BASE_URL
export default defineComponent({
export default {
name: 'TalkHistory',
setup() {
const tableData = ref<any[]>([]); //
const fetchData = async () => {
data() {
return {
tableData: [] //
};
},
methods: {
async fetchData() {
try {
// 使 axiosInstance
const response = await axiosInstance.get(BASE_URL);
console.log('Talk records fetched successfully:', response);
tableData.value = response; // 使 response
this.tableData = response;
} catch (error) {
console.error('错误:', error);
}
};
//
onMounted(() => {
fetchData();
});
return {
tableData
};
}
},
mounted() {
this.fetchData(); //
}
});
};
</script>

View File

@ -51,7 +51,10 @@ export default {
alert('用户登录成功');
console.log(data.data);
const token = data.data;
const username = data.username;
console.log(token, username);
sessionStorage.setItem('token', token);
sessionStorage.setItem('username', username);
await router.push('/home');
} else {
alert(data.message);