fix(ui): 账号详情页 pending 态页头保留返回入口;同步/编辑加空态防护(走查 P2-#9)
This commit is contained in:
@@ -152,30 +152,30 @@ export default function Page() {
|
||||
|
||||
// 页头 content 行右侧:返回/强制同步/编辑注册到 Layout 页头槽,不在卡片内重复渲染。
|
||||
usePageActions(
|
||||
account ? (
|
||||
<Space>
|
||||
<Button onClick={() => history.push('/accounts')}>返回社媒账号</Button>
|
||||
<Button
|
||||
disabled={actionBusy}
|
||||
onClick={async () => {
|
||||
// 强制同步:后端复用账号自身运行环境采集,需已登录+环境就绪(否则 409/503 提示原因)。
|
||||
setActionBusy(true);
|
||||
try {
|
||||
await creatorAction(`/creator/accounts/${encodeURIComponent(account.id)}/sync`);
|
||||
messageApi.success('强制同步已执行。');
|
||||
await loadAll();
|
||||
} catch (actionError) {
|
||||
messageApi.error(conflictMessage(actionError, '强制同步失败;账号需已登录且运行环境就绪。'));
|
||||
} finally {
|
||||
setActionBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
强制同步
|
||||
</Button>
|
||||
<Button type="primary" onClick={() => history.push(`/accounts/${account.id}/edit`)}>编辑账号</Button>
|
||||
</Space>
|
||||
) : null,
|
||||
<Space>
|
||||
<Button onClick={() => history.push('/accounts')}>返回社媒账号</Button>
|
||||
<Button
|
||||
disabled={actionBusy || !account}
|
||||
onClick={async () => {
|
||||
// 强制同步:后端复用账号自身运行环境采集,需已登录+环境就绪(否则 409/503 提示原因)。
|
||||
setActionBusy(true);
|
||||
try {
|
||||
await creatorAction(`/creator/accounts/${encodeURIComponent(account.id)}/sync`);
|
||||
messageApi.success('强制同步已执行。');
|
||||
await loadAll();
|
||||
} catch (actionError) {
|
||||
messageApi.error(conflictMessage(actionError, '强制同步失败;账号需已登录且运行环境就绪。'));
|
||||
} finally {
|
||||
setActionBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
强制同步
|
||||
</Button>
|
||||
<Button type="primary" disabled={!account} onClick={() => account && history.push(`/accounts/${account.id}/edit`)}>
|
||||
编辑账号
|
||||
</Button>
|
||||
</Space>,
|
||||
[account?.id],
|
||||
);
|
||||
|
||||
|
||||
@@ -87,49 +87,49 @@ export default function Page() {
|
||||
);
|
||||
|
||||
usePageActions(
|
||||
competitor ? (
|
||||
<Space>
|
||||
<Button onClick={() => history.push('/accounts/monitoring')}>返回监控账号</Button>
|
||||
<Button
|
||||
disabled={actionBusy || !competitor.enabled}
|
||||
onClick={async () => {
|
||||
// 强制同步:后端用临时匿名浏览器采集公开作品,无需自有账号身份。
|
||||
setActionBusy(true);
|
||||
try {
|
||||
await creatorAction(`/creator/competitors/${encodeURIComponent(competitor.id)}/sync`);
|
||||
messageApi.success('强制同步已执行。');
|
||||
await loadCompetitor();
|
||||
} catch (actionError) {
|
||||
messageApi.error(conflictMessage(actionError, '强制同步失败'));
|
||||
} finally {
|
||||
setActionBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
强制同步
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={actionBusy}
|
||||
onClick={async () => {
|
||||
setActionBusy(true);
|
||||
try {
|
||||
await creatorAction(
|
||||
`/creator/competitors/${encodeURIComponent(competitor.id)}/${competitor.enabled ? 'pause' : 'resume'}`,
|
||||
);
|
||||
messageApi.success(competitor.enabled ? '监测账号已暂停。' : '监测账号已恢复。');
|
||||
await loadCompetitor();
|
||||
} catch (actionError) {
|
||||
messageApi.error(conflictMessage(actionError, '监测账号状态更新失败'));
|
||||
} finally {
|
||||
setActionBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{competitor.enabled ? '暂停监控' : '恢复监控'}
|
||||
</Button>
|
||||
</Space>
|
||||
) : null,
|
||||
<Space>
|
||||
<Button onClick={() => history.push('/accounts/monitoring')}>返回监控账号</Button>
|
||||
<Button
|
||||
disabled={actionBusy || !competitor}
|
||||
onClick={async () => {
|
||||
// 强制同步:后端用临时匿名浏览器采集公开作品,无需自有账号身份。
|
||||
if (!competitor) return;
|
||||
setActionBusy(true);
|
||||
try {
|
||||
await creatorAction(`/creator/competitors/${encodeURIComponent(competitor.id)}/sync`);
|
||||
messageApi.success('强制同步已执行。');
|
||||
await loadCompetitor();
|
||||
} catch (actionError) {
|
||||
messageApi.error(conflictMessage(actionError, '强制同步失败'));
|
||||
} finally {
|
||||
setActionBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
强制同步
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={actionBusy || !competitor}
|
||||
onClick={async () => {
|
||||
if (!competitor) return;
|
||||
setActionBusy(true);
|
||||
try {
|
||||
await creatorAction(
|
||||
`/creator/competitors/${encodeURIComponent(competitor.id)}/${competitor.enabled ? 'pause' : 'resume'}`,
|
||||
);
|
||||
messageApi.success(competitor.enabled ? '监测账号已暂停。' : '监测账号已恢复。');
|
||||
await loadCompetitor();
|
||||
} catch (actionError) {
|
||||
messageApi.error(conflictMessage(actionError, '监测账号状态更新失败'));
|
||||
} finally {
|
||||
setActionBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{competitor ? (competitor.enabled ? '暂停监控' : '恢复监控') : '暂停监控'}
|
||||
</Button>
|
||||
</Space>,
|
||||
[competitor?.id, competitor?.enabled],
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user