Files
cdTestPlant3/cdTMP/src/views/dashboard/usercenter/index.vue

104 lines
3.9 KiB
Vue
Raw Normal View History

2023-06-08 21:09:28 +08:00
<template>
<div class="block">
<div class="user-header rounded-sm text-center">
2024-06-20 19:12:13 +08:00
<div class="pt-6 mx-auto avatar-box top-box">
{{ userStore.name }}
2023-06-08 21:09:28 +08:00
</div>
<div>
2024-06-20 19:12:13 +08:00
<a-tag size="large" class="mt-3 rounded-full" color="#de53ff"> 账号{{ userStore.username }} </a-tag>
2023-06-08 21:09:28 +08:00
</div>
</div>
<a-layout-content class="block lg:flex lg:justify-between">
<div class="ma-content-block w-full lg:w-6/12 mt-3 p-4">
<a-tabs type="rounded">
<a-tab-pane key="info" title="个人资料">
<user-infomation />
</a-tab-pane>
<a-tab-pane key="safe" title="安全设置">
<editpassword />
</a-tab-pane>
</a-tabs>
</div>
<div class="ma-content-block w-full lg:w-6/12 mt-3 p-4 ml-0 lg:ml-3">
<a-tabs type="rounded">
2024-06-17 18:44:39 +08:00
<a-tab-pane key="login-log" title="登录日志" v-loading="isDataLoading">
<a-timeline class="pl-5 mt-3" v-if="loginLogList.length">
2023-06-08 21:09:28 +08:00
<a-timeline-item
2024-06-17 18:44:39 +08:00
:label="`IP地址${item.ip},操作系统:${item.os}`"
2023-06-08 21:09:28 +08:00
v-for="(item, idx) in loginLogList"
:key="idx"
>
2024-06-17 18:44:39 +08:00
您于 {{ item.create_datetime }} 登录系统浏览器{{ item.browser }}
2023-06-08 21:09:28 +08:00
</a-timeline-item>
</a-timeline>
</a-tab-pane>
2024-06-17 18:44:39 +08:00
<a-tab-pane key="operation-log" title="操作日志" v-loading="isLoading">
2023-06-08 21:09:28 +08:00
<a-timeline class="pl-5 mt-3">
<a-timeline-item
2024-06-17 18:44:39 +08:00
:label="`IP地址${item.request_ip},方式:${item.request_method},系统:${item.request_os},浏览器:${item.request_browser}`"
2023-06-08 21:09:28 +08:00
v-for="(item, idx) in operationLogList"
:key="idx"
>
2024-06-20 19:12:13 +08:00
您于 {{ item.create_datetime }} 请求了 {{ item.request_path }}<span
:class="{ nostatus: item.response_code === '200' ? false : true }"
>状态码{{ item.response_code }}</span
>
2023-06-08 21:09:28 +08:00
</a-timeline-item>
</a-timeline>
</a-tab-pane>
</a-tabs>
</div>
</a-layout-content>
</div>
</template>
<script setup>
2024-06-17 18:44:39 +08:00
import { computed, ref } from "vue"
2023-06-08 21:09:28 +08:00
import MaUpload from "@cps/ma-upload/index.vue"
import userInfomation from "./components/userInfo.vue"
import editpassword from "./components/editpassword.vue"
import { useUserStore } from "@/store"
2024-06-17 18:44:39 +08:00
import logApi from "@/api/system/log"
import useFetchData from "@/hooks/fetchData"
const { loadingData, isDataLoading } = useFetchData([], logApi.getLoginLog)
2023-06-08 21:09:28 +08:00
const userStore = useUserStore()
2024-06-17 18:44:39 +08:00
const loginLogList = computed(() => {
return loadingData.value.map((item) => {
item.create_datetime = item.create_datetime.split(".")[0].replace("T", " ")
return item
})
})
// 操作日志不用hook
const isLoading = ref(true)
const data = ref([])
logApi.getOperationLog().then((res) => {
data.value = res.data
isLoading.value = false
})
const operationLogList = computed(() => {
return data.value.map((item) => {
item.create_datetime = item.create_datetime.split(".")[0].replace("T", " ")
return item
})
})
2023-06-08 21:09:28 +08:00
</script>
<style scoped>
.avatar-box {
width: 130px;
}
.user-header {
width: 100%;
2024-06-20 19:12:13 +08:00
height: 150px;
2023-06-08 21:09:28 +08:00
background: url("@/assets/userBanner.jpg") no-repeat;
background-size: cover;
}
2024-06-20 19:12:13 +08:00
.nostatus {
color: red;
}
.top-box {
font-size: 2rem;
}
2023-06-08 21:09:28 +08:00
</style>