From f3c2f53fe99beb02e779be6015c0490d97dccd19 Mon Sep 17 00:00:00 2001 From: MartialBE Date: Sat, 6 Apr 2024 16:06:52 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20improve:=20Optimized=20pri?= =?UTF-8?q?ority=20input=20handling=20in=20TableRow=20component.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/Channel/component/TableRow.js | 61 ++++++++----------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/web/berry/src/views/Channel/component/TableRow.js b/web/berry/src/views/Channel/component/TableRow.js index 1e58b678..2a7b9c7f 100644 --- a/web/berry/src/views/Channel/component/TableRow.js +++ b/web/berry/src/views/Channel/component/TableRow.js @@ -11,10 +11,7 @@ import { MenuItem, TableCell, IconButton, - FormControl, - InputLabel, - InputAdornment, - Input, + TextField, Dialog, DialogActions, DialogContent, @@ -31,12 +28,7 @@ import ResponseTimeLabel from "./ResponseTimeLabel"; import GroupLabel from "./GroupLabel"; import NameLabel from "./NameLabel"; -import { - IconDotsVertical, - IconEdit, - IconTrash, - IconPencil, -} from "@tabler/icons-react"; +import { IconDotsVertical, IconEdit, IconTrash } from "@tabler/icons-react"; export default function ChannelTableRow({ item, @@ -79,11 +71,19 @@ export default function ChannelTableRow({ } }; - const handlePriority = async () => { - if (priorityValve === "" || priorityValve === item.priority) { + const handlePriority = async (event) => { + const currentValue = parseInt(event.target.value); + if (isNaN(currentValue) || currentValue === priorityValve) { return; } - await manageChannel(item.id, "priority", priorityValve); + + if (currentValue < 0) { + showError("优先级不能小于 0"); + return; + } + + await manageChannel(item.id, "priority", currentValue); + setPriority(currentValue); }; const handleResponseTime = async () => { @@ -170,9 +170,7 @@ export default function ChannelTableRow({ handle_action={handleResponseTime} /> - - {renderNumber(item.used_quota)} - + {renderNumber(item.used_quota)} - - 优先级 - setPriority(e.target.value)} - sx={{ textAlign: "center" }} - endAdornment={ - - - - - - } - /> - +