feat(weibo): 支持管理员强制更新占用账号 CK
This commit is contained in:
@@ -775,6 +775,12 @@ export interface WeiboAccountItem {
|
||||
export interface WeiboImportError {
|
||||
line: number;
|
||||
message: string;
|
||||
account_id: number | null;
|
||||
uid: string;
|
||||
assigned_user_id: number | null;
|
||||
assigned_username: string;
|
||||
workbench_owner_id: number | null;
|
||||
workbench_owner_username: string;
|
||||
}
|
||||
|
||||
export interface WeiboImportDuplicate {
|
||||
|
||||
@@ -49,11 +49,17 @@ export const weiboApi = {
|
||||
),
|
||||
getAccount: (accountId: number) =>
|
||||
api.get<WeiboAccountItem, WeiboAccountItem>(`/weibo/accounts/${accountId}`),
|
||||
importCookies: (text: string, tag = '', updateExisting = false) =>
|
||||
importCookies: (
|
||||
text: string,
|
||||
tag = '',
|
||||
updateExisting = false,
|
||||
forceUpdate = false,
|
||||
) =>
|
||||
api.post<WeiboImportResult, WeiboImportResult>('/weibo/accounts/import-cookies', {
|
||||
text,
|
||||
tag,
|
||||
update_existing: updateExisting,
|
||||
force_update: forceUpdate,
|
||||
}),
|
||||
updateAccount: (
|
||||
accountId: number,
|
||||
|
||||
@@ -192,6 +192,7 @@ export default function WeiboAccountsPage({
|
||||
const canExchange = can('weibo:exchange');
|
||||
const canDelete = can('weibo:delete');
|
||||
const canAssign = can('weibo:assign');
|
||||
const canForceUpdateCk = can('weibo:assign:force');
|
||||
const canTransferCollab = can('weibo:workbench');
|
||||
|
||||
const [items, setItems] = useState<WeiboAccountItem[]>([]);
|
||||
@@ -241,7 +242,10 @@ export default function WeiboAccountsPage({
|
||||
text: string;
|
||||
tag?: string;
|
||||
update_existing?: boolean;
|
||||
force_update?: boolean;
|
||||
}>();
|
||||
const updateExistingCk = Form.useWatch('update_existing', form);
|
||||
const forceUpdateCk = Form.useWatch('force_update', form);
|
||||
const [editForm] = Form.useForm<{ tag?: string; remark?: string }>();
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
const [editAccount, setEditAccount] = useState<WeiboAccountItem | null>(null);
|
||||
@@ -406,6 +410,7 @@ export default function WeiboAccountsPage({
|
||||
values.text,
|
||||
values.tag || '',
|
||||
Boolean(values.update_existing),
|
||||
Boolean(values.force_update),
|
||||
);
|
||||
setImportErrors(result.errors);
|
||||
setImportDuplicates(result.duplicates);
|
||||
@@ -3140,7 +3145,16 @@ export default function WeiboAccountsPage({
|
||||
onCancel={() => setImportOpen(false)}
|
||||
destroyOnHidden
|
||||
>
|
||||
<Form form={form} layout="vertical" preserve={false}>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
preserve={false}
|
||||
onValuesChange={(changed) => {
|
||||
if (changed.update_existing === false) {
|
||||
form.setFieldValue('force_update', false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Form.Item
|
||||
name="text"
|
||||
label="Cookie"
|
||||
@@ -3159,6 +3173,26 @@ export default function WeiboAccountsPage({
|
||||
重复账号时更新 CK(仍只有一条全局账号,不新建)
|
||||
</Checkbox>
|
||||
</Form.Item>
|
||||
{canForceUpdateCk && (
|
||||
<Form.Item
|
||||
name="force_update"
|
||||
valuePropName="checked"
|
||||
style={{ marginTop: -8 }}
|
||||
>
|
||||
<Checkbox disabled={!updateExistingCk}>
|
||||
强制更新已被分配或工作台占用的 CK(保留原归属)
|
||||
</Checkbox>
|
||||
</Form.Item>
|
||||
)}
|
||||
{forceUpdateCk && (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
style={{ marginBottom: 16 }}
|
||||
title="强制更新会跳过归属和工作台占用校验"
|
||||
description="只替换 Cookie 和验证状态,不会取消或改变原账号归属与工作台成员。"
|
||||
/>
|
||||
)}
|
||||
</Form>
|
||||
{importErrors.length > 0 && (
|
||||
<Alert
|
||||
@@ -3168,9 +3202,12 @@ export default function WeiboAccountsPage({
|
||||
description={
|
||||
<Space orientation="vertical" size={2}>
|
||||
{importErrors.slice(0, 8).map((item) => (
|
||||
<Text key={`${item.line}-${item.message}`} style={{ fontSize: 12 }}>
|
||||
第 {item.line} 行:{item.message}
|
||||
</Text>
|
||||
<div key={`${item.line}-${item.message}`}>
|
||||
<Text style={{ fontSize: 12 }}>
|
||||
第 {item.line} 行{item.uid ? ` · UID ${item.uid}` : ''}:
|
||||
{item.message}
|
||||
</Text>
|
||||
</div>
|
||||
))}
|
||||
</Space>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user