fix(web): 出口重绑改走 POST /browsers/:alias/rebind(原 /network-exits/:id/rebind 无对应后端路由)
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
// 账号环境出口重绑:账号即环境下唯一的换绑入口(环境跟随账号,不再有独立环境页)。
|
||||
// 仅列举检测通过的出口;重绑走 POST /network-exits/:id/rebind(后端联动账号环境),成功后由父级刷新。
|
||||
// 仅列举检测通过的出口;重绑走 POST /browsers/:alias/rebind(alias=账号 ID,成功后由父级刷新)。
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { Button, Flex, Select, Typography } from 'antd';
|
||||
import { getList } from '@/services/api';
|
||||
import { jsonOptions, request } from '@/requestErrorConfig';
|
||||
|
||||
interface RebindEnvironmentProps {
|
||||
accountID: string;
|
||||
binding: any;
|
||||
disabled?: boolean;
|
||||
onRebound: () => void | Promise<void>;
|
||||
onError: (error: unknown) => void;
|
||||
}
|
||||
|
||||
export default function RebindEnvironment({ binding, disabled, onRebound, onError }: RebindEnvironmentProps) {
|
||||
export default function RebindEnvironment({ accountID, binding, disabled, onRebound, onError }: RebindEnvironmentProps) {
|
||||
const [exits, setExits] = useState<any[]>([]);
|
||||
const [exitsError, setExitsError] = useState(false);
|
||||
const [exitID, setExitID] = useState('');
|
||||
@@ -47,7 +48,7 @@ export default function RebindEnvironment({ binding, disabled, onRebound, onErro
|
||||
async function rebind() {
|
||||
setBusy(true);
|
||||
try {
|
||||
await request(`/network-exits/${encodeURIComponent(binding.network_exit_id ?? '')}/rebind`, jsonOptions('POST', { network_exit_id: exitID }));
|
||||
await request(`/browsers/${encodeURIComponent(accountID)}/rebind`, jsonOptions('POST', { network_exit_id: exitID }));
|
||||
await onRebound();
|
||||
} catch (reason) {
|
||||
onError(reason);
|
||||
|
||||
@@ -283,6 +283,7 @@ export default function Page() {
|
||||
<Descriptions.Item label="不可调度原因">{binding.schedule_block_reason || '无'}</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<RebindEnvironment
|
||||
accountID={id}
|
||||
binding={binding}
|
||||
disabled={actionBusy}
|
||||
onRebound={async () => {
|
||||
|
||||
Reference in New Issue
Block a user