chore(frontend): introduce prettier + eslint and prune unused code
Backend CI / Backend (push) Has been cancelled
Frontend CI / Frontend (push) Failing after 1m39s

- 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:
2026-05-01 20:39:09 +08:00
parent 21c7892ee4
commit 162abdc97c
258 changed files with 42261 additions and 37556 deletions
@@ -1,160 +1,157 @@
type ClientErrorTone = "error" | "warning";
type ClientActionKind = "bind-account" | "open-console" | "probe-account" | "unbind-account";
type ClientErrorTone = 'error' | 'warning'
type ClientActionKind = 'bind-account' | 'open-console' | 'probe-account' | 'unbind-account'
interface ClientErrorPresentation {
tone: ClientErrorTone;
title: string;
content: string;
tone: ClientErrorTone
title: string
content: string
}
const REMOTE_METHOD_PREFIX = /^Error invoking remote method '[^']+':\s*/i;
const ERROR_PREFIX = /^Error:\s*/i;
const REMOTE_METHOD_PREFIX = /^Error invoking remote method '[^']+':\s*/i
const ERROR_PREFIX = /^Error:\s*/i
function rawErrorMessage(error: unknown): string {
if (error instanceof Error) {
return error.message;
return error.message
}
if (typeof error === "string") {
return error;
if (typeof error === 'string') {
return error
}
return "";
return ''
}
export function unwrapClientErrorMessage(error: unknown, fallback: string): string {
let message = rawErrorMessage(error).trim();
let previous = "";
let message = rawErrorMessage(error).trim()
let previous = ''
while (message && message !== previous) {
previous = message;
message = message
.replace(REMOTE_METHOD_PREFIX, "")
.replace(ERROR_PREFIX, "")
.trim();
previous = message
message = message.replace(REMOTE_METHOD_PREFIX, '').replace(ERROR_PREFIX, '').trim()
}
return message || fallback;
return message || fallback
}
function presentClientError(kind: ClientActionKind, error: unknown): ClientErrorPresentation {
const message = unwrapClientErrorMessage(
error,
kind === "bind-account"
? "账号绑定失败"
: kind === "unbind-account"
? "账号解绑失败"
: kind === "probe-account"
? "账号校验失败"
: "打开平台失败",
);
kind === 'bind-account'
? '账号绑定失败'
: kind === 'unbind-account'
? '账号解绑失败'
: kind === 'probe-account'
? '账号校验失败'
: '打开平台失败',
)
if (message === "desktop_account_bind_window_closed") {
if (message === 'desktop_account_bind_window_closed') {
return {
tone: "warning",
title: "授权已中断",
content: "授权窗口已关闭,本次绑定没有完成。重新点击“绑定账号”即可继续。",
};
tone: 'warning',
title: '授权已中断',
content: '授权窗口已关闭,本次绑定没有完成。重新点击“绑定账号”即可继续。',
}
}
if (message === "desktop_account_bind_limit_reached") {
if (message === 'desktop_account_bind_limit_reached') {
return {
tone: "warning",
title: "授权窗口已达上限",
content: "当前最多同时打开 2 个授权窗口。请先完成或关闭已有授权窗口,再继续新的绑定。",
};
tone: 'warning',
title: '授权窗口已达上限',
content: '当前最多同时打开 2 个授权窗口。请先完成或关闭已有授权窗口,再继续新的绑定。',
}
}
if (message === "desktop_account_upsert_failed") {
if (message === 'desktop_account_upsert_failed') {
return {
tone: "error",
title: "保存授权账号失败",
content: "平台侧授权已经完成,但客户端回写账号信息失败。请稍后重试。",
};
tone: 'error',
title: '保存授权账号失败',
content: '平台侧授权已经完成,但客户端回写账号信息失败。请稍后重试。',
}
}
if (message === "desktop_account_bind_failed") {
if (message === 'desktop_account_bind_failed') {
return {
tone: "error",
title: "账号绑定失败",
content: "授权流程执行失败,请稍后重新发起绑定。",
};
tone: 'error',
title: '账号绑定失败',
content: '授权流程执行失败,请稍后重新发起绑定。',
}
}
if (message.startsWith("desktop_platform_not_supported:")) {
const platformId = message.split(":")[1] || "当前平台";
if (message.startsWith('desktop_platform_not_supported:')) {
const platformId = message.split(':')[1] || '当前平台'
return {
tone: "error",
title: "平台暂不支持",
tone: 'error',
title: '平台暂不支持',
content: `${platformId} 暂时还不支持这个操作。`,
};
}
}
if (message === "desktop_account_sync_conflict") {
if (message === 'desktop_account_sync_conflict') {
return {
tone: "warning",
title: kind === "unbind-account" ? "账号状态已变化" : "账号状态已更新",
content: "当前账号状态刚刚发生了变化。请先刷新列表,再重试这次操作。",
};
tone: 'warning',
title: kind === 'unbind-account' ? '账号状态已变化' : '账号状态已更新',
content: '当前账号状态刚刚发生了变化。请先刷新列表,再重试这次操作。',
}
}
if (message.startsWith("desktop_account_session_expired:")) {
const platformId = message.split(":")[1] || "当前平台";
const platformLabel = platformId === "qiehao" ? "企鹅号" : platformId;
if (message.startsWith('desktop_account_session_expired:')) {
const platformId = message.split(':')[1] || '当前平台'
const platformLabel = platformId === 'qiehao' ? '企鹅号' : platformId
return {
tone: "warning",
title: "授权已过期",
tone: 'warning',
title: '授权已过期',
content: `${platformLabel} 登录态已失效,请重新授权后再打开工作台。`,
};
}
}
if (message === "desktop_account_delete_failed") {
if (message === 'desktop_account_delete_failed') {
return {
tone: "error",
title: "账号解绑失败",
content: "服务端解绑没有成功完成,请稍后重试。",
};
tone: 'error',
title: '账号解绑失败',
content: '服务端解绑没有成功完成,请稍后重试。',
}
}
if (kind === "open-console") {
if (kind === 'open-console') {
return {
tone: "error",
title: "打开平台失败",
tone: 'error',
title: '打开平台失败',
content: message,
};
}
}
if (kind === "probe-account") {
if (kind === 'probe-account') {
return {
tone: "error",
title: "账号校验失败",
tone: 'error',
title: '账号校验失败',
content: message,
};
}
}
if (kind === "unbind-account") {
if (kind === 'unbind-account') {
return {
tone: "error",
title: "账号解绑失败",
tone: 'error',
title: '账号解绑失败',
content: message,
};
}
}
return {
tone: "error",
title: "账号绑定失败",
tone: 'error',
title: '账号绑定失败',
content: message,
};
}
}
export async function showClientActionError(kind: ClientActionKind, error: unknown): Promise<void> {
const presentation = presentClientError(kind, error);
const { Modal } = await import("ant-design-vue");
const showModal = presentation.tone === "warning" ? Modal.warning : Modal.error;
const presentation = presentClientError(kind, error)
const { Modal } = await import('ant-design-vue')
const showModal = presentation.tone === 'warning' ? Modal.warning : Modal.error
showModal({
title: presentation.title,
content: presentation.content,
okText: "知道了",
okText: '知道了',
centered: true,
maskClosable: true,
});
})
}
@@ -1,59 +1,59 @@
const relativeFormatter = new Intl.RelativeTimeFormat("zh-CN", { numeric: "auto" });
const relativeFormatter = new Intl.RelativeTimeFormat('zh-CN', { numeric: 'auto' })
export function formatRelativeTime(value: number): string {
const deltaSeconds = Math.round((value - Date.now()) / 1000);
const absSeconds = Math.abs(deltaSeconds);
const deltaSeconds = Math.round((value - Date.now()) / 1000)
const absSeconds = Math.abs(deltaSeconds)
if (absSeconds < 60) {
return relativeFormatter.format(deltaSeconds, "second");
return relativeFormatter.format(deltaSeconds, 'second')
}
if (absSeconds < 3600) {
return relativeFormatter.format(Math.round(deltaSeconds / 60), "minute");
return relativeFormatter.format(Math.round(deltaSeconds / 60), 'minute')
}
if (absSeconds < 86_400) {
return relativeFormatter.format(Math.round(deltaSeconds / 3600), "hour");
return relativeFormatter.format(Math.round(deltaSeconds / 3600), 'hour')
}
return relativeFormatter.format(Math.round(deltaSeconds / 86_400), "day");
return relativeFormatter.format(Math.round(deltaSeconds / 86_400), 'day')
}
export function formatClock(value: number | null): string {
if (!value) {
return "N/A";
return 'N/A'
}
return new Intl.DateTimeFormat("zh-CN", {
hour: "2-digit",
minute: "2-digit",
month: "2-digit",
day: "2-digit",
}).format(value);
return new Intl.DateTimeFormat('zh-CN', {
hour: '2-digit',
minute: '2-digit',
month: '2-digit',
day: '2-digit',
}).format(value)
}
export function formatDateTime(value: number | null): string {
if (!value) {
return "N/A";
return 'N/A'
}
return new Intl.DateTimeFormat("zh-CN", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
}).format(value);
return new Intl.DateTimeFormat('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
}).format(value)
}
export function formatVerifiedAtLabel(value: number | null): string {
if (!value) {
return "尚未完成校验";
return '尚未完成校验'
}
const deltaMs = Math.abs(Date.now() - value);
const deltaMs = Math.abs(Date.now() - value)
if (deltaMs < 60_000) {
return "刚刚校验通过";
return '刚刚校验通过'
}
if (deltaMs < 60 * 60_000) {
return `${Math.max(1, Math.round(deltaMs / 60_000))} 分钟前校验通过`;
return `${Math.max(1, Math.round(deltaMs / 60_000))} 分钟前校验通过`
}
return `${formatDateTime(value)} 校验通过`;
return `${formatDateTime(value)} 校验通过`
}
export function titleCaseToken(value: string): string {
@@ -61,5 +61,5 @@ export function titleCaseToken(value: string): string {
.split(/[_-]/g)
.filter(Boolean)
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
.join(" ");
.join(' ')
}
@@ -1,184 +1,186 @@
import logoBaijiahao from "../assets/logos/logo_baijiahao.png";
import logoBilibili from "../assets/logos/logo_bilibili.png";
import logoDongchedi from "../assets/logos/logo_dongchedi.svg";
import logoJianshu from "../assets/logos/logo_jianshu.svg";
import logoJuejin from "../assets/logos/logo_juejin.png";
import logoQiehao from "../assets/logos/logo_qiehao.png";
import logoSmzdm from "../assets/logos/logo_smzdm.svg";
import logoSouhu from "../assets/logos/logo_souhu.png";
import logoToutiao from "../assets/logos/logo_toutiao.png";
import logoWangyihao from "../assets/logos/logo_wangyihao.png";
import logoWeixinGzh from "../assets/logos/logo_weixin_gzh.svg";
import logoZhihu from "../assets/logos/logo_zhihu.png";
import logoZol from "../assets/logos/logo_zol.png";
import { aiPlatformCatalog } from "@geo/shared-types";
import { aiPlatformCatalog } from '@geo/shared-types'
import logoBaijiahao from '../assets/logos/logo_baijiahao.png'
import logoBilibili from '../assets/logos/logo_bilibili.png'
import logoDongchedi from '../assets/logos/logo_dongchedi.svg'
import logoJianshu from '../assets/logos/logo_jianshu.svg'
import logoJuejin from '../assets/logos/logo_juejin.png'
import logoQiehao from '../assets/logos/logo_qiehao.png'
import logoSmzdm from '../assets/logos/logo_smzdm.svg'
import logoSouhu from '../assets/logos/logo_souhu.png'
import logoToutiao from '../assets/logos/logo_toutiao.png'
import logoWangyihao from '../assets/logos/logo_wangyihao.png'
import logoWeixinGzh from '../assets/logos/logo_weixin_gzh.svg'
import logoZhihu from '../assets/logos/logo_zhihu.png'
import logoZol from '../assets/logos/logo_zol.png'
export interface DesktopMediaDefinition {
id: string;
label: string;
shortName: string;
accent: string;
loginUrl: string | null;
logoUrl: string | null;
category: "publish" | "monitoring";
description: string;
id: string
label: string
shortName: string
accent: string
loginUrl: string | null
logoUrl: string | null
category: 'publish' | 'monitoring'
description: string
}
export const desktopPublishMediaCatalog: DesktopMediaDefinition[] = [
{
id: "toutiaohao",
label: "头条号",
shortName: "头",
accent: "#f5222d",
loginUrl: "https://mp.toutiao.com/auth/page/login",
id: 'toutiaohao',
label: '头条号',
shortName: '头',
accent: '#f5222d',
loginUrl: 'https://mp.toutiao.com/auth/page/login',
logoUrl: logoToutiao,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
{
id: "baijiahao",
label: "百家号",
shortName: "百",
accent: "#31445a",
loginUrl: "https://baijiahao.baidu.com/builder/theme/bjh/login",
id: 'baijiahao',
label: '百家号',
shortName: '百',
accent: '#31445a',
loginUrl: 'https://baijiahao.baidu.com/builder/theme/bjh/login',
logoUrl: logoBaijiahao,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
{
id: "sohuhao",
label: "搜狐号",
shortName: "搜",
accent: "#fa8c16",
loginUrl: "https://mp.sohu.com/mpfe/v4/login",
id: 'sohuhao',
label: '搜狐号',
shortName: '搜',
accent: '#fa8c16',
loginUrl: 'https://mp.sohu.com/mpfe/v4/login',
logoUrl: logoSouhu,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
{
id: "qiehao",
label: "企鹅号",
shortName: "Q",
accent: "#111827",
loginUrl: "https://om.qq.com",
id: 'qiehao',
label: '企鹅号',
shortName: 'Q',
accent: '#111827',
loginUrl: 'https://om.qq.com',
logoUrl: logoQiehao,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
{
id: "zhihu",
label: "知乎",
shortName: "知",
accent: "#1677ff",
loginUrl: "https://www.zhihu.com/signin",
id: 'zhihu',
label: '知乎',
shortName: '知',
accent: '#1677ff',
loginUrl: 'https://www.zhihu.com/signin',
logoUrl: logoZhihu,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
{
id: "wangyihao",
label: "网易号",
shortName: "网",
accent: "#ff4d4f",
loginUrl: "https://mp.163.com/login.html",
id: 'wangyihao',
label: '网易号',
shortName: '网',
accent: '#ff4d4f',
loginUrl: 'https://mp.163.com/login.html',
logoUrl: logoWangyihao,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
{
id: "jianshu",
label: "简书",
shortName: "简",
accent: "#f56a5e",
loginUrl: "https://www.jianshu.com/sign_in",
id: 'jianshu',
label: '简书',
shortName: '简',
accent: '#f56a5e',
loginUrl: 'https://www.jianshu.com/sign_in',
logoUrl: logoJianshu,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
{
id: "bilibili",
label: "bilibili",
shortName: "B",
accent: "#eb2f96",
loginUrl: "https://www.bilibili.com",
id: 'bilibili',
label: 'bilibili',
shortName: 'B',
accent: '#eb2f96',
loginUrl: 'https://www.bilibili.com',
logoUrl: logoBilibili,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
{
id: "juejin",
label: "稀土掘金",
shortName: "掘",
accent: "#1677ff",
loginUrl: "https://juejin.cn/login",
id: 'juejin',
label: '稀土掘金',
shortName: '掘',
accent: '#1677ff',
loginUrl: 'https://juejin.cn/login',
logoUrl: logoJuejin,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
{
id: "smzdm",
label: "什么值得买",
shortName: "值",
accent: "#f5222d",
loginUrl: "https://zhiyou.smzdm.com/user/login",
id: 'smzdm',
label: '什么值得买',
shortName: '值',
accent: '#f5222d',
loginUrl: 'https://zhiyou.smzdm.com/user/login',
logoUrl: logoSmzdm,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
{
id: "weixin_gzh",
label: "微信公众号",
shortName: "微",
accent: "#13c26b",
loginUrl: "https://mp.weixin.qq.com/cgi-bin/loginpage",
id: 'weixin_gzh',
label: '微信公众号',
shortName: '微',
accent: '#13c26b',
loginUrl: 'https://mp.weixin.qq.com/cgi-bin/loginpage',
logoUrl: logoWeixinGzh,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
{
id: "zol",
label: "中关村在线",
shortName: "Z",
accent: "#ff4d4f",
loginUrl: "https://post.zol.com.cn/v2/manage/works/all",
id: 'zol',
label: '中关村在线',
shortName: 'Z',
accent: '#ff4d4f',
loginUrl: 'https://post.zol.com.cn/v2/manage/works/all',
logoUrl: logoZol,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
{
id: "dongchedi",
label: "懂车帝",
shortName: "懂",
accent: "#fadb14",
loginUrl: "https://mp.dcdapp.com/login",
id: 'dongchedi',
label: '懂车帝',
shortName: '懂',
accent: '#fadb14',
loginUrl: 'https://mp.dcdapp.com/login',
logoUrl: logoDongchedi,
category: "publish",
description: "发布媒体 / 浏览器登录检测",
category: 'publish',
description: '发布媒体 / 浏览器登录检测',
},
];
]
export const desktopMonitoringMediaCatalog: DesktopMediaDefinition[] = aiPlatformCatalog.map((platform) => ({
id: platform.id,
label: platform.label,
shortName: platform.shortName,
accent: platform.accent,
loginUrl: platform.loginUrl,
logoUrl: null,
category: "monitoring",
description: platform.description,
}));
export const desktopMonitoringMediaCatalog: DesktopMediaDefinition[] = aiPlatformCatalog.map(
(platform) => ({
id: platform.id,
label: platform.label,
shortName: platform.shortName,
accent: platform.accent,
loginUrl: platform.loginUrl,
logoUrl: null,
category: 'monitoring',
description: platform.description,
}),
)
export const desktopMediaCatalog = [...desktopPublishMediaCatalog, ...desktopMonitoringMediaCatalog];
export const desktopMediaCatalog = [...desktopPublishMediaCatalog, ...desktopMonitoringMediaCatalog]
export function getDesktopMediaDefinition(platform: string): DesktopMediaDefinition | null {
const key = (platform ?? "").toLowerCase();
return desktopMediaCatalog.find((item) => item.id === key) ?? null;
const key = (platform ?? '').toLowerCase()
return desktopMediaCatalog.find((item) => item.id === key) ?? null
}
export function translateDesktopPlatform(platform: string): string {
return getDesktopMediaDefinition(platform)?.label ?? "未知平台";
return getDesktopMediaDefinition(platform)?.label ?? '未知平台'
}
export function desktopPlatformShortName(platform: string): string {
return getDesktopMediaDefinition(platform)?.shortName ?? "未";
return getDesktopMediaDefinition(platform)?.shortName ?? '未'
}
@@ -1,29 +1,29 @@
import type { RuntimeAccount, RuntimeTask, RuntimeTone } from "../types";
import type { RuntimeAccount, RuntimeTask, RuntimeTone } from '../types'
export function healthTone(health: RuntimeAccount["health"]): RuntimeTone {
export function healthTone(health: RuntimeAccount['health']): RuntimeTone {
switch (health) {
case "live":
return "success";
case "expired":
return "danger";
case "captcha":
return "warn";
case "risk":
return "danger";
case 'live':
return 'success'
case 'expired':
return 'danger'
case 'captcha':
return 'warn'
case 'risk':
return 'danger'
default:
return "info";
return 'info'
}
}
export function taskTone(status: RuntimeTask["status"]): RuntimeTone {
export function taskTone(status: RuntimeTask['status']): RuntimeTone {
switch (status) {
case "succeeded":
return "success";
case "failed":
case "aborted":
case "unknown":
return "danger";
case 'succeeded':
return 'success'
case 'failed':
case 'aborted':
case 'unknown':
return 'danger'
default:
return "info";
return 'info'
}
}