douyin-release-gate / verify (push) Failing after 18m54s
Add Douyin notification polling, event details, and manual multi-account private messaging. Refine environment memory settings, account operations, login collection recovery, and message UI; update tests and documentation.
42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
export type CollectionCheckpoint = {
|
||
status?: string;
|
||
last_completed_at?: string | null;
|
||
last_error?: string | null;
|
||
};
|
||
|
||
const labels: Record<string, { text: string; color: string }> = {
|
||
idle: { text: '待采集', color: 'default' },
|
||
pending: { text: '待采集', color: 'default' },
|
||
succeeded: { text: '采集完成', color: 'success' },
|
||
running: { text: '采集运行中', color: 'processing' },
|
||
failed: { text: '采集失败', color: 'error' },
|
||
blocked: { text: '采集受阻', color: 'warning' },
|
||
};
|
||
|
||
export function collectionStatusPresentation(checkpoint?: CollectionCheckpoint | null) {
|
||
const reason = checkpoint?.last_error || '';
|
||
if (reason.includes('browser is awaiting user login')) {
|
||
return {
|
||
text: '需要登录',
|
||
color: 'warning',
|
||
reason: '浏览器需要登录,请登录并同步账号后重试。',
|
||
};
|
||
}
|
||
const state = checkpoint?.status ? labels[checkpoint.status] : undefined;
|
||
return { ...(state || { text: '状态未知', color: 'default' }), reason };
|
||
}
|
||
|
||
const accountStatusPriority = ['需要登录', '采集失败', '采集受阻', '状态未知', '采集运行中', '待采集', '采集完成'];
|
||
|
||
export function accountCollectionStatusPresentation(
|
||
works?: CollectionCheckpoint | null,
|
||
comments?: CollectionCheckpoint | null,
|
||
) {
|
||
const states = [works, comments].map(collectionStatusPresentation);
|
||
const primary = states.reduce((current, candidate) =>
|
||
accountStatusPriority.indexOf(current.text) <= accountStatusPriority.indexOf(candidate.text) ? current : candidate,
|
||
);
|
||
const reasons = [...new Set(states.map(state => state.reason).filter(Boolean))];
|
||
return { ...primary, reason: reasons.join(';') };
|
||
}
|