Compare commits
No commits in common. "a42225953ff4d43f0e86dc49d56563d3477afc69" and "883160eaee0b3b3ee29e8d4392fab3d889c5cd2c" have entirely different histories.
a42225953f
...
883160eaee
@ -1,44 +0,0 @@
|
|||||||
import request from '@/utils/request';
|
|
||||||
|
|
||||||
function base(module) {
|
|
||||||
return `/platform/accountPool/${module}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAccountPoolList(module, params) {
|
|
||||||
return request({
|
|
||||||
url: `${base(module)}/list`,
|
|
||||||
method: 'get',
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function addAccountPool(module, data) {
|
|
||||||
return request({
|
|
||||||
url: `${base(module)}/add`,
|
|
||||||
method: 'post',
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function batchAddAccountPool(module, rows) {
|
|
||||||
return request({
|
|
||||||
url: `${base(module)}/batchAdd`,
|
|
||||||
method: 'post',
|
|
||||||
data: { rows },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAccountPoolDetail(module, id) {
|
|
||||||
return request({
|
|
||||||
url: `${base(module)}/detail/${id}`,
|
|
||||||
method: 'get',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function extractAccountPool(module, data) {
|
|
||||||
return request({
|
|
||||||
url: `${base(module)}/extract`,
|
|
||||||
method: 'post',
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -1,256 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
import { computed, reactive, watch } from 'vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
modelValue: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
mode: {
|
|
||||||
type: String,
|
|
||||||
default: 'single', // single | batch
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'submit']);
|
|
||||||
|
|
||||||
const form = reactive({
|
|
||||||
type: 'account', // account | tk | account_tk
|
|
||||||
account: '',
|
|
||||||
password: '',
|
|
||||||
token: '',
|
|
||||||
batchText: '',
|
|
||||||
remark: '',
|
|
||||||
});
|
|
||||||
|
|
||||||
const isBatch = computed(() => props.mode === 'batch');
|
|
||||||
|
|
||||||
const dialogTitle = computed(() => {
|
|
||||||
return isBatch.value ? '批量添加账号' : '添加账号';
|
|
||||||
});
|
|
||||||
|
|
||||||
const formatExample = computed(() => {
|
|
||||||
if (form.type === 'account') {
|
|
||||||
return 'account,password';
|
|
||||||
}
|
|
||||||
if (form.type === 'account_tk') {
|
|
||||||
return 'account,password,token';
|
|
||||||
}
|
|
||||||
return 'token';
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.modelValue,
|
|
||||||
(visible) => {
|
|
||||||
if (!visible) return;
|
|
||||||
resetForm();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
function closeDialog() {
|
|
||||||
emit('update:modelValue', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetForm() {
|
|
||||||
form.type = 'account';
|
|
||||||
form.account = '';
|
|
||||||
form.password = '';
|
|
||||||
form.token = '';
|
|
||||||
form.batchText = '';
|
|
||||||
form.remark = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseBatchRows() {
|
|
||||||
const rows = form.batchText
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.map((line) => line.trim())
|
|
||||||
.filter(Boolean);
|
|
||||||
|
|
||||||
const parsed = [];
|
|
||||||
const errors = [];
|
|
||||||
|
|
||||||
rows.forEach((line, index) => {
|
|
||||||
if (form.type === 'account') {
|
|
||||||
const [account, password] = line.split(',').map((x) => (x || '').trim());
|
|
||||||
if (!account || !password) {
|
|
||||||
errors.push(`第 ${index + 1} 行格式错误,应为 account,password`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
parsed.push({
|
|
||||||
type: 'account',
|
|
||||||
account,
|
|
||||||
password,
|
|
||||||
token: '',
|
|
||||||
remark: form.remark,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (form.type === 'account_tk') {
|
|
||||||
const [account, password, token] = line
|
|
||||||
.split(',')
|
|
||||||
.map((x) => (x || '').trim());
|
|
||||||
if (!account || !password || !token) {
|
|
||||||
errors.push(`第 ${index + 1} 行格式错误,应为 account,password,token`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
parsed.push({
|
|
||||||
type: 'account_tk',
|
|
||||||
account,
|
|
||||||
password,
|
|
||||||
token,
|
|
||||||
remark: form.remark,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
parsed.push({
|
|
||||||
type: 'tk',
|
|
||||||
account: '',
|
|
||||||
password: '',
|
|
||||||
token: line,
|
|
||||||
remark: form.remark,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return { parsed, errors };
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSubmit() {
|
|
||||||
if (!isBatch.value) {
|
|
||||||
if (form.type === 'account') {
|
|
||||||
if (!form.account || !form.password) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit('submit', {
|
|
||||||
mode: 'single',
|
|
||||||
rows: [
|
|
||||||
{
|
|
||||||
type: 'account',
|
|
||||||
account: form.account.trim(),
|
|
||||||
password: form.password.trim(),
|
|
||||||
token: '',
|
|
||||||
remark: form.remark.trim(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
closeDialog();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (form.type === 'account_tk') {
|
|
||||||
if (!form.account || !form.password || !form.token) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit('submit', {
|
|
||||||
mode: 'single',
|
|
||||||
rows: [
|
|
||||||
{
|
|
||||||
type: 'account_tk',
|
|
||||||
account: form.account.trim(),
|
|
||||||
password: form.password.trim(),
|
|
||||||
token: form.token.trim(),
|
|
||||||
remark: form.remark.trim(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
closeDialog();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!form.token) return;
|
|
||||||
emit('submit', {
|
|
||||||
mode: 'single',
|
|
||||||
rows: [
|
|
||||||
{
|
|
||||||
type: 'tk',
|
|
||||||
account: '',
|
|
||||||
password: '',
|
|
||||||
token: form.token.trim(),
|
|
||||||
remark: form.remark.trim(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
closeDialog();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { parsed, errors } = parseBatchRows();
|
|
||||||
if (errors.length || parsed.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit('submit', {
|
|
||||||
mode: 'batch',
|
|
||||||
rows: parsed,
|
|
||||||
});
|
|
||||||
closeDialog();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<el-dialog
|
|
||||||
:model-value="modelValue"
|
|
||||||
:title="dialogTitle"
|
|
||||||
width="640px"
|
|
||||||
@close="closeDialog"
|
|
||||||
@update:model-value="(v) => emit('update:modelValue', v)"
|
|
||||||
>
|
|
||||||
<el-form label-width="96px">
|
|
||||||
<el-form-item label="账号类型">
|
|
||||||
<el-radio-group v-model="form.type">
|
|
||||||
<el-radio value="account">账号密码</el-radio>
|
|
||||||
<el-radio value="account_tk">账号密码+Token</el-radio>
|
|
||||||
<el-radio value="tk">Token</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<template v-if="!isBatch">
|
|
||||||
<template v-if="form.type === 'account' || form.type === 'account_tk'">
|
|
||||||
<el-form-item label="账号">
|
|
||||||
<el-input v-model="form.account" placeholder="请输入账号" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="密码">
|
|
||||||
<el-input v-model="form.password" placeholder="请输入密码" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item v-if="form.type === 'account_tk'" label="Token">
|
|
||||||
<el-input
|
|
||||||
v-model="form.token"
|
|
||||||
type="textarea"
|
|
||||||
:rows="4"
|
|
||||||
placeholder="请输入 token"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
<el-form-item v-else label="Token">
|
|
||||||
<el-input
|
|
||||||
v-model="form.token"
|
|
||||||
type="textarea"
|
|
||||||
:rows="4"
|
|
||||||
placeholder="请输入 token"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<el-form-item v-else label="批量内容">
|
|
||||||
<el-input
|
|
||||||
v-model="form.batchText"
|
|
||||||
type="textarea"
|
|
||||||
:rows="12"
|
|
||||||
:placeholder="`每行一条,格式:${formatExample}`"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="备注">
|
|
||||||
<el-input v-model="form.remark" placeholder="可选备注" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="closeDialog">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit">确认</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
@ -1,462 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
import { computed, onMounted, reactive, ref, watch } from 'vue';
|
|
||||||
import { ElMessage } from 'element-plus';
|
|
||||||
import Edit from './components/edit.vue';
|
|
||||||
import {
|
|
||||||
addAccountPool,
|
|
||||||
batchAddAccountPool,
|
|
||||||
extractAccountPool,
|
|
||||||
getAccountPoolDetail,
|
|
||||||
getAccountPoolList,
|
|
||||||
} from '@/api/accountPool';
|
|
||||||
|
|
||||||
const moduleKey = 'cursor';
|
|
||||||
|
|
||||||
const loading = ref(false);
|
|
||||||
const editVisible = ref(false);
|
|
||||||
const editMode = ref('single');
|
|
||||||
const detailVisible = ref(false);
|
|
||||||
const extractVisible = ref(false);
|
|
||||||
const extractTargetRow = ref(null);
|
|
||||||
|
|
||||||
const query = reactive({
|
|
||||||
keyword: '',
|
|
||||||
status: '',
|
|
||||||
});
|
|
||||||
const activeTypeTab = ref('all');
|
|
||||||
|
|
||||||
const extractForm = reactive({
|
|
||||||
platform: 'local', // local | xianyu
|
|
||||||
type: 'account', // account | tk | account_tk
|
|
||||||
});
|
|
||||||
|
|
||||||
const detailRow = ref(null);
|
|
||||||
|
|
||||||
const tableData = ref([]);
|
|
||||||
const total = ref(0);
|
|
||||||
|
|
||||||
const selectedRows = ref([]);
|
|
||||||
const pagination = reactive({
|
|
||||||
page: 1,
|
|
||||||
pageSize: 30,
|
|
||||||
});
|
|
||||||
|
|
||||||
const pagedList = computed(() => tableData.value);
|
|
||||||
|
|
||||||
function resetQuery() {
|
|
||||||
query.keyword = '';
|
|
||||||
query.status = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
const typeTabs = computed(() => {
|
|
||||||
return [
|
|
||||||
{ label: '全部', value: 'all' },
|
|
||||||
{ label: '账号密码', value: 'account' },
|
|
||||||
{ label: '账号密码+Token', value: 'account_tk' },
|
|
||||||
{ label: 'Token', value: 'tk' },
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [query.keyword, query.status, activeTypeTab.value],
|
|
||||||
() => {
|
|
||||||
pagination.page = 1;
|
|
||||||
fetchList();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [pagination.page, pagination.pageSize],
|
|
||||||
() => {
|
|
||||||
fetchList();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
function openAddDialog(mode = 'single') {
|
|
||||||
editMode.value = mode;
|
|
||||||
editVisible.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function nowText() {
|
|
||||||
const d = new Date();
|
|
||||||
const p = (v) => String(v).padStart(2, '0');
|
|
||||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(
|
|
||||||
d.getHours()
|
|
||||||
)}:${p(d.getMinutes())}:${p(d.getSeconds())}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveRows(rows) {
|
|
||||||
if (!rows.length) return;
|
|
||||||
if (rows.length === 1) {
|
|
||||||
await addAccountPool(moduleKey, rows[0]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await batchAddAccountPool(moduleKey, rows);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleEditSubmit(payload) {
|
|
||||||
loading.value = true;
|
|
||||||
try {
|
|
||||||
await saveRows(payload.rows || []);
|
|
||||||
ElMessage.success(
|
|
||||||
payload.mode === 'batch' ? '批量添加成功' : '账号添加成功'
|
|
||||||
);
|
|
||||||
await fetchList();
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSelectionChange(rows) {
|
|
||||||
selectedRows.value = rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
function openDetail(row) {
|
|
||||||
loading.value = true;
|
|
||||||
getAccountPoolDetail(moduleKey, row.id)
|
|
||||||
.then((res) => {
|
|
||||||
if (res?.code !== 200) {
|
|
||||||
ElMessage.error(res?.msg || '获取详情失败');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
detailRow.value = normalizeRow(res.data || {});
|
|
||||||
detailVisible.value = true;
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
loading.value = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function openExtractDialog() {
|
|
||||||
extractTargetRow.value = null;
|
|
||||||
extractForm.platform = 'local';
|
|
||||||
extractForm.type = 'account';
|
|
||||||
extractVisible.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function openExtractByRow(row) {
|
|
||||||
extractTargetRow.value = row;
|
|
||||||
extractForm.platform = 'local';
|
|
||||||
extractForm.type = row.type;
|
|
||||||
extractVisible.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleExtract() {
|
|
||||||
loading.value = true;
|
|
||||||
try {
|
|
||||||
const target = extractTargetRow.value;
|
|
||||||
if (!target) {
|
|
||||||
ElMessage.warning('未找到提取目标');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const res = await extractAccountPool(moduleKey, {
|
|
||||||
id: target.id,
|
|
||||||
type: target.type,
|
|
||||||
platform: extractForm.platform,
|
|
||||||
});
|
|
||||||
if (res?.code !== 200) {
|
|
||||||
ElMessage.error(res?.msg || '提取失败');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ElMessage.success('提取成功');
|
|
||||||
extractVisible.value = false;
|
|
||||||
await fetchList();
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function markExtractForSelected() {
|
|
||||||
if (!selectedRows.value.length) {
|
|
||||||
ElMessage.warning('请先选择数据');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
loading.value = true;
|
|
||||||
Promise.all(
|
|
||||||
selectedRows.value.map((row) =>
|
|
||||||
extractAccountPool(moduleKey, {
|
|
||||||
id: row.id,
|
|
||||||
type: row.type,
|
|
||||||
platform: 'local',
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
ElMessage.success('批量提取成功');
|
|
||||||
fetchList();
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
loading.value = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function typeText(type) {
|
|
||||||
if (type === 'account') return '账号密码';
|
|
||||||
if (type === 'account_tk') return '账号密码+Token';
|
|
||||||
return 'Token';
|
|
||||||
}
|
|
||||||
|
|
||||||
function platformText(platform) {
|
|
||||||
if (!platform) return '-';
|
|
||||||
return platform === 'local' ? '本地' : '闲鱼';
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeRow(raw) {
|
|
||||||
const pick = (...keys) => {
|
|
||||||
for (const key of keys) {
|
|
||||||
if (raw?.[key] !== undefined && raw?.[key] !== null) return raw[key];
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
};
|
|
||||||
return {
|
|
||||||
id: pick('id', 'Id'),
|
|
||||||
type: pick('data_type', 'dataType', 'type'),
|
|
||||||
account: pick('account', 'Account'),
|
|
||||||
password: pick('password', 'Password'),
|
|
||||||
token: pick('token', 'Token'),
|
|
||||||
remark: pick('remark', 'Remark'),
|
|
||||||
extracted: Number(pick('is_extracted', 'isExtracted')) === 1 || !!pick('extracted'),
|
|
||||||
extractedAt: pick('extracted_time', 'extracted_at', 'extractedAt'),
|
|
||||||
extractedPlatform: pick('extracted_platform', 'extractedPlatform'),
|
|
||||||
createdAt: pick('create_time', 'created_at', 'createdAt'),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchList() {
|
|
||||||
loading.value = true;
|
|
||||||
try {
|
|
||||||
const res = await getAccountPoolList(moduleKey, {
|
|
||||||
page: pagination.page,
|
|
||||||
pageSize: pagination.pageSize,
|
|
||||||
keyword: query.keyword || undefined,
|
|
||||||
status: query.status || undefined,
|
|
||||||
type: activeTypeTab.value === 'all' ? undefined : activeTypeTab.value,
|
|
||||||
});
|
|
||||||
if (res?.code !== 200) {
|
|
||||||
ElMessage.error(res?.msg || '获取列表失败');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const list = Array.isArray(res?.data?.list) ? res.data.list : [];
|
|
||||||
tableData.value = list.map(normalizeRow);
|
|
||||||
total.value = Number(res?.data?.total || 0);
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
fetchList();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="account-pool-page">
|
|
||||||
<el-card shadow="never">
|
|
||||||
<template #header>
|
|
||||||
<div class="card-header">
|
|
||||||
<span>号池管理(Cursor)</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<div class="toolbar">
|
|
||||||
<div class="toolbar-left">
|
|
||||||
<el-input
|
|
||||||
v-model="query.keyword"
|
|
||||||
placeholder="搜索账号 / token / 备注"
|
|
||||||
clearable
|
|
||||||
class="w-260"
|
|
||||||
/>
|
|
||||||
<el-select v-model="query.status" placeholder="提取状态" clearable class="w-140">
|
|
||||||
<el-option label="未提取" value="unused" />
|
|
||||||
<el-option label="已提取" value="extracted" />
|
|
||||||
</el-select>
|
|
||||||
<el-button @click="resetQuery">重置</el-button>
|
|
||||||
</div>
|
|
||||||
<div class="toolbar-right">
|
|
||||||
<el-button type="primary" @click="openAddDialog('single')">添加账号</el-button>
|
|
||||||
<el-button type="success" @click="openAddDialog('batch')">批量添加</el-button>
|
|
||||||
<el-button @click="markExtractForSelected">批量标记提取</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-tabs v-model="activeTypeTab" class="type-tabs">
|
|
||||||
<el-tab-pane
|
|
||||||
v-for="tab in typeTabs"
|
|
||||||
:key="tab.value"
|
|
||||||
:label="tab.label"
|
|
||||||
:name="tab.value"
|
|
||||||
/>
|
|
||||||
</el-tabs>
|
|
||||||
|
|
||||||
<el-table
|
|
||||||
:data="pagedList"
|
|
||||||
border
|
|
||||||
stripe
|
|
||||||
style="width: 100%"
|
|
||||||
:loading="loading"
|
|
||||||
@selection-change="handleSelectionChange"
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="52" />
|
|
||||||
<el-table-column prop="id" label="ID" width="80" />
|
|
||||||
<el-table-column label="账号类型" width="160" align="center">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag>{{ typeText(row.type) }}</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="account" label="账号" min-width="180" />
|
|
||||||
<el-table-column label="密码/Token" min-width="240">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<span v-if="row.type === 'account'">
|
|
||||||
{{ row.password || '-' }}
|
|
||||||
</span>
|
|
||||||
<span v-else-if="row.type === 'account_tk'">
|
|
||||||
{{ `${row.password || '-'} / ${row.token || '-'}` }}
|
|
||||||
</span>
|
|
||||||
<span v-else>{{ row.token || '-' }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="remark" label="备注" min-width="140" />
|
|
||||||
<el-table-column label="提取状态" width="100">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag :type="row.extracted ? 'success' : 'info'">
|
|
||||||
{{ row.extracted ? '已提取' : '未提取' }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="extractedAt" label="提取时间" width="180" />
|
|
||||||
<el-table-column label="提取平台" width="120">
|
|
||||||
<template #default="{ row }">
|
|
||||||
{{ platformText(row.extractedPlatform) }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" width="180" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button link type="primary" @click="openDetail(row)">详情</el-button>
|
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="warning"
|
|
||||||
:disabled="row.extracted"
|
|
||||||
@click="openExtractByRow(row)"
|
|
||||||
>
|
|
||||||
提取
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<div class="pagination-wrap">
|
|
||||||
<el-pagination
|
|
||||||
v-model:current-page="pagination.page"
|
|
||||||
v-model:page-size="pagination.pageSize"
|
|
||||||
background
|
|
||||||
layout="total, prev, pager, next, jumper"
|
|
||||||
:page-sizes="[30, 50, 100]"
|
|
||||||
:total="total"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
|
|
||||||
<Edit v-model="editVisible" :mode="editMode" @submit="handleEditSubmit" />
|
|
||||||
|
|
||||||
<el-dialog v-model="detailVisible" title="账号详情" width="560px">
|
|
||||||
<el-descriptions :column="1" border v-if="detailRow">
|
|
||||||
<el-descriptions-item label="ID">{{ detailRow.id }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="账号类型">
|
|
||||||
{{ typeText(detailRow.type) }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="账号">
|
|
||||||
{{ detailRow.account || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="密码">
|
|
||||||
{{ detailRow.password || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="Token">
|
|
||||||
{{ detailRow.token || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="提取状态">
|
|
||||||
{{ detailRow.extracted ? '已提取' : '未提取' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="提取时间">
|
|
||||||
{{ detailRow.extractedAt || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="提取平台">
|
|
||||||
{{ platformText(detailRow.extractedPlatform) }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="备注">
|
|
||||||
{{ detailRow.remark || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
<el-dialog v-model="extractVisible" title="提取账号" width="420px">
|
|
||||||
<el-form label-width="84px">
|
|
||||||
<el-form-item label="提取类型">
|
|
||||||
<el-input :model-value="typeText(extractForm.type)" disabled />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="提取平台">
|
|
||||||
<el-radio-group v-model="extractForm.platform">
|
|
||||||
<el-radio value="local">本地</el-radio>
|
|
||||||
<el-radio value="xianyu">闲鱼</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="extractVisible = false">取消</el-button>
|
|
||||||
<el-button type="primary" :loading="loading" @click="handleExtract">
|
|
||||||
确认提取
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.account-pool-page {
|
|
||||||
padding: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toolbar {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toolbar-left,
|
|
||||||
.toolbar-right {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-260 {
|
|
||||||
width: 260px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-140 {
|
|
||||||
width: 140px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-180 {
|
|
||||||
width: 180px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.type-tabs {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pagination-wrap {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-top: 14px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<router-view />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@ -1,256 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
import { computed, reactive, watch } from 'vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
modelValue: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
mode: {
|
|
||||||
type: String,
|
|
||||||
default: 'single', // single | batch
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'submit']);
|
|
||||||
|
|
||||||
const form = reactive({
|
|
||||||
type: 'account', // account | tk | account_tk
|
|
||||||
account: '',
|
|
||||||
password: '',
|
|
||||||
token: '',
|
|
||||||
batchText: '',
|
|
||||||
remark: '',
|
|
||||||
});
|
|
||||||
|
|
||||||
const isBatch = computed(() => props.mode === 'batch');
|
|
||||||
|
|
||||||
const dialogTitle = computed(() => {
|
|
||||||
return isBatch.value ? '批量添加账号' : '添加账号';
|
|
||||||
});
|
|
||||||
|
|
||||||
const formatExample = computed(() => {
|
|
||||||
if (form.type === 'account') {
|
|
||||||
return 'account,password';
|
|
||||||
}
|
|
||||||
if (form.type === 'account_tk') {
|
|
||||||
return 'account,password,token';
|
|
||||||
}
|
|
||||||
return 'token';
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.modelValue,
|
|
||||||
(visible) => {
|
|
||||||
if (!visible) return;
|
|
||||||
resetForm();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
function closeDialog() {
|
|
||||||
emit('update:modelValue', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetForm() {
|
|
||||||
form.type = 'account';
|
|
||||||
form.account = '';
|
|
||||||
form.password = '';
|
|
||||||
form.token = '';
|
|
||||||
form.batchText = '';
|
|
||||||
form.remark = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseBatchRows() {
|
|
||||||
const rows = form.batchText
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.map((line) => line.trim())
|
|
||||||
.filter(Boolean);
|
|
||||||
|
|
||||||
const parsed = [];
|
|
||||||
const errors = [];
|
|
||||||
|
|
||||||
rows.forEach((line, index) => {
|
|
||||||
if (form.type === 'account') {
|
|
||||||
const [account, password] = line.split(',').map((x) => (x || '').trim());
|
|
||||||
if (!account || !password) {
|
|
||||||
errors.push(`第 ${index + 1} 行格式错误,应为 account,password`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
parsed.push({
|
|
||||||
type: 'account',
|
|
||||||
account,
|
|
||||||
password,
|
|
||||||
token: '',
|
|
||||||
remark: form.remark,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (form.type === 'account_tk') {
|
|
||||||
const [account, password, token] = line
|
|
||||||
.split(',')
|
|
||||||
.map((x) => (x || '').trim());
|
|
||||||
if (!account || !password || !token) {
|
|
||||||
errors.push(`第 ${index + 1} 行格式错误,应为 account,password,token`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
parsed.push({
|
|
||||||
type: 'account_tk',
|
|
||||||
account,
|
|
||||||
password,
|
|
||||||
token,
|
|
||||||
remark: form.remark,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
parsed.push({
|
|
||||||
type: 'tk',
|
|
||||||
account: '',
|
|
||||||
password: '',
|
|
||||||
token: line,
|
|
||||||
remark: form.remark,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return { parsed, errors };
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSubmit() {
|
|
||||||
if (!isBatch.value) {
|
|
||||||
if (form.type === 'account') {
|
|
||||||
if (!form.account || !form.password) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit('submit', {
|
|
||||||
mode: 'single',
|
|
||||||
rows: [
|
|
||||||
{
|
|
||||||
type: 'account',
|
|
||||||
account: form.account.trim(),
|
|
||||||
password: form.password.trim(),
|
|
||||||
token: '',
|
|
||||||
remark: form.remark.trim(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
closeDialog();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (form.type === 'account_tk') {
|
|
||||||
if (!form.account || !form.password || !form.token) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit('submit', {
|
|
||||||
mode: 'single',
|
|
||||||
rows: [
|
|
||||||
{
|
|
||||||
type: 'account_tk',
|
|
||||||
account: form.account.trim(),
|
|
||||||
password: form.password.trim(),
|
|
||||||
token: form.token.trim(),
|
|
||||||
remark: form.remark.trim(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
closeDialog();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!form.token) return;
|
|
||||||
emit('submit', {
|
|
||||||
mode: 'single',
|
|
||||||
rows: [
|
|
||||||
{
|
|
||||||
type: 'tk',
|
|
||||||
account: '',
|
|
||||||
password: '',
|
|
||||||
token: form.token.trim(),
|
|
||||||
remark: form.remark.trim(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
closeDialog();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { parsed, errors } = parseBatchRows();
|
|
||||||
if (errors.length || parsed.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit('submit', {
|
|
||||||
mode: 'batch',
|
|
||||||
rows: parsed,
|
|
||||||
});
|
|
||||||
closeDialog();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<el-dialog
|
|
||||||
:model-value="modelValue"
|
|
||||||
:title="dialogTitle"
|
|
||||||
width="640px"
|
|
||||||
@close="closeDialog"
|
|
||||||
@update:model-value="(v) => emit('update:modelValue', v)"
|
|
||||||
>
|
|
||||||
<el-form label-width="96px">
|
|
||||||
<el-form-item label="账号类型">
|
|
||||||
<el-radio-group v-model="form.type">
|
|
||||||
<el-radio value="account">账号密码</el-radio>
|
|
||||||
<el-radio value="account_tk">账号密码+Token</el-radio>
|
|
||||||
<el-radio value="tk">Token</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<template v-if="!isBatch">
|
|
||||||
<template v-if="form.type === 'account' || form.type === 'account_tk'">
|
|
||||||
<el-form-item label="账号">
|
|
||||||
<el-input v-model="form.account" placeholder="请输入账号" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="密码">
|
|
||||||
<el-input v-model="form.password" placeholder="请输入密码" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item v-if="form.type === 'account_tk'" label="Token">
|
|
||||||
<el-input
|
|
||||||
v-model="form.token"
|
|
||||||
type="textarea"
|
|
||||||
:rows="4"
|
|
||||||
placeholder="请输入 token"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
<el-form-item v-else label="Token">
|
|
||||||
<el-input
|
|
||||||
v-model="form.token"
|
|
||||||
type="textarea"
|
|
||||||
:rows="4"
|
|
||||||
placeholder="请输入 token"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<el-form-item v-else label="批量内容">
|
|
||||||
<el-input
|
|
||||||
v-model="form.batchText"
|
|
||||||
type="textarea"
|
|
||||||
:rows="12"
|
|
||||||
:placeholder="`每行一条,格式:${formatExample}`"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="备注">
|
|
||||||
<el-input v-model="form.remark" placeholder="可选备注" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="closeDialog">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit">确认</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
@ -1,443 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
import { computed, onMounted, reactive, ref, watch } from 'vue';
|
|
||||||
import { ElMessage } from 'element-plus';
|
|
||||||
import Edit from './components/edit.vue';
|
|
||||||
import {
|
|
||||||
addAccountPool,
|
|
||||||
batchAddAccountPool,
|
|
||||||
extractAccountPool,
|
|
||||||
getAccountPoolDetail,
|
|
||||||
getAccountPoolList,
|
|
||||||
} from '@/api/accountPool';
|
|
||||||
|
|
||||||
const moduleKey = 'krio';
|
|
||||||
|
|
||||||
const loading = ref(false);
|
|
||||||
const editVisible = ref(false);
|
|
||||||
const editMode = ref('single');
|
|
||||||
const detailVisible = ref(false);
|
|
||||||
const extractVisible = ref(false);
|
|
||||||
const extractTargetRow = ref(null);
|
|
||||||
|
|
||||||
const query = reactive({
|
|
||||||
keyword: '',
|
|
||||||
status: '',
|
|
||||||
});
|
|
||||||
const activeTypeTab = ref('all');
|
|
||||||
|
|
||||||
const extractForm = reactive({
|
|
||||||
platform: 'local', // local | xianyu
|
|
||||||
type: 'account', // account | tk | account_tk
|
|
||||||
});
|
|
||||||
|
|
||||||
const detailRow = ref(null);
|
|
||||||
|
|
||||||
const tableData = ref([]);
|
|
||||||
const total = ref(0);
|
|
||||||
|
|
||||||
const selectedRows = ref([]);
|
|
||||||
const pagination = reactive({
|
|
||||||
page: 1,
|
|
||||||
pageSize: 30,
|
|
||||||
});
|
|
||||||
|
|
||||||
const pagedList = computed(() => tableData.value);
|
|
||||||
|
|
||||||
function resetQuery() {
|
|
||||||
query.keyword = '';
|
|
||||||
query.status = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
const typeTabs = computed(() => {
|
|
||||||
return [
|
|
||||||
{ label: '全部', value: 'all' },
|
|
||||||
{ label: '账号密码', value: 'account' },
|
|
||||||
{ label: '账号密码+Token', value: 'account_tk' },
|
|
||||||
{ label: 'Token', value: 'tk' },
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [query.keyword, query.status, activeTypeTab.value],
|
|
||||||
() => {
|
|
||||||
pagination.page = 1;
|
|
||||||
fetchList();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [pagination.page, pagination.pageSize],
|
|
||||||
() => {
|
|
||||||
fetchList();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
function openAddDialog(mode = 'single') {
|
|
||||||
editMode.value = mode;
|
|
||||||
editVisible.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveRows(rows) {
|
|
||||||
if (!rows.length) return;
|
|
||||||
if (rows.length === 1) {
|
|
||||||
await addAccountPool(moduleKey, rows[0]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await batchAddAccountPool(moduleKey, rows);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleEditSubmit(payload) {
|
|
||||||
loading.value = true;
|
|
||||||
try {
|
|
||||||
await saveRows(payload.rows || []);
|
|
||||||
ElMessage.success(
|
|
||||||
payload.mode === 'batch' ? '批量添加成功' : '账号添加成功'
|
|
||||||
);
|
|
||||||
await fetchList();
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSelectionChange(rows) {
|
|
||||||
selectedRows.value = rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
function openDetail(row) {
|
|
||||||
loading.value = true;
|
|
||||||
getAccountPoolDetail(moduleKey, row.id)
|
|
||||||
.then((res) => {
|
|
||||||
if (res?.code !== 200) {
|
|
||||||
ElMessage.error(res?.msg || '获取详情失败');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
detailRow.value = normalizeRow(res.data || {});
|
|
||||||
detailVisible.value = true;
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
loading.value = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function openExtractByRow(row) {
|
|
||||||
extractTargetRow.value = row;
|
|
||||||
extractForm.platform = 'local';
|
|
||||||
extractForm.type = row.type;
|
|
||||||
extractVisible.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleExtract() {
|
|
||||||
loading.value = true;
|
|
||||||
try {
|
|
||||||
const target = extractTargetRow.value;
|
|
||||||
if (!target) {
|
|
||||||
ElMessage.warning('未找到提取目标');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const res = await extractAccountPool(moduleKey, {
|
|
||||||
id: target.id,
|
|
||||||
type: target.type,
|
|
||||||
platform: extractForm.platform,
|
|
||||||
});
|
|
||||||
if (res?.code !== 200) {
|
|
||||||
ElMessage.error(res?.msg || '提取失败');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ElMessage.success('提取成功');
|
|
||||||
extractVisible.value = false;
|
|
||||||
await fetchList();
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function markExtractForSelected() {
|
|
||||||
if (!selectedRows.value.length) {
|
|
||||||
ElMessage.warning('请先选择数据');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
loading.value = true;
|
|
||||||
Promise.all(
|
|
||||||
selectedRows.value.map((row) =>
|
|
||||||
extractAccountPool(moduleKey, {
|
|
||||||
id: row.id,
|
|
||||||
type: row.type,
|
|
||||||
platform: 'local',
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
ElMessage.success('批量提取成功');
|
|
||||||
fetchList();
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
loading.value = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function typeText(type) {
|
|
||||||
if (type === 'account') return '账号密码';
|
|
||||||
if (type === 'account_tk') return '账号密码+Token';
|
|
||||||
return 'Token';
|
|
||||||
}
|
|
||||||
|
|
||||||
function platformText(platform) {
|
|
||||||
if (!platform) return '-';
|
|
||||||
return platform === 'local' ? '本地' : '闲鱼';
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeRow(raw) {
|
|
||||||
const pick = (...keys) => {
|
|
||||||
for (const key of keys) {
|
|
||||||
if (raw?.[key] !== undefined && raw?.[key] !== null) return raw[key];
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
};
|
|
||||||
return {
|
|
||||||
id: pick('id', 'Id'),
|
|
||||||
type: pick('data_type', 'dataType', 'type'),
|
|
||||||
account: pick('account', 'Account'),
|
|
||||||
password: pick('password', 'Password'),
|
|
||||||
token: pick('token', 'Token'),
|
|
||||||
remark: pick('remark', 'Remark'),
|
|
||||||
extracted: Number(pick('is_extracted', 'isExtracted')) === 1 || !!pick('extracted'),
|
|
||||||
extractedAt: pick('extracted_time', 'extracted_at', 'extractedAt'),
|
|
||||||
extractedPlatform: pick('extracted_platform', 'extractedPlatform'),
|
|
||||||
createdAt: pick('create_time', 'created_at', 'createdAt'),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchList() {
|
|
||||||
loading.value = true;
|
|
||||||
try {
|
|
||||||
const res = await getAccountPoolList(moduleKey, {
|
|
||||||
page: pagination.page,
|
|
||||||
pageSize: pagination.pageSize,
|
|
||||||
keyword: query.keyword || undefined,
|
|
||||||
status: query.status || undefined,
|
|
||||||
type: activeTypeTab.value === 'all' ? undefined : activeTypeTab.value,
|
|
||||||
});
|
|
||||||
if (res?.code !== 200) {
|
|
||||||
ElMessage.error(res?.msg || '获取列表失败');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const list = Array.isArray(res?.data?.list) ? res.data.list : [];
|
|
||||||
tableData.value = list.map(normalizeRow);
|
|
||||||
total.value = Number(res?.data?.total || 0);
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
fetchList();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="account-pool-page">
|
|
||||||
<el-card shadow="never">
|
|
||||||
<template #header>
|
|
||||||
<div class="card-header">
|
|
||||||
<span>号池管理(Kiro)</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<div class="toolbar">
|
|
||||||
<div class="toolbar-left">
|
|
||||||
<el-input
|
|
||||||
v-model="query.keyword"
|
|
||||||
placeholder="搜索账号 / token / 备注"
|
|
||||||
clearable
|
|
||||||
class="w-260"
|
|
||||||
/>
|
|
||||||
<el-select v-model="query.status" placeholder="提取状态" clearable class="w-140">
|
|
||||||
<el-option label="未提取" value="unused" />
|
|
||||||
<el-option label="已提取" value="extracted" />
|
|
||||||
</el-select>
|
|
||||||
<el-button @click="resetQuery">重置</el-button>
|
|
||||||
</div>
|
|
||||||
<div class="toolbar-right">
|
|
||||||
<el-button type="primary" @click="openAddDialog('single')">添加账号</el-button>
|
|
||||||
<el-button type="success" @click="openAddDialog('batch')">批量添加</el-button>
|
|
||||||
<el-button @click="markExtractForSelected">批量标记提取</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-tabs v-model="activeTypeTab" class="type-tabs">
|
|
||||||
<el-tab-pane
|
|
||||||
v-for="tab in typeTabs"
|
|
||||||
:key="tab.value"
|
|
||||||
:label="tab.label"
|
|
||||||
:name="tab.value"
|
|
||||||
/>
|
|
||||||
</el-tabs>
|
|
||||||
|
|
||||||
<el-table
|
|
||||||
:data="pagedList"
|
|
||||||
border
|
|
||||||
stripe
|
|
||||||
style="width: 100%"
|
|
||||||
:loading="loading"
|
|
||||||
@selection-change="handleSelectionChange"
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="52" />
|
|
||||||
<el-table-column prop="id" label="ID" width="80" />
|
|
||||||
<el-table-column label="账号类型" width="160" align="center">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag>{{ typeText(row.type) }}</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="account" label="账号" min-width="180" />
|
|
||||||
<el-table-column label="密码/Token" min-width="240">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<span v-if="row.type === 'account'">
|
|
||||||
{{ row.password || '-' }}
|
|
||||||
</span>
|
|
||||||
<span v-else-if="row.type === 'account_tk'">
|
|
||||||
{{ `${row.password || '-'} / ${row.token || '-'}` }}
|
|
||||||
</span>
|
|
||||||
<span v-else>{{ row.token || '-' }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="remark" label="备注" min-width="140" />
|
|
||||||
<el-table-column label="提取状态" width="100">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag :type="row.extracted ? 'success' : 'info'">
|
|
||||||
{{ row.extracted ? '已提取' : '未提取' }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="extractedAt" label="提取时间" width="180" />
|
|
||||||
<el-table-column label="提取平台" width="120">
|
|
||||||
<template #default="{ row }">
|
|
||||||
{{ platformText(row.extractedPlatform) }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" width="180" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button link type="primary" @click="openDetail(row)">详情</el-button>
|
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="warning"
|
|
||||||
:disabled="row.extracted"
|
|
||||||
@click="openExtractByRow(row)"
|
|
||||||
>
|
|
||||||
提取
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<div class="pagination-wrap">
|
|
||||||
<el-pagination
|
|
||||||
v-model:current-page="pagination.page"
|
|
||||||
v-model:page-size="pagination.pageSize"
|
|
||||||
background
|
|
||||||
layout="total, prev, pager, next, jumper"
|
|
||||||
:page-sizes="[30, 50, 100]"
|
|
||||||
:total="total"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
|
|
||||||
<Edit v-model="editVisible" :mode="editMode" @submit="handleEditSubmit" />
|
|
||||||
|
|
||||||
<el-dialog v-model="detailVisible" title="账号详情" width="560px">
|
|
||||||
<el-descriptions :column="1" border v-if="detailRow">
|
|
||||||
<el-descriptions-item label="ID">{{ detailRow.id }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="账号类型">
|
|
||||||
{{ typeText(detailRow.type) }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="账号">
|
|
||||||
{{ detailRow.account || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="密码">
|
|
||||||
{{ detailRow.password || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="Token">
|
|
||||||
{{ detailRow.token || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="提取状态">
|
|
||||||
{{ detailRow.extracted ? '已提取' : '未提取' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="提取时间">
|
|
||||||
{{ detailRow.extractedAt || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="提取平台">
|
|
||||||
{{ platformText(detailRow.extractedPlatform) }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="备注">
|
|
||||||
{{ detailRow.remark || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
<el-dialog v-model="extractVisible" title="提取账号" width="420px">
|
|
||||||
<el-form label-width="84px">
|
|
||||||
<el-form-item label="提取类型">
|
|
||||||
<el-input :model-value="typeText(extractForm.type)" disabled />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="提取平台">
|
|
||||||
<el-radio-group v-model="extractForm.platform">
|
|
||||||
<el-radio value="local">本地</el-radio>
|
|
||||||
<el-radio value="xianyu">闲鱼</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="extractVisible = false">取消</el-button>
|
|
||||||
<el-button type="primary" :loading="loading" @click="handleExtract">
|
|
||||||
确认提取
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.account-pool-page {
|
|
||||||
padding: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toolbar {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toolbar-left,
|
|
||||||
.toolbar-right {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-260 {
|
|
||||||
width: 260px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-140 {
|
|
||||||
width: 140px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.type-tabs {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pagination-wrap {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-top: 14px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -1,256 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
import { computed, reactive, watch } from 'vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
modelValue: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
mode: {
|
|
||||||
type: String,
|
|
||||||
default: 'single', // single | batch
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'submit']);
|
|
||||||
|
|
||||||
const form = reactive({
|
|
||||||
type: 'account', // account | tk | account_tk
|
|
||||||
account: '',
|
|
||||||
password: '',
|
|
||||||
token: '',
|
|
||||||
batchText: '',
|
|
||||||
remark: '',
|
|
||||||
});
|
|
||||||
|
|
||||||
const isBatch = computed(() => props.mode === 'batch');
|
|
||||||
|
|
||||||
const dialogTitle = computed(() => {
|
|
||||||
return isBatch.value ? '批量添加账号' : '添加账号';
|
|
||||||
});
|
|
||||||
|
|
||||||
const formatExample = computed(() => {
|
|
||||||
if (form.type === 'account') {
|
|
||||||
return 'account,password';
|
|
||||||
}
|
|
||||||
if (form.type === 'account_tk') {
|
|
||||||
return 'account,password,token';
|
|
||||||
}
|
|
||||||
return 'token';
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.modelValue,
|
|
||||||
(visible) => {
|
|
||||||
if (!visible) return;
|
|
||||||
resetForm();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
function closeDialog() {
|
|
||||||
emit('update:modelValue', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetForm() {
|
|
||||||
form.type = 'account';
|
|
||||||
form.account = '';
|
|
||||||
form.password = '';
|
|
||||||
form.token = '';
|
|
||||||
form.batchText = '';
|
|
||||||
form.remark = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseBatchRows() {
|
|
||||||
const rows = form.batchText
|
|
||||||
.split(/\r?\n/)
|
|
||||||
.map((line) => line.trim())
|
|
||||||
.filter(Boolean);
|
|
||||||
|
|
||||||
const parsed = [];
|
|
||||||
const errors = [];
|
|
||||||
|
|
||||||
rows.forEach((line, index) => {
|
|
||||||
if (form.type === 'account') {
|
|
||||||
const [account, password] = line.split(',').map((x) => (x || '').trim());
|
|
||||||
if (!account || !password) {
|
|
||||||
errors.push(`第 ${index + 1} 行格式错误,应为 account,password`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
parsed.push({
|
|
||||||
type: 'account',
|
|
||||||
account,
|
|
||||||
password,
|
|
||||||
token: '',
|
|
||||||
remark: form.remark,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (form.type === 'account_tk') {
|
|
||||||
const [account, password, token] = line
|
|
||||||
.split(',')
|
|
||||||
.map((x) => (x || '').trim());
|
|
||||||
if (!account || !password || !token) {
|
|
||||||
errors.push(`第 ${index + 1} 行格式错误,应为 account,password,token`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
parsed.push({
|
|
||||||
type: 'account_tk',
|
|
||||||
account,
|
|
||||||
password,
|
|
||||||
token,
|
|
||||||
remark: form.remark,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
parsed.push({
|
|
||||||
type: 'tk',
|
|
||||||
account: '',
|
|
||||||
password: '',
|
|
||||||
token: line,
|
|
||||||
remark: form.remark,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return { parsed, errors };
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSubmit() {
|
|
||||||
if (!isBatch.value) {
|
|
||||||
if (form.type === 'account') {
|
|
||||||
if (!form.account || !form.password) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit('submit', {
|
|
||||||
mode: 'single',
|
|
||||||
rows: [
|
|
||||||
{
|
|
||||||
type: 'account',
|
|
||||||
account: form.account.trim(),
|
|
||||||
password: form.password.trim(),
|
|
||||||
token: '',
|
|
||||||
remark: form.remark.trim(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
closeDialog();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (form.type === 'account_tk') {
|
|
||||||
if (!form.account || !form.password || !form.token) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit('submit', {
|
|
||||||
mode: 'single',
|
|
||||||
rows: [
|
|
||||||
{
|
|
||||||
type: 'account_tk',
|
|
||||||
account: form.account.trim(),
|
|
||||||
password: form.password.trim(),
|
|
||||||
token: form.token.trim(),
|
|
||||||
remark: form.remark.trim(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
closeDialog();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!form.token) return;
|
|
||||||
emit('submit', {
|
|
||||||
mode: 'single',
|
|
||||||
rows: [
|
|
||||||
{
|
|
||||||
type: 'tk',
|
|
||||||
account: '',
|
|
||||||
password: '',
|
|
||||||
token: form.token.trim(),
|
|
||||||
remark: form.remark.trim(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
closeDialog();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { parsed, errors } = parseBatchRows();
|
|
||||||
if (errors.length || parsed.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit('submit', {
|
|
||||||
mode: 'batch',
|
|
||||||
rows: parsed,
|
|
||||||
});
|
|
||||||
closeDialog();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<el-dialog
|
|
||||||
:model-value="modelValue"
|
|
||||||
:title="dialogTitle"
|
|
||||||
width="640px"
|
|
||||||
@close="closeDialog"
|
|
||||||
@update:model-value="(v) => emit('update:modelValue', v)"
|
|
||||||
>
|
|
||||||
<el-form label-width="96px">
|
|
||||||
<el-form-item label="账号类型">
|
|
||||||
<el-radio-group v-model="form.type">
|
|
||||||
<el-radio value="account">账号密码</el-radio>
|
|
||||||
<el-radio value="account_tk">账号密码+Token</el-radio>
|
|
||||||
<el-radio value="tk">Token</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<template v-if="!isBatch">
|
|
||||||
<template v-if="form.type === 'account' || form.type === 'account_tk'">
|
|
||||||
<el-form-item label="账号">
|
|
||||||
<el-input v-model="form.account" placeholder="请输入账号" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="密码">
|
|
||||||
<el-input v-model="form.password" placeholder="请输入密码" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item v-if="form.type === 'account_tk'" label="Token">
|
|
||||||
<el-input
|
|
||||||
v-model="form.token"
|
|
||||||
type="textarea"
|
|
||||||
:rows="4"
|
|
||||||
placeholder="请输入 token"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
<el-form-item v-else label="Token">
|
|
||||||
<el-input
|
|
||||||
v-model="form.token"
|
|
||||||
type="textarea"
|
|
||||||
:rows="4"
|
|
||||||
placeholder="请输入 token"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<el-form-item v-else label="批量内容">
|
|
||||||
<el-input
|
|
||||||
v-model="form.batchText"
|
|
||||||
type="textarea"
|
|
||||||
:rows="12"
|
|
||||||
:placeholder="`每行一条,格式:${formatExample}`"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="备注">
|
|
||||||
<el-input v-model="form.remark" placeholder="可选备注" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="closeDialog">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit">确认</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
@ -1,443 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
import { computed, onMounted, reactive, ref, watch } from 'vue';
|
|
||||||
import { ElMessage } from 'element-plus';
|
|
||||||
import Edit from './components/edit.vue';
|
|
||||||
import {
|
|
||||||
addAccountPool,
|
|
||||||
batchAddAccountPool,
|
|
||||||
extractAccountPool,
|
|
||||||
getAccountPoolDetail,
|
|
||||||
getAccountPoolList,
|
|
||||||
} from '@/api/accountPool';
|
|
||||||
|
|
||||||
const moduleKey = 'windsurf';
|
|
||||||
|
|
||||||
const loading = ref(false);
|
|
||||||
const editVisible = ref(false);
|
|
||||||
const editMode = ref('single');
|
|
||||||
const detailVisible = ref(false);
|
|
||||||
const extractVisible = ref(false);
|
|
||||||
const extractTargetRow = ref(null);
|
|
||||||
|
|
||||||
const query = reactive({
|
|
||||||
keyword: '',
|
|
||||||
status: '',
|
|
||||||
});
|
|
||||||
const activeTypeTab = ref('all');
|
|
||||||
|
|
||||||
const extractForm = reactive({
|
|
||||||
platform: 'local', // local | xianyu
|
|
||||||
type: 'account', // account | tk | account_tk
|
|
||||||
});
|
|
||||||
|
|
||||||
const detailRow = ref(null);
|
|
||||||
|
|
||||||
const tableData = ref([]);
|
|
||||||
const total = ref(0);
|
|
||||||
|
|
||||||
const selectedRows = ref([]);
|
|
||||||
const pagination = reactive({
|
|
||||||
page: 1,
|
|
||||||
pageSize: 30,
|
|
||||||
});
|
|
||||||
|
|
||||||
const pagedList = computed(() => tableData.value);
|
|
||||||
|
|
||||||
function resetQuery() {
|
|
||||||
query.keyword = '';
|
|
||||||
query.status = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
const typeTabs = computed(() => {
|
|
||||||
return [
|
|
||||||
{ label: '全部', value: 'all' },
|
|
||||||
{ label: '账号密码', value: 'account' },
|
|
||||||
{ label: '账号密码+Token', value: 'account_tk' },
|
|
||||||
{ label: 'Token', value: 'tk' },
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [query.keyword, query.status, activeTypeTab.value],
|
|
||||||
() => {
|
|
||||||
pagination.page = 1;
|
|
||||||
fetchList();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [pagination.page, pagination.pageSize],
|
|
||||||
() => {
|
|
||||||
fetchList();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
function openAddDialog(mode = 'single') {
|
|
||||||
editMode.value = mode;
|
|
||||||
editVisible.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveRows(rows) {
|
|
||||||
if (!rows.length) return;
|
|
||||||
if (rows.length === 1) {
|
|
||||||
await addAccountPool(moduleKey, rows[0]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await batchAddAccountPool(moduleKey, rows);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleEditSubmit(payload) {
|
|
||||||
loading.value = true;
|
|
||||||
try {
|
|
||||||
await saveRows(payload.rows || []);
|
|
||||||
ElMessage.success(
|
|
||||||
payload.mode === 'batch' ? '批量添加成功' : '账号添加成功'
|
|
||||||
);
|
|
||||||
await fetchList();
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSelectionChange(rows) {
|
|
||||||
selectedRows.value = rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
function openDetail(row) {
|
|
||||||
loading.value = true;
|
|
||||||
getAccountPoolDetail(moduleKey, row.id)
|
|
||||||
.then((res) => {
|
|
||||||
if (res?.code !== 200) {
|
|
||||||
ElMessage.error(res?.msg || '获取详情失败');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
detailRow.value = normalizeRow(res.data || {});
|
|
||||||
detailVisible.value = true;
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
loading.value = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function openExtractByRow(row) {
|
|
||||||
extractTargetRow.value = row;
|
|
||||||
extractForm.platform = 'local';
|
|
||||||
extractForm.type = row.type;
|
|
||||||
extractVisible.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleExtract() {
|
|
||||||
loading.value = true;
|
|
||||||
try {
|
|
||||||
const target = extractTargetRow.value;
|
|
||||||
if (!target) {
|
|
||||||
ElMessage.warning('未找到提取目标');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const res = await extractAccountPool(moduleKey, {
|
|
||||||
id: target.id,
|
|
||||||
type: target.type,
|
|
||||||
platform: extractForm.platform,
|
|
||||||
});
|
|
||||||
if (res?.code !== 200) {
|
|
||||||
ElMessage.error(res?.msg || '提取失败');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ElMessage.success('提取成功');
|
|
||||||
extractVisible.value = false;
|
|
||||||
await fetchList();
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function markExtractForSelected() {
|
|
||||||
if (!selectedRows.value.length) {
|
|
||||||
ElMessage.warning('请先选择数据');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
loading.value = true;
|
|
||||||
Promise.all(
|
|
||||||
selectedRows.value.map((row) =>
|
|
||||||
extractAccountPool(moduleKey, {
|
|
||||||
id: row.id,
|
|
||||||
type: row.type,
|
|
||||||
platform: 'local',
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
ElMessage.success('批量提取成功');
|
|
||||||
fetchList();
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
loading.value = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function typeText(type) {
|
|
||||||
if (type === 'account') return '账号密码';
|
|
||||||
if (type === 'account_tk') return '账号密码+Token';
|
|
||||||
return 'Token';
|
|
||||||
}
|
|
||||||
|
|
||||||
function platformText(platform) {
|
|
||||||
if (!platform) return '-';
|
|
||||||
return platform === 'local' ? '本地' : '闲鱼';
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeRow(raw) {
|
|
||||||
const pick = (...keys) => {
|
|
||||||
for (const key of keys) {
|
|
||||||
if (raw?.[key] !== undefined && raw?.[key] !== null) return raw[key];
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
};
|
|
||||||
return {
|
|
||||||
id: pick('id', 'Id'),
|
|
||||||
type: pick('data_type', 'dataType', 'type'),
|
|
||||||
account: pick('account', 'Account'),
|
|
||||||
password: pick('password', 'Password'),
|
|
||||||
token: pick('token', 'Token'),
|
|
||||||
remark: pick('remark', 'Remark'),
|
|
||||||
extracted: Number(pick('is_extracted', 'isExtracted')) === 1 || !!pick('extracted'),
|
|
||||||
extractedAt: pick('extracted_time', 'extracted_at', 'extractedAt'),
|
|
||||||
extractedPlatform: pick('extracted_platform', 'extractedPlatform'),
|
|
||||||
createdAt: pick('create_time', 'created_at', 'createdAt'),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchList() {
|
|
||||||
loading.value = true;
|
|
||||||
try {
|
|
||||||
const res = await getAccountPoolList(moduleKey, {
|
|
||||||
page: pagination.page,
|
|
||||||
pageSize: pagination.pageSize,
|
|
||||||
keyword: query.keyword || undefined,
|
|
||||||
status: query.status || undefined,
|
|
||||||
type: activeTypeTab.value === 'all' ? undefined : activeTypeTab.value,
|
|
||||||
});
|
|
||||||
if (res?.code !== 200) {
|
|
||||||
ElMessage.error(res?.msg || '获取列表失败');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const list = Array.isArray(res?.data?.list) ? res.data.list : [];
|
|
||||||
tableData.value = list.map(normalizeRow);
|
|
||||||
total.value = Number(res?.data?.total || 0);
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
fetchList();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="account-pool-page">
|
|
||||||
<el-card shadow="never">
|
|
||||||
<template #header>
|
|
||||||
<div class="card-header">
|
|
||||||
<span>号池管理(Windsurf)</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<div class="toolbar">
|
|
||||||
<div class="toolbar-left">
|
|
||||||
<el-input
|
|
||||||
v-model="query.keyword"
|
|
||||||
placeholder="搜索账号 / token / 备注"
|
|
||||||
clearable
|
|
||||||
class="w-260"
|
|
||||||
/>
|
|
||||||
<el-select v-model="query.status" placeholder="提取状态" clearable class="w-140">
|
|
||||||
<el-option label="未提取" value="unused" />
|
|
||||||
<el-option label="已提取" value="extracted" />
|
|
||||||
</el-select>
|
|
||||||
<el-button @click="resetQuery">重置</el-button>
|
|
||||||
</div>
|
|
||||||
<div class="toolbar-right">
|
|
||||||
<el-button type="primary" @click="openAddDialog('single')">添加账号</el-button>
|
|
||||||
<el-button type="success" @click="openAddDialog('batch')">批量添加</el-button>
|
|
||||||
<el-button @click="markExtractForSelected">批量标记提取</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-tabs v-model="activeTypeTab" class="type-tabs">
|
|
||||||
<el-tab-pane
|
|
||||||
v-for="tab in typeTabs"
|
|
||||||
:key="tab.value"
|
|
||||||
:label="tab.label"
|
|
||||||
:name="tab.value"
|
|
||||||
/>
|
|
||||||
</el-tabs>
|
|
||||||
|
|
||||||
<el-table
|
|
||||||
:data="pagedList"
|
|
||||||
border
|
|
||||||
stripe
|
|
||||||
style="width: 100%"
|
|
||||||
:loading="loading"
|
|
||||||
@selection-change="handleSelectionChange"
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="52" />
|
|
||||||
<el-table-column prop="id" label="ID" width="80" />
|
|
||||||
<el-table-column label="账号类型" width="160" align="center">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag>{{ typeText(row.type) }}</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="account" label="账号" min-width="180" />
|
|
||||||
<el-table-column label="密码/Token" min-width="240">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<span v-if="row.type === 'account'">
|
|
||||||
{{ row.password || '-' }}
|
|
||||||
</span>
|
|
||||||
<span v-else-if="row.type === 'account_tk'">
|
|
||||||
{{ `${row.password || '-'} / ${row.token || '-'}` }}
|
|
||||||
</span>
|
|
||||||
<span v-else>{{ row.token || '-' }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="remark" label="备注" min-width="140" />
|
|
||||||
<el-table-column label="提取状态" width="100">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag :type="row.extracted ? 'success' : 'info'">
|
|
||||||
{{ row.extracted ? '已提取' : '未提取' }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="extractedAt" label="提取时间" width="180" />
|
|
||||||
<el-table-column label="提取平台" width="120">
|
|
||||||
<template #default="{ row }">
|
|
||||||
{{ platformText(row.extractedPlatform) }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" width="180" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button link type="primary" @click="openDetail(row)">详情</el-button>
|
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="warning"
|
|
||||||
:disabled="row.extracted"
|
|
||||||
@click="openExtractByRow(row)"
|
|
||||||
>
|
|
||||||
提取
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<div class="pagination-wrap">
|
|
||||||
<el-pagination
|
|
||||||
v-model:current-page="pagination.page"
|
|
||||||
v-model:page-size="pagination.pageSize"
|
|
||||||
background
|
|
||||||
layout="total, prev, pager, next, jumper"
|
|
||||||
:page-sizes="[30, 50, 100]"
|
|
||||||
:total="total"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
|
|
||||||
<Edit v-model="editVisible" :mode="editMode" @submit="handleEditSubmit" />
|
|
||||||
|
|
||||||
<el-dialog v-model="detailVisible" title="账号详情" width="560px">
|
|
||||||
<el-descriptions :column="1" border v-if="detailRow">
|
|
||||||
<el-descriptions-item label="ID">{{ detailRow.id }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="账号类型">
|
|
||||||
{{ typeText(detailRow.type) }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="账号">
|
|
||||||
{{ detailRow.account || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="密码">
|
|
||||||
{{ detailRow.password || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="Token">
|
|
||||||
{{ detailRow.token || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="提取状态">
|
|
||||||
{{ detailRow.extracted ? '已提取' : '未提取' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="提取时间">
|
|
||||||
{{ detailRow.extractedAt || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="提取平台">
|
|
||||||
{{ platformText(detailRow.extractedPlatform) }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="备注">
|
|
||||||
{{ detailRow.remark || '-' }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
<el-dialog v-model="extractVisible" title="提取账号" width="420px">
|
|
||||||
<el-form label-width="84px">
|
|
||||||
<el-form-item label="提取类型">
|
|
||||||
<el-input :model-value="typeText(extractForm.type)" disabled />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="提取平台">
|
|
||||||
<el-radio-group v-model="extractForm.platform">
|
|
||||||
<el-radio value="local">本地</el-radio>
|
|
||||||
<el-radio value="xianyu">闲鱼</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="extractVisible = false">取消</el-button>
|
|
||||||
<el-button type="primary" :loading="loading" @click="handleExtract">
|
|
||||||
确认提取
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.account-pool-page {
|
|
||||||
padding: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toolbar {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toolbar-left,
|
|
||||||
.toolbar-right {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-260 {
|
|
||||||
width: 260px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-140 {
|
|
||||||
width: 140px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.type-tabs {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pagination-wrap {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-top: 14px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
Loading…
Reference in New Issue
Block a user