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,40 +1,42 @@
|
||||
<script setup lang="ts">
|
||||
import { LeftOutlined, LinkOutlined } from "@ant-design/icons-vue";
|
||||
import { useMutation, useQueryClient } from "@tanstack/vue-query";
|
||||
import { message } from "ant-design-vue";
|
||||
import { computed, reactive, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { LeftOutlined, LinkOutlined } from '@ant-design/icons-vue'
|
||||
import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { computed, reactive, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
import KnowledgeGroupSelect from "@/components/KnowledgeGroupSelect.vue";
|
||||
import { articlesApi } from "@/lib/api";
|
||||
import { formatError } from "@/lib/errors";
|
||||
import KnowledgeGroupSelect from '@/components/KnowledgeGroupSelect.vue'
|
||||
import { articlesApi } from '@/lib/api'
|
||||
import { formatError } from '@/lib/errors'
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const queryClient = useQueryClient();
|
||||
const { t } = useI18n();
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useI18n()
|
||||
|
||||
const form = reactive({
|
||||
source_url: "",
|
||||
source_title: "",
|
||||
locale: "zh-CN",
|
||||
industry: "",
|
||||
brand_name: "",
|
||||
region: "",
|
||||
target_audience: "",
|
||||
content_goal: "",
|
||||
tone: "",
|
||||
length_goal: "",
|
||||
source_url: '',
|
||||
source_title: '',
|
||||
locale: 'zh-CN',
|
||||
industry: '',
|
||||
brand_name: '',
|
||||
region: '',
|
||||
target_audience: '',
|
||||
content_goal: '',
|
||||
tone: '',
|
||||
length_goal: '',
|
||||
keywords: [] as string[],
|
||||
preserve_points: "",
|
||||
avoid_points: "",
|
||||
extra_requirements: "",
|
||||
preserve_points: '',
|
||||
avoid_points: '',
|
||||
extra_requirements: '',
|
||||
enable_web_search: false,
|
||||
knowledge_group_ids: [] as number[],
|
||||
});
|
||||
})
|
||||
|
||||
const canSubmit = computed(() => form.source_url.trim().length > 0 && !generateMutation.isPending.value);
|
||||
const canSubmit = computed(
|
||||
() => form.source_url.trim().length > 0 && !generateMutation.isPending.value,
|
||||
)
|
||||
|
||||
const generateMutation = useMutation({
|
||||
mutationFn: () =>
|
||||
@@ -59,41 +61,41 @@ const generateMutation = useMutation({
|
||||
}),
|
||||
onSuccess: async () => {
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: ["articles"] }),
|
||||
queryClient.invalidateQueries({ queryKey: ["workspace"] }),
|
||||
]);
|
||||
message.info(t("imitation.create.queued"));
|
||||
await router.replace({ name: "articles-imitations" });
|
||||
queryClient.invalidateQueries({ queryKey: ['articles'] }),
|
||||
queryClient.invalidateQueries({ queryKey: ['workspace'] }),
|
||||
])
|
||||
message.info(t('imitation.create.queued'))
|
||||
await router.replace({ name: 'articles-imitations' })
|
||||
},
|
||||
onError: (error) => {
|
||||
message.error(formatError(error) || t("imitation.create.submitError"));
|
||||
message.error(formatError(error) || t('imitation.create.submitError'))
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
watch(
|
||||
() => [route.query.source_url, route.query.source_title],
|
||||
([sourceURL, sourceTitle]) => {
|
||||
form.source_url = normalizeQueryValue(sourceURL);
|
||||
form.source_title = normalizeQueryValue(sourceTitle);
|
||||
form.source_url = normalizeQueryValue(sourceURL)
|
||||
form.source_title = normalizeQueryValue(sourceTitle)
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
)
|
||||
|
||||
function normalizeQueryValue(value: unknown): string {
|
||||
const raw = Array.isArray(value) ? value[0] : value;
|
||||
return String(raw ?? "").trim();
|
||||
const raw = Array.isArray(value) ? value[0] : value
|
||||
return String(raw ?? '').trim()
|
||||
}
|
||||
|
||||
function goBack(): void {
|
||||
void router.push({ name: "articles-imitations" });
|
||||
void router.push({ name: 'articles-imitations' })
|
||||
}
|
||||
|
||||
function submit(): void {
|
||||
if (!form.source_url.trim()) {
|
||||
message.warning(t("imitation.create.sourceURLRequired"));
|
||||
return;
|
||||
message.warning(t('imitation.create.sourceURLRequired'))
|
||||
return
|
||||
}
|
||||
generateMutation.mutate();
|
||||
generateMutation.mutate()
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -105,8 +107,8 @@ function submit(): void {
|
||||
<template #icon><LeftOutlined /></template>
|
||||
</a-button>
|
||||
<div class="imitation-generate-page__title-box">
|
||||
<h2>{{ t("imitation.create.title") }}</h2>
|
||||
<p>{{ t("imitation.create.subtitle") }}</p>
|
||||
<h2>{{ t('imitation.create.title') }}</h2>
|
||||
<p>{{ t('imitation.create.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
@@ -115,21 +117,21 @@ function submit(): void {
|
||||
<section class="imitation-generate-page__step">
|
||||
<div class="imitation-generate-page__step-line">
|
||||
<span>1</span>
|
||||
<strong>{{ t("imitation.create.settingsSection") }}</strong>
|
||||
<strong>{{ t('imitation.create.settingsSection') }}</strong>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="imitation-generate-page__section">
|
||||
<div class="imitation-generate-page__section-head">
|
||||
<div>
|
||||
<h3>{{ t("imitation.create.sourceSection") }}</h3>
|
||||
<p>{{ t("route.imitationCreate.description") }}</p>
|
||||
<h3>{{ t('imitation.create.sourceSection') }}</h3>
|
||||
<p>{{ t('route.imitationCreate.description') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field-grid">
|
||||
<div class="imitation-generate-page__field imitation-generate-page__field--wide">
|
||||
<label class="required-asterisk">{{ t("imitation.create.sourceURL") }}</label>
|
||||
<label class="required-asterisk">{{ t('imitation.create.sourceURL') }}</label>
|
||||
<a-input
|
||||
v-model:value="form.source_url"
|
||||
:placeholder="t('imitation.create.sourceURLPlaceholder')"
|
||||
@@ -139,7 +141,7 @@ function submit(): void {
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field">
|
||||
<label>{{ t("imitation.create.sourceTitle") }}</label>
|
||||
<label>{{ t('imitation.create.sourceTitle') }}</label>
|
||||
<a-input
|
||||
v-model:value="form.source_title"
|
||||
:placeholder="t('imitation.create.sourceTitlePlaceholder')"
|
||||
@@ -147,7 +149,7 @@ function submit(): void {
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field">
|
||||
<label>{{ t("imitation.create.language") }}</label>
|
||||
<label>{{ t('imitation.create.language') }}</label>
|
||||
<a-select
|
||||
v-model:value="form.locale"
|
||||
:options="[
|
||||
@@ -162,8 +164,8 @@ function submit(): void {
|
||||
<section class="imitation-generate-page__section">
|
||||
<div class="imitation-generate-page__section-head">
|
||||
<div>
|
||||
<h3>{{ t("imitation.create.settingsSection") }}</h3>
|
||||
<p>{{ t("templates.wizard.hints.keyPoints") }}</p>
|
||||
<h3>{{ t('imitation.create.settingsSection') }}</h3>
|
||||
<p>{{ t('templates.wizard.hints.keyPoints') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -171,10 +173,10 @@ function submit(): void {
|
||||
<div class="imitation-generate-page__capability-row">
|
||||
<div class="imitation-generate-page__capability-copy">
|
||||
<div class="imitation-generate-page__capability-label">
|
||||
{{ t("imitation.create.enableWebSearch") }}
|
||||
{{ t('imitation.create.enableWebSearch') }}
|
||||
</div>
|
||||
<div class="imitation-generate-page__capability-hint">
|
||||
{{ t("imitation.create.webSearchHint") }}
|
||||
{{ t('imitation.create.webSearchHint') }}
|
||||
</div>
|
||||
</div>
|
||||
<a-switch
|
||||
@@ -187,7 +189,7 @@ function submit(): void {
|
||||
|
||||
<div class="imitation-generate-page__capability-knowledge">
|
||||
<label class="imitation-generate-page__capability-label">
|
||||
{{ t("imitation.create.knowledgeBase") }}
|
||||
{{ t('imitation.create.knowledgeBase') }}
|
||||
</label>
|
||||
<KnowledgeGroupSelect
|
||||
v-model="form.knowledge_group_ids"
|
||||
@@ -195,49 +197,70 @@ function submit(): void {
|
||||
:placeholder="t('imitation.create.knowledgeBasePlaceholder')"
|
||||
/>
|
||||
<p class="imitation-generate-page__capability-hint">
|
||||
{{ t("imitation.create.knowledgeBaseHint") }}
|
||||
{{ t('imitation.create.knowledgeBaseHint') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field-grid">
|
||||
<div class="imitation-generate-page__field">
|
||||
<label>{{ t("imitation.create.industry") }}</label>
|
||||
<a-input v-model:value="form.industry" :placeholder="t('imitation.create.industryPlaceholder')" />
|
||||
<label>{{ t('imitation.create.industry') }}</label>
|
||||
<a-input
|
||||
v-model:value="form.industry"
|
||||
:placeholder="t('imitation.create.industryPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field">
|
||||
<label>{{ t("imitation.create.brandName") }}</label>
|
||||
<a-input v-model:value="form.brand_name" :placeholder="t('imitation.create.brandNamePlaceholder')" />
|
||||
<label>{{ t('imitation.create.brandName') }}</label>
|
||||
<a-input
|
||||
v-model:value="form.brand_name"
|
||||
:placeholder="t('imitation.create.brandNamePlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field">
|
||||
<label>{{ t("imitation.create.region") }}</label>
|
||||
<a-input v-model:value="form.region" :placeholder="t('imitation.create.regionPlaceholder')" />
|
||||
<label>{{ t('imitation.create.region') }}</label>
|
||||
<a-input
|
||||
v-model:value="form.region"
|
||||
:placeholder="t('imitation.create.regionPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field">
|
||||
<label>{{ t("imitation.create.targetAudience") }}</label>
|
||||
<a-input v-model:value="form.target_audience" :placeholder="t('imitation.create.targetAudiencePlaceholder')" />
|
||||
<label>{{ t('imitation.create.targetAudience') }}</label>
|
||||
<a-input
|
||||
v-model:value="form.target_audience"
|
||||
:placeholder="t('imitation.create.targetAudiencePlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field">
|
||||
<label>{{ t("imitation.create.contentGoal") }}</label>
|
||||
<a-input v-model:value="form.content_goal" :placeholder="t('imitation.create.contentGoalPlaceholder')" />
|
||||
<label>{{ t('imitation.create.contentGoal') }}</label>
|
||||
<a-input
|
||||
v-model:value="form.content_goal"
|
||||
:placeholder="t('imitation.create.contentGoalPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field">
|
||||
<label>{{ t("imitation.create.tone") }}</label>
|
||||
<a-input v-model:value="form.tone" :placeholder="t('imitation.create.tonePlaceholder')" />
|
||||
<label>{{ t('imitation.create.tone') }}</label>
|
||||
<a-input
|
||||
v-model:value="form.tone"
|
||||
:placeholder="t('imitation.create.tonePlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field">
|
||||
<label>{{ t("imitation.create.lengthGoal") }}</label>
|
||||
<a-input v-model:value="form.length_goal" :placeholder="t('imitation.create.lengthGoalPlaceholder')" />
|
||||
<label>{{ t('imitation.create.lengthGoal') }}</label>
|
||||
<a-input
|
||||
v-model:value="form.length_goal"
|
||||
:placeholder="t('imitation.create.lengthGoalPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field imitation-generate-page__field--wide">
|
||||
<label>{{ t("imitation.create.keywords") }}</label>
|
||||
<label>{{ t('imitation.create.keywords') }}</label>
|
||||
<a-select
|
||||
v-model:value="form.keywords"
|
||||
mode="tags"
|
||||
@@ -247,7 +270,7 @@ function submit(): void {
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field">
|
||||
<label>{{ t("imitation.create.preservePoints") }}</label>
|
||||
<label>{{ t('imitation.create.preservePoints') }}</label>
|
||||
<a-textarea
|
||||
v-model:value="form.preserve_points"
|
||||
:rows="4"
|
||||
@@ -256,7 +279,7 @@ function submit(): void {
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field">
|
||||
<label>{{ t("imitation.create.avoidPoints") }}</label>
|
||||
<label>{{ t('imitation.create.avoidPoints') }}</label>
|
||||
<a-textarea
|
||||
v-model:value="form.avoid_points"
|
||||
:rows="4"
|
||||
@@ -265,7 +288,7 @@ function submit(): void {
|
||||
</div>
|
||||
|
||||
<div class="imitation-generate-page__field imitation-generate-page__field--wide">
|
||||
<label>{{ t("imitation.create.extraRequirements") }}</label>
|
||||
<label>{{ t('imitation.create.extraRequirements') }}</label>
|
||||
<a-textarea
|
||||
v-model:value="form.extra_requirements"
|
||||
:rows="5"
|
||||
@@ -277,14 +300,14 @@ function submit(): void {
|
||||
</main>
|
||||
|
||||
<footer class="imitation-generate-page__footer">
|
||||
<a-button @click="goBack">{{ t("imitation.create.backToList") }}</a-button>
|
||||
<a-button @click="goBack">{{ t('imitation.create.backToList') }}</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
:disabled="!canSubmit"
|
||||
:loading="generateMutation.isPending.value"
|
||||
@click="submit"
|
||||
>
|
||||
{{ t("imitation.actions.submit") }}
|
||||
{{ t('imitation.actions.submit') }}
|
||||
</a-button>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -361,7 +384,7 @@ function submit(): void {
|
||||
width: min(320px, 28vw);
|
||||
height: 1px;
|
||||
background: #dbe4ef;
|
||||
content: "";
|
||||
content: '';
|
||||
}
|
||||
|
||||
.imitation-generate-page__step-line span {
|
||||
@@ -415,7 +438,7 @@ function submit(): void {
|
||||
margin-right: 12px;
|
||||
border-radius: 2px;
|
||||
background: #111827;
|
||||
content: "";
|
||||
content: '';
|
||||
}
|
||||
|
||||
.imitation-generate-page__section-head p {
|
||||
@@ -493,13 +516,13 @@ function submit(): void {
|
||||
}
|
||||
|
||||
.imitation-generate-page__field > label::after {
|
||||
content: ":";
|
||||
content: ':';
|
||||
}
|
||||
|
||||
.required-asterisk::before {
|
||||
margin-right: 4px;
|
||||
color: #ff4d4f;
|
||||
content: "*";
|
||||
content: '*';
|
||||
}
|
||||
|
||||
.imitation-generate-page__footer {
|
||||
|
||||
Reference in New Issue
Block a user