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:
@@ -1,200 +1,220 @@
|
||||
<script setup lang="ts">
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
import { message, type TableColumnsType } from "ant-design-vue";
|
||||
import type { ArticleListItem, ArticleListParams } from "@geo/shared-types";
|
||||
import type { Dayjs } from "dayjs";
|
||||
import { computed, onBeforeUnmount, reactive, ref, watch } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import type { ArticleListItem, ArticleListParams } from '@geo/shared-types'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query'
|
||||
import { message, type TableColumnsType } from 'ant-design-vue'
|
||||
import type { Dayjs } from 'dayjs'
|
||||
import { computed, onBeforeUnmount, reactive, ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import ArticleActionGroup from "@/components/ArticleActionGroup.vue";
|
||||
import ArticleGenerateStatus from "@/components/ArticleGenerateStatus.vue";
|
||||
import ArticlePublishStatus from "@/components/ArticlePublishStatus.vue";
|
||||
import ArticleSourceMeta from "@/components/ArticleSourceMeta.vue";
|
||||
import ArticleDetailDrawer from "@/components/ArticleDetailDrawer.vue";
|
||||
import PublishArticleModal from "@/components/PublishArticleModal.vue";
|
||||
import { articlesApi, promptRulesApi } from "@/lib/api";
|
||||
import { buildArticleClipboardContent, resolveArticleActionState } from "@/lib/article-list-actions";
|
||||
import {
|
||||
getGenerateStatusMeta,
|
||||
getPublishStatusMeta,
|
||||
} from "@/lib/display";
|
||||
import { formatError } from "@/lib/errors";
|
||||
import { formatPublishPlatformList } from "@/lib/publish-platforms";
|
||||
import ArticleActionGroup from '@/components/ArticleActionGroup.vue'
|
||||
import ArticleDetailDrawer from '@/components/ArticleDetailDrawer.vue'
|
||||
import ArticleGenerateStatus from '@/components/ArticleGenerateStatus.vue'
|
||||
import ArticlePublishStatus from '@/components/ArticlePublishStatus.vue'
|
||||
import ArticleSourceMeta from '@/components/ArticleSourceMeta.vue'
|
||||
import PublishArticleModal from '@/components/PublishArticleModal.vue'
|
||||
import { articlesApi, promptRulesApi } from '@/lib/api'
|
||||
import { buildArticleClipboardContent, resolveArticleActionState } from '@/lib/article-list-actions'
|
||||
import { getGenerateStatusMeta, getPublishStatusMeta } from '@/lib/display'
|
||||
import { formatError } from '@/lib/errors'
|
||||
import { formatPublishPlatformList } from '@/lib/publish-platforms'
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
const queryClient = useQueryClient()
|
||||
const router = useRouter()
|
||||
const { t } = useI18n()
|
||||
|
||||
const page = ref(1);
|
||||
const pageSize = ref(20);
|
||||
const draftGenerationRange = ref<[Dayjs, Dayjs] | null>(null);
|
||||
const page = ref(1)
|
||||
const pageSize = ref(20)
|
||||
const draftGenerationRange = ref<[Dayjs, Dayjs] | null>(null)
|
||||
|
||||
const draftFilters = reactive<{
|
||||
prompt_rule_id?: number;
|
||||
publish_status?: string;
|
||||
generate_status?: string;
|
||||
keyword?: string;
|
||||
prompt_rule_id?: number
|
||||
publish_status?: string
|
||||
generate_status?: string
|
||||
keyword?: string
|
||||
}>({
|
||||
keyword: "",
|
||||
});
|
||||
keyword: '',
|
||||
})
|
||||
|
||||
const appliedFilters = reactive<{
|
||||
prompt_rule_id?: number;
|
||||
publish_status?: string;
|
||||
generate_status?: string;
|
||||
keyword?: string;
|
||||
created_from?: string;
|
||||
created_to?: string;
|
||||
prompt_rule_id?: number
|
||||
publish_status?: string
|
||||
generate_status?: string
|
||||
keyword?: string
|
||||
created_from?: string
|
||||
created_to?: string
|
||||
}>({
|
||||
keyword: "",
|
||||
});
|
||||
keyword: '',
|
||||
})
|
||||
|
||||
const articleDrawerOpen = ref(false);
|
||||
const selectedArticleId = ref<number | null>(null);
|
||||
const publishModalOpen = ref(false);
|
||||
const selectedPublishArticleId = ref<number | null>(null);
|
||||
const articleDrawerOpen = ref(false)
|
||||
const selectedArticleId = ref<number | null>(null)
|
||||
const publishModalOpen = ref(false)
|
||||
const selectedPublishArticleId = ref<number | null>(null)
|
||||
|
||||
const rulesQuery = useQuery({
|
||||
queryKey: ["promptRules", "simple"],
|
||||
queryKey: ['promptRules', 'simple'],
|
||||
queryFn: () => promptRulesApi.listSimple(),
|
||||
});
|
||||
})
|
||||
|
||||
const ruleOptions = computed(() =>
|
||||
(rulesQuery.data.value ?? []).map((r) => ({ label: r.name, value: r.id })),
|
||||
);
|
||||
)
|
||||
|
||||
const generateStatusOptions = computed(() => [
|
||||
{ label: getGenerateStatusMeta("draft").label, value: "draft" },
|
||||
{ label: getGenerateStatusMeta("generating").label, value: "generating" },
|
||||
{ label: getGenerateStatusMeta("completed").label, value: "completed" },
|
||||
{ label: getGenerateStatusMeta("failed").label, value: "failed" },
|
||||
]);
|
||||
{ label: getGenerateStatusMeta('draft').label, value: 'draft' },
|
||||
{ label: getGenerateStatusMeta('generating').label, value: 'generating' },
|
||||
{ label: getGenerateStatusMeta('completed').label, value: 'completed' },
|
||||
{ label: getGenerateStatusMeta('failed').label, value: 'failed' },
|
||||
])
|
||||
|
||||
const publishStatusOptions = computed(() => [
|
||||
{ label: getPublishStatusMeta("unpublished").label, value: "unpublished" },
|
||||
{ label: getPublishStatusMeta("publishing").label, value: "publishing" },
|
||||
{ label: getPublishStatusMeta("success").label, value: "success" },
|
||||
{ label: getPublishStatusMeta("partial_success").label, value: "partial_success" },
|
||||
{ label: getPublishStatusMeta("failed").label, value: "failed" },
|
||||
]);
|
||||
{ label: getPublishStatusMeta('unpublished').label, value: 'unpublished' },
|
||||
{ label: getPublishStatusMeta('publishing').label, value: 'publishing' },
|
||||
{ label: getPublishStatusMeta('success').label, value: 'success' },
|
||||
{ label: getPublishStatusMeta('partial_success').label, value: 'partial_success' },
|
||||
{ label: getPublishStatusMeta('failed').label, value: 'failed' },
|
||||
])
|
||||
|
||||
const articleParams = computed<ArticleListParams>(() => {
|
||||
const params: ArticleListParams = {
|
||||
page: page.value,
|
||||
page_size: pageSize.value,
|
||||
source_type: "custom_generation",
|
||||
};
|
||||
if (appliedFilters.prompt_rule_id) params.prompt_rule_id = appliedFilters.prompt_rule_id;
|
||||
if (appliedFilters.publish_status) params.publish_status = appliedFilters.publish_status;
|
||||
if (appliedFilters.generate_status) params.generate_status = appliedFilters.generate_status;
|
||||
if (appliedFilters.keyword?.trim()) params.keyword = appliedFilters.keyword.trim();
|
||||
if (appliedFilters.created_from) params.created_from = appliedFilters.created_from;
|
||||
if (appliedFilters.created_to) params.created_to = appliedFilters.created_to;
|
||||
return params;
|
||||
});
|
||||
source_type: 'custom_generation',
|
||||
}
|
||||
if (appliedFilters.prompt_rule_id) params.prompt_rule_id = appliedFilters.prompt_rule_id
|
||||
if (appliedFilters.publish_status) params.publish_status = appliedFilters.publish_status
|
||||
if (appliedFilters.generate_status) params.generate_status = appliedFilters.generate_status
|
||||
if (appliedFilters.keyword?.trim()) params.keyword = appliedFilters.keyword.trim()
|
||||
if (appliedFilters.created_from) params.created_from = appliedFilters.created_from
|
||||
if (appliedFilters.created_to) params.created_to = appliedFilters.created_to
|
||||
return params
|
||||
})
|
||||
|
||||
const listQuery = useQuery({
|
||||
queryKey: computed(() => ["articles", "list", "custom_generation", articleParams.value]),
|
||||
queryKey: computed(() => ['articles', 'list', 'custom_generation', articleParams.value]),
|
||||
queryFn: () => articlesApi.list(articleParams.value),
|
||||
});
|
||||
})
|
||||
|
||||
let pollingTimer: number | null = null;
|
||||
let pollingTimer: number | null = null
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: (id: number) => articlesApi.remove(id),
|
||||
onSuccess: async () => {
|
||||
message.success(t("templates.list.deleteSuccess"));
|
||||
message.success(t('templates.list.deleteSuccess'))
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: ["articles"] }),
|
||||
queryClient.invalidateQueries({ queryKey: ["workspace"] }),
|
||||
]);
|
||||
queryClient.invalidateQueries({ queryKey: ['articles'] }),
|
||||
queryClient.invalidateQueries({ queryKey: ['workspace'] }),
|
||||
])
|
||||
},
|
||||
onError: (error) => message.error(formatError(error)),
|
||||
});
|
||||
})
|
||||
|
||||
const columns = computed<TableColumnsType<ArticleListItem>>(() => [
|
||||
{ title: t("custom.article.titleColumn"), dataIndex: "title", key: "title", width: 340 },
|
||||
{ title: t("custom.filters.promptRule"), dataIndex: "prompt_rule_name", key: "prompt_rule_name", width: 160 },
|
||||
{ title: t("custom.schedule.autoPublishPlatforms"), dataIndex: "auto_publish_platforms", key: "auto_publish_platforms", width: 180 },
|
||||
{ title: t("common.generateStatus"), dataIndex: "generate_status", key: "generate_status", width: 128 },
|
||||
{ title: t("common.publishStatus"), dataIndex: "publish_status", key: "publish_status", width: 128 },
|
||||
{ title: t("common.wordCount"), dataIndex: "word_count", key: "word_count", width: 100 },
|
||||
{ title: t("common.actions"), key: "actions", width: 156, fixed: "right", align: "right" },
|
||||
]);
|
||||
{ title: t('custom.article.titleColumn'), dataIndex: 'title', key: 'title', width: 340 },
|
||||
{
|
||||
title: t('custom.filters.promptRule'),
|
||||
dataIndex: 'prompt_rule_name',
|
||||
key: 'prompt_rule_name',
|
||||
width: 160,
|
||||
},
|
||||
{
|
||||
title: t('custom.schedule.autoPublishPlatforms'),
|
||||
dataIndex: 'auto_publish_platforms',
|
||||
key: 'auto_publish_platforms',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: t('common.generateStatus'),
|
||||
dataIndex: 'generate_status',
|
||||
key: 'generate_status',
|
||||
width: 128,
|
||||
},
|
||||
{
|
||||
title: t('common.publishStatus'),
|
||||
dataIndex: 'publish_status',
|
||||
key: 'publish_status',
|
||||
width: 128,
|
||||
},
|
||||
{ title: t('common.wordCount'), dataIndex: 'word_count', key: 'word_count', width: 100 },
|
||||
{ title: t('common.actions'), key: 'actions', width: 156, fixed: 'right', align: 'right' },
|
||||
])
|
||||
|
||||
function applyFilters(): void {
|
||||
page.value = 1;
|
||||
appliedFilters.prompt_rule_id = draftFilters.prompt_rule_id;
|
||||
appliedFilters.publish_status = draftFilters.publish_status;
|
||||
appliedFilters.generate_status = draftFilters.generate_status;
|
||||
appliedFilters.keyword = draftFilters.keyword?.trim() || "";
|
||||
appliedFilters.created_from = draftGenerationRange.value?.[0]?.toISOString();
|
||||
appliedFilters.created_to = draftGenerationRange.value?.[1]?.toISOString();
|
||||
page.value = 1
|
||||
appliedFilters.prompt_rule_id = draftFilters.prompt_rule_id
|
||||
appliedFilters.publish_status = draftFilters.publish_status
|
||||
appliedFilters.generate_status = draftFilters.generate_status
|
||||
appliedFilters.keyword = draftFilters.keyword?.trim() || ''
|
||||
appliedFilters.created_from = draftGenerationRange.value?.[0]?.toISOString()
|
||||
appliedFilters.created_to = draftGenerationRange.value?.[1]?.toISOString()
|
||||
}
|
||||
|
||||
function resetFilters(): void {
|
||||
draftFilters.prompt_rule_id = undefined;
|
||||
draftFilters.publish_status = undefined;
|
||||
draftFilters.generate_status = undefined;
|
||||
draftFilters.keyword = "";
|
||||
draftGenerationRange.value = null;
|
||||
applyFilters();
|
||||
draftFilters.prompt_rule_id = undefined
|
||||
draftFilters.publish_status = undefined
|
||||
draftFilters.generate_status = undefined
|
||||
draftFilters.keyword = ''
|
||||
draftGenerationRange.value = null
|
||||
applyFilters()
|
||||
}
|
||||
|
||||
function openDetail(article: ArticleListItem): void {
|
||||
selectedArticleId.value = article.id;
|
||||
articleDrawerOpen.value = true;
|
||||
selectedArticleId.value = article.id
|
||||
articleDrawerOpen.value = true
|
||||
}
|
||||
|
||||
function openEditor(article: ArticleListItem): void {
|
||||
void router.push({ name: "article-editor", params: { id: String(article.id) } });
|
||||
void router.push({ name: 'article-editor', params: { id: String(article.id) } })
|
||||
}
|
||||
|
||||
function openPublish(article: ArticleListItem): void {
|
||||
selectedPublishArticleId.value = article.id;
|
||||
publishModalOpen.value = true;
|
||||
selectedPublishArticleId.value = article.id
|
||||
publishModalOpen.value = true
|
||||
}
|
||||
|
||||
function getDisplayTitle(article: ArticleListItem): string {
|
||||
if ((article.generate_status === "generating" || article.generate_status === "running") && !article.title) {
|
||||
return t("custom.article.titleGenerating");
|
||||
if (
|
||||
(article.generate_status === 'generating' || article.generate_status === 'running') &&
|
||||
!article.title
|
||||
) {
|
||||
return t('custom.article.titleGenerating')
|
||||
}
|
||||
return article.title || t("article.untitled");
|
||||
return article.title || t('article.untitled')
|
||||
}
|
||||
|
||||
function handleTableChange(nextPage: number, nextPageSize: number): void {
|
||||
page.value = nextPage;
|
||||
pageSize.value = nextPageSize;
|
||||
page.value = nextPage
|
||||
pageSize.value = nextPageSize
|
||||
}
|
||||
|
||||
function startPolling(): void {
|
||||
if (pollingTimer !== null) return;
|
||||
if (pollingTimer !== null) return
|
||||
pollingTimer = window.setInterval(() => {
|
||||
void listQuery.refetch();
|
||||
}, 3000);
|
||||
void listQuery.refetch()
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
function stopPolling(): void {
|
||||
if (pollingTimer === null) return;
|
||||
window.clearInterval(pollingTimer);
|
||||
pollingTimer = null;
|
||||
if (pollingTimer === null) return
|
||||
window.clearInterval(pollingTimer)
|
||||
pollingTimer = null
|
||||
}
|
||||
|
||||
async function copyArticle(articleId: number): Promise<void> {
|
||||
try {
|
||||
const detail = await articlesApi.detail(articleId);
|
||||
const content = buildArticleClipboardContent(detail);
|
||||
const detail = await articlesApi.detail(articleId)
|
||||
const content = buildArticleClipboardContent(detail)
|
||||
|
||||
if (!content) {
|
||||
message.warning(t("common.noData"));
|
||||
return;
|
||||
message.warning(t('common.noData'))
|
||||
return
|
||||
}
|
||||
|
||||
await navigator.clipboard.writeText(content);
|
||||
message.success(t("common.copySuccess"));
|
||||
await navigator.clipboard.writeText(content)
|
||||
message.success(t('common.copySuccess'))
|
||||
} catch (error) {
|
||||
message.error(formatError(error) || t("common.noData"));
|
||||
message.error(formatError(error) || t('common.noData'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,27 +222,27 @@ watch(
|
||||
() => listQuery.data.value?.items ?? [],
|
||||
(items) => {
|
||||
const hasActive = items.some(
|
||||
(item) => item.generate_status === "generating" || item.generate_status === "running",
|
||||
);
|
||||
(item) => item.generate_status === 'generating' || item.generate_status === 'running',
|
||||
)
|
||||
if (hasActive) {
|
||||
startPolling();
|
||||
startPolling()
|
||||
} else {
|
||||
stopPolling();
|
||||
stopPolling()
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
)
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopPolling();
|
||||
});
|
||||
stopPolling()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="custom-article-tab">
|
||||
<div class="custom-article-tab__filters">
|
||||
<div class="custom-article-tab__filter-item">
|
||||
<label>{{ t("custom.filters.promptRule") }}:</label>
|
||||
<label>{{ t('custom.filters.promptRule') }}:</label>
|
||||
<a-select
|
||||
v-model:value="draftFilters.prompt_rule_id"
|
||||
allow-clear
|
||||
@@ -234,7 +254,7 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
|
||||
<div class="custom-article-tab__filter-item">
|
||||
<label>{{ t("custom.filters.publishStatus") }}:</label>
|
||||
<label>{{ t('custom.filters.publishStatus') }}:</label>
|
||||
<a-select
|
||||
v-model:value="draftFilters.publish_status"
|
||||
allow-clear
|
||||
@@ -245,7 +265,7 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
|
||||
<div class="custom-article-tab__filter-item">
|
||||
<label>{{ t("custom.filters.generateStatus") }}:</label>
|
||||
<label>{{ t('custom.filters.generateStatus') }}:</label>
|
||||
<a-select
|
||||
v-model:value="draftFilters.generate_status"
|
||||
allow-clear
|
||||
@@ -256,7 +276,7 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
|
||||
<div class="custom-article-tab__filter-item">
|
||||
<label>{{ t("custom.filters.generateTime") }}:</label>
|
||||
<label>{{ t('custom.filters.generateTime') }}:</label>
|
||||
<a-range-picker
|
||||
v-model:value="draftGenerationRange"
|
||||
allow-clear
|
||||
@@ -267,7 +287,7 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
|
||||
<div class="custom-article-tab__filter-item">
|
||||
<label>{{ t("custom.filters.title") }}:</label>
|
||||
<label>{{ t('custom.filters.title') }}:</label>
|
||||
<a-input-search
|
||||
v-model:value="draftFilters.keyword"
|
||||
:placeholder="t('templates.filters.keywordPlaceholder')"
|
||||
@@ -276,15 +296,15 @@ onBeforeUnmount(() => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<a-button @click="resetFilters">{{ t("common.reset") }}</a-button>
|
||||
<a-button @click="resetFilters">{{ t('common.reset') }}</a-button>
|
||||
</div>
|
||||
|
||||
<div class="custom-article-tab__head">
|
||||
<span class="custom-article-tab__count">
|
||||
{{ t("templates.list.count", { count: listQuery.data.value?.total ?? 0 }) }}
|
||||
{{ t('templates.list.count', { count: listQuery.data.value?.total ?? 0 }) }}
|
||||
</span>
|
||||
<a-button type="link" @click="listQuery.refetch()">
|
||||
{{ t("common.refresh") }}
|
||||
{{ t('common.refresh') }}
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
@@ -317,7 +337,7 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'prompt_rule_name'">
|
||||
{{ record.prompt_rule_name || "--" }}
|
||||
{{ record.prompt_rule_name || '--' }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'auto_publish_platforms'">
|
||||
{{ formatPublishPlatformList(record.auto_publish_platforms) }}
|
||||
@@ -326,13 +346,10 @@ onBeforeUnmount(() => {
|
||||
<ArticleGenerateStatus :status="record.generate_status" />
|
||||
</template>
|
||||
<template v-else-if="column.key === 'publish_status'">
|
||||
<ArticlePublishStatus
|
||||
:status="record.publish_status"
|
||||
:article-id="record.id"
|
||||
/>
|
||||
<ArticlePublishStatus :status="record.publish_status" :article-id="record.id" />
|
||||
</template>
|
||||
<template v-else-if="column.key === 'word_count'">
|
||||
{{ record.word_count || "--" }}
|
||||
{{ record.word_count || '--' }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<ArticleActionGroup
|
||||
@@ -355,10 +372,7 @@ onBeforeUnmount(() => {
|
||||
@close="articleDrawerOpen = false"
|
||||
/>
|
||||
|
||||
<PublishArticleModal
|
||||
v-model:open="publishModalOpen"
|
||||
:article-id="selectedPublishArticleId"
|
||||
/>
|
||||
<PublishArticleModal v-model:open="publishModalOpen" :article-id="selectedPublishArticleId" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -414,5 +428,4 @@ onBeforeUnmount(() => {
|
||||
gap: 8px;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user