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,196 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
PlusOutlined,
|
||||
} from "@ant-design/icons-vue";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
import { message } from "ant-design-vue";
|
||||
import type { ArticleListItem, ArticleListParams } from "@geo/shared-types";
|
||||
import type { TableColumnsType } from "ant-design-vue";
|
||||
import type { Dayjs } from "dayjs";
|
||||
import { computed, reactive, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import type { ArticleListItem, ArticleListParams } from '@geo/shared-types'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query'
|
||||
import type { TableColumnsType } from 'ant-design-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { Dayjs } from 'dayjs'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import ArticleActionGroup from "@/components/ArticleActionGroup.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 } from "@/lib/api";
|
||||
import { buildArticleClipboardContent, resolveArticleActionState } from "@/lib/article-list-actions";
|
||||
import { formatError } from "@/lib/errors";
|
||||
import {
|
||||
getPublishStatusMeta,
|
||||
} from "@/lib/display";
|
||||
import ArticleActionGroup from '@/components/ArticleActionGroup.vue'
|
||||
import ArticleDetailDrawer from '@/components/ArticleDetailDrawer.vue'
|
||||
import ArticlePublishStatus from '@/components/ArticlePublishStatus.vue'
|
||||
import ArticleSourceMeta from '@/components/ArticleSourceMeta.vue'
|
||||
import PublishArticleModal from '@/components/PublishArticleModal.vue'
|
||||
import { articlesApi } from '@/lib/api'
|
||||
import { buildArticleClipboardContent, resolveArticleActionState } from '@/lib/article-list-actions'
|
||||
import { getPublishStatusMeta } from '@/lib/display'
|
||||
import { formatError } from '@/lib/errors'
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
const queryClient = useQueryClient()
|
||||
const router = useRouter()
|
||||
const { t } = useI18n()
|
||||
|
||||
const publishModalOpen = ref(false);
|
||||
const selectedPublishArticleId = ref<number | null>(null);
|
||||
const articleDrawerOpen = ref(false);
|
||||
const selectedArticleId = ref<number | null>(null);
|
||||
const page = ref(1);
|
||||
const pageSize = ref(10);
|
||||
const createdRange = ref<[Dayjs, Dayjs] | null>(null);
|
||||
const publishModalOpen = ref(false)
|
||||
const selectedPublishArticleId = ref<number | null>(null)
|
||||
const articleDrawerOpen = ref(false)
|
||||
const selectedArticleId = ref<number | null>(null)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const createdRange = ref<[Dayjs, Dayjs] | null>(null)
|
||||
|
||||
const draftFilters = reactive<{
|
||||
publish_status?: string;
|
||||
keyword?: string;
|
||||
created_from?: string;
|
||||
created_to?: string;
|
||||
publish_status?: string
|
||||
keyword?: string
|
||||
created_from?: string
|
||||
created_to?: string
|
||||
}>({
|
||||
keyword: "",
|
||||
});
|
||||
keyword: '',
|
||||
})
|
||||
|
||||
const appliedFilters = reactive<{
|
||||
publish_status?: string;
|
||||
keyword?: string;
|
||||
created_from?: string;
|
||||
created_to?: string;
|
||||
publish_status?: string
|
||||
keyword?: string
|
||||
created_from?: string
|
||||
created_to?: string
|
||||
}>({
|
||||
keyword: "",
|
||||
});
|
||||
keyword: '',
|
||||
})
|
||||
|
||||
const articleParams = computed<ArticleListParams>(() => {
|
||||
const params: ArticleListParams = {
|
||||
page: page.value,
|
||||
page_size: pageSize.value,
|
||||
source_type: "free_create",
|
||||
};
|
||||
source_type: 'free_create',
|
||||
}
|
||||
|
||||
if (appliedFilters.publish_status) {
|
||||
params.publish_status = appliedFilters.publish_status;
|
||||
params.publish_status = appliedFilters.publish_status
|
||||
}
|
||||
if (appliedFilters.keyword?.trim()) {
|
||||
params.keyword = appliedFilters.keyword.trim();
|
||||
params.keyword = appliedFilters.keyword.trim()
|
||||
}
|
||||
if (appliedFilters.created_from) {
|
||||
params.created_from = appliedFilters.created_from;
|
||||
params.created_from = appliedFilters.created_from
|
||||
}
|
||||
if (appliedFilters.created_to) {
|
||||
params.created_to = appliedFilters.created_to;
|
||||
params.created_to = appliedFilters.created_to
|
||||
}
|
||||
|
||||
return params;
|
||||
});
|
||||
return params
|
||||
})
|
||||
|
||||
const articleListQuery = useQuery({
|
||||
queryKey: computed(() => ["articles", "list", articleParams.value]),
|
||||
queryKey: computed(() => ['articles', 'list', articleParams.value]),
|
||||
queryFn: () => articlesApi.list(articleParams.value),
|
||||
});
|
||||
})
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: (articleId: number) => articlesApi.remove(articleId),
|
||||
onSuccess: async () => {
|
||||
message.success(t("freeCreate.list.deleteSuccess"));
|
||||
message.success(t('freeCreate.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) || t("freeCreate.list.deleteError"));
|
||||
message.error(formatError(error) || t('freeCreate.list.deleteError'))
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: () => articlesApi.create({}),
|
||||
onSuccess: (data) => {
|
||||
void router.push({ name: "article-editor", params: { id: String(data.id) } });
|
||||
void router.push({ name: 'article-editor', params: { id: String(data.id) } })
|
||||
},
|
||||
onError: (error) => {
|
||||
message.error(formatError(error) || t("freeCreate.createError"));
|
||||
message.error(formatError(error) || t('freeCreate.createError'))
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
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 articleColumns = computed<TableColumnsType<ArticleListItem>>(() => [
|
||||
{
|
||||
title: t("common.title"),
|
||||
dataIndex: "title",
|
||||
key: "title",
|
||||
title: t('common.title'),
|
||||
dataIndex: 'title',
|
||||
key: 'title',
|
||||
},
|
||||
{
|
||||
title: t("common.publishStatus"),
|
||||
dataIndex: "publish_status",
|
||||
key: "publish_status",
|
||||
title: t('common.publishStatus'),
|
||||
dataIndex: 'publish_status',
|
||||
key: 'publish_status',
|
||||
width: 128,
|
||||
},
|
||||
{
|
||||
title: t("common.wordCount"),
|
||||
dataIndex: "word_count",
|
||||
key: "word_count",
|
||||
title: t('common.wordCount'),
|
||||
dataIndex: 'word_count',
|
||||
key: 'word_count',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: t("common.actions"),
|
||||
key: "actions",
|
||||
title: t('common.actions'),
|
||||
key: 'actions',
|
||||
width: 156,
|
||||
align: "right",
|
||||
align: 'right',
|
||||
},
|
||||
]);
|
||||
])
|
||||
|
||||
function applyFilters(): void {
|
||||
page.value = 1;
|
||||
appliedFilters.publish_status = draftFilters.publish_status;
|
||||
appliedFilters.keyword = draftFilters.keyword?.trim() || "";
|
||||
appliedFilters.created_from = createdRange.value?.[0]?.toISOString();
|
||||
appliedFilters.created_to = createdRange.value?.[1]?.toISOString();
|
||||
page.value = 1
|
||||
appliedFilters.publish_status = draftFilters.publish_status
|
||||
appliedFilters.keyword = draftFilters.keyword?.trim() || ''
|
||||
appliedFilters.created_from = createdRange.value?.[0]?.toISOString()
|
||||
appliedFilters.created_to = createdRange.value?.[1]?.toISOString()
|
||||
}
|
||||
|
||||
function resetFilters(): void {
|
||||
draftFilters.publish_status = undefined;
|
||||
draftFilters.keyword = "";
|
||||
createdRange.value = null;
|
||||
applyFilters();
|
||||
draftFilters.publish_status = undefined
|
||||
draftFilters.keyword = ''
|
||||
createdRange.value = null
|
||||
applyFilters()
|
||||
}
|
||||
|
||||
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 openPreview(article: ArticleListItem): void {
|
||||
selectedArticleId.value = article.id;
|
||||
articleDrawerOpen.value = true;
|
||||
selectedArticleId.value = article.id
|
||||
articleDrawerOpen.value = true
|
||||
}
|
||||
|
||||
function handleTableChange(nextPage: number, nextPageSize: number): void {
|
||||
page.value = nextPage;
|
||||
pageSize.value = nextPageSize;
|
||||
page.value = nextPage
|
||||
pageSize.value = nextPageSize
|
||||
}
|
||||
|
||||
async function handleDelete(articleId: number): Promise<void> {
|
||||
await deleteMutation.mutateAsync(articleId);
|
||||
await deleteMutation.mutateAsync(articleId)
|
||||
}
|
||||
|
||||
function handleCreate(): void {
|
||||
createMutation.mutate();
|
||||
createMutation.mutate()
|
||||
}
|
||||
|
||||
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'))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -210,17 +206,17 @@ async function copyArticle(articleId: number): Promise<void> {
|
||||
<div class="free-create-view__header-actions">
|
||||
<a-button type="primary" :loading="createMutation.isPending.value" @click="handleCreate">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
{{ t("freeCreate.actions.create") }}
|
||||
{{ t('freeCreate.actions.create') }}
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a-divider style="margin: 0; border-color: #f0f0f0;" />
|
||||
<a-divider style="margin: 0; border-color: #f0f0f0" />
|
||||
|
||||
<div class="free-create-view__filters">
|
||||
<div class="free-create-view__filters-inline">
|
||||
<div class="free-create-view__filter-item">
|
||||
<label>{{ t("freeCreate.filters.publishStatus") }}:</label>
|
||||
<label>{{ t('freeCreate.filters.publishStatus') }}:</label>
|
||||
<a-select
|
||||
v-model:value="draftFilters.publish_status"
|
||||
allow-clear
|
||||
@@ -231,7 +227,7 @@ async function copyArticle(articleId: number): Promise<void> {
|
||||
</div>
|
||||
|
||||
<div class="free-create-view__filter-item">
|
||||
<label>{{ t("freeCreate.filters.createdTime") }}:</label>
|
||||
<label>{{ t('freeCreate.filters.createdTime') }}:</label>
|
||||
<a-range-picker
|
||||
v-model:value="createdRange"
|
||||
allow-clear
|
||||
@@ -246,7 +242,7 @@ async function copyArticle(articleId: number): Promise<void> {
|
||||
</div>
|
||||
|
||||
<div class="free-create-view__filter-item">
|
||||
<label>{{ t("freeCreate.filters.keyword") }}:</label>
|
||||
<label>{{ t('freeCreate.filters.keyword') }}:</label>
|
||||
<a-input-search
|
||||
v-model:value="draftFilters.keyword"
|
||||
:placeholder="t('freeCreate.filters.keywordPlaceholder')"
|
||||
@@ -255,7 +251,9 @@ async function copyArticle(articleId: number): Promise<void> {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<a-button @click="resetFilters" class="free-create-view__reset-btn">{{ t("common.reset") }}</a-button>
|
||||
<a-button class="free-create-view__reset-btn" @click="resetFilters">
|
||||
{{ t('common.reset') }}
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -263,11 +261,13 @@ async function copyArticle(articleId: number): Promise<void> {
|
||||
<section class="free-create-view__table-card">
|
||||
<div class="free-create-view__table-head">
|
||||
<div>
|
||||
<p class="eyebrow">{{ t("freeCreate.list.eyebrow") }}</p>
|
||||
<h3>{{ t("freeCreate.list.count", { count: articleListQuery.data.value?.total ?? 0 }) }}</h3>
|
||||
<p class="eyebrow">{{ t('freeCreate.list.eyebrow') }}</p>
|
||||
<h3>
|
||||
{{ t('freeCreate.list.count', { count: articleListQuery.data.value?.total ?? 0 }) }}
|
||||
</h3>
|
||||
</div>
|
||||
<a-button type="link" @click="articleListQuery.refetch()">
|
||||
{{ t("common.refresh") }}
|
||||
{{ t('common.refresh') }}
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
@@ -285,12 +285,12 @@ async function copyArticle(articleId: number): Promise<void> {
|
||||
onShowSizeChange: handleTableChange,
|
||||
}"
|
||||
>
|
||||
<template #emptyText>{{ t("freeCreate.list.empty") }}</template>
|
||||
<template #emptyText>{{ t('freeCreate.list.empty') }}</template>
|
||||
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'title'">
|
||||
<div class="free-create-view__title-cell">
|
||||
<strong>{{ record.title || t("article.untitled") }}</strong>
|
||||
<strong>{{ record.title || t('article.untitled') }}</strong>
|
||||
<ArticleSourceMeta
|
||||
:source-type="record.source_type"
|
||||
:generation-mode="record.generation_mode"
|
||||
@@ -300,14 +300,11 @@ async function copyArticle(articleId: number): Promise<void> {
|
||||
</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'">
|
||||
@@ -326,10 +323,7 @@ async function copyArticle(articleId: number): Promise<void> {
|
||||
</a-table>
|
||||
</section>
|
||||
|
||||
<PublishArticleModal
|
||||
v-model:open="publishModalOpen"
|
||||
:article-id="selectedPublishArticleId"
|
||||
/>
|
||||
<PublishArticleModal v-model:open="publishModalOpen" :article-id="selectedPublishArticleId" />
|
||||
|
||||
<ArticleDetailDrawer
|
||||
:open="articleDrawerOpen"
|
||||
|
||||
Reference in New Issue
Block a user