(type, data)
| 1406 | }; |
| 1407 | |
| 1408 | const submitTagEdit = async (type, data) => { |
| 1409 | switch (type) { |
| 1410 | case 'priority': |
| 1411 | if (data.priority === undefined || data.priority === '') { |
| 1412 | showInfo('优先级必须是整数!'); |
| 1413 | return; |
| 1414 | } |
| 1415 | data.priority = parseInt(data.priority); |
| 1416 | break; |
| 1417 | case 'weight': |
| 1418 | if ( |
| 1419 | data.weight === undefined || |
| 1420 | data.weight < 0 || |
| 1421 | data.weight === '' |
| 1422 | ) { |
| 1423 | showInfo('权重必须是非负整数!'); |
| 1424 | return; |
| 1425 | } |
| 1426 | data.weight = parseInt(data.weight); |
| 1427 | break; |
| 1428 | } |
| 1429 | |
| 1430 | try { |
| 1431 | const res = await API.put('/api/channel/tag', data); |
| 1432 | if (res?.data?.success) { |
| 1433 | showSuccess('更新成功!'); |
| 1434 | await refresh(); |
| 1435 | } |
| 1436 | } catch (error) { |
| 1437 | showError(error); |
| 1438 | } |
| 1439 | }; |
| 1440 | |
| 1441 | const closeEdit = () => { |
| 1442 | setShowEdit(false); |
no test coverage detected