feat(digest): 每天把当天视频情况画成一张图推到企业微信
运营要看的是「他们今天发了什么」,文字版在企业微信手机上没法对齐, 所以直接用 PIL 画成表:博主 / 标题 / 点赞 / 评论 / 收藏 / 分享, 按发布时间取当天,指标取最近一轮,按点赞降序。 - 播放量没进表:抖音对普通作品恒返回 0,摆一列 0 只会误导 - 定时按「今天发过没有」判断,进程重启也不会重复推 - 发送失败不写标记,下一拍继续重试 - 设置页有开关和时间;Webhook 面板加了「预览今天」和「发今天图」 - 容器需要中文字体,Dockerfile 装上 fonts-wqy-zenhei
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
import { useState } from 'react'
|
||||
import { Send, Trash2, Webhook } from 'lucide-react'
|
||||
import { Eye, Image, Send, Trash2, Webhook } from 'lucide-react'
|
||||
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useClearWebhook, useSetWebhook, useTestWebhook, useWebhookStatus } from '@/hooks/useMonitor'
|
||||
import { monitorApi } from '@/lib/api'
|
||||
import { useCurrentPlatform } from '@/hooks/usePlatform'
|
||||
import {
|
||||
useClearWebhook,
|
||||
useSendDailyDigest,
|
||||
useSetWebhook,
|
||||
useTestWebhook,
|
||||
useWebhookStatus,
|
||||
} from '@/hooks/useMonitor'
|
||||
|
||||
/**
|
||||
* 企业微信机器人 Webhook 配置。
|
||||
@@ -16,6 +24,8 @@ export function WebhookPanel() {
|
||||
const setWebhook = useSetWebhook()
|
||||
const clearWebhook = useClearWebhook()
|
||||
const testWebhook = useTestWebhook()
|
||||
const sendDigest = useSendDailyDigest()
|
||||
const { platform } = useCurrentPlatform()
|
||||
|
||||
const [draft, setDraft] = useState('')
|
||||
const [editing, setEditing] = useState(false)
|
||||
@@ -41,32 +51,54 @@ export function WebhookPanel() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{status?.configured && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => testWebhook.mutate(undefined)}
|
||||
disabled={testWebhook.isPending}
|
||||
>
|
||||
<Send className="w-3 h-3 mr-1" />
|
||||
发测试
|
||||
</Button>
|
||||
{!editing && (
|
||||
<Button variant="ghost" size="sm" onClick={() => setEditing(true)}>
|
||||
替换
|
||||
<div className="flex items-center gap-1">
|
||||
{/* 预览不依赖 Webhook —— 先看图长什么样,再决定要不要开推送。 */}
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
window.open(monitorApi.dailyDigestPreviewUrl(platform), '_blank', 'noopener')
|
||||
}
|
||||
>
|
||||
<Eye className="w-3 h-3 mr-1" />
|
||||
预览今天
|
||||
</Button>
|
||||
{status?.configured && (
|
||||
<>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => sendDigest.mutate()}
|
||||
disabled={sendDigest.isPending}
|
||||
>
|
||||
<Image className="w-3 h-3 mr-1" />
|
||||
发今天图
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => clearWebhook.mutate()}
|
||||
disabled={clearWebhook.isPending}
|
||||
>
|
||||
<Trash2 className="w-3 h-3" />
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => testWebhook.mutate(undefined)}
|
||||
disabled={testWebhook.isPending}
|
||||
>
|
||||
<Send className="w-3 h-3 mr-1" />
|
||||
发测试
|
||||
</Button>
|
||||
{!editing && (
|
||||
<Button variant="ghost" size="sm" onClick={() => setEditing(true)}>
|
||||
替换
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => clearWebhook.mutate()}
|
||||
disabled={clearWebhook.isPending}
|
||||
>
|
||||
<Trash2 className="w-3 h-3" />
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{status?.configured && !editing && (
|
||||
|
||||
Reference in New Issue
Block a user