mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 01:17:23 +08:00
chore: 安全日志
This commit is contained in:
parent
2b132455d2
commit
f2fcaadcb4
38
mock/mine.ts
38
mock/mine.ts
@ -1,6 +1,8 @@
|
||||
import { defineFakeRoute } from "vite-plugin-fake-server/client";
|
||||
import { faker } from "@faker-js/faker/locale/zh_CN";
|
||||
|
||||
export default defineFakeRoute([
|
||||
// 账户设置-个人信息
|
||||
{
|
||||
url: "/mine",
|
||||
method: "get",
|
||||
@ -17,5 +19,41 @@ export default defineFakeRoute([
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
// 账户设置-个人安全日志
|
||||
{
|
||||
url: "/mine-logs",
|
||||
method: "get",
|
||||
response: () => {
|
||||
let list = [
|
||||
{
|
||||
id: 1,
|
||||
ip: faker.internet.ipv4(),
|
||||
address: "中国河南省信阳市",
|
||||
system: "macOS",
|
||||
browser: "Chrome",
|
||||
summary: "账户登录", // 详情
|
||||
operatingTime: new Date() // 时间
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
ip: faker.internet.ipv4(),
|
||||
address: "中国广东省深圳市",
|
||||
system: "Windows",
|
||||
browser: "Firefox",
|
||||
summary: "绑定了手机号码",
|
||||
operatingTime: new Date().setDate(new Date().getDate() - 1)
|
||||
}
|
||||
];
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
list,
|
||||
total: list.length, // 总条目数
|
||||
pageSize: 10, // 每页显示条目个数
|
||||
currentPage: 1 // 当前页数
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
@ -48,6 +48,20 @@ export type UserInfoResult = {
|
||||
data: UserInfo;
|
||||
};
|
||||
|
||||
type ResultTable = {
|
||||
success: boolean;
|
||||
data?: {
|
||||
/** 列表数据 */
|
||||
list: Array<any>;
|
||||
/** 总条目数 */
|
||||
total?: number;
|
||||
/** 每页显示条目个数 */
|
||||
pageSize?: number;
|
||||
/** 当前页数 */
|
||||
currentPage?: number;
|
||||
};
|
||||
};
|
||||
|
||||
/** 登录 */
|
||||
export const getLogin = (data?: object) => {
|
||||
return http.request<UserResult>("post", "/login", { data });
|
||||
@ -62,3 +76,8 @@ export const refreshTokenApi = (data?: object) => {
|
||||
export const getMine = (data?: object) => {
|
||||
return http.request<UserInfoResult>("get", "/mine", { data });
|
||||
};
|
||||
|
||||
/** 账户设置-个人安全日志 */
|
||||
export const getMineLogs = (data?: object) => {
|
||||
return http.request<ResultTable>("get", "/mine-logs", { data });
|
||||
};
|
||||
|
@ -1,7 +1,81 @@
|
||||
<script setup lang="ts"></script>
|
||||
<script setup lang="ts">
|
||||
import dayjs from "dayjs";
|
||||
import { getMineLogs } from "@/api/user";
|
||||
import { reactive, ref, onMounted } from "vue";
|
||||
import type { PaginationProps } from "@pureadmin/table";
|
||||
|
||||
const loading = ref(true);
|
||||
const dataList = ref([]);
|
||||
const pagination = reactive<PaginationProps>({
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
background: true,
|
||||
layout: "prev, pager, next"
|
||||
});
|
||||
const columns: TableColumnList = [
|
||||
{
|
||||
label: "详情",
|
||||
prop: "summary",
|
||||
minWidth: 140
|
||||
},
|
||||
{
|
||||
label: "IP 地址",
|
||||
prop: "ip",
|
||||
minWidth: 100
|
||||
},
|
||||
{
|
||||
label: "地点",
|
||||
prop: "address",
|
||||
minWidth: 140
|
||||
},
|
||||
{
|
||||
label: "操作系统",
|
||||
prop: "system",
|
||||
minWidth: 100
|
||||
},
|
||||
{
|
||||
label: "浏览器类型",
|
||||
prop: "browser",
|
||||
minWidth: 100
|
||||
},
|
||||
{
|
||||
label: "时间",
|
||||
prop: "operatingTime",
|
||||
minWidth: 180,
|
||||
formatter: ({ operatingTime }) =>
|
||||
dayjs(operatingTime).format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
];
|
||||
|
||||
async function onSearch() {
|
||||
loading.value = true;
|
||||
const { data } = await getMineLogs();
|
||||
dataList.value = data.list;
|
||||
pagination.total = data.total;
|
||||
pagination.pageSize = data.pageSize;
|
||||
pagination.currentPage = data.currentPage;
|
||||
|
||||
setTimeout(() => {
|
||||
loading.value = false;
|
||||
}, 200);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
onSearch();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="ml-[120px] min-w-[180px] max-w-[70%]">
|
||||
<h3 class="my-8">安全日志</h3>
|
||||
<pure-table
|
||||
row-key="id"
|
||||
table-layout="auto"
|
||||
:loading="loading"
|
||||
:data="dataList"
|
||||
:columns="columns"
|
||||
:pagination="pagination"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
Loading…
x
Reference in New Issue
Block a user