From 702fc4ba0d5ea211393bbc88c373e111341c5ba6 Mon Sep 17 00:00:00 2001 From: callmeyan Date: Thu, 9 Jan 2025 21:09:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=B0=E6=8D=AE=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/core/string.ts | 10 ++++++++-- src/pages/user/index.vue | 11 ++++++++--- src/service/api/user.ts | 2 ++ yarn.lock | 7 ++++++- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 2effd41..28acb5c 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "ant-design-vue": "^4.2.6", "autoprefixer": "^10.4.20", "axios": "^1.7.9", - "dayjs": "^1.11.10", + "dayjs": "^1.11.13", "js-md5": "^0.8.3", "pinia": "^2.3.0", "postcss": "^8.4.49", diff --git a/src/core/string.ts b/src/core/string.ts index adb533c..67260aa 100644 --- a/src/core/string.ts +++ b/src/core/string.ts @@ -1,5 +1,11 @@ -import { md5 } from "js-md5"; +import {md5} from "js-md5"; +import dayjs from "dayjs"; export function getMd5(str: string) { - return md5(str); + return md5(str); +} + +export function formatDatetime(date: Date | string | number, format = 'YYYY-MM-DD HH:mm:ss') { + if (!date) return date; + return dayjs(date).format(format); } \ No newline at end of file diff --git a/src/pages/user/index.vue b/src/pages/user/index.vue index 6615caf..baf65f4 100644 --- a/src/pages/user/index.vue +++ b/src/pages/user/index.vue @@ -10,8 +10,10 @@ import { RoleEnum, AllRoleList } from '@/core/enums.ts' import { columns, getList, deleteUser } from "@/service/api/user"; import PageHeader from '@/components/page-header.vue' import useRequest from "@/service/useRequest"; +import {useUserStore} from "@/service/user-store.ts"; import EditModal from './modal.vue' +import {formatDatetime} from "@/core/string.ts"; const editUser = ref>() const searchParams = ref({ @@ -19,6 +21,7 @@ const searchParams = ref({ limit: 10, role: '' }) +const {userInfo} = useUserStore(); const { data: allDataList, loading, run, refresh } = useRequest(() => getList(searchParams.value)) @@ -75,7 +78,7 @@ function handleSearch() { - + @@ -86,7 +89,7 @@ function handleSearch() { {{ th.title }} - 操作 + 操作 @@ -94,7 +97,9 @@ function handleSearch() { {{ user.nickname }} {{ user.account }} {{ user.role == RoleEnum.ROOT ? '超级管理员' : '管理员' }} - + {{ formatDatetime(user.created_at) }} + {{ user.last_login ?formatDatetime(user.last_login): '-' }} + 编辑 删除 diff --git a/src/service/api/user.ts b/src/service/api/user.ts index f405629..9e21113 100644 --- a/src/service/api/user.ts +++ b/src/service/api/user.ts @@ -32,4 +32,6 @@ export const columns = [ { title: '姓名', dataIndex: 'nickname' }, { title: '账号', dataIndex: 'account' }, { title: '角色', dataIndex: 'role' }, + { title: '创建时间', dataIndex: 'create_at' }, + { title: '最后登录时间', dataIndex: 'last_login' }, ] \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 248bcc0..ed7adb5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -923,11 +923,16 @@ csstype@^3.1.1, csstype@^3.1.3: resolved "https://registry.npmmirror.com/csstype/-/csstype-3.1.3.tgz" integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw== -dayjs@^1.10.5, dayjs@^1.11.10: +dayjs@^1.10.5: version "1.11.10" resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0" integrity sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ== +dayjs@^1.11.13: + version "1.11.13" + resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.13.tgz#92430b0139055c3ebb60150aa13e860a4b5a366c" + integrity sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg== + de-indent@^1.0.2: version "1.0.2" resolved "https://registry.npmmirror.com/de-indent/-/de-indent-1.0.2.tgz"