feat(migrations): Harden task audit tracking and optimize article templates

- Added migration to harden task audit tracking by modifying audit_logs and related tables.
- Introduced operator_id to several tables for better tracking of actions.
- Updated article_templates with new prompt templates for various article types, enhancing content generation.
- Created prompt_rules and schedule_tasks tables to manage content generation rules and scheduling.
- Added foreign key constraints to articles for better data integrity.
This commit is contained in:
2026-04-02 00:31:28 +08:00
parent de30497f59
commit b31d8d0096
101 changed files with 16671 additions and 721 deletions
@@ -0,0 +1,531 @@
<script setup lang="ts">
import { LeftOutlined } from "@ant-design/icons-vue";
import { useMutation, useQuery, useQueryClient } from "@tanstack/vue-query";
import { message } from "ant-design-vue";
import { computed, onBeforeUnmount, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
import { MilkdownProvider } from "@milkdown/vue";
import ArticleEditorCanvas from "@/components/ArticleEditorCanvas.vue";
import PublishPlatformSelector from "@/components/PublishPlatformSelector.vue";
import { articlesApi } from "@/lib/api";
import { formatError } from "@/lib/errors";
import { getBoundPublishPlatforms } from "@/lib/publish-platforms";
const route = useRoute();
const router = useRouter();
const queryClient = useQueryClient();
const { t } = useI18n();
const articleId = computed(() => Number(route.params.id));
const title = ref("");
const markdown = ref("");
const initialTitle = ref("");
const initialMarkdown = ref("");
const boundPublishPlatforms = getBoundPublishPlatforms();
const publishPlatforms = ref<string[]>([]);
const initialPublishPlatforms = ref<string[]>([]);
const coverEnabled = ref(true);
const coverPreviewUrl = ref("");
const leaveModalOpen = ref(false);
const detailQuery = useQuery({
queryKey: computed(() => ["articles", "detail", articleId.value]),
enabled: computed(() => Number.isInteger(articleId.value) && articleId.value > 0),
queryFn: () => articlesApi.detail(articleId.value),
});
watch(
() => detailQuery.data.value,
(detail) => {
if (!detail) {
return;
}
const nextTitle = detail.title ?? "";
const nextMarkdown = stripLeadingTitleHeading(nextTitle, detail.markdown_content ?? "");
title.value = nextTitle;
markdown.value = nextMarkdown;
initialTitle.value = nextTitle;
initialMarkdown.value = nextMarkdown;
publishPlatforms.value = [...(detail.platforms ?? [])];
initialPublishPlatforms.value = [...publishPlatforms.value];
},
{ immediate: true },
);
const detail = computed(() => detailQuery.data.value);
const editorLocked = computed(() => detail.value?.generate_status !== "completed");
const hasChanges = computed(
() =>
title.value.trim() !== initialTitle.value.trim() ||
markdown.value !== initialMarkdown.value ||
serializePlatformSelection(publishPlatforms.value) !== serializePlatformSelection(initialPublishPlatforms.value),
);
const saveMutation = useMutation({
mutationFn: () =>
articlesApi.update(articleId.value, {
title: title.value.trim(),
markdown_content: markdown.value,
platforms: publishPlatforms.value,
}),
onSuccess: async (data) => {
message.success(t("article.editor.messages.saved"));
title.value = data.title ?? "";
markdown.value = data.markdown_content ?? "";
initialTitle.value = title.value;
initialMarkdown.value = markdown.value;
publishPlatforms.value = [...(data.platforms ?? [])];
initialPublishPlatforms.value = [...publishPlatforms.value];
await Promise.all([
queryClient.invalidateQueries({ queryKey: ["articles"] }),
queryClient.invalidateQueries({ queryKey: ["workspace"] }),
queryClient.invalidateQueries({ queryKey: ["templates"] }),
queryClient.invalidateQueries({ queryKey: ["articles", "detail", articleId.value] }),
]);
},
onError: (error) => {
message.error(formatError(error));
},
});
const saveDisabled = computed(
() => editorLocked.value || saveMutation.isPending.value || title.value.trim() === "" || !hasChanges.value,
);
const leaveSaveDisabled = computed(
() => editorLocked.value || saveMutation.isPending.value || title.value.trim() === "",
);
async function saveArticle(): Promise<boolean> {
if (leaveSaveDisabled.value || !hasChanges.value) {
return false;
}
try {
await saveMutation.mutateAsync();
return true;
} catch {
return false;
}
}
async function handleSave(): Promise<void> {
if (saveDisabled.value) {
return;
}
await saveArticle();
}
async function handlePublish(): Promise<void> {
if (editorLocked.value) {
return;
}
if (hasChanges.value && !saveMutation.isPending.value) {
try {
await saveMutation.mutateAsync();
} catch {
return;
}
}
message.warning(t("article.editor.messages.publishPending"));
}
function handleBack(): void {
if (saveMutation.isPending.value) {
return;
}
if (hasChanges.value) {
leaveModalOpen.value = true;
return;
}
navigateBack();
}
function navigateBack(): void {
if (window.history.length > 1) {
void router.back();
return;
}
void router.push("/articles/templates");
}
function handleStay(): void {
leaveModalOpen.value = false;
}
function handleDiscardLeave(): void {
leaveModalOpen.value = false;
navigateBack();
}
async function handleSaveAndLeave(): Promise<void> {
const saved = await saveArticle();
if (!saved) {
return;
}
leaveModalOpen.value = false;
navigateBack();
}
function handleCoverChange(event: Event): void {
const input = event.target as HTMLInputElement;
const file = input.files?.[0];
if (!file) {
return;
}
if (coverPreviewUrl.value) {
URL.revokeObjectURL(coverPreviewUrl.value);
}
coverPreviewUrl.value = URL.createObjectURL(file);
}
onBeforeUnmount(() => {
if (coverPreviewUrl.value) {
URL.revokeObjectURL(coverPreviewUrl.value);
}
});
function stripLeadingTitleHeading(titleValue: string, markdownValue: string): string {
const normalizedTitle = titleValue.trim();
if (!normalizedTitle) {
return markdownValue;
}
const normalizedMarkdown = markdownValue.replace(/^\uFEFF/, "");
const match = normalizedMarkdown.match(/^#\s+(.+?)\s*(\r?\n|$)/);
if (!match) {
return markdownValue;
}
if (match[1].trim() !== normalizedTitle) {
return markdownValue;
}
return normalizedMarkdown.slice(match[0].length).replace(/^\s*\r?\n/, "");
}
function serializePlatformSelection(platformIds: string[]): string {
return [...platformIds]
.map((platformId) => platformId.trim())
.filter(Boolean)
.sort()
.join(",");
}
</script>
<template>
<div class="article-editor-view">
<header class="article-editor-view__topbar">
<button class="article-editor-view__back" type="button" @click="handleBack">
<LeftOutlined />
<span>{{ t("common.back") }}</span>
</button>
<div class="article-editor-view__actions">
<a-button :disabled="saveDisabled" :loading="saveMutation.isPending.value" @click="handleSave">
{{ t("common.save") }}
</a-button>
<a-button type="primary" :disabled="editorLocked" @click="handlePublish">
{{ t("article.editor.publish") }}
</a-button>
</div>
</header>
<div v-if="detailQuery.isPending.value" class="article-editor-view__loading">
<a-skeleton active :paragraph="{ rows: 14 }" />
</div>
<template v-else-if="detail">
<a-alert
v-if="editorLocked"
class="article-editor-view__alert"
type="info"
show-icon
:message="t('article.editor.messages.locked')"
/>
<div class="article-editor-view__layout">
<section class="article-editor-view__main">
<MilkdownProvider>
<ArticleEditorCanvas
:key="String(articleId)"
v-model:title="title"
v-model="markdown"
:disabled="editorLocked"
/>
</MilkdownProvider>
</section>
<aside class="article-editor-view__rail">
<section class="article-editor-view__card">
<h3>{{ t("article.editor.platformsTitle") }}</h3>
<p>{{ t("article.editor.platformsHint") }}</p>
<PublishPlatformSelector
v-model="publishPlatforms"
class="article-editor-view__platforms"
:platforms="boundPublishPlatforms"
:disabled="editorLocked"
/>
</section>
<section class="article-editor-view__card">
<div class="article-editor-view__card-head">
<div>
<h3>{{ t("article.editor.coverTitle") }}</h3>
<p>{{ t("article.editor.coverHint") }}</p>
</div>
<a-switch v-model:checked="coverEnabled" />
</div>
<label
class="article-editor-view__cover-dropzone"
:class="{ 'article-editor-view__cover-dropzone--disabled': !coverEnabled }"
>
<input
type="file"
accept="image/*"
:disabled="!coverEnabled"
hidden
@change="handleCoverChange"
/>
<template v-if="coverPreviewUrl">
<img :src="coverPreviewUrl" alt="cover preview" />
</template>
<template v-else>
<span class="article-editor-view__cover-plus">+</span>
<span>{{ t("article.editor.coverUpload") }}</span>
</template>
</label>
</section>
</aside>
</div>
</template>
<a-empty v-else :description="t('common.noData')" />
<a-modal
:open="leaveModalOpen"
:title="t('article.editor.leaveConfirm.title')"
:closable="false"
:mask-closable="false"
@cancel="handleStay"
>
<p class="article-editor-view__leave-copy">
{{ t("article.editor.leaveConfirm.description") }}
</p>
<template #footer>
<a-button @click="handleStay">
{{ t("common.cancel") }}
</a-button>
<a-button @click="handleDiscardLeave">
{{ t("article.editor.leaveConfirm.discard") }}
</a-button>
<a-button
type="primary"
:loading="saveMutation.isPending.value"
:disabled="leaveSaveDisabled"
@click="handleSaveAndLeave"
>
{{ t("article.editor.leaveConfirm.saveAndLeave") }}
</a-button>
</template>
</a-modal>
</div>
</template>
<style scoped>
.article-editor-view {
display: flex;
flex-direction: column;
gap: 18px;
}
.article-editor-view__topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
}
.article-editor-view__back {
display: inline-flex;
align-items: center;
gap: 10px;
padding: 0;
border: 0;
background: transparent;
color: #111827;
font-size: 16px;
font-weight: 700;
cursor: pointer;
}
.article-editor-view__back :deep(.anticon) {
display: inline-flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.82);
border: 1px solid rgba(144, 157, 181, 0.24);
}
.article-editor-view__actions {
display: flex;
gap: 12px;
}
.article-editor-view__main {
height: calc(100vh - 180px);
overflow: hidden;
background: rgba(255, 255, 255, 0.88);
border: 1px solid rgba(216, 225, 237, 0.9);
border-radius: 28px;
box-shadow: 0 18px 40px rgba(15, 23, 42, 0.05);
backdrop-filter: blur(14px);
}
.article-editor-view__loading,
.article-editor-view__card {
padding: 24px;
background: rgba(255, 255, 255, 0.88);
border: 1px solid rgba(216, 225, 237, 0.9);
border-radius: 28px;
box-shadow: 0 18px 40px rgba(15, 23, 42, 0.05);
backdrop-filter: blur(14px);
}
.article-editor-view__alert {
border-radius: 20px;
}
.article-editor-view__leave-copy {
margin: 0;
color: #475467;
line-height: 1.75;
}
.article-editor-view__layout {
display: grid;
grid-template-columns: minmax(0, 1fr) 360px;
gap: 18px;
align-items: start;
}
.article-editor-view__main {
display: flex;
flex-direction: column;
gap: 18px;
}
.article-editor-view__card h3 {
margin: 0;
color: #101828;
font-size: 15px;
font-weight: 700;
}
.article-editor-view__rail {
display: flex;
flex-direction: column;
gap: 18px;
}
.article-editor-view__card p {
margin: 6px 0 0;
color: #667085;
font-size: 13px;
line-height: 1.7;
}
.article-editor-view__platforms {
margin-top: 18px;
}
.article-editor-view__card-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
}
.article-editor-view__cover-dropzone {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 8px;
min-height: 176px;
margin-top: 18px;
border: 1px dashed #d3dceb;
border-radius: 20px;
background:
radial-gradient(circle at top, rgba(70, 102, 255, 0.08), transparent 45%),
#fbfcff;
color: #475467;
cursor: pointer;
overflow: hidden;
}
.article-editor-view__cover-dropzone img {
width: 100%;
height: 176px;
object-fit: cover;
}
.article-editor-view__cover-dropzone--disabled {
opacity: 0.48;
cursor: not-allowed;
}
.article-editor-view__cover-plus {
display: inline-flex;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
border-radius: 999px;
background: #eef4ff;
color: #355dff;
font-size: 28px;
line-height: 1;
}
@media (max-width: 1200px) {
.article-editor-view__layout {
grid-template-columns: 1fr;
}
.article-editor-view__rail {
order: -1;
}
}
@media (max-width: 768px) {
.article-editor-view__topbar {
flex-direction: column;
align-items: stretch;
}
.article-editor-view__actions {
width: 100%;
}
.article-editor-view__actions :deep(.ant-btn) {
flex: 1;
}
}
</style>
+3 -3
View File
@@ -661,7 +661,7 @@ async function submitCompetitor(): Promise<void> {
<a-input v-model:value="brandForm.name" />
</a-form-item>
<a-form-item :label="t('brands.form.brandDescription')">
<a-input-text-area v-model:value="brandForm.description" :rows="4" />
<a-textarea v-model:value="brandForm.description" :rows="4" />
</a-form-item>
</a-form>
</a-modal>
@@ -691,7 +691,7 @@ async function submitCompetitor(): Promise<void> {
/>
</a-form-item>
<a-form-item :label="t('brands.form.questionText')">
<a-input-text-area v-model:value="questionForm.question_text" :rows="4" />
<a-textarea v-model:value="questionForm.question_text" :rows="4" />
</a-form-item>
</a-form>
</a-modal>
@@ -709,7 +709,7 @@ async function submitCompetitor(): Promise<void> {
<a-input v-model:value="competitorForm.website" />
</a-form-item>
<a-form-item :label="t('brands.form.competitorDescription')">
<a-input-text-area v-model:value="competitorForm.description" :rows="3" />
<a-textarea v-model:value="competitorForm.description" :rows="3" />
</a-form-item>
<a-form-item :label="t('brands.form.competitorLines')">
<a-input
@@ -0,0 +1,149 @@
<script setup lang="ts">
import {
ThunderboltOutlined,
ClockCircleOutlined,
} from "@ant-design/icons-vue";
import { ref } from "vue";
import { useI18n } from "vue-i18n";
import CustomArticleTab from "@/components/CustomArticleTab.vue";
import PromptRuleTab from "@/components/PromptRuleTab.vue";
import ScheduleTaskTab from "@/components/ScheduleTaskTab.vue";
import InstantGenerateModal from "@/components/InstantGenerateModal.vue";
import ScheduleTaskModal from "@/components/ScheduleTaskModal.vue";
const { t } = useI18n();
const activeTab = ref("articles");
const instantModalOpen = ref(false);
const scheduleModalOpen = ref(false);
function openInstantModal(): void {
instantModalOpen.value = true;
}
function openScheduleModal(): void {
scheduleModalOpen.value = true;
}
</script>
<template>
<div class="custom-view">
<section class="custom-view__cards">
<div class="custom-view__card custom-view__card--instant" @click="openInstantModal">
<div class="custom-view__card-icon custom-view__card-icon--instant">
<ThunderboltOutlined />
</div>
<div>
<h4>{{ t("custom.cards.instantTitle") }}</h4>
<p>{{ t("custom.cards.instantDesc") }}</p>
</div>
</div>
<div class="custom-view__card custom-view__card--schedule" @click="openScheduleModal">
<div class="custom-view__card-icon custom-view__card-icon--schedule">
<ClockCircleOutlined />
</div>
<div>
<h4>{{ t("custom.cards.scheduleTitle") }}</h4>
<p>{{ t("custom.cards.scheduleDesc") }}</p>
</div>
</div>
</section>
<section class="custom-view__tabs-card">
<a-tabs v-model:activeKey="activeTab">
<a-tab-pane key="articles" :tab="t('custom.tabs.articles')">
<CustomArticleTab />
</a-tab-pane>
<a-tab-pane key="scheduleTasks" :tab="t('custom.tabs.scheduleTasks')">
<ScheduleTaskTab />
</a-tab-pane>
<a-tab-pane key="promptRules" :tab="t('custom.tabs.promptRules')">
<PromptRuleTab />
</a-tab-pane>
</a-tabs>
</section>
<InstantGenerateModal v-model:open="instantModalOpen" />
<ScheduleTaskModal v-model:open="scheduleModalOpen" />
</div>
</template>
<style scoped>
.custom-view {
display: flex;
flex-direction: column;
gap: 22px;
}
.custom-view__cards {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
}
.custom-view__card {
display: flex;
align-items: center;
gap: 16px;
padding: 20px 24px;
background: #fff;
border: 1px solid #e6edf5;
border-radius: 12px;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
.custom-view__card:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
}
.custom-view__card h4 {
margin: 0 0 4px;
font-size: 15px;
font-weight: 600;
color: #141414;
}
.custom-view__card p {
margin: 0;
font-size: 13px;
color: #8c8c8c;
}
.custom-view__card-icon {
flex-shrink: 0;
width: 40px;
height: 40px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
}
.custom-view__card-icon--instant {
background: #fff7e6;
color: #fa8c16;
}
.custom-view__card-icon--schedule {
background: #e6f7ff;
color: #1677ff;
}
.custom-view__tabs-card {
padding: 24px;
background: #fff;
border: 1px solid #e6edf5;
border-radius: 12px;
}
@media (max-width: 720px) {
.custom-view__cards {
grid-template-columns: 1fr;
}
}
</style>
File diff suppressed because it is too large Load Diff
+198 -134
View File
@@ -1,8 +1,9 @@
<script setup lang="ts">
import {
DeleteOutlined,
EyeOutlined,
EditOutlined,
PlusOutlined,
BlockOutlined,
ReloadOutlined,
LoadingOutlined,
ExperimentOutlined,
@@ -16,12 +17,11 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/vue-query";
import { message } from "ant-design-vue";
import type { ArticleListItem, ArticleListParams, TemplateListItem } from "@geo/shared-types";
import type { TableColumnsType } from "ant-design-vue";
import type { Dayjs } from "dayjs";
import { computed, onBeforeUnmount, reactive, ref, watch } from "vue";
import { useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
import ArticleDetailDrawer from "@/components/ArticleDetailDrawer.vue";
import PageHero from "@/components/PageHero.vue";
import { articlesApi, templatesApi } from "@/lib/api";
import { formatError } from "@/lib/errors";
import {
@@ -37,16 +37,17 @@ const router = useRouter();
const { t } = useI18n();
const pickerOpen = ref(false);
const articleDrawerOpen = ref(false);
const selectedArticleId = ref<number | null>(null);
const page = ref(1);
const pageSize = ref(10);
const draftGenerationRange = ref<[Dayjs, Dayjs] | null>(null);
const draftFilters = reactive<{
template_id?: number;
publish_status?: string;
generate_status?: string;
keyword?: string;
created_from?: string;
created_to?: string;
}>({
keyword: "",
});
@@ -56,6 +57,8 @@ const appliedFilters = reactive<{
publish_status?: string;
generate_status?: string;
keyword?: string;
created_from?: string;
created_to?: string;
}>({
keyword: "",
});
@@ -84,6 +87,12 @@ const articleParams = computed<ArticleListParams>(() => {
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;
});
@@ -110,7 +119,7 @@ const deleteMutation = useMutation({
});
const templateOptions = computed(() =>
(templateListQuery.data.value || []).map((template) => ({
(templateListQuery.data.value || []).map((template: TemplateListItem) => ({
label: template.template_name,
value: template.id,
})),
@@ -175,6 +184,8 @@ function applyFilters(): void {
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 getTemplateCardClass(idx: number): string {
@@ -203,6 +214,7 @@ function resetFilters(): void {
draftFilters.publish_status = undefined;
draftFilters.generate_status = undefined;
draftFilters.keyword = "";
draftGenerationRange.value = null;
applyFilters();
}
@@ -215,15 +227,29 @@ function startTemplate(template: TemplateListItem): void {
void router.push({ path: "/articles/wizard", query: { template_id: String(template.id) } });
}
function openArticle(articleId: number): void {
selectedArticleId.value = articleId;
articleDrawerOpen.value = true;
function openEditor(article: ArticleListItem): void {
if ((article.generate_status === "draft" || article.generate_status === "failed") && article.template_id) {
void router.push({
name: "article-wizard",
query: {
template_id: String(article.template_id),
article_id: String(article.id),
},
});
return;
}
void router.push({ name: "article-editor", params: { id: String(article.id) } });
}
function canEditArticle(status: string): boolean {
return status === "completed" || status === "draft" || status === "failed";
}
watch(
() => articleListQuery.data.value?.items ?? [],
(items) => {
const hasGeneratingArticles = items.some((item) =>
(items: ArticleListItem[]) => {
const hasGeneratingArticles = items.some((item: ArticleListItem) =>
item.generate_status === "generating" || item.generate_status === "running",
);
@@ -268,81 +294,91 @@ function stopArticlePolling(): void {
async function handleDelete(articleId: number): Promise<void> {
await deleteMutation.mutateAsync(articleId);
}
function handleDrawerClose(): void {
articleDrawerOpen.value = false;
selectedArticleId.value = null;
}
</script>
<template>
<div class="templates-view">
<PageHero
eyebrow="Article Creation"
:title="t('route.templates.title')"
:description="t('route.templates.description')"
>
<template #actions>
<a-button disabled>{{ t("templates.actions.batchGenerate") }}</a-button>
<a-button type="primary" @click="openTemplatePicker">
<template #icon><PlusOutlined /></template>
{{ t("templates.actions.chooseTemplate") }}
</a-button>
</template>
</PageHero>
<section class="templates-view__filters">
<div class="templates-view__filters-grid">
<div class="templates-view__filter">
<label>{{ t("templates.filters.template") }}</label>
<a-select
v-model:value="draftFilters.template_id"
allow-clear
:options="templateOptions"
:placeholder="t('common.selectPlease')"
/>
<section class="templates-view__top-card">
<div class="templates-view__header">
<div class="templates-view__header-title">
<h2>{{ t('route.templates.title') }}</h2>
<p>{{ t('route.templates.description') }}</p>
</div>
<div class="templates-view__filter">
<label>{{ t("templates.filters.publishStatus") }}</label>
<a-select
v-model:value="draftFilters.publish_status"
allow-clear
:options="publishStatusOptions"
:placeholder="t('common.selectPlease')"
/>
</div>
<div class="templates-view__filter">
<label>{{ t("templates.filters.generateStatus") }}</label>
<a-select
v-model:value="draftFilters.generate_status"
allow-clear
:options="generateStatusOptions"
:placeholder="t('common.selectPlease')"
/>
</div>
<div class="templates-view__filter">
<label>{{ t("templates.filters.keyword") }}</label>
<a-input
v-model:value="draftFilters.keyword"
:placeholder="t('templates.filters.keywordPlaceholder')"
@pressEnter="applyFilters"
/>
<div class="templates-view__header-actions">
<a-button class="batch-generate-btn">
<template #icon><BlockOutlined /></template>
{{ t("templates.actions.batchGenerate") }}
</a-button>
<a-button type="primary" @click="openTemplatePicker">
<template #icon><PlusOutlined /></template>
{{ t("templates.actions.chooseTemplate") }}
</a-button>
</div>
</div>
<div class="templates-view__filter-actions">
<div class="templates-view__filter-note">
{{ t("templates.filters.unsupportedDate") }}
</div>
<div class="templates-view__filter-buttons">
<a-button @click="resetFilters">{{ t("common.reset") }}</a-button>
<a-button type="primary" @click="applyFilters">
<template #icon><ReloadOutlined /></template>
{{ t("common.refresh") }}
</a-button>
<a-divider style="margin: 0; border-color: #f0f0f0;" />
<div class="templates-view__filters">
<div class="templates-view__filters-inline">
<div class="templates-view__filter-item">
<label>{{ t("templates.filters.template") }}:</label>
<a-select
v-model:value="draftFilters.template_id"
allow-clear
:options="templateOptions"
:placeholder="t('common.selectPlease')"
@change="applyFilters"
/>
</div>
<div class="templates-view__filter-item">
<label>{{ t("templates.filters.publishStatus") }}:</label>
<a-select
v-model:value="draftFilters.publish_status"
allow-clear
:options="publishStatusOptions"
:placeholder="t('common.selectPlease')"
@change="applyFilters"
/>
</div>
<div class="templates-view__filter-item">
<label>{{ t("templates.filters.generationTime") }}:</label>
<a-range-picker
v-model:value="draftGenerationRange"
allow-clear
show-time
format="YYYY-MM-DD HH:mm"
:placeholder="[
t('templates.filters.generationTimeStart'),
t('templates.filters.generationTimeEnd'),
]"
@change="applyFilters"
/>
</div>
<div class="templates-view__filter-item">
<label>{{ t("templates.filters.generateStatus") }}:</label>
<a-select
v-model:value="draftFilters.generate_status"
allow-clear
:options="generateStatusOptions"
:placeholder="t('common.selectPlease')"
@change="applyFilters"
/>
</div>
<div class="templates-view__filter-item">
<label>{{ t("templates.filters.keyword") }}:</label>
<a-input-search
v-model:value="draftFilters.keyword"
:placeholder="t('templates.filters.keywordPlaceholder')"
@search="applyFilters"
@pressEnter="applyFilters"
/>
</div>
<a-button @click="resetFilters" class="templates-view__reset-btn">{{ t("common.reset") }}</a-button>
</div>
</div>
</section>
@@ -412,9 +448,15 @@ function handleDrawerClose(): void {
<template v-else-if="column.key === 'actions'">
<div class="templates-view__actions">
<a-tooltip :title="t('templates.list.preview')">
<a-button size="small" @click="openArticle(record.id)">
<template #icon><EyeOutlined /></template>
<a-tooltip
:title="canEditArticle(record.generate_status) ? t('templates.list.edit') : t('templates.list.editDisabled')"
>
<a-button
size="small"
:disabled="!canEditArticle(record.generate_status)"
@click="openEditor(record)"
>
<template #icon><EditOutlined /></template>
</a-button>
</a-tooltip>
<a-popconfirm
@@ -461,14 +503,6 @@ function handleDrawerClose(): void {
</article>
</div>
</a-modal>
<ArticleDetailDrawer
:open="articleDrawerOpen"
:article-id="selectedArticleId"
@close="handleDrawerClose"
/>
</div>
</template>
@@ -479,48 +513,91 @@ function handleDrawerClose(): void {
gap: 22px;
}
.templates-view__filters,
.templates-view__top-card {
background: #fff;
border: 1px solid #e6edf5;
border-radius: 12px;
overflow: hidden;
}
.templates-view__header {
display: flex;
justify-content: space-between;
align-items: flex-start;
padding: 24px;
}
.templates-view__header-title h2 {
margin: 0;
font-size: 20px;
font-weight: 600;
color: #1a1a1a;
line-height: 1.4;
}
.templates-view__header-title p {
margin: 6px 0 0 0;
font-size: 13px;
color: #8c8c8c;
}
.templates-view__header-actions {
display: flex;
gap: 12px;
}
.batch-generate-btn {
color: #1677ff;
border-color: #1677ff;
}
.templates-view__filters {
padding: 20px 24px;
}
.templates-view__table-card {
padding: 24px;
background: #fff;
border: 1px solid #e6edf5;
border-radius: 24px;
border-radius: 12px;
}
.templates-view__filters-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 16px;
}
.templates-view__filter {
.templates-view__filters-inline {
display: flex;
flex-direction: column;
align-items: center;
flex-wrap: wrap;
gap: 16px 24px;
}
.templates-view__reset-btn {
flex-shrink: 0;
margin-left: auto;
}
.templates-view__filter-item {
display: flex;
align-items: center;
gap: 8px;
}
.templates-view__filter label {
color: #445164;
font-size: 13px;
font-weight: 600;
.templates-view__filter-item label {
color: #101828;
font-size: 14px;
font-weight: 500;
white-space: nowrap;
}
.templates-view__filter-actions {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-top: 18px;
.templates-view__filter-item :deep(.ant-select) {
min-width: 140px;
}
.templates-view__filter-note {
color: var(--muted);
font-size: 12px;
.templates-view__filter-item :deep(.ant-picker) {
width: 320px;
}
.templates-view__filter-buttons {
display: flex;
gap: 12px;
.templates-view__filter-item :deep(.ant-input-affix-wrapper),
.templates-view__filter-item :deep(.ant-input-search) {
width: 240px;
}
.templates-view__table-head {
@@ -645,33 +722,20 @@ function handleDrawerClose(): void {
background: #fcfcfc;
border: 1px dashed #d9d9d9;
}
.bg-grey { background: #f0f0f0; color: #8c8c8c; }
.card-grey .template-action { display: none; }
@media (max-width: 1080px) {
.templates-view__filters-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
@media (max-width: 1200px) {
.templates-view__filter-item :deep(.ant-picker) {
width: 280px;
}
}
@media (max-width: 720px) {
.templates-view__filters-grid,
.templates-view__picker-grid {
grid-template-columns: 1fr;
}
.bg-grey { background: #f0f0f0; color: #8c8c8c; }
.card-grey .template-action { display: none; }
.templates-view__filter-actions,
@media (max-width: 720px) {
.templates-view__table-head {
flex-direction: column;
align-items: stretch;
}
.templates-view__filter-buttons {
width: 100%;
}
.templates-view__filter-buttons :deep(.ant-btn) {
flex: 1;
}
}
</style>