mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-23 10:26:38 +08:00
日志添加查看信息功能
This commit is contained in:
parent
4c7384411d
commit
ec0d712b6f
@ -49,5 +49,5 @@
|
|||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"jsxSingleQuote": true
|
"jsxSingleQuote": true
|
||||||
},
|
},
|
||||||
"proxy": "http://localhost:3000"
|
"proxy": "https://nekoapi.com"
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@ import React, {useEffect, useState} from 'react';
|
|||||||
import {Label} from 'semantic-ui-react';
|
import {Label} from 'semantic-ui-react';
|
||||||
import {API, isAdmin, showError, timestamp2string} from '../helpers';
|
import {API, isAdmin, showError, timestamp2string} from '../helpers';
|
||||||
|
|
||||||
import {Table, Avatar, Tag, Form, Button, Layout, Select} from '@douyinfe/semi-ui';
|
import {Table, Avatar, Tag, Form, Button, Layout, Select, Popover, Modal} from '@douyinfe/semi-ui';
|
||||||
import {ITEMS_PER_PAGE} from '../constants';
|
import {ITEMS_PER_PAGE} from '../constants';
|
||||||
import {renderQuota, stringToColor} from '../helpers/render';
|
import {renderNumber, renderQuota, stringToColor} from '../helpers/render';
|
||||||
import {
|
import {
|
||||||
IconAt,
|
IconAt,
|
||||||
IconHistogram,
|
IconHistogram,
|
||||||
@ -88,7 +88,8 @@ const LogsTable = () => {
|
|||||||
return (
|
return (
|
||||||
isAdminUser ?
|
isAdminUser ?
|
||||||
<div>
|
<div>
|
||||||
<Avatar size="small" color={stringToColor(text)} style={{marginRight: 4}}>
|
<Avatar size="small" color={stringToColor(text)} style={{marginRight: 4}}
|
||||||
|
onClick={() => showUserInfo(record.user_id)}>
|
||||||
{typeof text === 'string' && text.slice(0, 1)}
|
{typeof text === 'string' && text.slice(0, 1)}
|
||||||
</Avatar>
|
</Avatar>
|
||||||
{text}
|
{text}
|
||||||
@ -251,6 +252,28 @@ const LogsTable = () => {
|
|||||||
setShowStat(!showStat);
|
setShowStat(!showStat);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const showUserInfo = async (userId) => {
|
||||||
|
if (!isAdminUser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const res = await API.get(`/api/user/${userId}`);
|
||||||
|
const {success, message, data} = res.data;
|
||||||
|
if (success) {
|
||||||
|
Modal.info({
|
||||||
|
title: '用户信息',
|
||||||
|
content: <div style={{padding: 12}}>
|
||||||
|
<p>用户名: {data.username}</p>
|
||||||
|
<p>余额: {renderQuota(data.quota)}</p>
|
||||||
|
<p>已用额度:{renderQuota(data.used_quota)}</p>
|
||||||
|
<p>请求次数:{renderNumber(data.request_count)}</p>
|
||||||
|
</div>,
|
||||||
|
centered: true,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
showError(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const setLogsFormat = (logs) => {
|
const setLogsFormat = (logs) => {
|
||||||
for (let i = 0; i < logs.length; i++) {
|
for (let i = 0; i < logs.length; i++) {
|
||||||
logs[i].timestamp2string = timestamp2string(logs[i].created_at);
|
logs[i].timestamp2string = timestamp2string(logs[i].created_at);
|
||||||
|
Loading…
Reference in New Issue
Block a user