feat(weibo): 增加外部 CK 单行复制
This commit is contained in:
@@ -801,6 +801,12 @@ export interface WeiboBindQrResult {
|
||||
schemes: WeiboBindScheme[];
|
||||
}
|
||||
|
||||
export interface WeiboAccountCkResult {
|
||||
account_id: number;
|
||||
uid: string;
|
||||
ck_text: string;
|
||||
}
|
||||
|
||||
export interface WeiboGoodsItem {
|
||||
id: number;
|
||||
goods_name: string;
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
MessageResponse,
|
||||
PaginatedResponse,
|
||||
WeiboAccountItem,
|
||||
WeiboAccountCkResult,
|
||||
WeiboBindQrResult,
|
||||
WeiboExchangeRecordsResult,
|
||||
WeiboExchangeResult,
|
||||
@@ -55,6 +56,10 @@ export const weiboApi = {
|
||||
api.post<WeiboAccountItem, WeiboAccountItem>(
|
||||
`/weibo/accounts/${accountId}/refresh`,
|
||||
),
|
||||
copyAccountCk: (accountId: number) =>
|
||||
api.post<WeiboAccountCkResult, WeiboAccountCkResult>(
|
||||
`/weibo/accounts/${accountId}/ck/copy`,
|
||||
),
|
||||
bindQrcodes: (accountId: number, channel: 'wx' | 'qq') =>
|
||||
api.post<WeiboBindQrResult, WeiboBindQrResult>(
|
||||
`/weibo/accounts/${accountId}/bind-qrcodes`,
|
||||
|
||||
@@ -86,6 +86,7 @@ export default function WeiboAccountsPage() {
|
||||
const { can } = usePermissions();
|
||||
const canImport = can('weibo:import');
|
||||
const canManage = can('weibo:manage');
|
||||
const canExportCk = can('weibo:account:ck_export');
|
||||
const canBind = can('weibo:bind');
|
||||
const canRecharge = can('weibo:recharge');
|
||||
const canExchange = can('weibo:exchange');
|
||||
@@ -100,6 +101,7 @@ export default function WeiboAccountsPage() {
|
||||
const [enabledFilter, setEnabledFilter] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [refreshingId, setRefreshingId] = useState<number | null>(null);
|
||||
const [copyingId, setCopyingId] = useState<number | null>(null);
|
||||
const [mutatingId, setMutatingId] = useState<number | null>(null);
|
||||
const [selectedIds, setSelectedIds] = useState<number[]>([]);
|
||||
const [batchBusy, setBatchBusy] = useState(false);
|
||||
@@ -216,6 +218,19 @@ export default function WeiboAccountsPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleCopyCk = async (account: WeiboAccountItem) => {
|
||||
setCopyingId(account.id);
|
||||
try {
|
||||
const result = await weiboApi.copyAccountCk(account.id);
|
||||
await copyTextToClipboard(result.ck_text);
|
||||
message.success(`${account.nickname || account.uid} 的 CK 已复制`);
|
||||
} catch (error) {
|
||||
message.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setCopyingId(null);
|
||||
}
|
||||
};
|
||||
|
||||
const openQr = (account: WeiboAccountItem) => {
|
||||
if (!account.is_enabled) {
|
||||
message.warning('账号已停用,请先启用');
|
||||
@@ -699,6 +714,16 @@ export default function WeiboAccountsPage() {
|
||||
>
|
||||
功能
|
||||
</Button>
|
||||
{canExportCk && (
|
||||
<Button
|
||||
size="small"
|
||||
icon={<CopyOutlined />}
|
||||
loading={copyingId === account.id}
|
||||
onClick={() => void handleCopyCk(account)}
|
||||
>
|
||||
复制CK
|
||||
</Button>
|
||||
)}
|
||||
{canManage && (
|
||||
<Button
|
||||
size="small"
|
||||
|
||||
Reference in New Issue
Block a user