feat(weibo): 增加工作台批量充值与批量导入
This commit is contained in:
@@ -814,6 +814,31 @@ export interface WeiboWorkbenchMutationResult {
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export interface WeiboWorkbenchBatchImportItem {
|
||||
identifier: string;
|
||||
status:
|
||||
| 'added'
|
||||
| 'already_added'
|
||||
| 'not_found'
|
||||
| 'ambiguous'
|
||||
| 'unavailable'
|
||||
| 'disabled'
|
||||
| 'duplicate';
|
||||
message: string;
|
||||
account_id: number | null;
|
||||
uid: string;
|
||||
nickname: string;
|
||||
}
|
||||
|
||||
export interface WeiboWorkbenchBatchImportResult {
|
||||
requested: number;
|
||||
added: number;
|
||||
already_added: number;
|
||||
failed: number;
|
||||
account_ids: number[];
|
||||
items: WeiboWorkbenchBatchImportItem[];
|
||||
}
|
||||
|
||||
export interface WeiboBatchTagResult {
|
||||
updated: number;
|
||||
tag: string;
|
||||
|
||||
@@ -15,6 +15,7 @@ import type {
|
||||
WeiboRechargeOrderResult,
|
||||
WeiboImportResult,
|
||||
WeiboWorkbenchMutationResult,
|
||||
WeiboWorkbenchBatchImportResult,
|
||||
} from './types';
|
||||
|
||||
export const weiboApi = {
|
||||
@@ -122,6 +123,11 @@ export const weiboApi = {
|
||||
'/weibo/workbench/accounts',
|
||||
{ account_ids: accountIds },
|
||||
),
|
||||
batchImportWorkbenchAccounts: (text: string) =>
|
||||
api.post<WeiboWorkbenchBatchImportResult, WeiboWorkbenchBatchImportResult>(
|
||||
'/weibo/workbench/accounts/batch-import',
|
||||
{ text },
|
||||
),
|
||||
removeWorkbenchAccounts: (accountIds: number[]) =>
|
||||
api.post<WeiboWorkbenchMutationResult, WeiboWorkbenchMutationResult>(
|
||||
'/weibo/workbench/accounts/remove',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,7 @@ import {
|
||||
} from 'antd';
|
||||
import type { TableProps } from 'antd';
|
||||
import {
|
||||
CopyOutlined,
|
||||
DeleteOutlined,
|
||||
EditOutlined,
|
||||
FileExcelOutlined,
|
||||
@@ -58,6 +59,7 @@ import { useCollabRealtime } from '../hooks/useCollabRealtime';
|
||||
import { usePermissions } from '../hooks/usePermissions';
|
||||
import { getErrorMessage } from '../utils/error';
|
||||
import { message } from '../utils/antdMessage';
|
||||
import { copyTextToClipboard } from '../utils/clipboard';
|
||||
import { formatTime } from '../utils/time';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
@@ -578,6 +580,38 @@ export default function WeiboCollabPage() {
|
||||
[summary],
|
||||
);
|
||||
|
||||
const copySelectedAccountValues = async (kind: 'username' | 'uid') => {
|
||||
const selectedOrders = orders.filter((row) => selectedIds.includes(row.id));
|
||||
const values = Array.from(
|
||||
new Set(
|
||||
selectedOrders
|
||||
.map((row) =>
|
||||
kind === 'uid'
|
||||
? row.account_uid
|
||||
: row.account_nickname || row.account_uid,
|
||||
)
|
||||
.map((value) => String(value || '').trim())
|
||||
.filter(Boolean),
|
||||
),
|
||||
);
|
||||
if (values.length === 0) {
|
||||
message.warning(
|
||||
kind === 'uid' ? '所选订单没有微博 UID' : '所选订单没有微博用户名',
|
||||
);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await copyTextToClipboard(values.join('\n'));
|
||||
message.success(
|
||||
`已复制 ${values.length} 个${
|
||||
kind === 'uid' ? ' UID' : '用户名'
|
||||
},可直接粘贴到工作台导入搜索框`,
|
||||
);
|
||||
} catch (error) {
|
||||
message.error(getErrorMessage(error));
|
||||
}
|
||||
};
|
||||
|
||||
const columns: TableProps<WeiboCollabOrder>['columns'] = [
|
||||
{
|
||||
title: '序号',
|
||||
@@ -618,9 +652,33 @@ export default function WeiboCollabPage() {
|
||||
width: 210,
|
||||
render: (_, row) => (
|
||||
<Space orientation="vertical" size={0}>
|
||||
<Text>{row.account_nickname || row.account_uid || '未关联'}</Text>
|
||||
<Text
|
||||
copyable={
|
||||
row.account_nickname || row.account_uid
|
||||
? {
|
||||
text: row.account_nickname || row.account_uid || '',
|
||||
tooltips: ['复制用户名', '已复制用户名'],
|
||||
}
|
||||
: false
|
||||
}
|
||||
>
|
||||
{row.account_nickname || row.account_uid || '未关联'}
|
||||
</Text>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
UID {row.account_uid || '-'}
|
||||
{row.account_uid ? (
|
||||
<Text
|
||||
type="secondary"
|
||||
style={{ fontSize: 12 }}
|
||||
copyable={{
|
||||
text: row.account_uid,
|
||||
tooltips: ['复制 UID', '已复制 UID'],
|
||||
}}
|
||||
>
|
||||
UID {row.account_uid}
|
||||
</Text>
|
||||
) : (
|
||||
'UID -'
|
||||
)}
|
||||
</Text>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{row.game_role_name || '未读到角色'}
|
||||
@@ -900,6 +958,22 @@ export default function WeiboCollabPage() {
|
||||
|
||||
<Space wrap>
|
||||
<Text type="secondary">已选 {selectedIds.length} 单</Text>
|
||||
{selectedIds.length > 0 && (
|
||||
<>
|
||||
<Button
|
||||
icon={<CopyOutlined />}
|
||||
onClick={() => void copySelectedAccountValues('username')}
|
||||
>
|
||||
复制所选用户名
|
||||
</Button>
|
||||
<Button
|
||||
icon={<CopyOutlined />}
|
||||
onClick={() => void copySelectedAccountValues('uid')}
|
||||
>
|
||||
复制所选 UID
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{canEdit && selectedIds.length > 0 && archiveScope !== 'archived' && (
|
||||
<>
|
||||
<Button
|
||||
@@ -1168,7 +1242,40 @@ export default function WeiboCollabPage() {
|
||||
column={2}
|
||||
items={[
|
||||
{ key: 'shop', label: '店铺 / 负责人', children: `${detail.shop || '-'} / ${detail.owner_name || '-'}` },
|
||||
{ key: 'account', label: '微博账号', children: `${detail.account_nickname || '-'} · UID ${detail.account_uid || '-'}` },
|
||||
{
|
||||
key: 'account',
|
||||
label: '微博账号',
|
||||
children: (
|
||||
<Space size={4} wrap>
|
||||
<Text
|
||||
copyable={
|
||||
detail.account_nickname || detail.account_uid
|
||||
? {
|
||||
text:
|
||||
detail.account_nickname ||
|
||||
detail.account_uid ||
|
||||
'',
|
||||
tooltips: ['复制用户名', '已复制用户名'],
|
||||
}
|
||||
: false
|
||||
}
|
||||
>
|
||||
{detail.account_nickname || '-'}
|
||||
</Text>
|
||||
{detail.account_uid && (
|
||||
<Text
|
||||
type="secondary"
|
||||
copyable={{
|
||||
text: detail.account_uid,
|
||||
tooltips: ['复制 UID', '已复制 UID'],
|
||||
}}
|
||||
>
|
||||
UID {detail.account_uid}
|
||||
</Text>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{ key: 'role', label: '绑定角色', children: detail.game_role_name || '-' },
|
||||
{ key: 'goods', label: '商品 / 所需微豆', children: `${detail.goods_name || '-'} / ${detail.required_weidou ?? '-'}` },
|
||||
{ key: 'status', label: '业务状态', children: <Tag color={STATUS_META[detail.status]?.color}>{detail.status_label}</Tag> },
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
export async function runWithConcurrency<T>(
|
||||
items: T[],
|
||||
limit: number,
|
||||
worker: (item: T) => Promise<void>,
|
||||
) {
|
||||
let nextIndex = 0;
|
||||
const workerCount = Math.min(Math.max(1, limit), items.length);
|
||||
await Promise.all(
|
||||
Array.from({ length: workerCount }, async () => {
|
||||
while (nextIndex < items.length) {
|
||||
const index = nextIndex;
|
||||
nextIndex += 1;
|
||||
await worker(items[index]);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user