Jelajahi Sumber

优化异步任务架构

luojunhui 1 bulan lalu
induk
melakukan
372b55a8a0
2 mengubah file dengan 205 tambahan dan 0 penghapusan
  1. 28 0
      ui/src/config/constants.ts
  2. 177 0
      ui/src/config/tasks.ts

+ 28 - 0
ui/src/config/constants.ts

@@ -0,0 +1,28 @@
+export const TASK_STATUS = {
+  INIT: 0,
+  PROCESSING: 1,
+  COMPLETED: 2,
+  FAILED: 99,
+} as const
+
+export const TASK_STATUS_OPTIONS = [
+  { label: '初始化(0)', value: TASK_STATUS.INIT },
+  { label: '处理中(1)', value: TASK_STATUS.PROCESSING },
+  { label: '完成(2)', value: TASK_STATUS.COMPLETED },
+  { label: '失败(99)', value: TASK_STATUS.FAILED },
+]
+
+export const TASK_STATUS_TYPE_MAP: Record<number, string> = {
+  [TASK_STATUS.INIT]: 'info',
+  [TASK_STATUS.PROCESSING]: 'warning',
+  [TASK_STATUS.COMPLETED]: 'success',
+  [TASK_STATUS.FAILED]: 'danger',
+}
+
+export const PAGE_SIZES = [10, 20, 50, 100]
+
+export const DEFAULT_PAGE_SIZE = 20
+
+export const AUTO_REFRESH_INTERVAL = 5000
+
+export const MIN_TABLE_HEIGHT = 260

+ 177 - 0
ui/src/config/tasks.ts

@@ -0,0 +1,177 @@
+export interface TaskConfig {
+  name: string
+  desc: string
+  url: string
+  data: Record<string, any>
+}
+
+export const EXEC_PASSWORD = 'curry'
+
+export const AUTO_REFRESH_INTERVAL = 5000
+
+export const TASK_LIST: TaskConfig[] = [
+  {
+    name: '合作方账号 daily发文抓取',
+    desc: '抓取合作方的 daily 发文',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'cooperate_accounts_monitor' },
+  },
+  {
+    name: '合作方发文详情获取',
+    desc: '获取合作方发文的详情',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'cooperate_accounts_detail' },
+  },
+  {
+    name: '公众号抓取-手动挑号',
+    desc: '公众文章抓取-手动挑号',
+    url: 'http://192.168.100.31:6060/api/run_task',
+    data: {
+      task_name: 'crawler_gzh_articles',
+      account_method: '1030-手动挑号',
+      crawl_mode: 'account',
+      strategy: 'V1',
+    },
+  },
+  {
+    name: '公众号抓取-合作账号',
+    desc: '公众文章抓取-合作挑号',
+    url: 'http://192.168.100.31:6060/api/run_task',
+    data: {
+      task_name: 'crawler_gzh_articles',
+      account_method: 'cooperate_account',
+      crawl_mode: 'account',
+      strategy: 'V1',
+    },
+  },
+  {
+    name: '头条文章抓取',
+    desc: '头条推荐流文章专区',
+    url: 'http://192.168.100.31:6060/api/run_task',
+    data: { task_name: 'crawler_toutiao' },
+  },
+  {
+    name: '公众号文章冷启动(v1)',
+    desc: '文章路冷启动-策略 1',
+    url: 'http://192.168.100.31:6060/api/run_task',
+    data: { task_name: 'article_pool_cold_start', strategy: 'strategy_v1' },
+  },
+  {
+    name: '公众号文章冷启动(v3)',
+    desc: '文章路冷启动-策略 3',
+    url: 'http://192.168.100.31:6060/api/run_task',
+    data: { task_name: 'article_pool_cold_start', strategy: 'strategy_v3' },
+  },
+  {
+    name: '头条文章冷启动',
+    desc: '文章路冷启动-头条平台',
+    url: 'http://192.168.100.31:6060/api/run_task',
+    data: {
+      task_name: 'article_pool_cold_start',
+      platform: 'toutiao',
+      crawler_methods: ['toutiao_account_association'],
+    },
+  },
+  {
+    name: '每日文章回收任务',
+    desc: 'daily_publish_articles_recycle',
+    url: 'http://192.168.100.31:6060/api/run_task',
+    data: { task_name: 'daily_publish_articles_recycle' },
+  },
+  {
+    name: 'root_source_id 更新',
+    desc: 'update_root_source_id',
+    url: 'http://192.168.100.31:6060/api/run_task',
+    data: { task_name: 'update_root_source_id' },
+  },
+  {
+    name: '视频下架任务',
+    desc: 'get_off_videos',
+    url: 'http://192.168.100.31:6060/api/run_task',
+    data: { task_name: 'get_off_videos' },
+  },
+  {
+    name: '内部文章监测',
+    desc: 'inner_article_monitor',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'inner_article_monitor' },
+  },
+  {
+    name: '关注公众号任务',
+    desc: 'follow_gzh_task',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'auto_follow_account' },
+  },
+  {
+    name: '获取自动回复结果',
+    desc: 'get_auto_reply_task',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'get_follow_result' },
+  },
+  {
+    name: '解析自动回复 xml',
+    desc: 'extract_task',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'extract_reply_result' },
+  },
+  {
+    name: '阅读率均值计算',
+    desc: 'update_account_read_rate_avg',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'update_account_read_rate_avg' },
+  },
+  {
+    name: '阅读均值计算',
+    desc: 'update_account_read_avg',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'update_account_read_avg' },
+  },
+  {
+    name: '打开率均值计算',
+    desc: 'update_account_open_rate_avg',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'update_account_open_rate_avg' },
+  },
+  {
+    name: '视频审核状态校验',
+    desc: 'check_publish_video_audit_status',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'check_publish_video_audit_status' },
+  },
+  {
+    name: 'kimi 余额校验',
+    desc: 'check_kimi_balance',
+    url: 'http://192.168.100.31:6060/api/run_task',
+    data: { task_name: 'check_kimi_balance' },
+  },
+  {
+    name: '小程序信息更新',
+    desc: 'mini_program_detail_process',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'mini_program_detail_process' },
+  },
+  {
+    name: '外部账号文章回收',
+    desc: 'recycle_outside_account_articles',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'recycle_outside_account_articles' },
+  },
+  {
+    name: '外部文章 RootID 更新',
+    desc: 'update_outside_account_article_root_source_id',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'update_outside_account_article_root_source_id' },
+  },
+  {
+    name: '限流文章分析',
+    desc: 'update_limited_account_info',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'update_limited_account_info' },
+  },
+  {
+    name: '候选账号质量分析',
+    desc: 'candidate_account_quality_analysis',
+    url: 'http://192.168.142.66:6060/api/run_task',
+    data: { task_name: 'candidate_account_quality_analysis' },
+  },
+]