Refactor brand service and related components
- Removed ListQuestionVersions method and associated types from BrandService and Queries. - Updated PromptRuleGenerationService to change task naming and handling. - Enhanced ScheduleTaskService to support filtering by created date range and keyword. - Introduced InstantTaskService for managing instant tasks with appropriate filtering and response structures. - Added InstantTaskHandler for handling API requests related to instant tasks. - Created InstantTaskTab component for the admin web interface to display and manage instant tasks. - Updated database migrations to rename source types for articles and generation tasks. - Adjusted models and repository queries to reflect the removal of question version handling.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
LoadingOutlined,
|
||||
AppstoreOutlined,
|
||||
ClockCircleOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined,
|
||||
} from "@ant-design/icons-vue";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
import { message, type TableColumnsType } from "ant-design-vue";
|
||||
@@ -16,6 +20,7 @@ import {
|
||||
formatDateTime,
|
||||
getGenerateStatusMeta,
|
||||
getPublishStatusMeta,
|
||||
getSourceTypeLabel,
|
||||
} from "@/lib/display";
|
||||
import { formatError } from "@/lib/errors";
|
||||
import { formatPublishPlatformList } from "@/lib/publish-platforms";
|
||||
@@ -78,7 +83,7 @@ const articleParams = computed<ArticleListParams>(() => {
|
||||
const params: ArticleListParams = {
|
||||
page: page.value,
|
||||
page_size: pageSize.value,
|
||||
source_type: "prompt_rule",
|
||||
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;
|
||||
@@ -90,7 +95,7 @@ const articleParams = computed<ArticleListParams>(() => {
|
||||
});
|
||||
|
||||
const listQuery = useQuery({
|
||||
queryKey: computed(() => ["articles", "list", "prompt_rule", articleParams.value]),
|
||||
queryKey: computed(() => ["articles", "list", "custom_generation", articleParams.value]),
|
||||
queryFn: () => articlesApi.list(articleParams.value),
|
||||
});
|
||||
|
||||
@@ -106,14 +111,13 @@ const deleteMutation = useMutation({
|
||||
});
|
||||
|
||||
const columns = computed<TableColumnsType<ArticleListItem>>(() => [
|
||||
{ title: t("common.title"), dataIndex: "title", key: "title" },
|
||||
{ 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.platform"), dataIndex: "platforms", key: "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.createdAt"), dataIndex: "created_at", key: "created_at", width: 168 },
|
||||
{ title: t("common.actions"), key: "actions", width: 140, fixed: "right" },
|
||||
{ title: t("common.actions"), key: "actions", width: 120, fixed: "right", align: "right" },
|
||||
]);
|
||||
|
||||
function applyFilters(): void {
|
||||
@@ -148,6 +152,13 @@ function canEditArticle(status: string): boolean {
|
||||
return status === "completed" || status === "draft";
|
||||
}
|
||||
|
||||
function getDisplayTitle(article: ArticleListItem): string {
|
||||
if ((article.generate_status === "generating" || article.generate_status === "running") && !article.title) {
|
||||
return t("custom.article.titleGenerating");
|
||||
}
|
||||
return article.title || t("article.untitled");
|
||||
}
|
||||
|
||||
function handleTableChange(nextPage: number, nextPageSize: number): void {
|
||||
page.value = nextPage;
|
||||
pageSize.value = nextPageSize;
|
||||
@@ -273,9 +284,21 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'title'">
|
||||
<a class="custom-article-tab__title-link" @click="openDetail(record)">
|
||||
{{ record.title || t("article.untitled") }}
|
||||
</a>
|
||||
<div class="custom-article-tab__title-cell">
|
||||
<a class="custom-article-tab__title-link" @click="openDetail(record)">
|
||||
{{ getDisplayTitle(record) }}
|
||||
</a>
|
||||
<div class="custom-article-tab__title-meta">
|
||||
<span class="custom-article-tab__title-badge">
|
||||
<AppstoreOutlined />
|
||||
<span>{{ getSourceTypeLabel(record.source_type, record.generation_mode) }}</span>
|
||||
</span>
|
||||
<span class="custom-article-tab__title-time">
|
||||
<ClockCircleOutlined />
|
||||
<span>{{ formatDateTime(record.created_at) }}</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'prompt_rule_name'">
|
||||
{{ record.prompt_rule_name || "--" }}
|
||||
@@ -302,28 +325,37 @@ onBeforeUnmount(() => {
|
||||
<template v-else-if="column.key === 'word_count'">
|
||||
{{ record.word_count || "--" }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'created_at'">
|
||||
{{ formatDateTime(record.created_at) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space :size="4">
|
||||
<a-button
|
||||
type="link"
|
||||
size="small"
|
||||
:disabled="!canEditArticle(record.generate_status)"
|
||||
@click="openEditor(record)"
|
||||
>
|
||||
{{ t("common.edit") }}
|
||||
</a-button>
|
||||
<div class="table-actions-row">
|
||||
<a-tooltip :title="t('common.edit')">
|
||||
<span>
|
||||
<a-button
|
||||
type="text"
|
||||
shape="circle"
|
||||
size="small"
|
||||
class="action-btn action-edit"
|
||||
:disabled="!canEditArticle(record.generate_status)"
|
||||
@click="openEditor(record)"
|
||||
>
|
||||
<EditOutlined />
|
||||
</a-button>
|
||||
</span>
|
||||
</a-tooltip>
|
||||
<a-popconfirm
|
||||
:title="t('templates.list.deleteConfirm')"
|
||||
@confirm="deleteMutation.mutate(record.id)"
|
||||
>
|
||||
<a-button type="link" size="small" danger>
|
||||
{{ t("common.delete") }}
|
||||
<a-button
|
||||
type="text"
|
||||
shape="circle"
|
||||
size="small"
|
||||
class="action-btn action-delete"
|
||||
:title="t('common.delete')"
|
||||
>
|
||||
<DeleteOutlined />
|
||||
</a-button>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
@@ -370,12 +402,46 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
|
||||
.custom-article-tab__title-link {
|
||||
color: #1677ff;
|
||||
display: inline-block;
|
||||
color: #434343;
|
||||
cursor: pointer;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.custom-article-tab__title-link:hover {
|
||||
text-decoration: underline;
|
||||
color: #1677ff;
|
||||
}
|
||||
|
||||
.custom-article-tab__title-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.custom-article-tab__title-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.custom-article-tab__title-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: #b45f06;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.custom-article-tab__title-time {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: #a3a3a3;
|
||||
}
|
||||
|
||||
.custom-article-tab__status-tag {
|
||||
|
||||
Reference in New Issue
Block a user