Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
45ea7025
authored
Aug 06, 2024
by
FENG
Committed by
GitHub
Aug 06, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: indent recovery
parent
b01c1522
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
401 additions
and
401 deletions
+401
-401
web/src/components/ChannelsTable.js
+401
-401
No files found.
web/src/components/ChannelsTable.js
View file @
45ea7025
...
@@ -49,9 +49,9 @@ function renderType(type) {
...
@@ -49,9 +49,9 @@ function renderType(type) {
type2label
[
0
]
=
{
value
:
0
,
text
:
'未知类型'
,
color
:
'grey'
};
type2label
[
0
]
=
{
value
:
0
,
text
:
'未知类型'
,
color
:
'grey'
};
}
}
return
(
return
(
<
Tag
size
=
'large'
color
=
{
type2label
[
type
]?.
color
}
>
<
Tag
size
=
'large'
color
=
{
type2label
[
type
]?.
color
}
>
{
type2label
[
type
]?.
text
}
{
type2label
[
type
]?.
text
}
<
/Tag
>
<
/Tag
>
);
);
}
}
...
@@ -75,13 +75,13 @@ const ChannelsTable = () => {
...
@@ -75,13 +75,13 @@ const ChannelsTable = () => {
dataIndex
:
'group'
,
dataIndex
:
'group'
,
render
:
(
text
,
record
,
index
)
=>
{
render
:
(
text
,
record
,
index
)
=>
{
return
(
return
(
<
div
>
<
div
>
<
Space
spacing
=
{
2
}
>
<
Space
spacing
=
{
2
}
>
{
text
.
split
(
','
).
map
((
item
,
index
)
=>
{
{
text
.
split
(
','
).
map
((
item
,
index
)
=>
{
return
renderGroup
(
item
);
return
renderGroup
(
item
);
})}
})}
<
/Space
>
<
/Space
>
<
/div
>
<
/div
>
);
);
},
},
},
},
...
@@ -104,11 +104,11 @@ const ChannelsTable = () => {
...
@@ -104,11 +104,11 @@ const ChannelsTable = () => {
let
reason
=
otherInfo
[
'status_reason'
];
let
reason
=
otherInfo
[
'status_reason'
];
let
time
=
otherInfo
[
'status_time'
];
let
time
=
otherInfo
[
'status_time'
];
return
(
return
(
<
div
>
<
div
>
<
Tooltip
content
=
{
'原因:'
+
reason
+
',时间:'
+
timestamp2string
(
time
)}
>
<
Tooltip
content
=
{
'原因:'
+
reason
+
',时间:'
+
timestamp2string
(
time
)}
>
{
renderStatus
(
text
)}
{
renderStatus
(
text
)}
<
/Tooltip
>
<
/Tooltip
>
<
/div
>
<
/div
>
);
);
}
else
{
}
else
{
return
renderStatus
(
text
);
return
renderStatus
(
text
);
...
@@ -127,27 +127,27 @@ const ChannelsTable = () => {
...
@@ -127,27 +127,27 @@ const ChannelsTable = () => {
dataIndex
:
'expired_time'
,
dataIndex
:
'expired_time'
,
render
:
(
text
,
record
,
index
)
=>
{
render
:
(
text
,
record
,
index
)
=>
{
return
(
return
(
<
div
>
<
div
>
<
Space
spacing
=
{
1
}
>
<
Space
spacing
=
{
1
}
>
<
Tooltip
content
=
{
'已用额度'
}
>
<
Tooltip
content
=
{
'已用额度'
}
>
<
Tag
color
=
'white'
type
=
'ghost'
size
=
'large'
>
<
Tag
color
=
'white'
type
=
'ghost'
size
=
'large'
>
{
renderQuota
(
record
.
used_quota
)}
{
renderQuota
(
record
.
used_quota
)}
<
/Tag
>
<
/Tag
>
<
/Tooltip
>
<
/Tooltip
>
<
Tooltip
content
=
{
'剩余额度'
+
record
.
balance
+
',点击更新'
}
>
<
Tooltip
content
=
{
'剩余额度'
+
record
.
balance
+
',点击更新'
}
>
<
Tag
<
Tag
color
=
'white'
color
=
'white'
type
=
'ghost'
type
=
'ghost'
size
=
'large'
size
=
'large'
onClick
=
{()
=>
{
onClick
=
{()
=>
{
updateChannelBalance
(
record
);
updateChannelBalance
(
record
);
}}
}}
>
>
$
{
renderNumberWithPoint
(
record
.
balance
)}
$
{
renderNumberWithPoint
(
record
.
balance
)}
<
/Tag
>
<
/Tag
>
<
/Tooltip
>
<
/Tooltip
>
<
/Space
>
<
/Space
>
<
/div
>
<
/div
>
);
);
},
},
},
},
...
@@ -156,19 +156,19 @@ const ChannelsTable = () => {
...
@@ -156,19 +156,19 @@ const ChannelsTable = () => {
dataIndex
:
'priority'
,
dataIndex
:
'priority'
,
render
:
(
text
,
record
,
index
)
=>
{
render
:
(
text
,
record
,
index
)
=>
{
return
(
return
(
<
div
>
<
div
>
<
InputNumber
<
InputNumber
style
=
{{
width
:
70
}}
style
=
{{
width
:
70
}}
name
=
'priority'
name
=
'priority'
onBlur
=
{(
e
)
=>
{
onBlur
=
{(
e
)
=>
{
manageChannel
(
record
.
id
,
'priority'
,
record
,
e
.
target
.
value
);
manageChannel
(
record
.
id
,
'priority'
,
record
,
e
.
target
.
value
);
}}
}}
keepFocus
=
{
true
}
keepFocus
=
{
true
}
innerButtons
innerButtons
defaultValue
=
{
record
.
priority
}
defaultValue
=
{
record
.
priority
}
min
=
{
-
999
}
min
=
{
-
999
}
/
>
/
>
<
/div
>
<
/div
>
);
);
},
},
},
},
...
@@ -177,19 +177,19 @@ const ChannelsTable = () => {
...
@@ -177,19 +177,19 @@ const ChannelsTable = () => {
dataIndex
:
'weight'
,
dataIndex
:
'weight'
,
render
:
(
text
,
record
,
index
)
=>
{
render
:
(
text
,
record
,
index
)
=>
{
return
(
return
(
<
div
>
<
div
>
<
InputNumber
<
InputNumber
style
=
{{
width
:
70
}}
style
=
{{
width
:
70
}}
name
=
'weight'
name
=
'weight'
onBlur
=
{(
e
)
=>
{
onBlur
=
{(
e
)
=>
{
manageChannel
(
record
.
id
,
'weight'
,
record
,
e
.
target
.
value
);
manageChannel
(
record
.
id
,
'weight'
,
record
,
e
.
target
.
value
);
}}
}}
keepFocus
=
{
true
}
keepFocus
=
{
true
}
innerButtons
innerButtons
defaultValue
=
{
record
.
weight
}
defaultValue
=
{
record
.
weight
}
min
=
{
0
}
min
=
{
0
}
/
>
/
>
<
/div
>
<
/div
>
);
);
},
},
},
},
...
@@ -197,95 +197,95 @@ const ChannelsTable = () => {
...
@@ -197,95 +197,95 @@ const ChannelsTable = () => {
title
:
''
,
title
:
''
,
dataIndex
:
'operate'
,
dataIndex
:
'operate'
,
render
:
(
text
,
record
,
index
)
=>
(
render
:
(
text
,
record
,
index
)
=>
(
<
div
>
<
div
>
<
SplitButtonGroup
<
SplitButtonGroup
style
=
{{
marginRight
:
1
}}
style
=
{{
marginRight
:
1
}}
aria
-
label
=
'测试操作项目组'
aria
-
label
=
'测试操作项目组'
>
<
Button
theme
=
'light'
onClick
=
{()
=>
{
testChannel
(
record
,
''
);
}}
>
>
<
Button
测试
theme
=
'light'
<
/Button
>
onClick
=
{()
=>
{
<
Dropdown
testChannel
(
record
,
''
);
trigger
=
'click'
}}
position
=
'bottomRight'
>
menu
=
{
record
.
test_models
}
测试
<
/Button
>
<
Dropdown
trigger
=
'click'
position
=
'bottomRight'
menu
=
{
record
.
test_models
}
>
<
Button
style
=
{{
padding
:
'8px 4px'
}}
type
=
'primary'
icon
=
{
<
IconTreeTriangleDown
/>
}
><
/Button
>
<
/Dropdown
>
<
/SplitButtonGroup
>
{
/*<Button theme='light' type='primary' style={{marginRight: 1}} onClick={()=>testChannel(record)}>测试</Button>*/
}
<
Popconfirm
title
=
'确定是否要删除此渠道?'
content
=
'此修改将不可逆'
okType
=
{
'danger'
}
position
=
{
'left'
}
onConfirm
=
{()
=>
{
manageChannel
(
record
.
id
,
'delete'
,
record
).
then
(()
=>
{
removeRecord
(
record
.
id
);
});
}}
>
>
<
Button
theme
=
'light'
type
=
'danger'
style
=
{{
marginRight
:
1
}}
>
<
Button
删除
style
=
{{
padding
:
'8px 4px'
}}
<
/Button
>
type
=
'primary'
<
/Popconfirm
>
icon
=
{
<
IconTreeTriangleDown
/>
}
{
record
.
status
===
1
?
(
><
/Button
>
<
Button
<
/Dropdown
>
theme
=
'light'
<
/SplitButtonGroup
>
type
=
'warning'
{
/*<Button theme='light' type='primary' style={{marginRight: 1}} onClick={()=>testChannel(record)}>测试</Button>*/
}
style
=
{{
marginRight
:
1
}}
<
Popconfirm
onClick
=
{
async
()
=>
{
title
=
'确定是否要删除此渠道?'
manageChannel
(
record
.
id
,
'disable'
,
record
);
content
=
'此修改将不可逆'
}}
okType
=
{
'danger'
}
>
position
=
{
'left'
}
禁用
onConfirm
=
{()
=>
{
<
/Button
>
manageChannel
(
record
.
id
,
'delete'
,
record
).
then
(()
=>
{
)
:
(
removeRecord
(
record
.
id
);
<
Button
});
theme
=
'light'
}}
type
=
'secondary'
>
style
=
{{
marginRight
:
1
}}
<
Button
theme
=
'light'
type
=
'danger'
style
=
{{
marginRight
:
1
}}
>
onClick
=
{
async
()
=>
{
删除
manageChannel
(
record
.
id
,
'enable'
,
record
);
<
/Button
>
}}
<
/Popconfirm
>
>
{
record
.
status
===
1
?
(
启用
<
/Button
>
)}
<
Button
<
Button
theme
=
'light'
theme
=
'light'
type
=
'tertiary'
type
=
'warning'
style
=
{{
marginRight
:
1
}}
style
=
{{
marginRight
:
1
}}
onClick
=
{()
=>
{
onClick
=
{
async
()
=>
{
setEditingChannel
(
record
);
manageChannel
(
record
.
id
,
'disable'
,
record
);
setShowEdit
(
true
);
}}
}}
>
>
编辑
禁用
<
/Button
>
<
/Button
>
<
Popconfirm
)
:
(
title
=
'确定是否要复制此渠道?'
<
Button
content
=
'复制渠道的所有信息
'
theme
=
'light
'
okType
=
{
'danger'
}
type
=
'secondary'
position
=
{
'left'
}
style
=
{{
marginRight
:
1
}
}
onConfirm
=
{
async
()
=>
{
onClick
=
{
async
()
=>
{
copySelectedChannel
(
record
.
i
d
);
manageChannel
(
record
.
id
,
'enable'
,
recor
d
);
}}
}}
>
>
<
Button
theme
=
'light'
type
=
'primary'
style
=
{{
marginRight
:
1
}}
>
启用
复制
<
/Button
>
<
/Button
>
)}
<
/Popconfirm
>
<
Button
<
/div
>
theme
=
'light'
type
=
'tertiary'
style
=
{{
marginRight
:
1
}}
onClick
=
{()
=>
{
setEditingChannel
(
record
);
setShowEdit
(
true
);
}}
>
编辑
<
/Button
>
<
Popconfirm
title
=
'确定是否要复制此渠道?'
content
=
'复制渠道的所有信息'
okType
=
{
'danger'
}
position
=
{
'left'
}
onConfirm
=
{
async
()
=>
{
copySelectedChannel
(
record
.
id
);
}}
>
<
Button
theme
=
'light'
type
=
'primary'
style
=
{{
marginRight
:
1
}}
>
复制
<
/Button
>
<
/Popconfirm
>
<
/div
>
),
),
},
},
];
];
...
@@ -301,7 +301,7 @@ const ChannelsTable = () => {
...
@@ -301,7 +301,7 @@ const ChannelsTable = () => {
const
[
updatingBalance
,
setUpdatingBalance
]
=
useState
(
false
);
const
[
updatingBalance
,
setUpdatingBalance
]
=
useState
(
false
);
const
[
pageSize
,
setPageSize
]
=
useState
(
ITEMS_PER_PAGE
);
const
[
pageSize
,
setPageSize
]
=
useState
(
ITEMS_PER_PAGE
);
const
[
showPrompt
,
setShowPrompt
]
=
useState
(
const
[
showPrompt
,
setShowPrompt
]
=
useState
(
shouldShowPrompt
(
'channel-test'
),
shouldShowPrompt
(
'channel-test'
),
);
);
const
[
channelCount
,
setChannelCount
]
=
useState
(
pageSize
);
const
[
channelCount
,
setChannelCount
]
=
useState
(
pageSize
);
const
[
groupOptions
,
setGroupOptions
]
=
useState
([]);
const
[
groupOptions
,
setGroupOptions
]
=
useState
([]);
...
@@ -357,7 +357,7 @@ const ChannelsTable = () => {
...
@@ -357,7 +357,7 @@ const ChannelsTable = () => {
const
loadChannels
=
async
(
startIdx
,
pageSize
,
idSort
)
=>
{
const
loadChannels
=
async
(
startIdx
,
pageSize
,
idSort
)
=>
{
setLoading
(
true
);
setLoading
(
true
);
const
res
=
await
API
.
get
(
const
res
=
await
API
.
get
(
`/api/channel/?p=
${
startIdx
}
&page_size=
${
pageSize
}
&id_sort=
${
idSort
}
`
,
`/api/channel/?p=
${
startIdx
}
&page_size=
${
pageSize
}
&id_sort=
${
idSort
}
`
,
);
);
if
(
res
===
undefined
)
{
if
(
res
===
undefined
)
{
return
;
return
;
...
@@ -379,7 +379,7 @@ const ChannelsTable = () => {
...
@@ -379,7 +379,7 @@ const ChannelsTable = () => {
const
copySelectedChannel
=
async
(
id
)
=>
{
const
copySelectedChannel
=
async
(
id
)
=>
{
const
channelToCopy
=
channels
.
find
(
const
channelToCopy
=
channels
.
find
(
(
channel
)
=>
String
(
channel
.
id
)
===
String
(
id
),
(
channel
)
=>
String
(
channel
.
id
)
===
String
(
id
),
);
);
console
.
log
(
channelToCopy
);
console
.
log
(
channelToCopy
);
channelToCopy
.
name
+=
'_复制'
;
channelToCopy
.
name
+=
'_复制'
;
...
@@ -412,14 +412,14 @@ const ChannelsTable = () => {
...
@@ -412,14 +412,14 @@ const ChannelsTable = () => {
// console.log('default effect')
// console.log('default effect')
const
localIdSort
=
localStorage
.
getItem
(
'id-sort'
)
===
'true'
;
const
localIdSort
=
localStorage
.
getItem
(
'id-sort'
)
===
'true'
;
const
localPageSize
=
const
localPageSize
=
parseInt
(
localStorage
.
getItem
(
'page-size'
))
||
ITEMS_PER_PAGE
;
parseInt
(
localStorage
.
getItem
(
'page-size'
))
||
ITEMS_PER_PAGE
;
setIdSort
(
localIdSort
);
setIdSort
(
localIdSort
);
setPageSize
(
localPageSize
);
setPageSize
(
localPageSize
);
loadChannels
(
0
,
localPageSize
,
localIdSort
)
loadChannels
(
0
,
localPageSize
,
localIdSort
)
.
then
()
.
then
()
.
catch
((
reason
)
=>
{
.
catch
((
reason
)
=>
{
showError
(
reason
);
showError
(
reason
);
});
});
fetchGroups
().
then
();
fetchGroups
().
then
();
loadChannelModels
().
then
();
loadChannelModels
().
then
();
},
[]);
},
[]);
...
@@ -476,27 +476,27 @@ const ChannelsTable = () => {
...
@@ -476,27 +476,27 @@ const ChannelsTable = () => {
switch
(
status
)
{
switch
(
status
)
{
case
1
:
case
1
:
return
(
return
(
<
Tag
size
=
'large'
color
=
'green'
>
<
Tag
size
=
'large'
color
=
'green'
>
已启用
已启用
<
/Tag
>
<
/Tag
>
);
);
case
2
:
case
2
:
return
(
return
(
<
Tag
size
=
'large'
color
=
'yellow'
>
<
Tag
size
=
'large'
color
=
'yellow'
>
已禁用
已禁用
<
/Tag
>
<
/Tag
>
);
);
case
3
:
case
3
:
return
(
return
(
<
Tag
size
=
'large'
color
=
'yellow'
>
<
Tag
size
=
'large'
color
=
'yellow'
>
自动禁用
自动禁用
<
/Tag
>
<
/Tag
>
);
);
default
:
default
:
return
(
return
(
<
Tag
size
=
'large'
color
=
'grey'
>
<
Tag
size
=
'large'
color
=
'grey'
>
未知状态
未知状态
<
/Tag
>
<
/Tag
>
);
);
}
}
};
};
...
@@ -506,33 +506,33 @@ const ChannelsTable = () => {
...
@@ -506,33 +506,33 @@ const ChannelsTable = () => {
time
=
time
.
toFixed
(
2
)
+
' 秒'
;
time
=
time
.
toFixed
(
2
)
+
' 秒'
;
if
(
responseTime
===
0
)
{
if
(
responseTime
===
0
)
{
return
(
return
(
<
Tag
size
=
'large'
color
=
'grey'
>
<
Tag
size
=
'large'
color
=
'grey'
>
未测试
未测试
<
/Tag
>
<
/Tag
>
);
);
}
else
if
(
responseTime
<=
1000
)
{
}
else
if
(
responseTime
<=
1000
)
{
return
(
return
(
<
Tag
size
=
'large'
color
=
'green'
>
<
Tag
size
=
'large'
color
=
'green'
>
{
time
}
{
time
}
<
/Tag
>
<
/Tag
>
);
);
}
else
if
(
responseTime
<=
3000
)
{
}
else
if
(
responseTime
<=
3000
)
{
return
(
return
(
<
Tag
size
=
'large'
color
=
'lime'
>
<
Tag
size
=
'large'
color
=
'lime'
>
{
time
}
{
time
}
<
/Tag
>
<
/Tag
>
);
);
}
else
if
(
responseTime
<=
5000
)
{
}
else
if
(
responseTime
<=
5000
)
{
return
(
return
(
<
Tag
size
=
'large'
color
=
'yellow'
>
<
Tag
size
=
'large'
color
=
'yellow'
>
{
time
}
{
time
}
<
/Tag
>
<
/Tag
>
);
);
}
else
{
}
else
{
return
(
return
(
<
Tag
size
=
'large'
color
=
'red'
>
<
Tag
size
=
'large'
color
=
'red'
>
{
time
}
{
time
}
<
/Tag
>
<
/Tag
>
);
);
}
}
};
};
...
@@ -546,7 +546,7 @@ const ChannelsTable = () => {
...
@@ -546,7 +546,7 @@ const ChannelsTable = () => {
}
}
setSearching
(
true
);
setSearching
(
true
);
const
res
=
await
API
.
get
(
const
res
=
await
API
.
get
(
`/api/channel/search?keyword=
${
searchKeyword
}
&group=
${
searchGroup
}
&model=
${
searchModel
}
`
,
`/api/channel/search?keyword=
${
searchKeyword
}
&group=
${
searchGroup
}
&model=
${
searchModel
}
`
,
);
);
const
{
success
,
message
,
data
}
=
res
.
data
;
const
{
success
,
message
,
data
}
=
res
.
data
;
if
(
success
)
{
if
(
success
)
{
...
@@ -648,8 +648,8 @@ const ChannelsTable = () => {
...
@@ -648,8 +648,8 @@ const ChannelsTable = () => {
};
};
let
pageData
=
channels
.
slice
(
let
pageData
=
channels
.
slice
(
(
activePage
-
1
)
*
pageSize
,
(
activePage
-
1
)
*
pageSize
,
activePage
*
pageSize
,
activePage
*
pageSize
,
);
);
const
handlePageChange
=
(
page
)
=>
{
const
handlePageChange
=
(
page
)
=>
{
...
@@ -665,10 +665,10 @@ const ChannelsTable = () => {
...
@@ -665,10 +665,10 @@ const ChannelsTable = () => {
setPageSize
(
size
);
setPageSize
(
size
);
setActivePage
(
1
);
setActivePage
(
1
);
loadChannels
(
0
,
size
,
idSort
)
loadChannels
(
0
,
size
,
idSort
)
.
then
()
.
then
()
.
catch
((
reason
)
=>
{
.
catch
((
reason
)
=>
{
showError
(
reason
);
showError
(
reason
);
});
});
};
};
const
fetchGroups
=
async
()
=>
{
const
fetchGroups
=
async
()
=>
{
...
@@ -680,10 +680,10 @@ const ChannelsTable = () => {
...
@@ -680,10 +680,10 @@ const ChannelsTable = () => {
return
;
return
;
}
}
setGroupOptions
(
setGroupOptions
(
res
.
data
.
data
.
map
((
group
)
=>
({
res
.
data
.
data
.
map
((
group
)
=>
({
label
:
group
,
label
:
group
,
value
:
group
,
value
:
group
,
})),
})),
);
);
}
catch
(
error
)
{
}
catch
(
error
)
{
showError
(
error
.
message
);
showError
(
error
.
message
);
...
@@ -707,226 +707,226 @@ const ChannelsTable = () => {
...
@@ -707,226 +707,226 @@ const ChannelsTable = () => {
};
};
return
(
return
(
<>
<>
<
EditChannel
<
EditChannel
refresh
=
{
refresh
}
refresh
=
{
refresh
}
visible
=
{
showEdit
}
visible
=
{
showEdit
}
handleClose
=
{
closeEdit
}
handleClose
=
{
closeEdit
}
editingChannel
=
{
editingChannel
}
editingChannel
=
{
editingChannel
}
/
>
/
>
<
Form
<
Form
onSubmit
=
{()
=>
{
onSubmit
=
{()
=>
{
searchChannels
(
searchKeyword
,
searchGroup
,
searchModel
);
searchChannels
(
searchKeyword
,
searchGroup
,
searchModel
);
}}
}}
labelPosition
=
'left'
labelPosition
=
'left'
>
>
<
div
style
=
{{
display
:
'flex'
}}
>
<
div
style
=
{{
display
:
'flex'
}}
>
<
Space
>
<
Form
.
Input
field
=
'search_keyword'
label
=
'搜索渠道关键词'
placeholder
=
'ID,名称和密钥 ...'
value
=
{
searchKeyword
}
loading
=
{
searching
}
onChange
=
{(
v
)
=>
{
setSearchKeyword
(
v
.
trim
());
}}
/
>
<
Form
.
Input
field
=
'search_model'
label
=
'模型'
placeholder
=
'模型关键字'
value
=
{
searchModel
}
loading
=
{
searching
}
onChange
=
{(
v
)
=>
{
setSearchModel
(
v
.
trim
());
}}
/
>
<
Form
.
Select
field
=
'group'
label
=
'分组'
optionList
=
{[{
label
:
'选择分组'
,
value
:
null
},
...
groupOptions
]}
initValue
=
{
null
}
onChange
=
{(
v
)
=>
{
setSearchGroup
(
v
);
searchChannels
(
searchKeyword
,
v
,
searchModel
);
}}
/
>
<
Button
label
=
'查询'
type
=
'primary'
htmlType
=
'submit'
className
=
'btn-margin-right'
style
=
{{
marginRight
:
8
}}
>
查询
<
/Button
>
<
/Space
>
<
/div
>
<
/Form
>
<
div
style
=
{{
marginTop
:
10
,
display
:
'flex'
}}
>
<
Space
>
<
Space
>
<
Space
>
<
Form
.
Input
<
Typography
.
Text
strong
>
使用
ID
排序
<
/Typography.Text
>
field
=
'search_keyword'
<
Switch
label
=
'搜索渠道关键词'
checked
=
{
idSort
}
placeholder
=
'ID,名称和密钥 ...'
label
=
'使用ID排序'
value
=
{
searchKeyword
}
uncheckedText
=
'关'
loading
=
{
searching
}
aria
-
label
=
'是否用ID排序'
onChange
=
{(
v
)
=>
{
onChange
=
{(
v
)
=>
{
setSearchKeyword
(
v
.
trim
());
localStorage
.
setItem
(
'id-sort'
,
v
+
''
);
}}
setIdSort
(
v
);
/
>
loadChannels
(
0
,
pageSize
,
v
)
<
Form
.
Input
.
then
()
field
=
'search_model'
.
catch
((
reason
)
=>
{
label
=
'模型'
showError
(
reason
);
placeholder
=
'模型关键字'
});
value
=
{
searchModel
}
}}
loading
=
{
searching
}
><
/Switch
>
onChange
=
{(
v
)
=>
{
<
/Space
>
setSearchModel
(
v
.
trim
());
<
/Space
>
}}
<
/div
>
/
>
<
Form
.
Select
<
Table
field
=
'group'
className
=
{
'channel-table'
}
label
=
'分组'
style
=
{{
marginTop
:
15
}}
optionList
=
optionList
=
{[{
label
:
'选择分组'
,
value
:
null
},
...
groupOptions
]}
columns
=
{
columns
}
initValue
=
{
null
}
dataSource
=
{
pageData
}
onChange
=
{(
v
)
=>
{
pagination
=
{{
setSearchGroup
(
v
);
currentPage
:
activePage
,
searchChannels
(
searchKeyword
,
v
,
searchModel
);
pageSize
:
pageSize
,
}}
total
:
channelCount
,
/
>
pageSizeOpts
:
[
10
,
20
,
50
,
100
],
showSizeChanger
:
true
,
formatPageText
:
(
page
)
=>
''
,
onPageSizeChange
:
(
size
)
=>
{
handlePageSizeChange
(
size
).
then
();
},
onPageChange
:
handlePageChange
,
}}
loading
=
{
loading
}
onRow
=
{
handleRow
}
rowSelection
=
{
enableBatchDelete
?
{
onChange
:
(
selectedRowKeys
,
selectedRows
)
=>
{
// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
setSelectedChannels
(
selectedRows
);
},
}
:
null
}
/
>
<
div
style
=
{{
display
:
isMobile
()
?
''
:
'flex'
,
marginTop
:
isMobile
()
?
0
:
-
45
,
zIndex
:
999
,
position
:
'relative'
,
pointerEvents
:
'none'
,
}}
>
<
Space
style
=
{{
pointerEvents
:
'auto'
,
marginTop
:
isMobile
()
?
0
:
45
}}
>
<
Button
<
Button
theme
=
'light'
label
=
'查询'
type
=
'primary'
type
=
'primary'
style
=
{{
marginRight
:
8
}}
htmlType
=
'submit'
onClick
=
{()
=>
{
className
=
'btn-margin-right'
setEditingChannel
({
style
=
{{
marginRight
:
8
}}
id
:
undefined
,
});
setShowEdit
(
true
);
}}
>
>
添加渠道
查询
<
/Button
>
<
Popconfirm
title
=
'确定?'
okType
=
{
'warning'
}
onConfirm
=
{
testAllChannels
}
position
=
{
isMobile
()
?
'top'
:
'top'
}
>
<
Button
theme
=
'light'
type
=
'warning'
style
=
{{
marginRight
:
8
}}
>
测试所有通道
<
/Button
>
<
/Popconfirm
>
<
Popconfirm
title
=
'确定?'
okType
=
{
'secondary'
}
onConfirm
=
{
updateAllChannelsBalance
}
>
<
Button
theme
=
'light'
type
=
'secondary'
style
=
{{
marginRight
:
8
}}
>
更新所有已启用通道余额
<
/Button
>
<
/Popconfirm
>
<
Popconfirm
title
=
'确定是否要删除禁用通道?'
content
=
'此修改将不可逆'
okType
=
{
'danger'
}
onConfirm
=
{
deleteAllDisabledChannels
}
>
<
Button
theme
=
'light'
type
=
'danger'
style
=
{{
marginRight
:
8
}}
>
删除禁用通道
<
/Button
>
<
/Popconfirm
>
<
Button
theme
=
'light'
type
=
'primary'
style
=
{{
marginRight
:
8
}}
onClick
=
{
refresh
}
>
刷新
<
/Button
>
<
/Button
>
<
/Space
>
<
/Space
>
{
/*<div style={{width: '100%', pointerEvents: 'none', position: 'absolute'}}>*/
}
{
/*</div>*/
}
<
/div
>
<
/div
>
<
div
style
=
{{
marginTop
:
20
}}
>
<
/Form
>
<
div
style
=
{{
marginTop
:
10
,
display
:
'flex'
}}
>
<
Space
>
<
Space
>
<
Space
>
<
Typography
.
Text
strong
>
开启批量删除
<
/Typography.Text
>
<
Typography
.
Text
strong
>
使用
ID
排序
<
/Typography.Text
>
<
Switch
<
Switch
label
=
'开启批量删除'
checked
=
{
idSort
}
uncheckedText
=
'关'
label
=
'使用ID排序'
aria
-
label
=
'是否开启批量删除'
uncheckedText
=
'关'
onChange
=
{(
v
)
=>
{
aria
-
label
=
'是否用ID排序'
setEnableBatchDelete
(
v
);
onChange
=
{(
v
)
=>
{
}}
localStorage
.
setItem
(
'id-sort'
,
v
+
''
);
setIdSort
(
v
);
loadChannels
(
0
,
pageSize
,
v
)
.
then
()
.
catch
((
reason
)
=>
{
showError
(
reason
);
});
}}
><
/Switch
>
><
/Switch
>
<
Popconfirm
title
=
'确定是否要删除所选通道?'
content
=
'此修改将不可逆'
okType
=
{
'danger'
}
onConfirm
=
{
batchDeleteChannels
}
disabled
=
{
!
enableBatchDelete
}
position
=
{
'top'
}
>
<
Button
disabled
=
{
!
enableBatchDelete
}
theme
=
'light'
type
=
'danger'
style
=
{{
marginRight
:
8
}}
>
删除所选通道
<
/Button
>
<
/Popconfirm
>
<
Popconfirm
title
=
'确定是否要修复数据库一致性?'
content
=
'进行该操作时,可能导致渠道访问错误,请仅在数据库出现问题时使用'
okType
=
{
'warning'
}
onConfirm
=
{
fixChannelsAbilities
}
position
=
{
'top'
}
>
<
Button
theme
=
'light'
type
=
'secondary'
style
=
{{
marginRight
:
8
}}
>
修复数据库一致性
<
/Button
>
<
/Popconfirm
>
<
/Space
>
<
/Space
>
<
/div
>
<
/Space
>
<
/
>
<
/div
>
<
Table
className
=
{
'channel-table'
}
style
=
{{
marginTop
:
15
}}
columns
=
{
columns
}
dataSource
=
{
pageData
}
pagination
=
{{
currentPage
:
activePage
,
pageSize
:
pageSize
,
total
:
channelCount
,
pageSizeOpts
:
[
10
,
20
,
50
,
100
],
showSizeChanger
:
true
,
formatPageText
:
(
page
)
=>
''
,
onPageSizeChange
:
(
size
)
=>
{
handlePageSizeChange
(
size
).
then
();
},
onPageChange
:
handlePageChange
,
}}
loading
=
{
loading
}
onRow
=
{
handleRow
}
rowSelection
=
{
enableBatchDelete
?
{
onChange
:
(
selectedRowKeys
,
selectedRows
)
=>
{
// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
setSelectedChannels
(
selectedRows
);
},
}
:
null
}
/
>
<
div
style
=
{{
display
:
isMobile
()
?
''
:
'flex'
,
marginTop
:
isMobile
()
?
0
:
-
45
,
zIndex
:
999
,
position
:
'relative'
,
pointerEvents
:
'none'
,
}}
>
<
Space
style
=
{{
pointerEvents
:
'auto'
,
marginTop
:
isMobile
()
?
0
:
45
}}
>
<
Button
theme
=
'light'
type
=
'primary'
style
=
{{
marginRight
:
8
}}
onClick
=
{()
=>
{
setEditingChannel
({
id
:
undefined
,
});
setShowEdit
(
true
);
}}
>
添加渠道
<
/Button
>
<
Popconfirm
title
=
'确定?'
okType
=
{
'warning'
}
onConfirm
=
{
testAllChannels
}
position
=
{
isMobile
()
?
'top'
:
'top'
}
>
<
Button
theme
=
'light'
type
=
'warning'
style
=
{{
marginRight
:
8
}}
>
测试所有通道
<
/Button
>
<
/Popconfirm
>
<
Popconfirm
title
=
'确定?'
okType
=
{
'secondary'
}
onConfirm
=
{
updateAllChannelsBalance
}
>
<
Button
theme
=
'light'
type
=
'secondary'
style
=
{{
marginRight
:
8
}}
>
更新所有已启用通道余额
<
/Button
>
<
/Popconfirm
>
<
Popconfirm
title
=
'确定是否要删除禁用通道?'
content
=
'此修改将不可逆'
okType
=
{
'danger'
}
onConfirm
=
{
deleteAllDisabledChannels
}
>
<
Button
theme
=
'light'
type
=
'danger'
style
=
{{
marginRight
:
8
}}
>
删除禁用通道
<
/Button
>
<
/Popconfirm
>
<
Button
theme
=
'light'
type
=
'primary'
style
=
{{
marginRight
:
8
}}
onClick
=
{
refresh
}
>
刷新
<
/Button
>
<
/Space
>
{
/*<div style={{width: '100%', pointerEvents: 'none', position: 'absolute'}}>*/
}
{
/*</div>*/
}
<
/div
>
<
div
style
=
{{
marginTop
:
20
}}
>
<
Space
>
<
Typography
.
Text
strong
>
开启批量删除
<
/Typography.Text
>
<
Switch
label
=
'开启批量删除'
uncheckedText
=
'关'
aria
-
label
=
'是否开启批量删除'
onChange
=
{(
v
)
=>
{
setEnableBatchDelete
(
v
);
}}
><
/Switch
>
<
Popconfirm
title
=
'确定是否要删除所选通道?'
content
=
'此修改将不可逆'
okType
=
{
'danger'
}
onConfirm
=
{
batchDeleteChannels
}
disabled
=
{
!
enableBatchDelete
}
position
=
{
'top'
}
>
<
Button
disabled
=
{
!
enableBatchDelete
}
theme
=
'light'
type
=
'danger'
style
=
{{
marginRight
:
8
}}
>
删除所选通道
<
/Button
>
<
/Popconfirm
>
<
Popconfirm
title
=
'确定是否要修复数据库一致性?'
content
=
'进行该操作时,可能导致渠道访问错误,请仅在数据库出现问题时使用'
okType
=
{
'warning'
}
onConfirm
=
{
fixChannelsAbilities
}
position
=
{
'top'
}
>
<
Button
theme
=
'light'
type
=
'secondary'
style
=
{{
marginRight
:
8
}}
>
修复数据库一致性
<
/Button
>
<
/Popconfirm
>
<
/Space
>
<
/div
>
<
/
>
);
);
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment