mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-18 17:51:28 +00:00
chore: update default theme style
This commit is contained in:
@@ -435,7 +435,7 @@ const ChannelsTable = () => {
|
|||||||
点击下方详情按钮可以显示余额以及设置额外的测试模型。
|
点击下方详情按钮可以显示余额以及设置额外的测试模型。
|
||||||
</Message>
|
</Message>
|
||||||
)}
|
)}
|
||||||
<Table basic compact size='small'>
|
<Table basic={'very'} compact size='small'>
|
||||||
<Table.Header>
|
<Table.Header>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.HeaderCell
|
<Table.HeaderCell
|
||||||
|
@@ -388,7 +388,7 @@ const LogsTable = () => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Form>
|
</Form>
|
||||||
<Table basic compact size='small'>
|
<Table basic={'very'} compact size='small'>
|
||||||
<Table.Header>
|
<Table.Header>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.HeaderCell
|
<Table.HeaderCell
|
||||||
|
@@ -1,29 +1,59 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Button, Form, Label, Popup, Pagination, Table } from 'semantic-ui-react';
|
import {
|
||||||
|
Button,
|
||||||
|
Form,
|
||||||
|
Label,
|
||||||
|
Popup,
|
||||||
|
Pagination,
|
||||||
|
Table,
|
||||||
|
} from 'semantic-ui-react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { API, copy, showError, showInfo, showSuccess, showWarning, timestamp2string } from '../helpers';
|
import {
|
||||||
|
API,
|
||||||
|
copy,
|
||||||
|
showError,
|
||||||
|
showInfo,
|
||||||
|
showSuccess,
|
||||||
|
showWarning,
|
||||||
|
timestamp2string,
|
||||||
|
} from '../helpers';
|
||||||
|
|
||||||
import { ITEMS_PER_PAGE } from '../constants';
|
import { ITEMS_PER_PAGE } from '../constants';
|
||||||
import { renderQuota } from '../helpers/render';
|
import { renderQuota } from '../helpers/render';
|
||||||
|
|
||||||
function renderTimestamp(timestamp) {
|
function renderTimestamp(timestamp) {
|
||||||
return (
|
return <>{timestamp2string(timestamp)}</>;
|
||||||
<>
|
|
||||||
{timestamp2string(timestamp)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderStatus(status) {
|
function renderStatus(status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 1:
|
case 1:
|
||||||
return <Label basic color='green'>未使用</Label>;
|
return (
|
||||||
|
<Label basic color='green'>
|
||||||
|
未使用
|
||||||
|
</Label>
|
||||||
|
);
|
||||||
case 2:
|
case 2:
|
||||||
return <Label basic color='red'> 已禁用 </Label>;
|
return (
|
||||||
|
<Label basic color='red'>
|
||||||
|
{' '}
|
||||||
|
已禁用{' '}
|
||||||
|
</Label>
|
||||||
|
);
|
||||||
case 3:
|
case 3:
|
||||||
return <Label basic color='grey'> 已使用 </Label>;
|
return (
|
||||||
|
<Label basic color='grey'>
|
||||||
|
{' '}
|
||||||
|
已使用{' '}
|
||||||
|
</Label>
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return <Label basic color='black'> 未知状态 </Label>;
|
return (
|
||||||
|
<Label basic color='black'>
|
||||||
|
{' '}
|
||||||
|
未知状态{' '}
|
||||||
|
</Label>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +140,9 @@ const RedemptionsTable = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setSearching(true);
|
setSearching(true);
|
||||||
const res = await API.get(`/api/redemption/search?keyword=${searchKeyword}`);
|
const res = await API.get(
|
||||||
|
`/api/redemption/search?keyword=${searchKeyword}`
|
||||||
|
);
|
||||||
const { success, message, data } = res.data;
|
const { success, message, data } = res.data;
|
||||||
if (success) {
|
if (success) {
|
||||||
setRedemptions(data);
|
setRedemptions(data);
|
||||||
@@ -159,7 +191,7 @@ const RedemptionsTable = () => {
|
|||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
<Table basic compact size='small'>
|
<Table basic={'very'} compact size='small'>
|
||||||
<Table.Header>
|
<Table.Header>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.HeaderCell
|
<Table.HeaderCell
|
||||||
@@ -225,11 +257,19 @@ const RedemptionsTable = () => {
|
|||||||
return (
|
return (
|
||||||
<Table.Row key={redemption.id}>
|
<Table.Row key={redemption.id}>
|
||||||
<Table.Cell>{redemption.id}</Table.Cell>
|
<Table.Cell>{redemption.id}</Table.Cell>
|
||||||
<Table.Cell>{redemption.name ? redemption.name : '无'}</Table.Cell>
|
<Table.Cell>
|
||||||
|
{redemption.name ? redemption.name : '无'}
|
||||||
|
</Table.Cell>
|
||||||
<Table.Cell>{renderStatus(redemption.status)}</Table.Cell>
|
<Table.Cell>{renderStatus(redemption.status)}</Table.Cell>
|
||||||
<Table.Cell>{renderQuota(redemption.quota)}</Table.Cell>
|
<Table.Cell>{renderQuota(redemption.quota)}</Table.Cell>
|
||||||
<Table.Cell>{renderTimestamp(redemption.created_time)}</Table.Cell>
|
<Table.Cell>
|
||||||
<Table.Cell>{redemption.redeemed_time ? renderTimestamp(redemption.redeemed_time) : "尚未兑换"} </Table.Cell>
|
{renderTimestamp(redemption.created_time)}
|
||||||
|
</Table.Cell>
|
||||||
|
<Table.Cell>
|
||||||
|
{redemption.redeemed_time
|
||||||
|
? renderTimestamp(redemption.redeemed_time)
|
||||||
|
: '尚未兑换'}{' '}
|
||||||
|
</Table.Cell>
|
||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
@@ -239,7 +279,9 @@ const RedemptionsTable = () => {
|
|||||||
if (await copy(redemption.key)) {
|
if (await copy(redemption.key)) {
|
||||||
showSuccess('已复制到剪贴板!');
|
showSuccess('已复制到剪贴板!');
|
||||||
} else {
|
} else {
|
||||||
showWarning('无法复制到剪贴板,请手动复制,已将兑换码填入搜索框。')
|
showWarning(
|
||||||
|
'无法复制到剪贴板,请手动复制,已将兑换码填入搜索框。'
|
||||||
|
);
|
||||||
setSearchKeyword(redemption.key);
|
setSearchKeyword(redemption.key);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@@ -267,7 +309,7 @@ const RedemptionsTable = () => {
|
|||||||
</Popup>
|
</Popup>
|
||||||
<Button
|
<Button
|
||||||
size={'small'}
|
size={'small'}
|
||||||
disabled={redemption.status === 3} // used
|
disabled={redemption.status === 3} // used
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
manageRedemption(
|
manageRedemption(
|
||||||
redemption.id,
|
redemption.id,
|
||||||
@@ -295,7 +337,12 @@ const RedemptionsTable = () => {
|
|||||||
<Table.Footer>
|
<Table.Footer>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.HeaderCell colSpan='8'>
|
<Table.HeaderCell colSpan='8'>
|
||||||
<Button size='small' as={Link} to='/redemption/add' loading={loading}>
|
<Button
|
||||||
|
size='small'
|
||||||
|
as={Link}
|
||||||
|
to='/redemption/add'
|
||||||
|
loading={loading}
|
||||||
|
>
|
||||||
添加新的兑换码
|
添加新的兑换码
|
||||||
</Button>
|
</Button>
|
||||||
<Pagination
|
<Pagination
|
||||||
|
@@ -1,7 +1,22 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Button, Dropdown, Form, Label, Pagination, Popup, Table } from 'semantic-ui-react';
|
import {
|
||||||
|
Button,
|
||||||
|
Dropdown,
|
||||||
|
Form,
|
||||||
|
Label,
|
||||||
|
Pagination,
|
||||||
|
Popup,
|
||||||
|
Table,
|
||||||
|
} from 'semantic-ui-react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { API, copy, showError, showSuccess, showWarning, timestamp2string } from '../helpers';
|
import {
|
||||||
|
API,
|
||||||
|
copy,
|
||||||
|
showError,
|
||||||
|
showSuccess,
|
||||||
|
showWarning,
|
||||||
|
timestamp2string,
|
||||||
|
} from '../helpers';
|
||||||
|
|
||||||
import { ITEMS_PER_PAGE } from '../constants';
|
import { ITEMS_PER_PAGE } from '../constants';
|
||||||
import { renderQuota } from '../helpers/render';
|
import { renderQuota } from '../helpers/render';
|
||||||
@@ -21,25 +36,45 @@ const OPEN_LINK_OPTIONS = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
function renderTimestamp(timestamp) {
|
function renderTimestamp(timestamp) {
|
||||||
return (
|
return <>{timestamp2string(timestamp)}</>;
|
||||||
<>
|
|
||||||
{timestamp2string(timestamp)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderStatus(status) {
|
function renderStatus(status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 1:
|
case 1:
|
||||||
return <Label basic color='green'>已启用</Label>;
|
return (
|
||||||
|
<Label basic color='green'>
|
||||||
|
已启用
|
||||||
|
</Label>
|
||||||
|
);
|
||||||
case 2:
|
case 2:
|
||||||
return <Label basic color='red'> 已禁用 </Label>;
|
return (
|
||||||
|
<Label basic color='red'>
|
||||||
|
{' '}
|
||||||
|
已禁用{' '}
|
||||||
|
</Label>
|
||||||
|
);
|
||||||
case 3:
|
case 3:
|
||||||
return <Label basic color='yellow'> 已过期 </Label>;
|
return (
|
||||||
|
<Label basic color='yellow'>
|
||||||
|
{' '}
|
||||||
|
已过期{' '}
|
||||||
|
</Label>
|
||||||
|
);
|
||||||
case 4:
|
case 4:
|
||||||
return <Label basic color='grey'> 已耗尽 </Label>;
|
return (
|
||||||
|
<Label basic color='grey'>
|
||||||
|
{' '}
|
||||||
|
已耗尽{' '}
|
||||||
|
</Label>
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return <Label basic color='black'> 未知状态 </Label>;
|
return (
|
||||||
|
<Label basic color='black'>
|
||||||
|
{' '}
|
||||||
|
未知状态{' '}
|
||||||
|
</Label>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,9 +133,10 @@ const TokensTable = () => {
|
|||||||
let encodedServerAddress = encodeURIComponent(serverAddress);
|
let encodedServerAddress = encodeURIComponent(serverAddress);
|
||||||
const nextLink = localStorage.getItem('chat_link');
|
const nextLink = localStorage.getItem('chat_link');
|
||||||
let nextUrl;
|
let nextUrl;
|
||||||
|
|
||||||
if (nextLink) {
|
if (nextLink) {
|
||||||
nextUrl = nextLink + `/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
|
nextUrl =
|
||||||
|
nextLink + `/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
|
||||||
} else {
|
} else {
|
||||||
nextUrl = `https://app.nextchat.dev/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
|
nextUrl = `https://app.nextchat.dev/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
|
||||||
}
|
}
|
||||||
@@ -117,7 +153,9 @@ const TokensTable = () => {
|
|||||||
url = nextUrl;
|
url = nextUrl;
|
||||||
break;
|
break;
|
||||||
case 'lobechat':
|
case 'lobechat':
|
||||||
url = nextLink + `/?settings={"keyVaults":{"openai":{"apiKey":"sk-${key}","baseURL":"${serverAddress}/v1"}}}`;
|
url =
|
||||||
|
nextLink +
|
||||||
|
`/?settings={"keyVaults":{"openai":{"apiKey":"sk-${key}","baseURL":"${serverAddress}/v1"}}}`;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
url = `sk-${key}`;
|
url = `sk-${key}`;
|
||||||
@@ -135,7 +173,7 @@ const TokensTable = () => {
|
|||||||
let serverAddress = '';
|
let serverAddress = '';
|
||||||
if (status) {
|
if (status) {
|
||||||
status = JSON.parse(status);
|
status = JSON.parse(status);
|
||||||
serverAddress = status.server_address;
|
serverAddress = status.server_address;
|
||||||
}
|
}
|
||||||
if (serverAddress === '') {
|
if (serverAddress === '') {
|
||||||
serverAddress = window.location.origin;
|
serverAddress = window.location.origin;
|
||||||
@@ -143,9 +181,10 @@ const TokensTable = () => {
|
|||||||
let encodedServerAddress = encodeURIComponent(serverAddress);
|
let encodedServerAddress = encodeURIComponent(serverAddress);
|
||||||
const chatLink = localStorage.getItem('chat_link');
|
const chatLink = localStorage.getItem('chat_link');
|
||||||
let defaultUrl;
|
let defaultUrl;
|
||||||
|
|
||||||
if (chatLink) {
|
if (chatLink) {
|
||||||
defaultUrl = chatLink + `/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
|
defaultUrl =
|
||||||
|
chatLink + `/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
|
||||||
} else {
|
} else {
|
||||||
defaultUrl = `https://app.nextchat.dev/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
|
defaultUrl = `https://app.nextchat.dev/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
|
||||||
}
|
}
|
||||||
@@ -154,21 +193,23 @@ const TokensTable = () => {
|
|||||||
case 'ama':
|
case 'ama':
|
||||||
url = `ama://set-api-key?server=${encodedServerAddress}&key=sk-${key}`;
|
url = `ama://set-api-key?server=${encodedServerAddress}&key=sk-${key}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'opencat':
|
case 'opencat':
|
||||||
url = `opencat://team/join?domain=${encodedServerAddress}&token=sk-${key}`;
|
url = `opencat://team/join?domain=${encodedServerAddress}&token=sk-${key}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'lobechat':
|
case 'lobechat':
|
||||||
url = chatLink + `/?settings={"keyVaults":{"openai":{"apiKey":"sk-${key}","baseURL":"${serverAddress}/v1"}}}`;
|
url =
|
||||||
|
chatLink +
|
||||||
|
`/?settings={"keyVaults":{"openai":{"apiKey":"sk-${key}","baseURL":"${serverAddress}/v1"}}}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
url = defaultUrl;
|
url = defaultUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
}
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadTokens(0, orderBy)
|
loadTokens(0, orderBy)
|
||||||
@@ -274,7 +315,7 @@ const TokensTable = () => {
|
|||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
<Table basic compact size='small'>
|
<Table basic={'very'} compact size='small'>
|
||||||
<Table.Header>
|
<Table.Header>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.HeaderCell
|
<Table.HeaderCell
|
||||||
@@ -342,12 +383,20 @@ const TokensTable = () => {
|
|||||||
<Table.Cell>{token.name ? token.name : '无'}</Table.Cell>
|
<Table.Cell>{token.name ? token.name : '无'}</Table.Cell>
|
||||||
<Table.Cell>{renderStatus(token.status)}</Table.Cell>
|
<Table.Cell>{renderStatus(token.status)}</Table.Cell>
|
||||||
<Table.Cell>{renderQuota(token.used_quota)}</Table.Cell>
|
<Table.Cell>{renderQuota(token.used_quota)}</Table.Cell>
|
||||||
<Table.Cell>{token.unlimited_quota ? '无限制' : renderQuota(token.remain_quota, 2)}</Table.Cell>
|
<Table.Cell>
|
||||||
|
{token.unlimited_quota
|
||||||
|
? '无限制'
|
||||||
|
: renderQuota(token.remain_quota, 2)}
|
||||||
|
</Table.Cell>
|
||||||
<Table.Cell>{renderTimestamp(token.created_time)}</Table.Cell>
|
<Table.Cell>{renderTimestamp(token.created_time)}</Table.Cell>
|
||||||
<Table.Cell>{token.expired_time === -1 ? '永不过期' : renderTimestamp(token.expired_time)}</Table.Cell>
|
<Table.Cell>
|
||||||
|
{token.expired_time === -1
|
||||||
|
? '永不过期'
|
||||||
|
: renderTimestamp(token.expired_time)}
|
||||||
|
</Table.Cell>
|
||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
<div>
|
<div>
|
||||||
<Button.Group color='green' size={'small'}>
|
<Button.Group color='green' size={'small'}>
|
||||||
<Button
|
<Button
|
||||||
size={'small'}
|
size={'small'}
|
||||||
positive
|
positive
|
||||||
@@ -360,38 +409,37 @@ const TokensTable = () => {
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
className='button icon'
|
className='button icon'
|
||||||
floating
|
floating
|
||||||
options={COPY_OPTIONS.map(option => ({
|
options={COPY_OPTIONS.map((option) => ({
|
||||||
...option,
|
...option,
|
||||||
onClick: async () => {
|
onClick: async () => {
|
||||||
await onCopy(option.value, token.key);
|
await onCopy(option.value, token.key);
|
||||||
}
|
},
|
||||||
}))}
|
}))}
|
||||||
trigger={<></>}
|
trigger={<></>}
|
||||||
/>
|
/>
|
||||||
</Button.Group>
|
</Button.Group>{' '}
|
||||||
{' '}
|
|
||||||
<Button.Group color='blue' size={'small'}>
|
<Button.Group color='blue' size={'small'}>
|
||||||
<Button
|
<Button
|
||||||
size={'small'}
|
size={'small'}
|
||||||
positive
|
positive
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onOpenLink('', token.key);
|
onOpenLink('', token.key);
|
||||||
}}>
|
}}
|
||||||
聊天
|
>
|
||||||
</Button>
|
聊天
|
||||||
<Dropdown
|
</Button>
|
||||||
className="button icon"
|
<Dropdown
|
||||||
floating
|
className='button icon'
|
||||||
options={OPEN_LINK_OPTIONS.map(option => ({
|
floating
|
||||||
...option,
|
options={OPEN_LINK_OPTIONS.map((option) => ({
|
||||||
onClick: async () => {
|
...option,
|
||||||
await onOpenLink(option.value, token.key);
|
onClick: async () => {
|
||||||
}
|
await onOpenLink(option.value, token.key);
|
||||||
}))}
|
},
|
||||||
trigger={<></>}
|
}))}
|
||||||
/>
|
trigger={<></>}
|
||||||
</Button.Group>
|
/>
|
||||||
{' '}
|
</Button.Group>{' '}
|
||||||
<Popup
|
<Popup
|
||||||
trigger={
|
trigger={
|
||||||
<Button size='small' negative>
|
<Button size='small' negative>
|
||||||
@@ -443,14 +491,24 @@ const TokensTable = () => {
|
|||||||
<Button size='small' as={Link} to='/token/add' loading={loading}>
|
<Button size='small' as={Link} to='/token/add' loading={loading}>
|
||||||
添加新的令牌
|
添加新的令牌
|
||||||
</Button>
|
</Button>
|
||||||
<Button size='small' onClick={refresh} loading={loading}>刷新</Button>
|
<Button size='small' onClick={refresh} loading={loading}>
|
||||||
|
刷新
|
||||||
|
</Button>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
placeholder='排序方式'
|
placeholder='排序方式'
|
||||||
selection
|
selection
|
||||||
options={[
|
options={[
|
||||||
{ key: '', text: '默认排序', value: '' },
|
{ key: '', text: '默认排序', value: '' },
|
||||||
{ key: 'remain_quota', text: '按剩余额度排序', value: 'remain_quota' },
|
{
|
||||||
{ key: 'used_quota', text: '按已用额度排序', value: 'used_quota' },
|
key: 'remain_quota',
|
||||||
|
text: '按剩余额度排序',
|
||||||
|
value: 'remain_quota',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'used_quota',
|
||||||
|
text: '按已用额度排序',
|
||||||
|
value: 'used_quota',
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
value={orderBy}
|
value={orderBy}
|
||||||
onChange={handleOrderByChange}
|
onChange={handleOrderByChange}
|
||||||
|
@@ -1,10 +1,23 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Button, Form, Label, Pagination, Popup, Table, Dropdown } from 'semantic-ui-react';
|
import {
|
||||||
|
Button,
|
||||||
|
Form,
|
||||||
|
Label,
|
||||||
|
Pagination,
|
||||||
|
Popup,
|
||||||
|
Table,
|
||||||
|
Dropdown,
|
||||||
|
} from 'semantic-ui-react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { API, showError, showSuccess } from '../helpers';
|
import { API, showError, showSuccess } from '../helpers';
|
||||||
|
|
||||||
import { ITEMS_PER_PAGE } from '../constants';
|
import { ITEMS_PER_PAGE } from '../constants';
|
||||||
import { renderGroup, renderNumber, renderQuota, renderText } from '../helpers/render';
|
import {
|
||||||
|
renderGroup,
|
||||||
|
renderNumber,
|
||||||
|
renderQuota,
|
||||||
|
renderText,
|
||||||
|
} from '../helpers/render';
|
||||||
|
|
||||||
function renderRole(role) {
|
function renderRole(role) {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
@@ -66,7 +79,7 @@ const UsersTable = () => {
|
|||||||
(async () => {
|
(async () => {
|
||||||
const res = await API.post('/api/user/manage', {
|
const res = await API.post('/api/user/manage', {
|
||||||
username,
|
username,
|
||||||
action
|
action,
|
||||||
});
|
});
|
||||||
const { success, message } = res.data;
|
const { success, message } = res.data;
|
||||||
if (success) {
|
if (success) {
|
||||||
@@ -169,7 +182,7 @@ const UsersTable = () => {
|
|||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
<Table basic compact size='small'>
|
<Table basic={'very'} compact size='small'>
|
||||||
<Table.Header>
|
<Table.Header>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.HeaderCell
|
<Table.HeaderCell
|
||||||
@@ -239,7 +252,9 @@ const UsersTable = () => {
|
|||||||
<Popup
|
<Popup
|
||||||
content={user.email ? user.email : '未绑定邮箱地址'}
|
content={user.email ? user.email : '未绑定邮箱地址'}
|
||||||
key={user.username}
|
key={user.username}
|
||||||
header={user.display_name ? user.display_name : user.username}
|
header={
|
||||||
|
user.display_name ? user.display_name : user.username
|
||||||
|
}
|
||||||
trigger={<span>{renderText(user.username, 15)}</span>}
|
trigger={<span>{renderText(user.username, 15)}</span>}
|
||||||
hoverable
|
hoverable
|
||||||
/>
|
/>
|
||||||
@@ -249,9 +264,22 @@ const UsersTable = () => {
|
|||||||
{/* {user.email ? <Popup hoverable content={user.email} trigger={<span>{renderText(user.email, 24)}</span>} /> : '无'}*/}
|
{/* {user.email ? <Popup hoverable content={user.email} trigger={<span>{renderText(user.email, 24)}</span>} /> : '无'}*/}
|
||||||
{/*</Table.Cell>*/}
|
{/*</Table.Cell>*/}
|
||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
<Popup content='剩余额度' trigger={<Label basic>{renderQuota(user.quota)}</Label>} />
|
<Popup
|
||||||
<Popup content='已用额度' trigger={<Label basic>{renderQuota(user.used_quota)}</Label>} />
|
content='剩余额度'
|
||||||
<Popup content='请求次数' trigger={<Label basic>{renderNumber(user.request_count)}</Label>} />
|
trigger={<Label basic>{renderQuota(user.quota)}</Label>}
|
||||||
|
/>
|
||||||
|
<Popup
|
||||||
|
content='已用额度'
|
||||||
|
trigger={
|
||||||
|
<Label basic>{renderQuota(user.used_quota)}</Label>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Popup
|
||||||
|
content='请求次数'
|
||||||
|
trigger={
|
||||||
|
<Label basic>{renderNumber(user.request_count)}</Label>
|
||||||
|
}
|
||||||
|
/>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell>{renderRole(user.role)}</Table.Cell>
|
<Table.Cell>{renderRole(user.role)}</Table.Cell>
|
||||||
<Table.Cell>{renderStatus(user.status)}</Table.Cell>
|
<Table.Cell>{renderStatus(user.status)}</Table.Cell>
|
||||||
@@ -279,7 +307,11 @@ const UsersTable = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
<Popup
|
<Popup
|
||||||
trigger={
|
trigger={
|
||||||
<Button size='small' negative disabled={user.role === 100}>
|
<Button
|
||||||
|
size='small'
|
||||||
|
negative
|
||||||
|
disabled={user.role === 100}
|
||||||
|
>
|
||||||
删除
|
删除
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
@@ -335,8 +367,16 @@ const UsersTable = () => {
|
|||||||
options={[
|
options={[
|
||||||
{ key: '', text: '默认排序', value: '' },
|
{ key: '', text: '默认排序', value: '' },
|
||||||
{ key: 'quota', text: '按剩余额度排序', value: 'quota' },
|
{ key: 'quota', text: '按剩余额度排序', value: 'quota' },
|
||||||
{ key: 'used_quota', text: '按已用额度排序', value: 'used_quota' },
|
{
|
||||||
{ key: 'request_count', text: '按请求次数排序', value: 'request_count' },
|
key: 'used_quota',
|
||||||
|
text: '按已用额度排序',
|
||||||
|
value: 'used_quota',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'request_count',
|
||||||
|
text: '按请求次数排序',
|
||||||
|
value: 'request_count',
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
value={orderBy}
|
value={orderBy}
|
||||||
onChange={handleOrderByChange}
|
onChange={handleOrderByChange}
|
||||||
|
Reference in New Issue
Block a user