Skip to content

Commit

Permalink
🐛 修复排序后点击错乱的问题 #283
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Jul 7, 2024
1 parent f6f0a80 commit 8a05f00
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/pages/options/routes/ScriptList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,23 @@ function ScriptList() {
},
],
onFilter: (value, row) => row.status === value,
render: (col, item: ListType, index) => {
render: (col, item: ListType) => {
return (
<Switch
checked={item.status === SCRIPT_STATUS_ENABLE}
loading={item.loading}
disabled={item.loading}
onChange={(checked) => {
setScriptList((list) => {
list[index].loading = true;
return [...list];
return list.map((script) => {
if (script.id === item.id) {
script.loading = true;
}
return script;
});
});
setScriptList((list) => {
const index = list.findIndex((script) => script.id === item.id);
let p: Promise<any>;
if (checked) {
p = scriptCtrl.enable(item.id).then(() => {
Expand Down

0 comments on commit 8a05f00

Please sign in to comment.