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