From 8958cb44c07327b00ae8156c51c32cb1da71e262 Mon Sep 17 00:00:00 2001 From: liangxu Date: Thu, 2 Apr 2026 21:16:12 +0800 Subject: [PATCH] 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. --- .../src/components/ArticleDetailDrawer.vue | 2 +- .../src/components/CustomArticleTab.vue | 116 +++++-- .../src/components/GenerateTaskDrawer.vue | 6 +- .../src/components/InstantTaskTab.vue | 328 ++++++++++++++++++ .../src/components/PromptRuleTab.vue | 60 +++- .../src/components/ScheduleTaskTab.vue | 290 ++++++++++++---- apps/admin-web/src/i18n/messages/en-US.ts | 17 + apps/admin-web/src/i18n/messages/zh-CN.ts | 17 + apps/admin-web/src/layouts/AppShell.vue | 10 +- apps/admin-web/src/lib/api.ts | 12 +- apps/admin-web/src/lib/display.ts | 32 +- apps/admin-web/src/router/index.ts | 2 +- apps/admin-web/src/router/meta.d.ts | 2 +- apps/admin-web/src/styles.css | 73 ++++ apps/admin-web/src/views/BrandsView.vue | 184 +++++----- .../src/views/CustomGenerateView.vue | 4 + apps/admin-web/src/views/TemplatesView.vue | 40 ++- ...platform-ops-admin-tech-architecture-v1.md | 1 - ...026-03-31-admin-web-backend-core-design.md | 1 - packages/shared-types/src/index.ts | 44 ++- server/internal/tenant/app/article_service.go | 50 ++- server/internal/tenant/app/brand_service.go | 40 --- .../tenant/app/instant_task_service.go | 165 +++++++++ .../tenant/app/prompt_generate_service.go | 47 ++- .../tenant/app/schedule_task_service.go | 20 +- .../tenant/repository/generated/brand.sql.go | 41 --- .../tenant/repository/generated/models.go | 1 + .../tenant/repository/generated/querier.go | 1 - .../tenant/repository/queries/brand.sql | 7 - .../tenant/transport/article_handler.go | 3 + .../tenant/transport/brand_handler.go | 10 - .../tenant/transport/instant_task_handler.go | 71 ++++ server/internal/tenant/transport/router.go | 5 +- .../tenant/transport/schedule_task_handler.go | 20 ++ ..._source_type_to_custom_generation.down.sql | 7 + ...le_source_type_to_custom_generation.up.sql | 7 + 36 files changed, 1378 insertions(+), 358 deletions(-) create mode 100644 apps/admin-web/src/components/InstantTaskTab.vue create mode 100644 server/internal/tenant/app/instant_task_service.go create mode 100644 server/internal/tenant/transport/instant_task_handler.go create mode 100644 server/migrations/20260402120000_rename_prompt_rule_source_type_to_custom_generation.down.sql create mode 100644 server/migrations/20260402120000_rename_prompt_rule_source_type_to_custom_generation.up.sql diff --git a/apps/admin-web/src/components/ArticleDetailDrawer.vue b/apps/admin-web/src/components/ArticleDetailDrawer.vue index 24b5a36..1ed1fe8 100644 --- a/apps/admin-web/src/components/ArticleDetailDrawer.vue +++ b/apps/admin-web/src/components/ArticleDetailDrawer.vue @@ -209,7 +209,7 @@ async function refreshArticleData(): Promise {

{{ t("article.preview") }}

{{ displayTitle }}

- {{ getSourceTypeLabel(detail.source_type) }} · + {{ getSourceTypeLabel(detail.source_type, detail.generation_mode) }} · {{ formatDateTime(detail.created_at) }}

diff --git a/apps/admin-web/src/components/CustomArticleTab.vue b/apps/admin-web/src/components/CustomArticleTab.vue index 5c8ee71..776a730 100644 --- a/apps/admin-web/src/components/CustomArticleTab.vue +++ b/apps/admin-web/src/components/CustomArticleTab.vue @@ -1,6 +1,10 @@ + + + + diff --git a/apps/admin-web/src/components/PromptRuleTab.vue b/apps/admin-web/src/components/PromptRuleTab.vue index bc738c8..621b111 100644 --- a/apps/admin-web/src/components/PromptRuleTab.vue +++ b/apps/admin-web/src/components/PromptRuleTab.vue @@ -2,6 +2,8 @@ import { DeleteOutlined, EditOutlined, + PauseCircleOutlined, + PlayCircleOutlined, PlusOutlined, } from "@ant-design/icons-vue"; import { useMutation, useQuery, useQueryClient } from "@tanstack/vue-query"; @@ -59,7 +61,7 @@ const columns = computed>(() => [ { title: t("custom.promptRule.articleCount"), dataIndex: "article_count", key: "article_count", width: 100 }, { title: t("custom.promptRule.status"), dataIndex: "status", key: "status", 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: 140, fixed: "right", align: "right" }, ]); const groupMutations = { @@ -252,29 +254,53 @@ watch(selectedGroupId, () => { {{ formatDateTime(record.created_at) }} diff --git a/apps/admin-web/src/components/ScheduleTaskTab.vue b/apps/admin-web/src/components/ScheduleTaskTab.vue index 34c02fe..3e74bb5 100644 --- a/apps/admin-web/src/components/ScheduleTaskTab.vue +++ b/apps/admin-web/src/components/ScheduleTaskTab.vue @@ -1,14 +1,20 @@ diff --git a/apps/admin-web/src/i18n/messages/en-US.ts b/apps/admin-web/src/i18n/messages/en-US.ts index cec8ac1..f930c65 100644 --- a/apps/admin-web/src/i18n/messages/en-US.ts +++ b/apps/admin-web/src/i18n/messages/en-US.ts @@ -187,6 +187,7 @@ const enUS = { status: { generate: { draft: "Draft", + queued: "Queued", generating: "Generating", running: "Running", completed: "Completed", @@ -202,6 +203,9 @@ const enUS = { }, sourceType: { template: "Template generation", + custom_generation: "Custom generation", + instant_task: "Instant task", + schedule_task: "Scheduled task", }, }, templates: { @@ -568,6 +572,11 @@ const enUS = { selectPlatform: "Target platform", submit: "Generate now", extraParams: "Extra parameters", + name: "Task name", + executionStatus: "Execution status", + executionTime: "Execution time", + createdTime: "Created time", + empty: "No instant tasks yet.", }, filters: { promptRule: "Prompt rule", @@ -575,6 +584,14 @@ const enUS = { generateStatus: "Generation status", title: "Title", generateTime: "Generation time", + status: "Status", + name: "Name", + namePlaceholder: "Search by task name", + createdTime: "Created time", + }, + article: { + titleColumn: "Article title", + titleGenerating: "Generating title", }, messages: { ruleCreated: "Rule created.", diff --git a/apps/admin-web/src/i18n/messages/zh-CN.ts b/apps/admin-web/src/i18n/messages/zh-CN.ts index a402f38..d9aa44b 100644 --- a/apps/admin-web/src/i18n/messages/zh-CN.ts +++ b/apps/admin-web/src/i18n/messages/zh-CN.ts @@ -187,6 +187,7 @@ const zhCN = { status: { generate: { draft: "草稿", + queued: "排队中", generating: "生成中", running: "运行中", completed: "已完成", @@ -202,6 +203,9 @@ const zhCN = { }, sourceType: { template: "模版单次生成", + custom_generation: "自定义生成", + instant_task: "即时任务", + schedule_task: "定时任务", }, }, templates: { @@ -577,6 +581,11 @@ const zhCN = { selectPlatform: "目标平台", submit: "立即生成", extraParams: "额外参数", + name: "任务名称", + executionStatus: "执行状态", + executionTime: "执行时间", + createdTime: "创建时间", + empty: "还未创建即时任务,暂无相关数据~", }, filters: { promptRule: "Prompt 规则", @@ -584,6 +593,14 @@ const zhCN = { generateStatus: "生成状态", title: "标题", generateTime: "生成时间", + status: "状态", + name: "名称", + namePlaceholder: "请输入任务名称内搜索", + createdTime: "创建时间", + }, + article: { + titleColumn: "文章标题", + titleGenerating: "标题生成中", }, messages: { ruleCreated: "规则创建成功", diff --git a/apps/admin-web/src/layouts/AppShell.vue b/apps/admin-web/src/layouts/AppShell.vue index 565777e..c020f33 100644 --- a/apps/admin-web/src/layouts/AppShell.vue +++ b/apps/admin-web/src/layouts/AppShell.vue @@ -29,7 +29,13 @@ const quotaQuery = useQuery({ }); const userInitial = computed(() => authStore.user?.name?.slice(0, 1).toUpperCase() ?? "A"); -const selectedKey = computed(() => String(route.meta.navKey ?? route.path)); +const selectedKeys = computed(() => { + if (route.meta.navKey === null) { + return []; + } + + return [String(route.meta.navKey ?? route.path)]; +}); const pageTitle = computed(() => t(String(route.meta.titleKey ?? "route.workspace.title"))); const localeOptions = computed(() => [ @@ -117,7 +123,7 @@ async function handleLogout(): Promise {