整合数据
This commit is contained in:
@@ -59,6 +59,14 @@ export function setAccountPoolUnavailable(module, data) {
|
||||
});
|
||||
}
|
||||
|
||||
export function updateAccountPoolUsable(module, data) {
|
||||
return request({
|
||||
url: `${base(module)}/updateUsable`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export function updateAccountPoolPlatform(module, data) {
|
||||
return request({
|
||||
url: `${base(module)}/updatePlatform`,
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
// @ts-ignore request 封装是 JS 文件,项目未提供 TS 声明
|
||||
import request from '@/utils/request';
|
||||
|
||||
const baseUrl = '/platform/cursor/activationcode';
|
||||
|
||||
export interface CursorActivationCodeQuery {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
keyword?: string;
|
||||
status?: number | string;
|
||||
type?: number | string;
|
||||
bindStatus?: number | string;
|
||||
}
|
||||
|
||||
export interface CursorActivationCodePayload {
|
||||
id?: number | string;
|
||||
code?: string;
|
||||
type?: number;
|
||||
status?: number;
|
||||
durationDays?: number;
|
||||
bindAccount?: string;
|
||||
bindDeviceId?: number | string;
|
||||
ownerUserId?: number | string;
|
||||
ownerUserName?: string;
|
||||
activatedAt?: string;
|
||||
expiredAt?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface GenerateActivationCodePayload {
|
||||
count: number;
|
||||
type?: number;
|
||||
durationDays?: number;
|
||||
ownerUserId?: number | string;
|
||||
ownerUserName?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export function getCursorActivationCodeList(params: CursorActivationCodeQuery) {
|
||||
return request({
|
||||
url: `${baseUrl}/list`,
|
||||
method: 'get',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export function getCursorActivationCodeDetail(id: number | string) {
|
||||
return request({
|
||||
url: `${baseUrl}/detail/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
export function addCursorActivationCode(data: CursorActivationCodePayload) {
|
||||
return request({
|
||||
url: `${baseUrl}/add`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export function updateCursorActivationCode(data: CursorActivationCodePayload) {
|
||||
return request({
|
||||
url: `${baseUrl}/update`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export function deleteCursorActivationCode(id: number | string) {
|
||||
return request({
|
||||
url: `${baseUrl}/delete/${id}`,
|
||||
method: 'post',
|
||||
});
|
||||
}
|
||||
|
||||
export function generateCursorActivationCode(data: GenerateActivationCodePayload) {
|
||||
return request({
|
||||
url: `${baseUrl}/generate`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export function enableCursorActivationCode(id: number | string) {
|
||||
return request({
|
||||
url: `${baseUrl}/enable/${id}`,
|
||||
method: 'post',
|
||||
});
|
||||
}
|
||||
|
||||
export function disableCursorActivationCode(id: number | string) {
|
||||
return request({
|
||||
url: `${baseUrl}/disable/${id}`,
|
||||
method: 'post',
|
||||
});
|
||||
}
|
||||
|
||||
export function exportCursorActivationCode(params: CursorActivationCodeQuery) {
|
||||
return request({
|
||||
url: `${baseUrl}/export`,
|
||||
method: 'get',
|
||||
params,
|
||||
responseType: 'blob',
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
// @ts-ignore request 封装是 JS 文件,项目未提供 TS 声明
|
||||
import request from '@/utils/request';
|
||||
|
||||
const baseUrl = '/platform/cursor/equipment';
|
||||
|
||||
export interface CursorEquipmentQuery {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
keyword?: string;
|
||||
status?: number | string;
|
||||
system?: string;
|
||||
os?: string;
|
||||
}
|
||||
|
||||
export interface CursorEquipmentPayload {
|
||||
id?: number;
|
||||
deviceInfo?: string;
|
||||
machineCode?: string;
|
||||
status?: number;
|
||||
system?: string;
|
||||
version?: string;
|
||||
bindAccount?: string;
|
||||
ownerUserId?: number;
|
||||
ownerUserName?: string;
|
||||
activationTime?: string;
|
||||
expireTime?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export function getCursorEquipmentList(params: CursorEquipmentQuery) {
|
||||
return request({
|
||||
url: `${baseUrl}/list`,
|
||||
method: 'get',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export function getCursorEquipmentDetail(id: number | string) {
|
||||
return request({
|
||||
url: `${baseUrl}/detail/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
export function addCursorEquipment(data: CursorEquipmentPayload) {
|
||||
return request({
|
||||
url: `${baseUrl}/add`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export function updateCursorEquipment(data: CursorEquipmentPayload) {
|
||||
return request({
|
||||
url: `${baseUrl}/update`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export function deleteCursorEquipment(id: number | string) {
|
||||
return request({
|
||||
url: `${baseUrl}/delete/${id}`,
|
||||
method: 'post',
|
||||
});
|
||||
}
|
||||
|
||||
export function activateCursorEquipment(data: { id: number | string }) {
|
||||
return request({
|
||||
url: `${baseUrl}/activate`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export function getCursorEquipmentActivationRecords(params: Record<string, any>) {
|
||||
return request({
|
||||
url: `${baseUrl}/activationRecords`,
|
||||
method: 'get',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export function getCursorEquipmentExtractRecords(params: Record<string, any>) {
|
||||
return request({
|
||||
url: `${baseUrl}/extractRecords`,
|
||||
method: 'get',
|
||||
params,
|
||||
});
|
||||
}
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
<!-- 菜单主体 -->
|
||||
<el-menu
|
||||
v-else
|
||||
:collapse="isCollapse"
|
||||
:collapse-transition="false"
|
||||
:background-color="asideBgColor"
|
||||
@@ -23,6 +22,7 @@
|
||||
:active-background-color="activeBgColor"
|
||||
class="el-menu-vertical-demo"
|
||||
:unique-opened="true"
|
||||
:default-openeds="defaultOpeneds"
|
||||
@select="handleMenuSelect"
|
||||
:default-active="route.path"
|
||||
>
|
||||
@@ -284,10 +284,29 @@ const currentModule = computed(() => {
|
||||
});
|
||||
|
||||
const displayMenus = computed(() => {
|
||||
// 侧边栏始终展示完整菜单树,不随当前路由切换为“子菜单视图”
|
||||
// 侧边栏始终展示完整菜单树,不随当前路由切换为"子菜单视图"
|
||||
return list.value;
|
||||
});
|
||||
|
||||
const findOpenMenuPaths = (menus, targetPath, ancestors = []) => {
|
||||
for (const menu of menus) {
|
||||
const currentPath = menu.path || menu.id.toString();
|
||||
if (menu.path && (targetPath === menu.path || targetPath.startsWith(menu.path + "/"))) {
|
||||
return [...ancestors, currentPath];
|
||||
}
|
||||
if (menu.children && menu.children.length > 0) {
|
||||
const found = findOpenMenuPaths(menu.children, targetPath, [...ancestors, currentPath]);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const defaultOpeneds = computed(() => {
|
||||
const result = findOpenMenuPaths(displayMenus.value, route.path);
|
||||
return result || [];
|
||||
});
|
||||
|
||||
const asideTitle = computed(() => {
|
||||
if (isCollapse.value) return "管理";
|
||||
return "菜单";
|
||||
@@ -311,7 +330,7 @@ const processMenus = (menus) => {
|
||||
.map((menu) => ({
|
||||
id: menu.id,
|
||||
path: menu.path,
|
||||
icon: menu.icon || "Document",
|
||||
icon: menu.icon || null,
|
||||
title: menu.title,
|
||||
route: menu.path,
|
||||
component_path: menu.component_path,
|
||||
@@ -541,13 +560,13 @@ h3 {
|
||||
// 高亮样式
|
||||
.el-menu-item.is-active {
|
||||
html:not(.dark) & {
|
||||
background-color: rgba(57, 115, 255, 0.3) !important;
|
||||
background-color: rgba(255, 255, 255, 0.2) !important;
|
||||
border-left: 3px solid #ffffff;
|
||||
}
|
||||
html.dark & {
|
||||
background-color: rgba(60, 60, 60, 0.8) !important;
|
||||
}
|
||||
color: #ffffff !important;
|
||||
border-left: 3px solid #4f84ff;
|
||||
margin-left: -3px;
|
||||
|
||||
.menu-icon {
|
||||
@@ -574,12 +593,17 @@ h3 {
|
||||
}
|
||||
|
||||
&.is-opened .el-sub-menu__title {
|
||||
background: rgba(255, 255, 255, 0.08) !important;
|
||||
background: rgba(255, 255, 255, 0.12) !important;
|
||||
margin-left: -3px;
|
||||
}
|
||||
|
||||
.el-menu-item {
|
||||
padding-left: 48px !important;
|
||||
font-size: 13px;
|
||||
|
||||
&.is-active {
|
||||
background: rgba(255, 255, 255, 0.18) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -604,6 +628,10 @@ h3 {
|
||||
.el-sub-menu.is-opened .el-sub-menu__title {
|
||||
background: rgba(64, 158, 255, 0.08) !important;
|
||||
}
|
||||
|
||||
.el-sub-menu .el-menu-item.is-active {
|
||||
background: rgba(64, 158, 255, 0.15) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
@@ -22,8 +22,10 @@ const remarkText = ref("");
|
||||
const remarkDialogVisible = ref(false);
|
||||
const platformDialogVisible = ref(false);
|
||||
const unavailableDialogVisible = ref(false);
|
||||
const usableDialogVisible = ref(false);
|
||||
const unextractDialogVisible = ref(false);
|
||||
const platformForm = reactive({ platform: "local" });
|
||||
const usableForm = reactive({ usable: 1 });
|
||||
|
||||
const TYPE_MAP = {
|
||||
account: { label: "账号密码", type: "success" },
|
||||
@@ -82,6 +84,12 @@ watch(
|
||||
(row) => {
|
||||
remarkText.value = row?.remark || "";
|
||||
platformForm.platform = row?.extractedPlatform || "local";
|
||||
const raw = row?.isUsed;
|
||||
if (raw === null || raw === undefined || raw === "") {
|
||||
usableForm.usable = 1;
|
||||
} else {
|
||||
usableForm.usable = Number(raw) === 0 ? 0 : 1;
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
@@ -107,6 +115,26 @@ function onSetUnavailable() {
|
||||
unavailableDialogVisible.value = false;
|
||||
}
|
||||
|
||||
function openUsableDialog() {
|
||||
const raw = props.row?.isUsed;
|
||||
if (raw === null || raw === undefined || raw === "") {
|
||||
usableForm.usable = 1;
|
||||
} else {
|
||||
usableForm.usable = Number(raw) === 0 ? 0 : 1;
|
||||
}
|
||||
usableDialogVisible.value = true;
|
||||
}
|
||||
|
||||
function onUpdateUsable() {
|
||||
if (!props.row?.id) return;
|
||||
emit("detail-action", {
|
||||
action: "usable",
|
||||
id: props.row.id,
|
||||
usable: usableForm.usable,
|
||||
});
|
||||
usableDialogVisible.value = false;
|
||||
}
|
||||
|
||||
function onUpdatePlatform() {
|
||||
if (!props.row?.id) return;
|
||||
emit("detail-action", {
|
||||
@@ -299,6 +327,9 @@ function copyAll() {
|
||||
</div>
|
||||
</div>
|
||||
<div class="copy-actions">
|
||||
<el-button type="success" plain @click="openUsableDialog">
|
||||
改可用状态
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
@@ -334,6 +365,28 @@ function copyAll() {
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="usableDialogVisible"
|
||||
title="改可用状态"
|
||||
width="420px"
|
||||
append-to-body
|
||||
>
|
||||
<el-form label-width="84px">
|
||||
<el-form-item label="可用状态">
|
||||
<el-radio-group v-model="usableForm.usable">
|
||||
<el-radio :value="1">可用</el-radio>
|
||||
<el-radio :value="0">不可用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="usableDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saveLoading" @click="onUpdateUsable">
|
||||
确认修改
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="unavailableDialogVisible"
|
||||
title="改不可用"
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
h,
|
||||
nextTick,
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
reactive,
|
||||
ref,
|
||||
watch,
|
||||
} from "vue";
|
||||
import { computed, h, nextTick, onMounted, onUnmounted, reactive, ref, watch } from "vue";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { Loading } from "@element-plus/icons-vue";
|
||||
import Edit from "./components/edit.vue";
|
||||
import DetailDialog from "./components/detail.vue";
|
||||
import ExtractDialog from "./components/extract.vue";
|
||||
@@ -22,6 +14,7 @@ import {
|
||||
getAccountPoolList,
|
||||
updateAccountPoolRemark,
|
||||
setAccountPoolUnavailable,
|
||||
updateAccountPoolUsable,
|
||||
updateAccountPoolPlatform,
|
||||
unextractAccountPool,
|
||||
replenishAccountPool,
|
||||
@@ -29,6 +22,35 @@ import {
|
||||
} from "@/api/accountPool";
|
||||
|
||||
const moduleKey = "cursor";
|
||||
const PAGINATION_STORAGE_KEY = `accountPool:${moduleKey}:pagination`;
|
||||
|
||||
function loadStoredPagination() {
|
||||
try {
|
||||
const raw = sessionStorage.getItem(PAGINATION_STORAGE_KEY);
|
||||
if (!raw) return { page: 1, pageSize: 20 };
|
||||
const saved = JSON.parse(raw);
|
||||
const pageSize = Number(saved.pageSize);
|
||||
const page = Number(saved.page);
|
||||
return {
|
||||
page: Number.isFinite(page) && page >= 1 ? page : 1,
|
||||
pageSize: [20, 50, 100].includes(pageSize) ? pageSize : 20,
|
||||
};
|
||||
} catch {
|
||||
return { page: 1, pageSize: 20 };
|
||||
}
|
||||
}
|
||||
|
||||
function savePagination() {
|
||||
sessionStorage.setItem(
|
||||
PAGINATION_STORAGE_KEY,
|
||||
JSON.stringify({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const storedPagination = loadStoredPagination();
|
||||
|
||||
const loading = ref(false);
|
||||
const editVisible = ref(false);
|
||||
@@ -67,10 +89,24 @@ const selectedRows = ref([]);
|
||||
const detailRow = ref(null);
|
||||
const detailRemarkSaving = ref(false);
|
||||
const probeLoadingId = ref(null);
|
||||
const batchProbeDialogVisible = ref(false);
|
||||
const batchProbePhase = ref("running");
|
||||
const batchProbeProgress = reactive({
|
||||
total: 0,
|
||||
current: 0,
|
||||
currentId: null,
|
||||
percent: 0,
|
||||
});
|
||||
const batchProbeSummary = reactive({
|
||||
total: 0,
|
||||
available: 0,
|
||||
unavailable: 0,
|
||||
skipped: 0,
|
||||
});
|
||||
const isMobile = ref(false);
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
page: storedPagination.page,
|
||||
pageSize: storedPagination.pageSize,
|
||||
});
|
||||
|
||||
/** 跳转未提取末页时跳过 watcher,避免先被重置到第 1 页 */
|
||||
@@ -97,15 +133,7 @@ const typeTabs = computed(() => {
|
||||
});
|
||||
|
||||
watch(
|
||||
() => [
|
||||
query.account,
|
||||
query.token,
|
||||
query.remark,
|
||||
query.status,
|
||||
query.platform,
|
||||
query.usable,
|
||||
activeTypeTab.value,
|
||||
],
|
||||
() => [query.account, query.token, query.remark, query.status, query.platform, query.usable, activeTypeTab.value],
|
||||
() => {
|
||||
if (skipWatchFetchDuringUnusedJump.value) return;
|
||||
pagination.page = 1;
|
||||
@@ -116,6 +144,7 @@ watch(
|
||||
watch(
|
||||
() => [pagination.page, pagination.pageSize],
|
||||
() => {
|
||||
savePagination();
|
||||
if (skipWatchFetchDuringUnusedJump.value) return;
|
||||
fetchList();
|
||||
},
|
||||
@@ -200,7 +229,7 @@ function buildCopyTextByRow(row) {
|
||||
if (row?.account) parts.push(row.account);
|
||||
if (row?.password) parts.push(row.password);
|
||||
if (row?.token) parts.push(row.token);
|
||||
return parts.join("\n");
|
||||
return parts.join('\n');
|
||||
}
|
||||
|
||||
function rowToText(row) {
|
||||
@@ -208,20 +237,20 @@ function rowToText(row) {
|
||||
if (row?.account) parts.push(row.account);
|
||||
if (row?.password) parts.push(row.password);
|
||||
if (row?.token) parts.push(row.token);
|
||||
return parts.join(" / ");
|
||||
return parts.join(' / ');
|
||||
}
|
||||
|
||||
async function copyToClipboard(text) {
|
||||
if (!text) {
|
||||
ElMessage.warning("无可复制内容");
|
||||
ElMessage.warning('无可复制内容');
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
ElMessage.success("已复制");
|
||||
ElMessage.success('已复制');
|
||||
return true;
|
||||
} catch (e) {
|
||||
ElMessage.error("复制失败,请检查浏览器权限");
|
||||
ElMessage.error('复制失败,请检查浏览器权限');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -289,6 +318,11 @@ async function handleDetailAction(payload) {
|
||||
let res;
|
||||
if (payload.action === "unavailable") {
|
||||
res = await setAccountPoolUnavailable(moduleKey, { id: payload.id });
|
||||
} else if (payload.action === "usable") {
|
||||
res = await updateAccountPoolUsable(moduleKey, {
|
||||
id: payload.id,
|
||||
usable: payload.usable,
|
||||
});
|
||||
} else if (payload.action === "platform") {
|
||||
res = await updateAccountPoolPlatform(moduleKey, {
|
||||
id: payload.id,
|
||||
@@ -395,20 +429,16 @@ function extractStatusTagType(row) {
|
||||
}
|
||||
|
||||
const tooltipOpts = {
|
||||
popperClass: "pool-tooltip",
|
||||
popperStyle: {
|
||||
maxWidth: "600px",
|
||||
wordBreak: "break-all",
|
||||
whiteSpace: "pre-wrap",
|
||||
},
|
||||
popperClass: 'pool-tooltip',
|
||||
popperStyle: { maxWidth: '600px', wordBreak: 'break-all', whiteSpace: 'pre-wrap' },
|
||||
};
|
||||
|
||||
const PLATFORM_MAP = {
|
||||
local: { label: "本地", type: "info" },
|
||||
xianyu: { label: "闲鱼", type: "warning" },
|
||||
pinduoduo: { label: "拼多多", type: "danger" },
|
||||
jingdong: { label: "京东", type: "primary" },
|
||||
douyin: { label: "抖音", type: "success" },
|
||||
local: { label: '本地', type: 'info' },
|
||||
xianyu: { label: '闲鱼', type: 'warning' },
|
||||
pinduoduo: { label: '拼多多', type: 'danger' },
|
||||
jingdong: { label: '京东', type: 'primary' },
|
||||
douyin: { label: '抖音', type: 'success' },
|
||||
};
|
||||
|
||||
function platformText(platform) {
|
||||
@@ -437,17 +467,12 @@ function isUsedTagType(isUsed) {
|
||||
function decodeJwtPayload(rawToken) {
|
||||
const token = String(rawToken || "").trim();
|
||||
if (!token) return null;
|
||||
const pureToken = token.includes("::")
|
||||
? token.split("::").pop().trim()
|
||||
: token;
|
||||
const pureToken = token.includes("::") ? token.split("::").pop().trim() : token;
|
||||
const parts = pureToken.split(".");
|
||||
if (parts.length < 2) return null;
|
||||
try {
|
||||
const base64 = parts[1].replace(/-/g, "+").replace(/_/g, "/");
|
||||
const padded = base64.padEnd(
|
||||
base64.length + ((4 - (base64.length % 4)) % 4),
|
||||
"=",
|
||||
);
|
||||
const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), "=");
|
||||
const json = decodeURIComponent(
|
||||
atob(padded)
|
||||
.split("")
|
||||
@@ -554,8 +579,7 @@ async function fetchList() {
|
||||
remark: query.remark || undefined,
|
||||
status: query.status || undefined,
|
||||
platform: query.platform || undefined,
|
||||
usable:
|
||||
query.usable === "1" || query.usable === "0" ? query.usable : undefined,
|
||||
usable: query.usable === "1" || query.usable === "0" ? query.usable : undefined,
|
||||
type: activeTypeTab.value === "all" ? undefined : activeTypeTab.value,
|
||||
});
|
||||
if (res?.code !== 200) {
|
||||
@@ -565,6 +589,10 @@ async function fetchList() {
|
||||
const list = Array.isArray(res?.data?.list) ? res.data.list : [];
|
||||
tableData.value = list.map(normalizeRow);
|
||||
total.value = Number(res?.data?.total || 0);
|
||||
const maxPage = Math.max(1, Math.ceil(total.value / pagination.pageSize));
|
||||
if (pagination.page > maxPage) {
|
||||
pagination.page = maxPage;
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -580,8 +608,7 @@ async function jumpToLastUnusedPage() {
|
||||
token: query.token || undefined,
|
||||
remark: query.remark || undefined,
|
||||
status: "unused",
|
||||
usable:
|
||||
query.usable === "1" || query.usable === "0" ? query.usable : undefined,
|
||||
usable: query.usable === "1" || query.usable === "0" ? query.usable : undefined,
|
||||
type,
|
||||
});
|
||||
if (res?.code !== 200) {
|
||||
@@ -609,44 +636,29 @@ function updateDeviceType() {
|
||||
|
||||
onMounted(() => {
|
||||
updateDeviceType();
|
||||
window.addEventListener("resize", updateDeviceType);
|
||||
window.addEventListener('resize', updateDeviceType);
|
||||
fetchList();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener("resize", updateDeviceType);
|
||||
window.removeEventListener('resize', updateDeviceType);
|
||||
});
|
||||
|
||||
// ---- 接口说明数据 ----
|
||||
const BASE_URL = "https://api.yunzer.cn";
|
||||
|
||||
const paramDocs = [
|
||||
{
|
||||
name: "type",
|
||||
required: true,
|
||||
desc: "来源平台,用于标记本次提取来自哪个渠道",
|
||||
values: "xianyu / taobao / pinduoduo / jingdong / local",
|
||||
},
|
||||
{
|
||||
name: "module",
|
||||
required: true,
|
||||
desc: "号池模块,指定从哪个产品的号池提取",
|
||||
values: "cursor / windsurf / krio",
|
||||
},
|
||||
{
|
||||
name: "data_type",
|
||||
required: false,
|
||||
desc: "账号类型,不传则提取任意类型",
|
||||
values: "account / tk / account_tk",
|
||||
},
|
||||
{ name: 'type', required: true, desc: '来源平台,用于标记本次提取来自哪个渠道', values: 'xianyu / taobao / pinduoduo / jingdong / local' },
|
||||
{ name: 'module', required: true, desc: '号池模块,指定从哪个产品的号池提取', values: 'cursor / windsurf / krio' },
|
||||
{ name: 'data_type', required: false, desc: '账号类型,不传则提取任意类型', values: 'account / tk / account_tk' },
|
||||
];
|
||||
|
||||
const platformDocs = [
|
||||
{ value: "xianyu", label: "闲鱼", desc: "闲鱼平台发货调用" },
|
||||
{ value: "pinduoduo", label: "拼多多", desc: "拼多多平台发货调用" },
|
||||
{ value: "jingdong", label: "京东", desc: "京东平台发货调用" },
|
||||
{ value: "douyin", label: "抖音", desc: "抖音平台发货调用" },
|
||||
{ value: "local", label: "本地", desc: "本地手动调用" },
|
||||
{ value: 'xianyu', label: '闲鱼', desc: '闲鱼平台发货调用' },
|
||||
{ value: 'pinduoduo', label: '拼多多', desc: '拼多多平台发货调用' },
|
||||
{ value: 'jingdong', label: '京东', desc: '京东平台发货调用' },
|
||||
{ value: 'douyin', label: '抖音', desc: '抖音平台发货调用' },
|
||||
{ value: 'local', label: '本地', desc: '本地手动调用' },
|
||||
];
|
||||
|
||||
const moduleDocs = [
|
||||
@@ -700,48 +712,64 @@ function copyCardInfo(row) {
|
||||
if (row.account) parts.push(row.account);
|
||||
if (row.password) parts.push(row.password);
|
||||
if (row.token) parts.push(row.token);
|
||||
if (!parts.length) {
|
||||
ElMessage.warning("无可复制内容");
|
||||
return;
|
||||
}
|
||||
navigator.clipboard.writeText(parts.join("\n")).then(() => {
|
||||
ElMessage.success("已复制");
|
||||
if (!parts.length) { ElMessage.warning('无可复制内容'); return; }
|
||||
navigator.clipboard.writeText(parts.join('\n')).then(() => {
|
||||
ElMessage.success('已复制');
|
||||
});
|
||||
}
|
||||
|
||||
const CURSOR_PRO_LIMIT_TEXT =
|
||||
"Get Cursor Pro for more Agent usage, unlimited Tab, and more.";
|
||||
const CURSOR_PRO_LIMIT_TEXT = 'Get Cursor Pro for more Agent usage, unlimited Tab, and more.';
|
||||
|
||||
function formatCursorProbeDialogText(d) {
|
||||
const detail = String(d?.detail || "").trim();
|
||||
const rawPreview = String(d?.rawPreview || "").trim();
|
||||
const serverOutput = detail || rawPreview;
|
||||
|
||||
// 1. 优先以新版后端的 ok 字段(也就是底层探针的交叉判定结论)为核心准则
|
||||
if (d && typeof d.ok === "boolean") {
|
||||
if (d.ok) {
|
||||
return serverOutput || "该TOKEN可用";
|
||||
}
|
||||
return `该TOKEN已用完 (${detail || rawPreview || "额度枯竭"})`;
|
||||
if (d && typeof d.ok === 'boolean') {
|
||||
return d.ok ? '该TOKEN可用' : `该TOKEN已用完 (${d.detail || '额度枯竭'})`;
|
||||
}
|
||||
|
||||
// 2. 兼容旧数据的兜底检测
|
||||
const CURSOR_PRO_LIMIT_TEXT =
|
||||
"Get Cursor Pro for more Agent usage, unlimited Tab, and more.";
|
||||
|
||||
if (
|
||||
detail.includes(CURSOR_PRO_LIMIT_TEXT) ||
|
||||
rawPreview.includes(CURSOR_PRO_LIMIT_TEXT)
|
||||
) {
|
||||
return `该TOKEN已用完 (${detail || rawPreview})`;
|
||||
const CURSOR_PRO_LIMIT_TEXT = 'Get Cursor Pro for more Agent usage, unlimited Tab, and more.';
|
||||
const detail = String(d?.detail || '');
|
||||
const rawPreview = String(d?.rawPreview || '');
|
||||
|
||||
if (detail.includes(CURSOR_PRO_LIMIT_TEXT) || rawPreview.includes(CURSOR_PRO_LIMIT_TEXT)) {
|
||||
return '该TOKEN已用完';
|
||||
}
|
||||
|
||||
return '该TOKEN可用';
|
||||
}
|
||||
|
||||
return serverOutput || "该TOKEN可用";
|
||||
function formatCursorProbeDetail(d) {
|
||||
if (!d) return '';
|
||||
|
||||
const parts = [];
|
||||
|
||||
// 提取关键信息
|
||||
if (d.httpStatus) parts.push(`HTTP状态: ${d.httpStatus}`);
|
||||
if (d.endpoint) parts.push(`接口: ${d.endpoint}`);
|
||||
if (d.probeMessage) parts.push(`探测方式: ${d.probeMessage}`);
|
||||
if (d.bytesRead) parts.push(`响应大小: ${d.bytesRead} 字节`);
|
||||
if (d.streamProtocol) parts.push(`协议: ${d.streamProtocol}`);
|
||||
|
||||
// 提取检测结论
|
||||
if (d.detail) {
|
||||
// 解析流匹配信息
|
||||
const matchPrefix = '流中匹配:';
|
||||
if (d.detail.includes(matchPrefix)) {
|
||||
const matchStart = d.detail.indexOf(matchPrefix);
|
||||
const matchEnd = d.detail.indexOf(';', matchStart);
|
||||
const matchText = matchEnd > 0 ? d.detail.substring(matchStart, matchEnd) : d.detail.substring(matchStart);
|
||||
parts.push(`检测结论: ${matchText}`);
|
||||
} else {
|
||||
parts.push(`检测结论: ${d.detail}`);
|
||||
}
|
||||
}
|
||||
|
||||
return parts.join('\n');
|
||||
}
|
||||
|
||||
async function handleProbeToken(row) {
|
||||
if (!row?.token) {
|
||||
ElMessage.warning("该行无 Token");
|
||||
ElMessage.warning('该行无 Token');
|
||||
return;
|
||||
}
|
||||
probeLoadingId.value = row.id;
|
||||
@@ -751,17 +779,50 @@ async function handleProbeToken(row) {
|
||||
accessToken: row.token,
|
||||
});
|
||||
if (res?.code !== 200) {
|
||||
ElMessage.error(res?.msg || "探测失败");
|
||||
ElMessage.error(res?.msg || '探测失败');
|
||||
return;
|
||||
}
|
||||
const d = res?.data || {};
|
||||
const text = formatCursorProbeDialogText(d);
|
||||
const isOk = d.ok === true;
|
||||
|
||||
// 构建详细信息
|
||||
const detailItems = [];
|
||||
if (d.httpStatus) detailItems.push(`HTTP状态: ${d.httpStatus}`);
|
||||
if (d.endpoint) detailItems.push(`接口: ${d.endpoint}`);
|
||||
if (d.probeMessage) detailItems.push(`探测方式: ${d.probeMessage}`);
|
||||
if (d.bytesRead) detailItems.push(`响应大小: ${d.bytesRead} 字节`);
|
||||
if (d.streamProtocol) detailItems.push(`协议: ${d.streamProtocol}`);
|
||||
|
||||
// 提取检测结论(从 detail 字段)
|
||||
if (d.detail) {
|
||||
const matchPrefix = '流中匹配:';
|
||||
if (d.detail.includes(matchPrefix)) {
|
||||
const matchStart = d.detail.indexOf(matchPrefix);
|
||||
const matchEnd = d.detail.indexOf(';', matchStart);
|
||||
const matchText = matchEnd > 0 ? d.detail.substring(matchStart, matchEnd) : d.detail.substring(matchStart);
|
||||
detailItems.push(`检测结论: ${matchText}`);
|
||||
} else {
|
||||
detailItems.push(`检测结论: ${d.detail}`);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox({
|
||||
title: "检测结果",
|
||||
message: h("div", { class: "cursor-probe-result" }, text),
|
||||
confirmButtonText: "关闭",
|
||||
customClass: "cursor-probe-dialog",
|
||||
title: isOk ? '检测结果 - 可用' : '检测结果 - 不可用',
|
||||
message: h('div', { class: 'cursor-probe-result cursor-expire-result' }, [
|
||||
h('div', {
|
||||
style: `text-align:center;font-size:18px;font-weight:700;margin-bottom:12px;color:${isOk ? '#67c23a' : '#f56c6c'}`
|
||||
}, text),
|
||||
detailItems.length > 0 ? h('div', {
|
||||
style: 'text-align:left;font-size:13px;color:#606266;margin-bottom:8px;line-height:1.8'
|
||||
}, detailItems.map(item => h('div', null, `• ${item}`))) : null,
|
||||
d.streamNote ? h('div', {
|
||||
style: 'text-align:left;font-size:12px;color:#909399;margin-top:8px;padding:8px;background:#f5f7fa;border-radius:4px;white-space:pre-wrap;line-height:1.6;'
|
||||
}, d.streamNote) : null,
|
||||
]),
|
||||
confirmButtonText: '关闭',
|
||||
customClass: 'cursor-probe-dialog',
|
||||
closeOnClickModal: true,
|
||||
});
|
||||
} catch {
|
||||
@@ -769,7 +830,7 @@ async function handleProbeToken(row) {
|
||||
}
|
||||
await fetchList();
|
||||
} catch {
|
||||
ElMessage.error("探测请求失败");
|
||||
ElMessage.error('探测请求失败');
|
||||
} finally {
|
||||
probeLoadingId.value = null;
|
||||
}
|
||||
@@ -786,7 +847,8 @@ async function handleBatchProbe() {
|
||||
return;
|
||||
}
|
||||
const skipped = selectedRows.value.length - rows.length;
|
||||
const skipHint = skipped > 0 ? `(已跳过 ${skipped} 条无 Token)` : "";
|
||||
const skipHint =
|
||||
skipped > 0 ? `(已跳过 ${skipped} 条无 Token)` : "";
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`将对 ${rows.length} 条 Token进行检测,是否继续?${skipHint}`,
|
||||
@@ -796,36 +858,61 @@ async function handleBatchProbe() {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
let ok = 0;
|
||||
let fail = 0;
|
||||
|
||||
let available = 0;
|
||||
let unavailable = 0;
|
||||
|
||||
batchProbePhase.value = "running";
|
||||
batchProbeProgress.total = rows.length;
|
||||
batchProbeProgress.current = 0;
|
||||
batchProbeProgress.currentId = null;
|
||||
batchProbeProgress.percent = 0;
|
||||
batchProbeDialogVisible.value = true;
|
||||
await nextTick();
|
||||
|
||||
try {
|
||||
for (const row of rows) {
|
||||
for (let i = 0; i < rows.length; i += 1) {
|
||||
const row = rows[i];
|
||||
batchProbeProgress.current = i + 1;
|
||||
batchProbeProgress.currentId = row.id;
|
||||
batchProbeProgress.percent = Math.round((i / rows.length) * 100);
|
||||
await nextTick();
|
||||
|
||||
try {
|
||||
const res = await probeAccountPoolToken(moduleKey, {
|
||||
id: row.id,
|
||||
accessToken: row.token,
|
||||
});
|
||||
if (res?.code === 200) {
|
||||
ok += 1;
|
||||
if (res?.code === 200 && res?.data?.ok === true) {
|
||||
available += 1;
|
||||
} else {
|
||||
fail += 1;
|
||||
unavailable += 1;
|
||||
}
|
||||
} catch {
|
||||
fail += 1;
|
||||
unavailable += 1;
|
||||
}
|
||||
|
||||
batchProbeProgress.percent = Math.round(((i + 1) / rows.length) * 100);
|
||||
await nextTick();
|
||||
}
|
||||
if (fail > 0) {
|
||||
ElMessage.warning(`批量检测完成:成功 ${ok} 条,失败 ${fail} 条`);
|
||||
} else {
|
||||
ElMessage.success(`批量检测完成:共 ${ok} 条`);
|
||||
}
|
||||
|
||||
batchProbeSummary.total = rows.length;
|
||||
batchProbeSummary.available = available;
|
||||
batchProbeSummary.unavailable = unavailable;
|
||||
batchProbeSummary.skipped = skipped;
|
||||
batchProbePhase.value = "done";
|
||||
await fetchList();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
} catch {
|
||||
batchProbeDialogVisible.value = false;
|
||||
ElMessage.error("批量检测异常");
|
||||
}
|
||||
}
|
||||
|
||||
function closeBatchProbeDialog() {
|
||||
batchProbeDialogVisible.value = false;
|
||||
batchProbePhase.value = "running";
|
||||
}
|
||||
|
||||
// async function handleBatchProbeExpireTime() {
|
||||
// if (!selectedRows.value.length) {
|
||||
// ElMessage.warning("请先选择数据");
|
||||
@@ -876,6 +963,7 @@ async function handleBatchProbe() {
|
||||
// closeOnClickModal: true,
|
||||
// });
|
||||
// }
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -951,12 +1039,8 @@ async function handleBatchProbe() {
|
||||
<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 type="primary" @click="openAddDialog('single')">添加账号</el-button>
|
||||
<el-button type="success" @click="openAddDialog('batch')">批量添加</el-button>
|
||||
<el-button @click="replenishVisible = true">补号</el-button>
|
||||
<el-button @click="markExtractForSelected">批量提取</el-button>
|
||||
<el-button plain @click="handleBatchProbe">批量检测</el-button>
|
||||
@@ -984,108 +1068,84 @@ async function handleBatchProbe() {
|
||||
: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"
|
||||
show-overflow-tooltip
|
||||
:tooltip-options="tooltipOpts"
|
||||
/>
|
||||
<!-- <el-table-column prop="password" label="密码" min-width="160" show-overflow-tooltip :tooltip-options="tooltipOpts">
|
||||
<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" show-overflow-tooltip :tooltip-options="tooltipOpts" />
|
||||
<!-- <el-table-column prop="password" label="密码" min-width="160" show-overflow-tooltip :tooltip-options="tooltipOpts">
|
||||
<template #default="{ row }">{{ row.password || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="Token" min-width="200" show-overflow-tooltip :tooltip-options="tooltipOpts">
|
||||
<template #default="{ row }">{{ row.token || '-' }}</template>
|
||||
</el-table-column> -->
|
||||
<el-table-column label="提取状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="extractStatusTagType(row)">
|
||||
{{ extractStatusLabel(row) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="探测可用" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="isUsedTagType(row.isUsed)" size="small">
|
||||
{{ isUsedLabel(row.isUsed) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column
|
||||
label="accessToken失效时间"
|
||||
width="190"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
:type="accessTokenExpireTagType(row.accessTokenExpireStatus)"
|
||||
size="small"
|
||||
>
|
||||
{{ row.accessTokenExpireText || "-" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
<el-table-column label="提取平台" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="row.extractedPlatform"
|
||||
:type="platformTagType(row.extractedPlatform)"
|
||||
size="small"
|
||||
>
|
||||
{{ platformText(row.extractedPlatform) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="extractedAt" label="提取时间" width="180" />
|
||||
<el-table-column
|
||||
prop="remark"
|
||||
label="备注"
|
||||
min-width="140"
|
||||
show-overflow-tooltip
|
||||
:tooltip-options="tooltipOpts"
|
||||
/>
|
||||
<el-table-column
|
||||
label="操作"
|
||||
width="300"
|
||||
fixed="right"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="row.token"
|
||||
link
|
||||
type="info"
|
||||
:loading="probeLoadingId === row.id"
|
||||
@click="handleProbeToken(row)"
|
||||
>检测</el-button
|
||||
>
|
||||
<el-button link type="primary" @click="openDetail(row)"
|
||||
>详情</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="!row.extractedAt && !row.extracted"
|
||||
link
|
||||
type="warning"
|
||||
@click="openExtractByRow(row)"
|
||||
>提取</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="row.extracted"
|
||||
link
|
||||
type="success"
|
||||
@click="copyCardInfo(row)"
|
||||
>复制</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="提取状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="extractStatusTagType(row)">
|
||||
{{ extractStatusLabel(row) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="探测可用" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="isUsedTagType(row.isUsed)" size="small">
|
||||
{{ isUsedLabel(row.isUsed) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="accessToken失效时间" width="190" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="accessTokenExpireTagType(row.accessTokenExpireStatus)" size="small">
|
||||
{{ row.accessTokenExpireText || "-" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
<el-table-column label="提取平台" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="row.extractedPlatform"
|
||||
:type="platformTagType(row.extractedPlatform)"
|
||||
size="small"
|
||||
>
|
||||
{{ platformText(row.extractedPlatform) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="extractedAt" label="提取时间" width="180" />
|
||||
<el-table-column prop="remark" label="备注" min-width="140" show-overflow-tooltip :tooltip-options="tooltipOpts" />
|
||||
<el-table-column label="操作" width="300" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="row.token"
|
||||
link
|
||||
type="info"
|
||||
:loading="probeLoadingId === row.id"
|
||||
@click="handleProbeToken(row)"
|
||||
>检测</el-button
|
||||
>
|
||||
<el-button link type="primary" @click="openDetail(row)"
|
||||
>详情</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="!row.extractedAt && !row.extracted"
|
||||
link
|
||||
type="warning"
|
||||
@click="openExtractByRow(row)"
|
||||
>提取</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="row.extracted"
|
||||
link
|
||||
type="success"
|
||||
@click="copyCardInfo(row)"
|
||||
>复制</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
@@ -1094,9 +1154,7 @@ async function handleBatchProbe() {
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
background
|
||||
:layout="
|
||||
isMobile ? 'prev, pager, next' : 'total, prev, pager, next, jumper'
|
||||
"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:page-sizes="[20, 50, 100]"
|
||||
:total="total"
|
||||
/>
|
||||
@@ -1148,9 +1206,7 @@ async function handleBatchProbe() {
|
||||
destroy-on-close
|
||||
>
|
||||
<el-alert type="info" :closable="false" style="margin-bottom: 12px">
|
||||
将对已选的
|
||||
<strong>{{ selectedRows.length }}</strong>
|
||||
条记录执行提取并标记为已提取。
|
||||
将对已选的 <strong>{{ selectedRows.length }}</strong> 条记录执行提取并标记为已提取。
|
||||
</el-alert>
|
||||
<el-form label-width="84px">
|
||||
<el-form-item label="提取平台">
|
||||
@@ -1174,16 +1230,67 @@ async function handleBatchProbe() {
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="batchExtractVisible = false">取消</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
@click="handleBatchExtract"
|
||||
>
|
||||
<el-button type="primary" :loading="loading" @click="handleBatchExtract">
|
||||
确认提取
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="batchProbeDialogVisible"
|
||||
:title="batchProbePhase === 'running' ? '批量检测中' : '批量检测结果'"
|
||||
width="440px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
:show-close="batchProbePhase === 'done'"
|
||||
@close="closeBatchProbeDialog"
|
||||
>
|
||||
<div v-if="batchProbePhase === 'running'" class="batch-probe-progress">
|
||||
<div class="batch-probe-icon">
|
||||
<el-icon class="is-loading" :size="36" color="#409eff">
|
||||
<Loading />
|
||||
</el-icon>
|
||||
</div>
|
||||
<el-progress
|
||||
:percentage="batchProbeProgress.percent"
|
||||
:stroke-width="14"
|
||||
striped
|
||||
striped-flow
|
||||
:duration="8"
|
||||
/>
|
||||
<div class="batch-probe-status">
|
||||
正在检测第 {{ batchProbeProgress.current }} / {{ batchProbeProgress.total }} 条
|
||||
</div>
|
||||
<div v-if="batchProbeProgress.currentId" class="batch-probe-id">
|
||||
当前 ID:{{ batchProbeProgress.currentId }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="batch-probe-summary">
|
||||
<div class="batch-probe-summary-title">检测完成</div>
|
||||
<div class="batch-probe-summary-grid">
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">共检测</span>
|
||||
<span class="summary-value">{{ batchProbeSummary.total }} 条</span>
|
||||
</div>
|
||||
<div class="summary-item available">
|
||||
<span class="summary-label">可用</span>
|
||||
<span class="summary-value">{{ batchProbeSummary.available }} 条</span>
|
||||
</div>
|
||||
<div class="summary-item unavailable">
|
||||
<span class="summary-label">失效</span>
|
||||
<span class="summary-value">{{ batchProbeSummary.unavailable }} 条</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="batchProbeSummary.skipped > 0" class="batch-probe-skipped">
|
||||
已跳过无 Token {{ batchProbeSummary.skipped }} 条
|
||||
</div>
|
||||
</div>
|
||||
<template v-if="batchProbePhase === 'done'" #footer>
|
||||
<el-button type="primary" @click="closeBatchProbeDialog">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 接口说明抽屉 -->
|
||||
<el-drawer
|
||||
v-model="apiDocVisible"
|
||||
@@ -1337,7 +1444,7 @@ async function handleBatchProbe() {
|
||||
}
|
||||
|
||||
:deep(.pool-batch-extract-dialog) {
|
||||
max-width: 420px;
|
||||
max-width: 600px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
@@ -1375,6 +1482,12 @@ async function handleBatchProbe() {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.pager :deep(.el-pagination) {
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
row-gap: 8px;
|
||||
}
|
||||
|
||||
:deep(.pool-batch-extract-dialog) {
|
||||
width: calc(100vw - 24px) !important;
|
||||
margin: 0 auto;
|
||||
@@ -1398,6 +1511,7 @@ async function handleBatchProbe() {
|
||||
gap: 12px;
|
||||
padding: 8px 12px 12px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* 接口说明抽屉 */
|
||||
@@ -1501,6 +1615,88 @@ async function handleBatchProbe() {
|
||||
font-size: 12px;
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.batch-probe-progress {
|
||||
padding: 8px 4px 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.batch-probe-icon {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.batch-probe-status {
|
||||
margin-top: 16px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.batch-probe-id {
|
||||
margin-top: 8px;
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.batch-probe-summary {
|
||||
padding: 8px 4px 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.batch-probe-summary-title {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: #303133;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.batch-probe-summary-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.summary-item {
|
||||
padding: 14px 10px;
|
||||
border-radius: 12px;
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
.summary-item.available {
|
||||
background: #f0f9eb;
|
||||
}
|
||||
|
||||
.summary-item.unavailable {
|
||||
background: #fef0f0;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
display: block;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.summary-item.available .summary-value {
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
.summary-item.unavailable .summary-value {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.batch-probe-skipped {
|
||||
margin-top: 14px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
@@ -1516,16 +1712,14 @@ async function handleBatchProbe() {
|
||||
/* Cursor 探测结果弹窗(teleport 到 body,需非 scoped) */
|
||||
.cursor-probe-dialog .el-message-box__message {
|
||||
padding: 12px 8px 4px;
|
||||
width: 100%;
|
||||
}
|
||||
.cursor-probe-dialog .cursor-probe-result {
|
||||
margin: 0;
|
||||
max-height: 420px;
|
||||
overflow: auto;
|
||||
text-align: left;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
line-height: 1.6;
|
||||
font-weight: 500;
|
||||
white-space: pre-wrap;
|
||||
font-weight: 600;
|
||||
word-break: break-all;
|
||||
}
|
||||
.cursor-probe-dialog .cursor-expire-result {
|
||||
|
||||
@@ -0,0 +1,957 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue';
|
||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus';
|
||||
import {
|
||||
addCursorActivationCode,
|
||||
deleteCursorActivationCode,
|
||||
disableCursorActivationCode,
|
||||
enableCursorActivationCode,
|
||||
exportCursorActivationCode,
|
||||
generateCursorActivationCode,
|
||||
getCursorActivationCodeDetail,
|
||||
getCursorActivationCodeList,
|
||||
updateCursorActivationCode,
|
||||
} from '../../../api/cursorActivationCode';
|
||||
|
||||
type ActivationCodeRow = Record<string, any>;
|
||||
|
||||
const loading = ref(false);
|
||||
const actionLoading = ref(false);
|
||||
const editVisible = ref(false);
|
||||
const generateVisible = ref(false);
|
||||
const detailVisible = ref(false);
|
||||
const isMobile = ref(false);
|
||||
const currentRow = ref<ActivationCodeRow | null>(null);
|
||||
const selectedRows = ref<ActivationCodeRow[]>([]);
|
||||
const tableData = ref<ActivationCodeRow[]>([]);
|
||||
const total = ref(0);
|
||||
const formRef = ref<FormInstance>();
|
||||
const generateFormRef = ref<FormInstance>();
|
||||
|
||||
const query = reactive({
|
||||
keyword: '',
|
||||
status: '',
|
||||
type: '',
|
||||
bindStatus: '',
|
||||
});
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
});
|
||||
|
||||
const form = reactive({
|
||||
id: '',
|
||||
code: '',
|
||||
type: 30,
|
||||
status: 0,
|
||||
durationDays: 30,
|
||||
bindAccount: '',
|
||||
bindDeviceId: '',
|
||||
ownerUserId: '',
|
||||
ownerUserName: '',
|
||||
activatedAt: '',
|
||||
expiredAt: '',
|
||||
remark: '',
|
||||
});
|
||||
|
||||
const generateForm = reactive({
|
||||
count: 10,
|
||||
type: 30,
|
||||
durationDays: 30,
|
||||
ownerUserId: '',
|
||||
ownerUserName: '',
|
||||
remark: '',
|
||||
});
|
||||
|
||||
const statusOptions = [
|
||||
{ label: '未使用', value: 0 },
|
||||
{ label: '已使用', value: 1 },
|
||||
{ label: '已过期', value: 2 },
|
||||
{ label: '已禁用', value: 3 },
|
||||
];
|
||||
|
||||
const typeOptions = [
|
||||
{ label: '天卡', value: 1, days: 1 },
|
||||
{ label: '周卡', value: 7, days: 7 },
|
||||
{ label: '月卡', value: 30, days: 30 },
|
||||
{ label: '季卡', value: 90, days: 90 },
|
||||
{ label: '年卡', value: 365, days: 365 },
|
||||
{ label: '自定义', value: 0, days: 0 },
|
||||
];
|
||||
|
||||
const bindStatusOptions = [
|
||||
{ label: '未绑定', value: 0 },
|
||||
{ label: '已绑定', value: 1 },
|
||||
];
|
||||
|
||||
const statusMap: Record<string, { label: string; type: string }> = {
|
||||
'0': { label: '未使用', type: 'info' },
|
||||
'1': { label: '已使用', type: 'success' },
|
||||
'2': { label: '已过期', type: 'warning' },
|
||||
'3': { label: '已禁用', type: 'danger' },
|
||||
};
|
||||
|
||||
const rules: FormRules = {
|
||||
code: [{ required: true, message: '请输入激活码', trigger: 'blur' }],
|
||||
type: [{ required: true, message: '请选择卡密类型', trigger: 'change' }],
|
||||
durationDays: [{ required: true, message: '请输入有效天数', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
};
|
||||
|
||||
const generateRules: FormRules = {
|
||||
count: [{ required: true, message: '请输入生成数量', trigger: 'blur' }],
|
||||
type: [{ required: true, message: '请选择卡密类型', trigger: 'change' }],
|
||||
durationDays: [{ required: true, message: '请输入有效天数', trigger: 'blur' }],
|
||||
};
|
||||
|
||||
const summary = computed(() => {
|
||||
const unused = tableData.value.filter((item) => Number(item.status) === 0).length;
|
||||
const used = tableData.value.filter((item) => Number(item.status) === 1).length;
|
||||
const expired = tableData.value.filter((item) => Number(item.status) === 2).length;
|
||||
const disabled = tableData.value.filter((item) => Number(item.status) === 3).length;
|
||||
|
||||
return [
|
||||
{ label: '当前页激活码', value: tableData.value.length, type: 'primary' },
|
||||
{ label: '未使用', value: unused, type: 'info' },
|
||||
{ label: '已使用', value: used, type: 'success' },
|
||||
{ label: '过期/禁用', value: expired + disabled, type: 'danger' },
|
||||
];
|
||||
});
|
||||
|
||||
watch(
|
||||
() => [query.keyword, query.status, query.type, query.bindStatus],
|
||||
() => {
|
||||
pagination.page = 1;
|
||||
fetchList();
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => [pagination.page, pagination.pageSize],
|
||||
() => {
|
||||
fetchList();
|
||||
},
|
||||
);
|
||||
|
||||
function pick(raw: any, ...keys: string[]) {
|
||||
for (const key of keys) {
|
||||
if (raw?.[key] !== undefined && raw?.[key] !== null) return raw[key];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function formatTime(value: any) {
|
||||
if (!value) return '';
|
||||
const d = new Date(value);
|
||||
if (Number.isNaN(d.getTime())) return String(value);
|
||||
const p = (v: number) => String(v).padStart(2, '0');
|
||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`;
|
||||
}
|
||||
|
||||
function normalizeRow(raw: any): ActivationCodeRow {
|
||||
const status = Number(pick(raw, 'status', 'Status') || 0);
|
||||
const type = Number(pick(raw, 'type', 'Type', 'card_type', 'cardType') || 0);
|
||||
const bindAccount = pick(raw, 'bind_account', 'bindAccount', 'BindAccount', 'account', 'Account', 'email', 'Email');
|
||||
const bindDeviceId = pick(raw, 'bind_device_id', 'bindDeviceId', 'BindDeviceID', 'device_id', 'deviceId');
|
||||
|
||||
return {
|
||||
id: pick(raw, 'id', 'ID', 'Id'),
|
||||
code: pick(raw, 'code', 'Code', 'activation_code', 'activationCode', 'card_no', 'cardNo'),
|
||||
type,
|
||||
typeName: typeLabel(type),
|
||||
status,
|
||||
durationDays: Number(pick(raw, 'duration_days', 'durationDays', 'DurationDays', 'days', 'Days') || 0),
|
||||
bindAccount,
|
||||
bindDeviceId,
|
||||
bindStatus: bindAccount || bindDeviceId ? 1 : 0,
|
||||
deviceInfo: pick(raw, 'device_info', 'deviceInfo', 'DeviceInfo'),
|
||||
machineCode: pick(raw, 'machine_code', 'machineCode', 'MachineCode'),
|
||||
ownerUserId: pick(raw, 'owner_user_id', 'ownerUserId', 'OwnerUserID'),
|
||||
ownerUserName: pick(raw, 'owner_user_name', 'ownerUserName', 'OwnerUserName', 'owner', 'Owner', 'user_name', 'userName'),
|
||||
activatedAt: formatTime(pick(raw, 'activated_at', 'activatedAt', 'activation_time', 'activationTime')),
|
||||
expiredAt: formatTime(pick(raw, 'expired_at', 'expiredAt', 'expire_time', 'expireTime')),
|
||||
createdAt: formatTime(pick(raw, 'created_at', 'createdAt', 'create_time', 'createTime', 'CreatedAt')),
|
||||
updatedAt: formatTime(pick(raw, 'updated_at', 'updatedAt', 'update_time', 'updateTime', 'UpdatedAt')),
|
||||
remark: pick(raw, 'remark', 'Remark'),
|
||||
raw,
|
||||
};
|
||||
}
|
||||
|
||||
function statusLabel(status: string | number) {
|
||||
const key = String(status ?? '');
|
||||
return statusMap[key]?.label || key || '-';
|
||||
}
|
||||
|
||||
function statusTagType(status: string | number) {
|
||||
return statusMap[String(status ?? '')]?.type || 'info';
|
||||
}
|
||||
|
||||
function typeLabel(type: string | number) {
|
||||
const item = typeOptions.find((option) => Number(option.value) === Number(type));
|
||||
return item?.label || (type ? `${type}天` : '自定义');
|
||||
}
|
||||
|
||||
function resetQuery() {
|
||||
query.keyword = '';
|
||||
query.status = '';
|
||||
query.type = '';
|
||||
query.bindStatus = '';
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.id = '';
|
||||
form.code = '';
|
||||
form.type = 30;
|
||||
form.status = 0;
|
||||
form.durationDays = 30;
|
||||
form.bindAccount = '';
|
||||
form.bindDeviceId = '';
|
||||
form.ownerUserId = '';
|
||||
form.ownerUserName = '';
|
||||
form.activatedAt = '';
|
||||
form.expiredAt = '';
|
||||
form.remark = '';
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
|
||||
function resetGenerateForm() {
|
||||
generateForm.count = 10;
|
||||
generateForm.type = 30;
|
||||
generateForm.durationDays = 30;
|
||||
generateForm.ownerUserId = '';
|
||||
generateForm.ownerUserName = '';
|
||||
generateForm.remark = '';
|
||||
generateFormRef.value?.clearValidate();
|
||||
}
|
||||
|
||||
function handleSelectionChange(rows: ActivationCodeRow[]) {
|
||||
selectedRows.value = rows;
|
||||
}
|
||||
|
||||
function handleTypeChange(type: number) {
|
||||
const item = typeOptions.find((option) => Number(option.value) === Number(type));
|
||||
if (item && item.days > 0) form.durationDays = item.days;
|
||||
}
|
||||
|
||||
function handleGenerateTypeChange(type: number) {
|
||||
const item = typeOptions.find((option) => Number(option.value) === Number(type));
|
||||
if (item && item.days > 0) generateForm.durationDays = item.days;
|
||||
}
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getCursorActivationCodeList({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
keyword: query.keyword || undefined,
|
||||
status: query.status === '' ? undefined : query.status,
|
||||
type: query.type === '' ? undefined : query.type,
|
||||
bindStatus: query.bindStatus === '' ? undefined : query.bindStatus,
|
||||
});
|
||||
|
||||
if (res?.code !== 200) {
|
||||
ElMessage.error(res?.msg || '获取激活码列表失败');
|
||||
return;
|
||||
}
|
||||
|
||||
const list = Array.isArray(res?.data?.list) ? res.data.list : Array.isArray(res?.data) ? res.data : [];
|
||||
tableData.value = list.map(normalizeRow);
|
||||
total.value = Number(res?.data?.total || list.length || 0);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function openAdd() {
|
||||
currentRow.value = null;
|
||||
resetForm();
|
||||
editVisible.value = true;
|
||||
}
|
||||
|
||||
function openEdit(row: ActivationCodeRow) {
|
||||
currentRow.value = row;
|
||||
resetForm();
|
||||
form.id = String(row.id || '');
|
||||
form.code = row.code || '';
|
||||
form.type = Number(row.type || 0);
|
||||
form.status = Number(row.status || 0);
|
||||
form.durationDays = Number(row.durationDays || 0);
|
||||
form.bindAccount = row.bindAccount || '';
|
||||
form.bindDeviceId = row.bindDeviceId ? String(row.bindDeviceId) : '';
|
||||
form.ownerUserId = row.ownerUserId ? String(row.ownerUserId) : '';
|
||||
form.ownerUserName = row.ownerUserName || '';
|
||||
form.activatedAt = row.activatedAt || '';
|
||||
form.expiredAt = row.expiredAt || '';
|
||||
form.remark = row.remark || '';
|
||||
editVisible.value = true;
|
||||
}
|
||||
|
||||
function openGenerate() {
|
||||
resetGenerateForm();
|
||||
generateVisible.value = true;
|
||||
}
|
||||
|
||||
async function openDetail(row: ActivationCodeRow) {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getCursorActivationCodeDetail(row.id);
|
||||
if (res?.code === 200) {
|
||||
currentRow.value = normalizeRow(res.data || row.raw || row);
|
||||
} else {
|
||||
currentRow.value = row;
|
||||
ElMessage.warning(res?.msg || '详情接口异常,已展示列表数据');
|
||||
}
|
||||
detailVisible.value = true;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
await formRef.value?.validate();
|
||||
|
||||
actionLoading.value = true;
|
||||
try {
|
||||
const data = {
|
||||
id: form.id || undefined,
|
||||
code: form.code,
|
||||
type: Number(form.type),
|
||||
status: Number(form.status),
|
||||
durationDays: Number(form.durationDays || 0),
|
||||
bindAccount: form.bindAccount || undefined,
|
||||
bindDeviceId: form.bindDeviceId || undefined,
|
||||
ownerUserId: form.ownerUserId || undefined,
|
||||
ownerUserName: form.ownerUserName || undefined,
|
||||
activatedAt: form.activatedAt || undefined,
|
||||
expiredAt: form.expiredAt || undefined,
|
||||
remark: form.remark || undefined,
|
||||
};
|
||||
|
||||
const api = form.id ? updateCursorActivationCode : addCursorActivationCode;
|
||||
const res = await api(data);
|
||||
|
||||
if (res?.code !== 200) {
|
||||
ElMessage.error(res?.msg || '保存失败');
|
||||
return;
|
||||
}
|
||||
|
||||
ElMessage.success(form.id ? '激活码已更新' : '激活码已新增');
|
||||
editVisible.value = false;
|
||||
await fetchList();
|
||||
} finally {
|
||||
actionLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleGenerate() {
|
||||
await generateFormRef.value?.validate();
|
||||
|
||||
actionLoading.value = true;
|
||||
try {
|
||||
const res = await generateCursorActivationCode({
|
||||
count: Number(generateForm.count || 1),
|
||||
type: Number(generateForm.type),
|
||||
durationDays: Number(generateForm.durationDays || 0),
|
||||
ownerUserId: generateForm.ownerUserId || undefined,
|
||||
ownerUserName: generateForm.ownerUserName || undefined,
|
||||
remark: generateForm.remark || undefined,
|
||||
});
|
||||
|
||||
if (res?.code !== 200) {
|
||||
ElMessage.error(res?.msg || '生成失败');
|
||||
return;
|
||||
}
|
||||
|
||||
ElMessage.success('激活码已生成');
|
||||
generateVisible.value = false;
|
||||
await fetchList();
|
||||
} finally {
|
||||
actionLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(row: ActivationCodeRow) {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确认删除激活码「${row.code || row.id}」?`, '删除激活码', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '确认删除',
|
||||
cancelButtonText: '取消',
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await deleteCursorActivationCode(row.id);
|
||||
if (res?.code !== 200) {
|
||||
ElMessage.error(res?.msg || '删除失败');
|
||||
return;
|
||||
}
|
||||
|
||||
ElMessage.success('激活码已删除');
|
||||
await fetchList();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleBatchDelete() {
|
||||
if (!selectedRows.value.length) {
|
||||
ElMessage.warning('请选择需要删除的激活码');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(`确认删除选中的 ${selectedRows.value.length} 个激活码?`, '批量删除', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '确认删除',
|
||||
cancelButtonText: '取消',
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
for (const row of selectedRows.value) {
|
||||
const res = await deleteCursorActivationCode(row.id);
|
||||
if (res?.code !== 200) {
|
||||
ElMessage.error(res?.msg || `删除「${row.code || row.id}」失败`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ElMessage.success('选中激活码已删除');
|
||||
selectedRows.value = [];
|
||||
await fetchList();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleToggleStatus(row: ActivationCodeRow) {
|
||||
const isDisabled = Number(row.status) === 3;
|
||||
const title = isDisabled ? '启用激活码' : '禁用激活码';
|
||||
const text = isDisabled ? '确认启用该激活码?' : '确认禁用该激活码?';
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(text, title, {
|
||||
type: 'info',
|
||||
confirmButtonText: isDisabled ? '确认启用' : '确认禁用',
|
||||
cancelButtonText: '取消',
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const api = isDisabled ? enableCursorActivationCode : disableCursorActivationCode;
|
||||
const res = await api(row.id);
|
||||
|
||||
if (res?.code !== 200) {
|
||||
ElMessage.error(res?.msg || '操作失败');
|
||||
return;
|
||||
}
|
||||
|
||||
ElMessage.success(isDisabled ? '激活码已启用' : '激活码已禁用');
|
||||
await fetchList();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function copyCode(code: unknown) {
|
||||
const text = String(code || '').trim();
|
||||
if (!text) {
|
||||
ElMessage.warning('暂无激活码可复制');
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
ElMessage.success('激活码已复制');
|
||||
});
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await exportCursorActivationCode({
|
||||
keyword: query.keyword || undefined,
|
||||
status: query.status === '' ? undefined : query.status,
|
||||
type: query.type === '' ? undefined : query.type,
|
||||
bindStatus: query.bindStatus === '' ? undefined : query.bindStatus,
|
||||
});
|
||||
|
||||
const blob = res instanceof Blob ? res : res?.data instanceof Blob ? res.data : null;
|
||||
if (!blob) {
|
||||
ElMessage.success('导出请求已提交');
|
||||
return;
|
||||
}
|
||||
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = `cursor-activation-code-${Date.now()}.xlsx`;
|
||||
link.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function updateDeviceType() {
|
||||
isMobile.value = window.innerWidth <= 768;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
updateDeviceType();
|
||||
window.addEventListener('resize', updateDeviceType);
|
||||
fetchList();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', updateDeviceType);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="cursor-activation-code-page">
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>激活码管理(Cursor)</span>
|
||||
<div class="header-actions">
|
||||
<el-button type="success" @click="openGenerate">批量生成</el-button>
|
||||
<el-button type="primary" @click="openAdd">新增激活码</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="summary-grid">
|
||||
<div v-for="item in summary" :key="item.label" class="summary-card">
|
||||
<div class="summary-label">{{ item.label }}</div>
|
||||
<div class="summary-value" :class="`is-${item.type}`">{{ item.value }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-left">
|
||||
<el-input v-model="query.keyword" placeholder="搜索激活码 / 账号 / 设备 / 归属用户" clearable class="w-320" />
|
||||
<el-select v-model="query.status" placeholder="使用状态" clearable class="w-140">
|
||||
<el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<el-select v-model="query.type" placeholder="卡密类型" clearable class="w-140">
|
||||
<el-option v-for="item in typeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<el-select v-model="query.bindStatus" placeholder="绑定状态" clearable class="w-140">
|
||||
<el-option v-for="item in bindStatusOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<el-button @click="resetQuery">重置</el-button>
|
||||
</div>
|
||||
<div class="toolbar-right">
|
||||
<el-button :disabled="!selectedRows.length" type="danger" plain @click="handleBatchDelete">批量删除</el-button>
|
||||
<el-button @click="handleExport">导出</el-button>
|
||||
<el-button :loading="loading" @click="fetchList">刷新</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-scroll">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
class="activation-code-table"
|
||||
:data="tableData"
|
||||
border
|
||||
stripe
|
||||
style="width: 100%"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="52" />
|
||||
<el-table-column prop="id" label="ID" width="80" />
|
||||
<el-table-column label="激活码" min-width="260" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<span class="code-text">{{ row.code || '-' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="类型" width="100" align="center">
|
||||
<template #default="{ row }">{{ row.typeName || typeLabel(row.type) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="有效天数" width="100" align="center">
|
||||
<template #default="{ row }">{{ row.durationDays || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusTagType(row.status)">
|
||||
{{ statusLabel(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="绑定信息" min-width="220" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<div>{{ row.bindAccount || '-' }}</div>
|
||||
<div class="muted">设备:{{ row.machineCode || row.bindDeviceId || '-' }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column prop="ownerUserName" label="归属用户" min-width="130" show-overflow-tooltip /> -->
|
||||
<el-table-column prop="activatedAt" label="激活时间" width="180">
|
||||
<template #default="{ row }">{{ row.activatedAt || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="expiredAt" label="过期时间" width="180">
|
||||
<template #default="{ row }">{{ row.expiredAt || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createdAt" label="创建时间" width="180">
|
||||
<template #default="{ row }">{{ row.createdAt || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="290" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openDetail(row)">详情</el-button>
|
||||
<el-button v-if="row.code" link type="primary" @click="copyCode(row.code)">复制</el-button>
|
||||
<el-button link type="warning" @click="openEdit(row)">编辑</el-button>
|
||||
<el-button link :type="Number(row.status) === 3 ? 'success' : 'info'" @click="handleToggleStatus(row)">
|
||||
{{ Number(row.status) === 3 ? '启用' : '禁用' }}
|
||||
</el-button>
|
||||
<el-button link type="danger" @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pager">
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
background
|
||||
:layout="isMobile ? 'prev, pager, next' : 'total, sizes, prev, pager, next, jumper'"
|
||||
:page-sizes="[20, 50, 100]"
|
||||
:total="total"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-dialog
|
||||
v-model="editVisible"
|
||||
:title="form.id ? '编辑激活码' : '新增激活码'"
|
||||
width="720px"
|
||||
class="activation-code-edit-dialog"
|
||||
>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px">
|
||||
<el-form-item label="激活码" prop="code">
|
||||
<el-input v-model="form.code" placeholder="请输入激活码" clearable />
|
||||
</el-form-item>
|
||||
<el-row :gutter="12">
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="卡密类型" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择卡密类型" class="full" @change="handleTypeChange">
|
||||
<el-option v-for="item in typeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="有效天数" prop="durationDays">
|
||||
<el-input-number v-model="form.durationDays" :min="0" :max="9999" class="full" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="12">
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="form.status" placeholder="请选择状态" class="full">
|
||||
<el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="归属用户ID">
|
||||
<el-input v-model="form.ownerUserId" placeholder="请输入归属用户ID" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="归属用户">
|
||||
<el-input v-model="form.ownerUserName" placeholder="请输入归属用户名称" clearable />
|
||||
</el-form-item>
|
||||
<el-row :gutter="12">
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="绑定账号">
|
||||
<el-input v-model="form.bindAccount" placeholder="请输入绑定账号" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="绑定设备ID">
|
||||
<el-input v-model="form.bindDeviceId" placeholder="请输入绑定设备ID" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="12">
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="激活时间">
|
||||
<el-date-picker
|
||||
v-model="form.activatedAt"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="请选择激活时间"
|
||||
class="full"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="过期时间">
|
||||
<el-date-picker
|
||||
v-model="form.expiredAt"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="请选择过期时间"
|
||||
class="full"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="editVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="actionLoading" @click="handleSave">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="generateVisible" title="批量生成激活码" width="620px" class="activation-code-generate-dialog">
|
||||
<el-form ref="generateFormRef" :model="generateForm" :rules="generateRules" label-width="110px">
|
||||
<el-row :gutter="12">
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="生成数量" prop="count">
|
||||
<el-input-number v-model="generateForm.count" :min="1" :max="10000" class="full" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="卡密类型" prop="type">
|
||||
<el-select
|
||||
v-model="generateForm.type"
|
||||
placeholder="请选择卡密类型"
|
||||
class="full"
|
||||
@change="handleGenerateTypeChange"
|
||||
>
|
||||
<el-option v-for="item in typeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="有效天数" prop="durationDays">
|
||||
<el-input-number v-model="generateForm.durationDays" :min="0" :max="9999" class="full" />
|
||||
</el-form-item>
|
||||
<el-row :gutter="12">
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="归属用户ID">
|
||||
<el-input v-model="generateForm.ownerUserId" placeholder="请输入归属用户ID" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="归属用户">
|
||||
<el-input v-model="generateForm.ownerUserName" placeholder="请输入归属用户名称" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="generateForm.remark" type="textarea" :rows="3" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="generateVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="actionLoading" @click="handleGenerate">确认生成</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-drawer v-model="detailVisible" title="激活码详情" size="640px" direction="rtl" class="activation-code-detail-drawer">
|
||||
<el-descriptions v-if="currentRow" :column="1" border>
|
||||
<el-descriptions-item label="ID">{{ currentRow.id || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="激活码">
|
||||
<span class="code-text">{{ currentRow.code || '-' }}</span>
|
||||
<el-button v-if="currentRow.code" link type="primary" @click="copyCode(currentRow.code)">复制</el-button>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="卡密类型">{{ currentRow.typeName || typeLabel(currentRow.type) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="有效天数">{{ currentRow.durationDays || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="状态">
|
||||
<el-tag :type="statusTagType(currentRow.status)">
|
||||
{{ statusLabel(currentRow.status) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="绑定账号">{{ currentRow.bindAccount || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="绑定设备">{{ currentRow.machineCode || currentRow.bindDeviceId || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="设备信息">{{ currentRow.deviceInfo || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="归属用户">{{ currentRow.ownerUserName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="归属用户ID">{{ currentRow.ownerUserId || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="激活时间">{{ currentRow.activatedAt || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="过期时间">{{ currentRow.expiredAt || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">{{ currentRow.createdAt || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">{{ currentRow.updatedAt || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注">{{ currentRow.remark || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.cursor-activation-code-page {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.card-header,
|
||||
.header-actions,
|
||||
.toolbar,
|
||||
.toolbar-left,
|
||||
.toolbar-right,
|
||||
.code-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.header-actions,
|
||||
.toolbar-left,
|
||||
.toolbar-right,
|
||||
.code-cell {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.summary-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(120px, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.summary-card {
|
||||
padding: 14px 16px;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 8px;
|
||||
background: #fbfcff;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: #409eff;
|
||||
|
||||
&.is-success {
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
&.is-info {
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
&.is-danger {
|
||||
color: #f56c6c;
|
||||
}
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.toolbar-left,
|
||||
.toolbar-right {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.w-320 {
|
||||
width: 320px;
|
||||
}
|
||||
|
||||
.w-140 {
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
.table-scroll {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.activation-code-table {
|
||||
min-width: 1360px;
|
||||
}
|
||||
|
||||
.code-text {
|
||||
font-family: Consolas, Monaco, 'Courier New', monospace;
|
||||
font-weight: 600;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.muted {
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pager {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
:deep(.activation-code-edit-dialog),
|
||||
:deep(.activation-code-generate-dialog) {
|
||||
max-width: calc(100vw - 24px);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.cursor-activation-code-page {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.card-header,
|
||||
.header-actions {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.summary-grid {
|
||||
grid-template-columns: repeat(2, minmax(120px, 1fr));
|
||||
}
|
||||
|
||||
.toolbar-left,
|
||||
.toolbar-right,
|
||||
.w-320,
|
||||
.w-140 {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.toolbar-right .el-button,
|
||||
.header-actions .el-button {
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.pager {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
:deep(.activation-code-detail-drawer) {
|
||||
width: 100vw !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
defineProps({
|
||||
modelValue: {
|
||||
type: Boolean,
|
||||
@@ -45,6 +47,18 @@ function statusType(status: unknown) {
|
||||
if (value === 'failed' || value === '0') return 'danger';
|
||||
return 'info';
|
||||
}
|
||||
|
||||
function copyCode(code: unknown) {
|
||||
const text = String(code || '').trim();
|
||||
if (!text) {
|
||||
ElMessage.warning('暂无激活码可复制');
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
ElMessage.success('激活码已复制');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -54,7 +68,7 @@ function statusType(status: unknown) {
|
||||
title="激活记录"
|
||||
size="760px"
|
||||
direction="rtl"
|
||||
@update:model-value="(v) => emit('update:modelValue', v)"
|
||||
@update:model-value="(v: boolean) => emit('update:modelValue', v)"
|
||||
@opened="emit('refresh')"
|
||||
>
|
||||
<div class="record-header">
|
||||
@@ -74,10 +88,23 @@ function statusType(status: unknown) {
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="account" label="激活账号" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="ip" label="IP" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column prop="clientVersion" label="客户端版本" width="120" />
|
||||
<el-table-column prop="createdAt" label="激活时间" width="180" />
|
||||
<el-table-column label="激活码" min-width="260" show-overflow-tooltip>
|
||||
<template #default="{ row: item }">
|
||||
<span class="code-text">{{ item.activationCode || item.code || '-' }}</span>
|
||||
<el-button v-if="item.activationCode || item.code" link type="primary" @click="copyCode(item.activationCode || item.code)">
|
||||
复制
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="machineCode" label="机器码" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="deviceInfo" label="设备信息" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="durationDays" label="有效天数" width="100" align="center" />
|
||||
<el-table-column prop="activatedAt" label="激活时间" width="180">
|
||||
<template #default="{ row: item }">{{ item.activatedAt || item.createdAt || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="expiredAt" label="到期时间" width="180">
|
||||
<template #default="{ row: item }">{{ item.expiredAt || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="180" show-overflow-tooltip />
|
||||
</el-table>
|
||||
|
||||
@@ -88,8 +115,8 @@ function statusType(status: unknown) {
|
||||
background
|
||||
layout="total, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
@update:current-page="(v) => emit('update:page', v)"
|
||||
@update:page-size="(v) => emit('update:pageSize', v)"
|
||||
@update:current-page="(v: number) => emit('update:page', v)"
|
||||
@update:page-size="(v: number) => emit('update:pageSize', v)"
|
||||
/>
|
||||
</div>
|
||||
</el-drawer>
|
||||
@@ -121,6 +148,12 @@ function statusType(status: unknown) {
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.code-text {
|
||||
font-family: Consolas, Monaco, 'Courier New', monospace;
|
||||
font-weight: 600;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
:deep(.equipment-record-drawer) {
|
||||
width: 100vw !important;
|
||||
|
||||
@@ -16,7 +16,7 @@ const props = defineProps({
|
||||
const emit = defineEmits(['update:modelValue']);
|
||||
|
||||
const statusMap: Record<string, { label: string; type: string }> = {
|
||||
active: { label: '正常', type: 'success' },
|
||||
active: { label: '已激活', type: 'success' },
|
||||
inactive: { label: '未激活', type: 'info' },
|
||||
disabled: { label: '禁用', type: 'danger' },
|
||||
expired: { label: '已过期', type: 'warning' },
|
||||
@@ -50,7 +50,7 @@ function copyText(text: unknown, label = '内容') {
|
||||
:model-value="modelValue"
|
||||
title="设备详情"
|
||||
width="760px"
|
||||
@update:model-value="(v) => emit('update:modelValue', v)"
|
||||
@update:model-value="(v: boolean) => emit('update:modelValue', v)"
|
||||
>
|
||||
<el-descriptions v-if="row" :column="2" border>
|
||||
<el-descriptions-item label="设备ID">
|
||||
@@ -73,7 +73,7 @@ function copyText(text: unknown, label = '内容') {
|
||||
<el-descriptions-item label="机器码">
|
||||
<span class="code-text">{{ display(row.machineCode) }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="授权码">
|
||||
<el-descriptions-item label="绑定激活码">
|
||||
<span class="code-text">{{ display(row.licenseCode) }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="系统平台">
|
||||
@@ -83,7 +83,7 @@ function copyText(text: unknown, label = '内容') {
|
||||
{{ display(row.version) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="绑定账号">
|
||||
{{ display(row.account) }}
|
||||
{{ display(row.raw?.bindAccount || row.raw?.bind_account) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="归属用户">
|
||||
{{ display(row.owner) }}
|
||||
|
||||
@@ -34,28 +34,31 @@ defineProps({
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'update:page', 'update:pageSize', 'refresh']);
|
||||
|
||||
function copyContent(content: unknown) {
|
||||
function copyContent(content: unknown, label = '提取内容') {
|
||||
const text = String(content || '').trim();
|
||||
if (!text) {
|
||||
ElMessage.warning('暂无提取内容可复制');
|
||||
ElMessage.warning(`暂无${label}可复制`);
|
||||
return;
|
||||
}
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
ElMessage.success('提取内容已复制');
|
||||
ElMessage.success(`${label}已复制`);
|
||||
});
|
||||
}
|
||||
|
||||
function statusText(status: unknown) {
|
||||
const value = String(status || '');
|
||||
if (value === 'success' || value === '1') return '成功';
|
||||
if (value === 'failed' || value === '0') return '失败';
|
||||
if (value === 'success' || value === '1') return '已提取';
|
||||
if (value === '2') return '补号';
|
||||
if (value === '3') return '异常';
|
||||
if (value === 'failed' || value === '0') return '未提取';
|
||||
return value || '-';
|
||||
}
|
||||
|
||||
function statusType(status: unknown) {
|
||||
const value = String(status || '');
|
||||
if (value === 'success' || value === '1') return 'success';
|
||||
if (value === 'failed' || value === '0') return 'danger';
|
||||
if (value === '2') return 'warning';
|
||||
if (value === '3' || value === 'failed') return 'danger';
|
||||
return 'info';
|
||||
}
|
||||
</script>
|
||||
@@ -67,7 +70,7 @@ function statusType(status: unknown) {
|
||||
title="提取记录"
|
||||
size="860px"
|
||||
direction="rtl"
|
||||
@update:model-value="(v) => emit('update:modelValue', v)"
|
||||
@update:model-value="(v: boolean) => emit('update:modelValue', v)"
|
||||
@opened="emit('refresh')"
|
||||
>
|
||||
<div class="record-header">
|
||||
@@ -87,19 +90,47 @@ function statusType(status: unknown) {
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="platform" label="提取平台" width="110" />
|
||||
<el-table-column prop="type" label="提取类型" width="110" />
|
||||
<el-table-column prop="account" label="提取账号" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column label="提取内容" min-width="220" show-overflow-tooltip>
|
||||
<el-table-column prop="platform" label="提取平台" width="110">
|
||||
<template #default="{ row: item }">{{ item.platform || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="type" label="数据类型" width="110">
|
||||
<template #default="{ row: item }">{{ item.type || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="Cursor账号" min-width="170" show-overflow-tooltip>
|
||||
<template #default="{ row: item }">
|
||||
<span>{{ item.content || '-' }}</span>
|
||||
<el-button v-if="item.content" link type="primary" @click="copyContent(item.content)">
|
||||
<span>{{ item.account || '-' }}</span>
|
||||
<el-button v-if="item.account" link type="primary" @click="copyContent(item.account, 'Cursor账号')">
|
||||
复制
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="ip" label="IP" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column prop="createdAt" label="提取时间" width="180" />
|
||||
<el-table-column label="密码" min-width="150" show-overflow-tooltip>
|
||||
<template #default="{ row: item }">
|
||||
<span>{{ item.password || '-' }}</span>
|
||||
<el-button v-if="item.password" link type="primary" @click="copyContent(item.password, '密码')">
|
||||
复制
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="Token" min-width="240" show-overflow-tooltip>
|
||||
<template #default="{ row: item }">
|
||||
<span>{{ item.token || '-' }}</span>
|
||||
<el-button v-if="item.token" link type="primary" @click="copyContent(item.token, 'Token')">
|
||||
复制
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="提取内容" min-width="260" show-overflow-tooltip>
|
||||
<template #default="{ row: item }">
|
||||
<span>{{ item.content || '-' }}</span>
|
||||
<el-button v-if="item.content" link type="primary" @click="copyContent(item.content, '提取内容')">
|
||||
复制
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="extractedAt" label="提取时间" width="180">
|
||||
<template #default="{ row: item }">{{ item.extractedAt || item.createdAt || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="180" show-overflow-tooltip />
|
||||
</el-table>
|
||||
|
||||
@@ -110,8 +141,8 @@ function statusType(status: unknown) {
|
||||
background
|
||||
layout="total, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
@update:current-page="(v) => emit('update:page', v)"
|
||||
@update:page-size="(v) => emit('update:pageSize', v)"
|
||||
@update:current-page="(v: number) => emit('update:page', v)"
|
||||
@update:page-size="(v: number) => emit('update:pageSize', v)"
|
||||
/>
|
||||
</div>
|
||||
</el-drawer>
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
getCursorEquipmentExtractRecords,
|
||||
getCursorEquipmentList,
|
||||
updateCursorEquipment,
|
||||
} from '@/api/cursorEquipment';
|
||||
} from '../../../api/cursorEquipment';
|
||||
|
||||
type EquipmentRow = Record<string, any>;
|
||||
|
||||
@@ -60,10 +60,10 @@ const extractState = reactive({
|
||||
});
|
||||
|
||||
const statusOptions = [
|
||||
{ label: '未激活', value: 'inactive' },
|
||||
{ label: '正常', value: 'active' },
|
||||
{ label: '禁用', value: 'disabled' },
|
||||
{ label: '已过期', value: 'expired' },
|
||||
{ label: '未激活', value: 0 },
|
||||
{ label: '已激活', value: 1 },
|
||||
{ label: '禁用', value: 3 },
|
||||
{ label: '已过期', value: 2 },
|
||||
];
|
||||
|
||||
const osOptions = [
|
||||
@@ -74,7 +74,7 @@ const osOptions = [
|
||||
];
|
||||
|
||||
const statusMap: Record<string, { label: string; type: string }> = {
|
||||
active: { label: '正常', type: 'success' },
|
||||
active: { label: '已激活', type: 'success' },
|
||||
inactive: { label: '未激活', type: 'info' },
|
||||
disabled: { label: '禁用', type: 'danger' },
|
||||
expired: { label: '已过期', type: 'warning' },
|
||||
@@ -87,7 +87,7 @@ const summary = computed(() => {
|
||||
const expired = tableData.value.filter((item) => item.status === 'expired').length;
|
||||
return [
|
||||
{ label: '当前页设备', value: tableData.value.length, type: 'primary' },
|
||||
{ label: '正常设备', value: active, type: 'success' },
|
||||
{ label: '已激活设备', value: active, type: 'success' },
|
||||
{ label: '未激活', value: inactive, type: 'info' },
|
||||
{ label: '禁用/过期', value: disabled + expired, type: 'danger' },
|
||||
];
|
||||
@@ -137,24 +137,35 @@ function formatTime(value: any) {
|
||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`;
|
||||
}
|
||||
|
||||
function normalizeEquipmentStatus(status: any) {
|
||||
const value = String(status ?? '').trim();
|
||||
|
||||
if (value === '0' || value === 'inactive') return 'inactive';
|
||||
if (value === '1' || value === 'active' || value === 'normal') return 'active';
|
||||
if (value === '2' || value === 'expired') return 'expired';
|
||||
if (value === '3' || value === 'disabled' || value === 'disable') return 'disabled';
|
||||
|
||||
return value || 'inactive';
|
||||
}
|
||||
|
||||
function normalizeRow(raw: any): EquipmentRow {
|
||||
const status = String(pick(raw, 'status', 'Status') || 'inactive');
|
||||
const status = normalizeEquipmentStatus(pick(raw, 'status', 'Status'));
|
||||
return {
|
||||
id: pick(raw, 'id', 'ID', 'Id'),
|
||||
name: pick(raw, 'name', 'device_name', 'deviceName', 'Name', 'DeviceName'),
|
||||
deviceNo: pick(raw, 'device_no', 'deviceNo', 'DeviceNo', 'serial_no', 'serialNo'),
|
||||
machineCode: pick(raw, 'machine_code', 'machineCode', 'MachineCode', 'fingerprint'),
|
||||
licenseCode: pick(raw, 'license_code', 'licenseCode', 'LicenseCode'),
|
||||
os: pick(raw, 'os', 'OS', 'platform', 'Platform'),
|
||||
licenseCode: pick(raw, 'bindActivationCode', 'activationCode', 'activation_code', 'code', 'Code', 'license_code', 'licenseCode', 'LicenseCode'),
|
||||
os: pick(raw, 'system', 'System', 'os', 'OS', 'platform', 'Platform'),
|
||||
version: pick(raw, 'version', 'Version', 'client_version', 'clientVersion'),
|
||||
account: pick(raw, 'account', 'Account', 'email', 'Email'),
|
||||
account: pick(raw, 'bindActivationCode', 'activationCode', 'activation_code', 'code', 'Code', 'license_code', 'licenseCode', 'LicenseCode'),
|
||||
owner: pick(raw, 'owner', 'Owner', 'user_name', 'userName', 'tenant_name', 'tenantName'),
|
||||
status,
|
||||
activationCount: Number(pick(raw, 'activation_count', 'activationCount', 'ActivationCount') || 0),
|
||||
extractCount: Number(pick(raw, 'extract_count', 'extractCount', 'ExtractCount') || 0),
|
||||
lastActivatedAt: formatTime(pick(raw, 'last_activated_at', 'lastActivatedAt', 'activated_at')),
|
||||
lastActivatedAt: formatTime(pick(raw, 'lastActivatedAt', 'last_activated_at', 'activationTime', 'activation_time', 'activated_at', 'activatedAt')),
|
||||
lastExtractedAt: formatTime(pick(raw, 'last_extracted_at', 'lastExtractedAt', 'extracted_at')),
|
||||
expiredAt: formatTime(pick(raw, 'expired_at', 'expiredAt', 'expire_time', 'expireTime')),
|
||||
expiredAt: formatTime(pick(raw, 'expiredAt', 'expired_at', 'expireTime', 'expire_time')),
|
||||
createdAt: formatTime(pick(raw, 'create_time', 'created_at', 'createdAt', 'CreatedAt')),
|
||||
remark: pick(raw, 'remark', 'Remark'),
|
||||
raw,
|
||||
@@ -164,14 +175,23 @@ function normalizeRow(raw: any): EquipmentRow {
|
||||
function normalizeRecord(raw: any): EquipmentRow {
|
||||
return {
|
||||
id: pick(raw, 'id', 'ID', 'Id'),
|
||||
status: pick(raw, 'status', 'Status', 'result', 'Result'),
|
||||
status: pick(raw, 'status', 'Status', 'result', 'Result', 'isExtracted', 'is_extracted'),
|
||||
activationCode: pick(raw, 'activationCode', 'activation_code', 'code', 'Code'),
|
||||
durationDays: pick(raw, 'durationDays', 'duration_days'),
|
||||
machineCode: pick(raw, 'machineCode', 'machine_code', 'MachineCode'),
|
||||
deviceInfo: pick(raw, 'deviceInfo', 'device_info', 'DeviceInfo'),
|
||||
expiredAt: formatTime(pick(raw, 'expiredAt', 'expired_at', 'expireTime', 'expire_time')),
|
||||
activatedAt: formatTime(pick(raw, 'activatedAt', 'activated_at', 'activationTime', 'activation_time')),
|
||||
account: pick(raw, 'account', 'Account', 'email', 'Email'),
|
||||
platform: pick(raw, 'platform', 'Platform', 'source', 'Source'),
|
||||
password: pick(raw, 'password', 'Password'),
|
||||
token: pick(raw, 'token', 'Token'),
|
||||
platform: pick(raw, 'platform', 'Platform', 'source', 'Source', 'extractedPlatform', 'extracted_platform'),
|
||||
type: pick(raw, 'type', 'Type', 'data_type', 'dataType'),
|
||||
content: pick(raw, 'content', 'Content', 'extract_content', 'extractContent', 'token', 'Token'),
|
||||
content: pick(raw, 'content', 'Content', 'extract_content', 'extractContent'),
|
||||
ip: pick(raw, 'ip', 'IP', 'client_ip', 'clientIp'),
|
||||
clientVersion: pick(raw, 'client_version', 'clientVersion', 'version', 'Version'),
|
||||
createdAt: formatTime(pick(raw, 'create_time', 'created_at', 'createdAt', 'CreatedAt')),
|
||||
extractedAt: formatTime(pick(raw, 'extractedAt', 'extracted_at', 'extracted_time')),
|
||||
remark: pick(raw, 'remark', 'Remark', 'message', 'Message'),
|
||||
raw,
|
||||
};
|
||||
@@ -202,7 +222,7 @@ async function fetchList() {
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
keyword: query.keyword || undefined,
|
||||
status: query.status || undefined,
|
||||
status: query.status === '' ? undefined : query.status,
|
||||
os: query.os || undefined,
|
||||
});
|
||||
if (res?.code !== 200) {
|
||||
@@ -401,7 +421,7 @@ onUnmounted(() => {
|
||||
<div class="toolbar-left">
|
||||
<el-input
|
||||
v-model="query.keyword"
|
||||
placeholder="搜索设备名称 / 编号 / 机器码 / 账号"
|
||||
placeholder="搜索设备名称 / 编号 / 机器码 / 激活码"
|
||||
clearable
|
||||
class="w-300"
|
||||
/>
|
||||
@@ -450,7 +470,7 @@ onUnmounted(() => {
|
||||
<el-table-column prop="version" label="版本" width="110" align="center">
|
||||
<template #default="{ row }">{{ row.version || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="account" label="绑定账号" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="account" label="绑定激活码" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="owner" label="归属用户" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column label="激活/提取" width="120" align="center">
|
||||
<template #default="{ row }">
|
||||
@@ -492,18 +512,18 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<DetailDialog v-model="detailVisible" :row="currentRow" />
|
||||
<DetailDialog v-model="detailVisible" :row="currentRow || undefined" />
|
||||
|
||||
<EditDialog
|
||||
v-model="editVisible"
|
||||
:row="currentRow"
|
||||
:row="currentRow || undefined"
|
||||
:loading="actionLoading"
|
||||
@submit="handleSave"
|
||||
/>
|
||||
|
||||
<DeleteDialog
|
||||
v-model="deleteVisible"
|
||||
:row="currentRow"
|
||||
:row="currentRow || undefined"
|
||||
:loading="actionLoading"
|
||||
@confirm="handleDelete"
|
||||
/>
|
||||
@@ -512,7 +532,7 @@ onUnmounted(() => {
|
||||
v-model="activationVisible"
|
||||
v-model:page="activationState.page"
|
||||
v-model:page-size="activationState.pageSize"
|
||||
:row="currentRow"
|
||||
:row="currentRow || undefined"
|
||||
:loading="activationState.loading"
|
||||
:records="activationState.records"
|
||||
:total="activationState.total"
|
||||
@@ -523,7 +543,7 @@ onUnmounted(() => {
|
||||
v-model="extractVisible"
|
||||
v-model:page="extractState.page"
|
||||
v-model:page-size="extractState.pageSize"
|
||||
:row="currentRow"
|
||||
:row="currentRow || undefined"
|
||||
:loading="extractState.loading"
|
||||
:records="extractState.records"
|
||||
:total="extractState.total"
|
||||
|
||||
@@ -27,6 +27,7 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
server: {
|
||||
host: "127.0.0.1",
|
||||
port: 5000,
|
||||
// 开发时前端在 5000,接口走相对路径 /platform/*、/backend/*,转发到本地 Go(当前 httpport=8081)
|
||||
proxy: {
|
||||
|
||||
Reference in New Issue
Block a user