增加头部名称
This commit is contained in:
parent
34d84fa02f
commit
6f6e2d5200
|
@ -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>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue