Skip to content

Commit

Permalink
feat(user-manage): 新增 Provider 字段
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwumm committed Jan 13, 2025
1 parent 57a8290 commit e6e4ec5
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
3 changes: 2 additions & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
},
"user-manage":{
"title":"User",
"email":"Email"
"email":"Email",
"provider":"Provider"
},
"captcha":{
"rotateCode": "Rotate Code",
Expand Down
3 changes: 2 additions & 1 deletion messages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
},
"user-manage":{
"title":"用户",
"email":"邮箱"
"email":"邮箱",
"provider":"认证平台"
},
"captcha":{
"rotateCode": "图片旋转验证码",
Expand Down
12 changes: 1 addition & 11 deletions src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,7 @@ import { Button, Card, CardBody, CardHeader, Divider, User } from '@nextui-org/r
import { RiGithubFill, RiGoogleFill } from '@remixicon/react';

import { signIn } from '@/auth';

export const GiteeFill = ({ fill = 'currentColor', size = 20 }) => {
return (
<svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24">
<path
fill={fill}
d="M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12a12 12 0 0 0 12-12A12 12 0 0 0 12 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.59.59 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296Z"
/>
</svg>
);
};
import { GiteeFill } from '@/constants/icon';

export default async function Login() {
return (
Expand Down
20 changes: 18 additions & 2 deletions src/app/user-manage/components/TableTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
* @Author: 白雾茫茫丶<baiwumm.com>
* @Date: 2024-12-26 15:10:28
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2025-01-08 14:43:33
* @LastEditTime: 2025-01-13 14:51:28
* @Description: 表格列表
*/
'use client';

import {
Button,
Chip,
Dropdown,
DropdownItem,
DropdownMenu,
Expand All @@ -24,12 +25,13 @@ import {
TableRow,
User,
} from '@nextui-org/react';
import { RiEqualizer2Line } from '@remixicon/react';
import { RiEqualizer2Line, RiGithubFill, RiGoogleFill } from '@remixicon/react';
import dayjs from 'dayjs';
import { useTranslations } from 'next-intl';
import { Key, ReactNode, useCallback, useMemo, useState } from 'react';

import { Empty } from '@/components/ui/empty';
import { GiteeFill } from '@/constants/icon';

import HeaderSearch, { type HeaderSearchProps } from './HeaderSearch';

Expand Down Expand Up @@ -57,6 +59,7 @@ export default function TableTemplate({
// 列配置项
const columns: Column[] = [
{ key: 'userName', label: t('title') },
{ key: 'provider', label: t('provider') },
{ key: 'createdAt', label: tGlobal('createdAt') },
];
// 列设置
Expand Down Expand Up @@ -117,6 +120,13 @@ export default function TableTemplate({
const renderCell = useCallback(
(user: App.SystemManage.User, columnKey: Key) => {
const cellValue = getKeyValue(user, columnKey as keyof App.SystemManage.User);

const providerIcon: Record<string, ReactNode> = {
github: <RiGithubFill size={18} />,
gitee: <GiteeFill size={18} />,
google: <RiGoogleFill size={18} />,
};
const firstAccount = user?.accounts?.[0];
switch (columnKey) {
case 'userName':
return (
Expand All @@ -129,6 +139,12 @@ export default function TableTemplate({
name={user.name}
/>
);
case 'provider':
return (
<Chip startContent={providerIcon[firstAccount?.provider]} variant="flat">
{firstAccount?.provider}
</Chip>
);
case 'createdAt':
return dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss');
default:
Expand Down
10 changes: 10 additions & 0 deletions src/constants/icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const GiteeFill = ({ fill = 'currentColor', size = 20 }) => {
return (
<svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24">
<path
fill={fill}
d="M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12a12 12 0 0 0 12-12A12 12 0 0 0 12 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.59.59 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296Z"
/>
</svg>
);
};
4 changes: 3 additions & 1 deletion src/typings/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ declare namespace App {
}
namespace SystemManage {
/** @description: 用户管理 */
type User = import('@prisma/client').User;
type User = import('@prisma/client').User & {
accounts: import('@prisma/client').Account[];
};
/** @description: 查询参数 */
type UserSearchParams = Common.PaginatingParams & {
name?: string;
Expand Down

0 comments on commit e6e4ec5

Please sign in to comment.