chore(frontend): introduce prettier + eslint and prune unused code
- Add Prettier 3 with prettier-plugin-organize-imports (sorts/removes unused imports) - Add ESLint 10 flat config with typescript-eslint + eslint-plugin-vue + eslint-config-prettier - Add root scripts: format, format:check, lint, lint:fix - Reformat 257 files across admin-web, ops-web, desktop-client, packages - Remove unused locals/exports flagged by --noUnusedLocals/--noUnusedParameters - Fix duplicate localTabLabel key, surrogate-pair regex u-flag, NBSP literal in regex - Skip server/ (Go) and apps/browser-extension/ (deprecated per ADR) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,197 +5,198 @@ import {
|
||||
LinkOutlined,
|
||||
ReloadOutlined,
|
||||
WarningOutlined,
|
||||
} from "@ant-design/icons-vue";
|
||||
import { notification } from "ant-design-vue";
|
||||
import { computed, ref } from "vue";
|
||||
} from '@ant-design/icons-vue'
|
||||
import { notification } from 'ant-design-vue'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import { useDesktopRuntime } from "../composables/useDesktopRuntime";
|
||||
import { showClientActionError } from "../lib/client-errors";
|
||||
import { formatDateTime, formatRelativeTime, formatVerifiedAtLabel } from "../lib/formatters";
|
||||
import { desktopMonitoringMediaCatalog } from "../lib/media-catalog";
|
||||
import type { RuntimeAccount } from "../types";
|
||||
import { useDesktopRuntime } from '../composables/useDesktopRuntime'
|
||||
import { showClientActionError } from '../lib/client-errors'
|
||||
import { formatDateTime, formatRelativeTime, formatVerifiedAtLabel } from '../lib/formatters'
|
||||
import { desktopMonitoringMediaCatalog } from '../lib/media-catalog'
|
||||
import type { RuntimeAccount } from '../types'
|
||||
|
||||
type AccountRow = Readonly<Omit<RuntimeAccount, "tags">> & { tags: readonly string[] };
|
||||
type AccountRow = Readonly<Omit<RuntimeAccount, 'tags'>> & { tags: readonly string[] }
|
||||
|
||||
const { snapshot, refresh, refreshAccounts, loading } = useDesktopRuntime();
|
||||
const { snapshot, refresh, refreshAccounts, loading } = useDesktopRuntime()
|
||||
|
||||
const bindPendingPlatformId = ref<string | null>(null);
|
||||
const openPendingAccountId = ref<string | null>(null);
|
||||
const unbindPendingAccountId = ref<string | null>(null);
|
||||
const bindPendingPlatformId = ref<string | null>(null)
|
||||
const openPendingAccountId = ref<string | null>(null)
|
||||
const unbindPendingAccountId = ref<string | null>(null)
|
||||
|
||||
const aiAccounts = computed(() =>
|
||||
(snapshot.value?.accounts ?? []).filter((account) =>
|
||||
desktopMonitoringMediaCatalog.some((platform) => platform.id === account.platform),
|
||||
),
|
||||
);
|
||||
)
|
||||
|
||||
const overview = computed(() => ({
|
||||
configuredPlatforms: desktopMonitoringMediaCatalog.length,
|
||||
bound: aiAccounts.value.length,
|
||||
live: aiAccounts.value.filter((item) => item.health === "live").length,
|
||||
live: aiAccounts.value.filter((item) => item.health === 'live').length,
|
||||
onlineClients: snapshot.value?.summary.onlineClients ?? 0,
|
||||
}));
|
||||
}))
|
||||
|
||||
const platformCards = computed(() =>
|
||||
desktopMonitoringMediaCatalog.map((platform) => {
|
||||
const matched = aiAccounts.value.filter((account) => account.platform === platform.id);
|
||||
const matched = aiAccounts.value.filter((account) => account.platform === platform.id)
|
||||
return {
|
||||
...platform,
|
||||
account: matched[0] ?? null,
|
||||
duplicateCount: Math.max(0, matched.length - 1),
|
||||
};
|
||||
}
|
||||
}),
|
||||
);
|
||||
)
|
||||
|
||||
function authLabel(account: AccountRow | null) {
|
||||
if (!account) {
|
||||
return "未绑定";
|
||||
return '未绑定'
|
||||
}
|
||||
|
||||
switch (account.authState) {
|
||||
case "active":
|
||||
return "授权正常";
|
||||
case "challenge_required":
|
||||
return account.authReason === "risk_control" ? "触发风控" : "需人工验证";
|
||||
case "expired":
|
||||
return "授权过期";
|
||||
case "expiring_soon":
|
||||
return account.probeState === "network_error" ? "最近校验失败" : "待重新校验";
|
||||
case "revoked":
|
||||
return "已停用";
|
||||
case 'active':
|
||||
return '授权正常'
|
||||
case 'challenge_required':
|
||||
return account.authReason === 'risk_control' ? '触发风控' : '需人工验证'
|
||||
case 'expired':
|
||||
return '授权过期'
|
||||
case 'expiring_soon':
|
||||
return account.probeState === 'network_error' ? '最近校验失败' : '待重新校验'
|
||||
case 'revoked':
|
||||
return '已停用'
|
||||
default:
|
||||
return account.probeState === "queued"
|
||||
? "等待校验"
|
||||
: account.probeState === "probing"
|
||||
? "校验中"
|
||||
: "待校验";
|
||||
return account.probeState === 'queued'
|
||||
? '等待校验'
|
||||
: account.probeState === 'probing'
|
||||
? '校验中'
|
||||
: '待校验'
|
||||
}
|
||||
}
|
||||
|
||||
function authColor(account: AccountRow | null) {
|
||||
if (!account) {
|
||||
return "default";
|
||||
return 'default'
|
||||
}
|
||||
|
||||
switch (account.authState) {
|
||||
case "active":
|
||||
return "success";
|
||||
case "challenge_required":
|
||||
return "warning";
|
||||
case "expired":
|
||||
case "revoked":
|
||||
return "error";
|
||||
case "expiring_soon":
|
||||
return account.probeState === "network_error" ? "warning" : "default";
|
||||
case 'active':
|
||||
return 'success'
|
||||
case 'challenge_required':
|
||||
return 'warning'
|
||||
case 'expired':
|
||||
case 'revoked':
|
||||
return 'error'
|
||||
case 'expiring_soon':
|
||||
return account.probeState === 'network_error' ? 'warning' : 'default'
|
||||
default:
|
||||
return account.probeState === "queued" || account.probeState === "probing"
|
||||
? "processing"
|
||||
: "default";
|
||||
return account.probeState === 'queued' || account.probeState === 'probing'
|
||||
? 'processing'
|
||||
: 'default'
|
||||
}
|
||||
}
|
||||
|
||||
function accountActionAlert(account: AccountRow | null): string | null {
|
||||
if (!account) {
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
|
||||
if (account.authState === "expired") {
|
||||
return "当前账号授权已过期,相关任务会暂停执行。请点击“重新授权”完成登录后再继续。";
|
||||
if (account.authState === 'expired') {
|
||||
return '当前账号授权已过期,相关任务会暂停执行。请点击“重新授权”完成登录后再继续。'
|
||||
}
|
||||
|
||||
if (account.authState !== "challenge_required") {
|
||||
return null;
|
||||
if (account.authState !== 'challenge_required') {
|
||||
return null
|
||||
}
|
||||
|
||||
if (account.authReason === "risk_control" && account.platform === "doubao") {
|
||||
return "豆包账号疑似触发风控,监控已暂停。请点击“打开平台”,在前台完成验证或等待限制解除后,再刷新状态。";
|
||||
if (account.authReason === 'risk_control' && account.platform === 'doubao') {
|
||||
return '豆包账号疑似触发风控,监控已暂停。请点击“打开平台”,在前台完成验证或等待限制解除后,再刷新状态。'
|
||||
}
|
||||
|
||||
if (account.authReason === "risk_control") {
|
||||
return "当前账号疑似触发平台限制,相关任务已暂停。请先打开平台处理验证后,再刷新状态。";
|
||||
if (account.authReason === 'risk_control') {
|
||||
return '当前账号疑似触发平台限制,相关任务已暂停。请先打开平台处理验证后,再刷新状态。'
|
||||
}
|
||||
|
||||
return "当前账号需要人工验证,相关任务会暂停执行。请先打开平台完成验证后,再刷新状态。";
|
||||
return '当前账号需要人工验证,相关任务会暂停执行。请先打开平台完成验证后,再刷新状态。'
|
||||
}
|
||||
|
||||
function verificationLabel(account: AccountRow): string {
|
||||
switch (account.authState) {
|
||||
case "expired":
|
||||
return "需要重新授权";
|
||||
case "revoked":
|
||||
return "已停用";
|
||||
case "challenge_required":
|
||||
return account.authReason === "risk_control" ? "触发风控,需处理" : "需要人工验证";
|
||||
case 'expired':
|
||||
return '需要重新授权'
|
||||
case 'revoked':
|
||||
return '已停用'
|
||||
case 'challenge_required':
|
||||
return account.authReason === 'risk_control' ? '触发风控,需处理' : '需要人工验证'
|
||||
}
|
||||
|
||||
if (account.lastVerifiedAt) {
|
||||
return formatVerifiedAtLabel(account.lastVerifiedAt);
|
||||
return formatVerifiedAtLabel(account.lastVerifiedAt)
|
||||
}
|
||||
if (account.probeState === "queued") {
|
||||
return "等待首轮校验";
|
||||
if (account.probeState === 'queued') {
|
||||
return '等待首轮校验'
|
||||
}
|
||||
if (account.probeState === "probing") {
|
||||
return "正在执行首轮校验";
|
||||
if (account.probeState === 'probing') {
|
||||
return '正在执行首轮校验'
|
||||
}
|
||||
return "尚未完成校验";
|
||||
return '尚未完成校验'
|
||||
}
|
||||
|
||||
function nextProbeLabel(account: AccountRow): string {
|
||||
if (!account.nextProbeAt) {
|
||||
return "未排程";
|
||||
return '未排程'
|
||||
}
|
||||
return formatRelativeTime(account.nextProbeAt);
|
||||
return formatRelativeTime(account.nextProbeAt)
|
||||
}
|
||||
|
||||
function sessionLabel(account: AccountRow): string {
|
||||
switch (account.sessionState) {
|
||||
case "hot":
|
||||
return "活跃会话";
|
||||
case "warm":
|
||||
return "已缓存";
|
||||
case 'hot':
|
||||
return '活跃会话'
|
||||
case 'warm':
|
||||
return '已缓存'
|
||||
default:
|
||||
return "冷启动";
|
||||
return '冷启动'
|
||||
}
|
||||
}
|
||||
|
||||
function isReauthorizePending(account: AccountRow): boolean {
|
||||
return bindPendingPlatformId.value === account.platform;
|
||||
return bindPendingPlatformId.value === account.platform
|
||||
}
|
||||
|
||||
function onlineLabel(account: AccountRow): string {
|
||||
return account.online ? "客户端在线" : "客户端离线";
|
||||
return account.online ? '客户端在线' : '客户端离线'
|
||||
}
|
||||
|
||||
function showActionNotification(
|
||||
type: "success" | "info",
|
||||
title: string,
|
||||
description: string,
|
||||
) {
|
||||
function showActionNotification(type: 'success' | 'info', title: string, description: string) {
|
||||
notification[type]({
|
||||
message: title,
|
||||
description,
|
||||
placement: "topRight",
|
||||
placement: 'topRight',
|
||||
duration: 3.2,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
async function bindPlatform(platformId: string) {
|
||||
bindPendingPlatformId.value = platformId;
|
||||
bindPendingPlatformId.value = platformId
|
||||
|
||||
try {
|
||||
const account = await window.desktopBridge.app.bindPublishAccount(platformId);
|
||||
const platformLabel = desktopMonitoringMediaCatalog.find((item) => item.id === platformId)?.label ?? platformId;
|
||||
showActionNotification("success", "绑定成功", `${account.display_name} 已绑定到 ${platformLabel}`);
|
||||
await refresh();
|
||||
const account = await window.desktopBridge.app.bindPublishAccount(platformId)
|
||||
const platformLabel =
|
||||
desktopMonitoringMediaCatalog.find((item) => item.id === platformId)?.label ?? platformId
|
||||
showActionNotification(
|
||||
'success',
|
||||
'绑定成功',
|
||||
`${account.display_name} 已绑定到 ${platformLabel}`,
|
||||
)
|
||||
await refresh()
|
||||
} catch (error) {
|
||||
showClientActionError("bind-account", error);
|
||||
showClientActionError('bind-account', error)
|
||||
} finally {
|
||||
bindPendingPlatformId.value = null;
|
||||
bindPendingPlatformId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function openPlatform(account: AccountRow) {
|
||||
openPendingAccountId.value = account.id;
|
||||
openPendingAccountId.value = account.id
|
||||
|
||||
try {
|
||||
await window.desktopBridge.app.openPublishAccountConsole({
|
||||
@@ -203,25 +204,29 @@ async function openPlatform(account: AccountRow) {
|
||||
platform: account.platform,
|
||||
platformUid: account.platformUid,
|
||||
displayName: account.displayName,
|
||||
});
|
||||
})
|
||||
} catch (error) {
|
||||
showClientActionError("open-console", error);
|
||||
showClientActionError('open-console', error)
|
||||
} finally {
|
||||
openPendingAccountId.value = null;
|
||||
openPendingAccountId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function unbindPlatform(account: AccountRow) {
|
||||
unbindPendingAccountId.value = account.id;
|
||||
unbindPendingAccountId.value = account.id
|
||||
|
||||
try {
|
||||
await window.desktopBridge.app.unbindPublishAccount(account.id, account.syncVersion);
|
||||
showActionNotification("info", "解绑成功", `${account.displayName} 已从 ${desktopMonitoringMediaCatalog.find((item) => item.id === account.platform)?.label ?? account.platform} 移除`);
|
||||
await refreshAccounts();
|
||||
await window.desktopBridge.app.unbindPublishAccount(account.id, account.syncVersion)
|
||||
showActionNotification(
|
||||
'info',
|
||||
'解绑成功',
|
||||
`${account.displayName} 已从 ${desktopMonitoringMediaCatalog.find((item) => item.id === account.platform)?.label ?? account.platform} 移除`,
|
||||
)
|
||||
await refreshAccounts()
|
||||
} catch (error) {
|
||||
showClientActionError("unbind-account", error);
|
||||
showClientActionError('unbind-account', error)
|
||||
} finally {
|
||||
unbindPendingAccountId.value = null;
|
||||
unbindPendingAccountId.value = null
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -235,7 +240,13 @@ async function unbindPlatform(account: AccountRow) {
|
||||
<h2>AI 平台管理</h2>
|
||||
</div>
|
||||
<div class="hero-actions">
|
||||
<a-button type="primary" ghost class="modern-btn" :loading="loading" @click="refreshAccounts">
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
class="modern-btn"
|
||||
:loading="loading"
|
||||
@click="refreshAccounts"
|
||||
>
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
刷新状态
|
||||
</a-button>
|
||||
@@ -278,7 +289,11 @@ async function unbindPlatform(account: AccountRow) {
|
||||
<div class="brand-info">
|
||||
<div
|
||||
class="brand-logo"
|
||||
:style="{ backgroundColor: `${platform.accent}14`, color: platform.accent, border: `1px solid ${platform.accent}24` }"
|
||||
:style="{
|
||||
backgroundColor: `${platform.accent}14`,
|
||||
color: platform.accent,
|
||||
border: `1px solid ${platform.accent}24`,
|
||||
}"
|
||||
>
|
||||
{{ platform.shortName }}
|
||||
</div>
|
||||
@@ -300,7 +315,9 @@ async function unbindPlatform(account: AccountRow) {
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">平台 UID</span>
|
||||
<span class="info-value mono-text" :title="platform.account.platformUid">{{ platform.account.platformUid }}</span>
|
||||
<span class="info-value mono-text" :title="platform.account.platformUid">
|
||||
{{ platform.account.platformUid }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="info-label">本地会话</span>
|
||||
@@ -322,10 +339,17 @@ async function unbindPlatform(account: AccountRow) {
|
||||
|
||||
<div class="card-footer">
|
||||
<div class="online-status">
|
||||
<a-badge :status="platform.account.online ? 'success' : 'default'" :text="onlineLabel(platform.account)" />
|
||||
<a-badge
|
||||
:status="platform.account.online ? 'success' : 'default'"
|
||||
:text="onlineLabel(platform.account)"
|
||||
/>
|
||||
</div>
|
||||
<div class="action-group">
|
||||
<a-tooltip v-if="platform.account.authState === 'expired'" title="重新授权" placement="top">
|
||||
<a-tooltip
|
||||
v-if="platform.account.authState === 'expired'"
|
||||
title="重新授权"
|
||||
placement="top"
|
||||
>
|
||||
<a-button
|
||||
type="text"
|
||||
class="action-btn"
|
||||
@@ -382,11 +406,7 @@ async function unbindPlatform(account: AccountRow) {
|
||||
</div>
|
||||
|
||||
<div v-if="accountActionAlert(platform.account)" class="card-alert">
|
||||
<a-alert
|
||||
type="warning"
|
||||
show-icon
|
||||
banner
|
||||
>
|
||||
<a-alert type="warning" show-icon banner>
|
||||
<template #message>
|
||||
{{ accountActionAlert(platform.account) }}
|
||||
</template>
|
||||
@@ -395,11 +415,7 @@ async function unbindPlatform(account: AccountRow) {
|
||||
</div>
|
||||
|
||||
<div v-if="platform.duplicateCount > 0" class="card-alert">
|
||||
<a-alert
|
||||
type="warning"
|
||||
show-icon
|
||||
banner
|
||||
>
|
||||
<a-alert type="warning" show-icon banner>
|
||||
<template #message>
|
||||
发现额外 {{ platform.duplicateCount }} 个同平台账号缓存,当前卡片只保留主账号展示。
|
||||
</template>
|
||||
@@ -426,7 +442,9 @@ async function unbindPlatform(account: AccountRow) {
|
||||
background: #ffffff;
|
||||
border-radius: 20px;
|
||||
border: 1px solid #eef2f6;
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -2px rgba(0, 0, 0, 0.01);
|
||||
box-shadow:
|
||||
0 4px 6px -1px rgba(0, 0, 0, 0.02),
|
||||
0 2px 4px -2px rgba(0, 0, 0, 0.01);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -496,7 +514,7 @@ async function unbindPlatform(account: AccountRow) {
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
line-height: 1;
|
||||
font-feature-settings: "tnum";
|
||||
font-feature-settings: 'tnum';
|
||||
}
|
||||
|
||||
/* Content Section Elements */
|
||||
@@ -546,7 +564,9 @@ async function unbindPlatform(account: AccountRow) {
|
||||
|
||||
.modern-card:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
|
||||
box-shadow:
|
||||
0 20px 25px -5px rgba(0, 0, 0, 0.05),
|
||||
0 8px 10px -6px rgba(0, 0, 0, 0.01);
|
||||
border-color: #cbd5e1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user