增加头部名称

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

View File

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

View File

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