授权列表新增过期时间和重新授权按钮

This commit is contained in:
Lrd
2026-06-30 09:49:34 +08:00
parent 7c2071aa80
commit d6b32620b7
3 changed files with 54 additions and 38 deletions
+13 -1
View File
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Button, Table, Modal, App, Input, Pagination, Typography, Space } from 'antd'; import { Button, Table, Modal, App, Input, Pagination, Typography, Space } from 'antd';
import { LockOutlined } from '@ant-design/icons'; import { LockOutlined, ArrowLeftOutlined } from '@ant-design/icons';
import { useNavigate } from 'react-router-dom';
import { getOAuthAccountList, deleteOAuthAccount, getOpenTypeAll } from '../api'; import { getOAuthAccountList, deleteOAuthAccount, getOpenTypeAll } from '../api';
const formatDateTime = (dateStr: string) => { const formatDateTime = (dateStr: string) => {
@@ -25,6 +26,7 @@ interface AuthorizationData {
} }
const AuthAccountPage: React.FC = () => { const AuthAccountPage: React.FC = () => {
const navigate = useNavigate();
const { message } = App.useApp(); const { message } = App.useApp();
const [authorizations, setAuthorizations] = useState<AuthorizationData[]>([]); const [authorizations, setAuthorizations] = useState<AuthorizationData[]>([]);
const [listLoading, setListLoading] = useState(false); const [listLoading, setListLoading] = useState(false);
@@ -213,6 +215,15 @@ const AuthAccountPage: React.FC = () => {
}, },
]; ];
const handleBack = () => {
const referrer = document.referrer;
if (referrer.includes(window.location.origin)) {
navigate(-1);
} else {
navigate('/authorization');
}
};
const tableData = authorizations.map((item, index) => ({ const tableData = authorizations.map((item, index) => ({
...item, ...item,
index: index + 1, index: index + 1,
@@ -222,6 +233,7 @@ const AuthAccountPage: React.FC = () => {
return ( return (
<div style={{ minHeight: '94vh' }}> <div style={{ minHeight: '94vh' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 12 }}> <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 12 }}>
<Button type="text" icon={<ArrowLeftOutlined />} onClick={handleBack} />
<LockOutlined style={{ color: '#6366f1', fontSize: 16 }} /> <LockOutlined style={{ color: '#6366f1', fontSize: 16 }} />
<Typography.Text strong style={{ fontSize: 16 }}></Typography.Text> <Typography.Text strong style={{ fontSize: 16 }}></Typography.Text>
</div> </div>
+40 -36
View File
@@ -154,6 +154,19 @@ const AuthorizationPage: React.FC = () => {
} }
}; };
const handleReauthorize = async (record: AuthorizationData) => {
try {
const response = await requestOAuth({ open_type: record.openType });
if (response.authUrl) {
window.open(response.authUrl, '_blank');
} else {
message.error('获取授权链接失败');
}
} catch (error) {
message.error('重新授权失败');
}
};
const columns = [ const columns = [
{ {
title: 'ID', title: 'ID',
@@ -162,13 +175,12 @@ const AuthorizationPage: React.FC = () => {
}, },
{ {
title: '授权账户ID', title: '授权账户ID',
dataIndex: 'advertiserId', dataIndex: 'accountId',
key: 'advertiserId', key: 'accountId',
width: 160,
}, },
{ {
title: '授权账户名称', title: '授权账户名称',
dataIndex: 'advertiserName', dataIndex: 'accountName',
key: 'accountName', key: 'accountName',
}, },
{ {
@@ -211,9 +223,10 @@ const AuthorizationPage: React.FC = () => {
key: 'accountUsername', key: 'accountUsername',
}, },
{ {
title: '授权应用ID', title: '开户方式',
dataIndex: 'appid', dataIndex: 'openType',
key: 'appid', key: 'openType',
render: (text: number) => <span style={{ color: '#1e293b' }}>{openTypeMap[text] || text}</span>,
}, },
{ {
title: '是否敏感物料授权', title: '是否敏感物料授权',
@@ -227,27 +240,9 @@ const AuthorizationPage: React.FC = () => {
), ),
}, },
{ {
title: '开户方式', title: '授权过期时间',
dataIndex: 'openType', dataIndex: 'accessTokenExpired',
key: 'openType', key: 'accessTokenExpired',
render: (text: number) => <span style={{ color: '#1e293b' }}>{openTypeMap[text] || text}</span>,
},
{
title: '平台端口',
dataIndex: 'portType',
key: 'portType',
ellipsis: true,
render: (text: number) => <span style={{ color: '#1e293b' }}>{PORT_TYPE_MAP[text] || text}</span>,
},
{
title: '用户id',
dataIndex: 'userId',
key: 'userId',
},
{
title: '创建时间',
dataIndex: 'createdAt',
key: 'createdAt',
width: 160, width: 160,
render: (text: string) => <span style={{ color: '#64748b' }}>{formatDateTime(text)}</span>, render: (text: string) => <span style={{ color: '#64748b' }}>{formatDateTime(text)}</span>,
}, },
@@ -263,15 +258,24 @@ const AuthorizationPage: React.FC = () => {
dataIndex: 'action', dataIndex: 'action',
fixed: 'right' as const, fixed: 'right' as const,
key: 'action', key: 'action',
width: 140, width: 190,
render: (_: unknown, record) => ( render: (_: unknown, record) => (
<Button <>
type="link" <Button
onClick={() => navigate(`/consume?advertiserId=${record.advertiserId}`)} type="link"
style={{ color: '#6366f1', padding: 0 }} onClick={() => navigate(`/authacc?advertiserId=${record.advertiserId}`)}
> style={{ color: '#6366f1', padding: 0 }}
>
</Button>
</Button>
<Button
type="link"
onClick={() => handleReauthorize(record)}
style={{ color: '#00c49f', padding: 0, marginLeft: 8 }}
>
</Button>
</>
), ),
}, },
]; ];
+1 -1
View File
@@ -92,7 +92,7 @@ const ConsumePage: React.FC = () => {
if (referrer.includes(window.location.origin)) { if (referrer.includes(window.location.origin)) {
navigate(-1); navigate(-1);
} else { } else {
navigate('/authorization'); navigate('/materials');
} }
}; };