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
80b41dc0
authored
Nov 30, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 完善标签编辑(优先级,权重)
parent
341e1b72
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
12 deletions
+122
-12
web/src/components/ChannelsTable.js
+99
-11
web/src/components/custom/TextInput.js
+0
-0
web/src/components/custom/TextNumberInput.js
+22
-0
web/src/pages/Channel/EditTagModal.js
+1
-1
No files found.
web/src/components/ChannelsTable.js
View file @
80b41dc0
...
@@ -12,15 +12,16 @@ import {
...
@@ -12,15 +12,16 @@ import {
import
{
CHANNEL_OPTIONS
,
ITEMS_PER_PAGE
}
from
'../constants'
;
import
{
CHANNEL_OPTIONS
,
ITEMS_PER_PAGE
}
from
'../constants'
;
import
{
import
{
getQuotaPerUnit
,
renderGroup
,
renderGroup
,
renderNumberWithPoint
,
renderNumberWithPoint
,
renderQuota
renderQuota
,
renderQuotaWithPrompt
}
from
'../helpers/render'
;
}
from
'../helpers/render'
;
import
{
import
{
Button
,
Divider
,
Button
,
Divider
,
Dropdown
,
Dropdown
,
Form
,
Form
,
Input
,
InputNumber
,
InputNumber
,
Modal
,
Popconfirm
,
Popconfirm
,
Space
,
Space
,
SplitButtonGroup
,
SplitButtonGroup
,
...
@@ -34,6 +35,7 @@ import EditChannel from '../pages/Channel/EditChannel';
...
@@ -34,6 +35,7 @@ import EditChannel from '../pages/Channel/EditChannel';
import
{
IconList
,
IconTreeTriangleDown
}
from
'@douyinfe/semi-icons'
;
import
{
IconList
,
IconTreeTriangleDown
}
from
'@douyinfe/semi-icons'
;
import
{
loadChannelModels
}
from
'./utils.js'
;
import
{
loadChannelModels
}
from
'./utils.js'
;
import
EditTagModal
from
'../pages/Channel/EditTagModal.js'
;
import
EditTagModal
from
'../pages/Channel/EditTagModal.js'
;
import
TextNumberInput
from
'./custom/TextNumberInput.js'
;
function
renderTimestamp
(
timestamp
)
{
function
renderTimestamp
(
timestamp
)
{
return
<>
{
timestamp2string
(
timestamp
)}
<
/>
;
return
<>
{
timestamp2string
(
timestamp
)}
<
/>
;
...
@@ -200,7 +202,29 @@ const ChannelsTable = () => {
...
@@ -200,7 +202,29 @@ const ChannelsTable = () => {
);
);
}
else
{
}
else
{
return
<>
return
<>
<
Button
theme
=
"outline"
type
=
"primary"
>
修改
<
/Button
>
<
InputNumber
style
=
{{
width
:
70
}}
name
=
"priority"
keepFocus
=
{
true
}
onBlur
=
{(
e
)
=>
{
Modal
.
warning
({
title
:
'修改子渠道优先级'
,
content
:
'确定要修改所有子渠道优先级为 '
+
e
.
target
.
value
+
' 吗?'
,
onOk
:
()
=>
{
if
(
e
.
target
.
value
===
''
)
{
return
;
}
submitTagEdit
(
'priority'
,
{
tag
:
record
.
key
,
priority
:
e
.
target
.
value
})
},
})
}}
innerButtons
defaultValue
=
{
record
.
priority
}
min
=
{
-
999
}
/
>
<
/>
;
<
/>
;
}
}
}
}
...
@@ -227,12 +251,29 @@ const ChannelsTable = () => {
...
@@ -227,12 +251,29 @@ const ChannelsTable = () => {
);
);
}
else
{
}
else
{
return
(
return
(
<
Button
<
InputNumber
theme
=
"outline"
style
=
{{
width
:
70
}}
type
=
"primary"
name
=
"weight"
>
keepFocus
=
{
true
}
修改
onBlur
=
{(
e
)
=>
{
<
/Button
>
Modal
.
warning
({
title
:
'修改子渠道权重'
,
content
:
'确定要修改所有子渠道权重为 '
+
e
.
target
.
value
+
' 吗?'
,
onOk
:
()
=>
{
if
(
e
.
target
.
value
===
''
)
{
return
;
}
submitTagEdit
(
'weight'
,
{
tag
:
record
.
key
,
weight
:
e
.
target
.
value
})
},
})
}}
innerButtons
defaultValue
=
{
record
.
weight
}
min
=
{
-
999
}
/
>
);
);
}
}
}
}
...
@@ -397,6 +438,8 @@ const ChannelsTable = () => {
...
@@ -397,6 +438,8 @@ const ChannelsTable = () => {
const
[
showEditTag
,
setShowEditTag
]
=
useState
(
false
);
const
[
showEditTag
,
setShowEditTag
]
=
useState
(
false
);
const
[
editingTag
,
setEditingTag
]
=
useState
(
''
);
const
[
editingTag
,
setEditingTag
]
=
useState
(
''
);
const
[
selectedChannels
,
setSelectedChannels
]
=
useState
([]);
const
[
selectedChannels
,
setSelectedChannels
]
=
useState
([]);
const
[
showEditPriority
,
setShowEditPriority
]
=
useState
(
false
);
const
removeRecord
=
(
id
)
=>
{
const
removeRecord
=
(
id
)
=>
{
let
newDataSource
=
[...
channels
];
let
newDataSource
=
[...
channels
];
...
@@ -444,7 +487,9 @@ const ChannelsTable = () => {
...
@@ -444,7 +487,9 @@ const ChannelsTable = () => {
name
:
'标签:'
+
tag
,
name
:
'标签:'
+
tag
,
group
:
''
,
group
:
''
,
used_quota
:
0
,
used_quota
:
0
,
response_time
:
0
response_time
:
0
,
priority
:
-
1
,
weight
:
-
1
,
};
};
tagChannelDates
.
children
=
[];
tagChannelDates
.
children
=
[];
channelDates
.
push
(
tagChannelDates
);
channelDates
.
push
(
tagChannelDates
);
...
@@ -452,6 +497,20 @@ const ChannelsTable = () => {
...
@@ -452,6 +497,20 @@ const ChannelsTable = () => {
// found, add to the tag
// found, add to the tag
tagChannelDates
=
channelDates
.
find
((
item
)
=>
item
.
key
===
tag
);
tagChannelDates
=
channelDates
.
find
((
item
)
=>
item
.
key
===
tag
);
}
}
if
(
tagChannelDates
.
priority
===
-
1
)
{
tagChannelDates
.
priority
=
channels
[
i
].
priority
;
}
else
{
if
(
tagChannelDates
.
priority
!==
channels
[
i
].
priority
)
{
tagChannelDates
.
priority
=
''
;
}
}
if
(
tagChannelDates
.
weight
===
-
1
)
{
tagChannelDates
.
weight
=
channels
[
i
].
weight
;
}
else
{
if
(
tagChannelDates
.
weight
!==
channels
[
i
].
weight
)
{
tagChannelDates
.
weight
=
''
;
}
}
if
(
tagChannelDates
.
group
===
''
)
{
if
(
tagChannelDates
.
group
===
''
)
{
tagChannelDates
.
group
=
channels
[
i
].
group
;
tagChannelDates
.
group
=
channels
[
i
].
group
;
...
@@ -855,6 +914,35 @@ const ChannelsTable = () => {
...
@@ -855,6 +914,35 @@ const ChannelsTable = () => {
}
}
};
};
const
submitTagEdit
=
async
(
type
,
data
)
=>
{
switch
(
type
)
{
case
'priority'
:
if
(
data
.
priority
===
undefined
||
data
.
priority
===
''
)
{
showInfo
(
'优先级必须是整数!'
);
return
;
}
data
.
priority
=
parseInt
(
data
.
priority
);
break
;
case
'weight'
:
if
(
data
.
weight
===
undefined
||
data
.
weight
<
0
||
data
.
weight
===
''
)
{
showInfo
(
'权重必须是非负整数!'
);
return
;
}
data
.
weight
=
parseInt
(
data
.
weight
);
break
}
try
{
const
res
=
await
API
.
put
(
'/api/channel/tag'
,
data
);
if
(
res
?.
data
?.
success
)
{
showSuccess
(
'更新成功!'
);
await
refresh
();
}
}
catch
(
error
)
{
showError
(
error
);
}
}
const
closeEdit
=
()
=>
{
const
closeEdit
=
()
=>
{
setShowEdit
(
false
);
setShowEdit
(
false
);
};
};
...
...
web/src/components/TextInput.js
→
web/src/components/
custom/
TextInput.js
View file @
80b41dc0
File moved
web/src/components/custom/TextNumberInput.js
0 → 100644
View file @
80b41dc0
import
{
Input
,
InputNumber
,
Typography
}
from
'@douyinfe/semi-ui'
;
import
React
from
'react'
;
const
TextNumberInput
=
({
label
,
name
,
value
,
onChange
,
placeholder
})
=>
{
return
(
<>
<
div
style
=
{{
marginTop
:
10
}}
>
<
Typography
.
Text
strong
>
{
label
}
<
/Typography.Text
>
<
/div
>
<
InputNumber
name
=
{
name
}
placeholder
=
{
placeholder
}
onChange
=
{(
value
)
=>
onChange
(
value
)}
value
=
{
value
}
autoComplete
=
"new-password"
/>
<
/
>
);
}
export
default
TextNumberInput
;
\ No newline at end of file
web/src/pages/Channel/EditTagModal.js
View file @
80b41dc0
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
{
API
,
showError
,
showInfo
,
showSuccess
,
showWarning
,
verifyJSON
}
from
'../../helpers'
;
import
{
API
,
showError
,
showInfo
,
showSuccess
,
showWarning
,
verifyJSON
}
from
'../../helpers'
;
import
{
SideSheet
,
Space
,
Button
,
Input
,
Typography
,
Spin
,
Modal
,
Select
,
Banner
,
TextArea
}
from
'@douyinfe/semi-ui'
;
import
{
SideSheet
,
Space
,
Button
,
Input
,
Typography
,
Spin
,
Modal
,
Select
,
Banner
,
TextArea
}
from
'@douyinfe/semi-ui'
;
import
TextInput
from
'../../components/TextInput.js'
;
import
TextInput
from
'../../components/
custom/
TextInput.js'
;
import
{
getChannelModels
}
from
'../../components/utils.js'
;
import
{
getChannelModels
}
from
'../../components/utils.js'
;
const
MODEL_MAPPING_EXAMPLE
=
{
const
MODEL_MAPPING_EXAMPLE
=
{
...
...
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