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,221 +1,223 @@
<script setup lang="ts">
import { CopyOutlined, LinkOutlined } from "@ant-design/icons-vue";
import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { message } from "ant-design-vue";
import type { TableColumnsType } from "ant-design-vue";
import type { ArticleVersion, PublishRecord } from "@geo/shared-types";
import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { CopyOutlined, LinkOutlined } from '@ant-design/icons-vue'
import type { ArticleVersion, PublishRecord } from '@geo/shared-types'
import { useQuery, useQueryClient } from '@tanstack/vue-query'
import type { TableColumnsType } from 'ant-design-vue'
import { message } from 'ant-design-vue'
import { computed, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import ArticlePublishStatus from "@/components/ArticlePublishStatus.vue";
import MarkdownPreview from "@/components/MarkdownPreview.vue";
import ArticlePublishStatus from '@/components/ArticlePublishStatus.vue'
import MarkdownPreview from '@/components/MarkdownPreview.vue'
import {
articlesApi,
isGenerationStreamEnabled,
subscribeArticleGeneration,
type ArticleGenerationStreamEvent,
} from "@/lib/api";
} from '@/lib/api'
import {
formatDateTime,
getGenerateStatusMeta,
getPublishStatusMeta,
getSourceTypeLabel,
} from "@/lib/display";
} from '@/lib/display'
const props = defineProps<{
open: boolean;
articleId: number | null;
}>();
open: boolean
articleId: number | null
}>()
const emit = defineEmits<{
close: [];
}>();
close: []
}>()
const queryClient = useQueryClient();
const { t } = useI18n();
const activeTab = ref("content");
const enabled = computed(() => props.open && Boolean(props.articleId));
const streamTitle = ref("");
const streamMarkdown = ref("");
const streamStatus = ref<string | null>(null);
const streamFeatureEnabled = isGenerationStreamEnabled();
const queryClient = useQueryClient()
const { t } = useI18n()
const activeTab = ref('content')
const enabled = computed(() => props.open && Boolean(props.articleId))
const streamTitle = ref('')
const streamMarkdown = ref('')
const streamStatus = ref<string | null>(null)
const streamFeatureEnabled = isGenerationStreamEnabled()
const detailQuery = useQuery({
queryKey: computed(() => ["articles", "detail", props.articleId]),
queryKey: computed(() => ['articles', 'detail', props.articleId]),
enabled,
queryFn: () => articlesApi.detail(props.articleId as number),
});
})
const versionsQuery = useQuery({
queryKey: computed(() => ["articles", "versions", props.articleId]),
queryKey: computed(() => ['articles', 'versions', props.articleId]),
enabled,
queryFn: () => articlesApi.versions(props.articleId as number),
});
})
const publishRecordsQuery = useQuery({
queryKey: computed(() => ["articles", "publish-records", props.articleId]),
queryKey: computed(() => ['articles', 'publish-records', props.articleId]),
enabled,
queryFn: () => articlesApi.publishRecords(props.articleId as number),
});
})
const versionColumns = computed<TableColumnsType<ArticleVersion>>(() => [
{
title: t("common.versions"),
dataIndex: "version_no",
key: "version_no",
title: t('common.versions'),
dataIndex: 'version_no',
key: 'version_no',
width: 88,
},
{
title: t("common.title"),
dataIndex: "title",
key: "title",
title: t('common.title'),
dataIndex: 'title',
key: 'title',
},
{
title: t("common.source"),
dataIndex: "source_label",
key: "source_label",
title: t('common.source'),
dataIndex: 'source_label',
key: 'source_label',
width: 120,
},
{
title: t("common.wordCount"),
dataIndex: "word_count",
key: "word_count",
title: t('common.wordCount'),
dataIndex: 'word_count',
key: 'word_count',
width: 92,
},
{
title: t("common.createdAt"),
dataIndex: "created_at",
key: "created_at",
title: t('common.createdAt'),
dataIndex: 'created_at',
key: 'created_at',
width: 168,
},
]);
])
const publishRecordColumns = computed<TableColumnsType<PublishRecord>>(() => [
{
title: t("media.records.platform"),
dataIndex: "platform_name",
key: "platform_name",
title: t('media.records.platform'),
dataIndex: 'platform_name',
key: 'platform_name',
width: 140,
},
{
title: t("media.records.status"),
dataIndex: "status",
key: "status",
title: t('media.records.status'),
dataIndex: 'status',
key: 'status',
width: 130,
},
{
title: t("media.records.publishedAt"),
dataIndex: "published_at",
key: "published_at",
title: t('media.records.publishedAt'),
dataIndex: 'published_at',
key: 'published_at',
width: 168,
},
{
title: t("media.records.link"),
dataIndex: "external_article_url",
key: "external_article_url",
title: t('media.records.link'),
dataIndex: 'external_article_url',
key: 'external_article_url',
},
]);
])
const detail = computed(() => detailQuery.data.value);
const displayTitle = computed(() => streamTitle.value || detail.value?.title || t("article.untitled"));
const displayMarkdown = computed(() => streamMarkdown.value || detail.value?.markdown_content || "");
const detail = computed(() => detailQuery.data.value)
const displayTitle = computed(
() => streamTitle.value || detail.value?.title || t('article.untitled'),
)
const displayMarkdown = computed(() => streamMarkdown.value || detail.value?.markdown_content || '')
const generateMeta = computed(() =>
getGenerateStatusMeta(streamStatus.value || detail.value?.generate_status),
);
const sourceArticleTitle = computed(() => detail.value?.source_title?.trim() || "");
const sourceArticleURL = computed(() => detail.value?.source_url?.trim() || "");
)
const sourceArticleTitle = computed(() => detail.value?.source_title?.trim() || '')
const sourceArticleURL = computed(() => detail.value?.source_url?.trim() || '')
function handleClose(): void {
activeTab.value = "content";
emit("close");
activeTab.value = 'content'
emit('close')
}
watch(
[() => props.open, () => props.articleId],
([open, articleId], _prev, onCleanup) => {
resetStreamState();
resetStreamState()
if (!open || !articleId || !streamFeatureEnabled) {
return;
return
}
const controller = new AbortController();
const controller = new AbortController()
void subscribeArticleGeneration(
articleId,
{
onEvent: handleStreamEvent,
onClose: () => {
if (!controller.signal.aborted) {
void refreshArticleData();
void refreshArticleData()
}
},
},
controller.signal,
).catch(() => {
if (controller.signal.aborted) {
return;
return
}
void refreshArticleData();
});
void refreshArticleData()
})
onCleanup(() => {
controller.abort();
});
controller.abort()
})
},
{ immediate: true },
);
)
watch(
[() => props.open, () => props.articleId, () => detail.value?.generate_status],
([open, articleId, generateStatus], _prev, onCleanup) => {
if (!open || !articleId || streamFeatureEnabled || generateStatus !== "generating") {
return;
if (!open || !articleId || streamFeatureEnabled || generateStatus !== 'generating') {
return
}
const timer = window.setInterval(() => {
void refreshArticleData();
}, 2000);
void refreshArticleData()
}, 2000)
onCleanup(() => {
window.clearInterval(timer);
});
window.clearInterval(timer)
})
},
{ immediate: true },
);
)
function handleStreamEvent(event: ArticleGenerationStreamEvent): void {
if (event.type === "ping") {
return;
if (event.type === 'ping') {
return
}
if (event.title) {
streamTitle.value = event.title;
streamTitle.value = event.title
}
if (event.status) {
streamStatus.value = event.status;
streamStatus.value = event.status
}
if (event.type === "snapshot" || event.type === "completed") {
if (event.type === 'snapshot' || event.type === 'completed') {
if (event.content) {
streamMarkdown.value = event.content;
streamMarkdown.value = event.content
}
} else if (event.type === "delta") {
} else if (event.type === 'delta') {
if (event.content) {
streamMarkdown.value = event.content;
streamMarkdown.value = event.content
} else if (event.delta) {
streamMarkdown.value += event.delta;
streamMarkdown.value += event.delta
}
}
if (event.type === "completed" || event.type === "error") {
void refreshArticleData();
if (event.type === 'completed' || event.type === 'error') {
void refreshArticleData()
}
}
function resetStreamState(): void {
streamTitle.value = "";
streamMarkdown.value = "";
streamStatus.value = null;
streamTitle.value = ''
streamMarkdown.value = ''
streamStatus.value = null
}
async function refreshArticleData(): Promise<void> {
@@ -223,29 +225,31 @@ async function refreshArticleData(): Promise<void> {
detailQuery.refetch(),
versionsQuery.refetch(),
publishRecordsQuery.refetch(),
queryClient.invalidateQueries({ queryKey: ["articles"] }),
queryClient.invalidateQueries({ queryKey: ["workspace"] }),
]);
queryClient.invalidateQueries({ queryKey: ['articles'] }),
queryClient.invalidateQueries({ queryKey: ['workspace'] }),
])
}
function resolvePublishLink(record: PublishRecord): string {
return record.external_article_url?.trim() || "";
return record.external_article_url?.trim() || ''
}
function shouldShowClientManageHint(record: PublishRecord): boolean {
return !resolvePublishLink(record)
&& Boolean(record.external_manage_url?.trim())
&& ["weixin_gzh", "zol"].includes(record.platform_id);
return (
!resolvePublishLink(record) &&
Boolean(record.external_manage_url?.trim()) &&
['weixin_gzh', 'zol'].includes(record.platform_id)
)
}
async function copyPublishLink(record: PublishRecord): Promise<void> {
const target = resolvePublishLink(record);
const target = resolvePublishLink(record)
if (!target) {
return;
return
}
await navigator.clipboard.writeText(target);
message.success(t("media.records.copySuccess"));
await navigator.clipboard.writeText(target)
message.success(t('media.records.copySuccess'))
}
</script>
@@ -264,7 +268,7 @@ async function copyPublishLink(record: PublishRecord): Promise<void> {
<template v-else-if="detail">
<section class="article-drawer__hero">
<div>
<p class="eyebrow">{{ t("article.preview") }}</p>
<p class="eyebrow">{{ t('article.preview') }}</p>
<h2>{{ displayTitle }}</h2>
<p>
{{ getSourceTypeLabel(detail.source_type, detail.generation_mode) }} ·
@@ -285,16 +289,16 @@ async function copyPublishLink(record: PublishRecord): Promise<void> {
<section class="article-drawer__meta">
<a-descriptions :column="2" size="small" bordered>
<a-descriptions-item :label="t('article.meta.templateType')">
{{ detail.template_name || "--" }}
{{ detail.template_name || '--' }}
</a-descriptions-item>
<a-descriptions-item :label="t('article.meta.currentVersion')">
{{ detail.version_no ?? "--" }}
{{ detail.version_no ?? '--' }}
</a-descriptions-item>
<a-descriptions-item :label="t('article.meta.source')">
{{ detail.source_label || "--" }}
{{ detail.source_label || '--' }}
</a-descriptions-item>
<a-descriptions-item :label="t('article.meta.wordCount')">
{{ detail.word_count || "--" }}
{{ detail.word_count || '--' }}
</a-descriptions-item>
<a-descriptions-item
v-if="sourceArticleURL"
@@ -347,12 +351,12 @@ async function copyPublishLink(record: PublishRecord): Promise<void> {
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'title'">
<div class="article-drawer__version-title">
<strong>{{ record.title || t("article.versionUntitled") }}</strong>
<strong>{{ record.title || t('article.versionUntitled') }}</strong>
<span>{{ formatDateTime(record.created_at) }}</span>
</div>
</template>
<template v-else-if="column.key === 'source_label'">
{{ record.source_label || "--" }}
{{ record.source_label || '--' }}
</template>
<template v-else-if="column.key === 'created_at'">
{{ formatDateTime(record.created_at) }}
@@ -370,7 +374,7 @@ async function copyPublishLink(record: PublishRecord): Promise<void> {
row-key="id"
size="small"
>
<template #emptyText>{{ t("media.records.empty") }}</template>
<template #emptyText>{{ t('media.records.empty') }}</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'platform_name'">
<div class="article-drawer__record-platform">
@@ -407,8 +411,11 @@ async function copyPublishLink(record: PublishRecord): Promise<void> {
</a-button>
</a-tooltip>
</div>
<span v-else-if="shouldShowClientManageHint(record)" class="article-drawer__record-hint">
{{ t("media.records.clientManageHint") }}
<span
v-else-if="shouldShowClientManageHint(record)"
class="article-drawer__record-hint"
>
{{ t('media.records.clientManageHint') }}
</span>
<span v-else class="article-drawer__record-empty">--</span>
</template>