mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-11-30 16:02:58 +08:00
feat: 增加日报模板
This commit is contained in:
1 parent
3f019faa38
commit
eb4cb30fb5
36 files changed
+5068
-559
No files matched your search
@@ -1,6 +1,8 @@
|
||||
export type ReportHeat = '高' | '中' | '低'
|
||||
export type ReportMode = 'compact' | 'full'
|
||||
|
||||
import type { ReportTemplateRequestId } from './report-templates'
|
||||
|
||||
export const selectHeroParticipantNames = (names: string[]): string[] =>
|
||||
Array.from(new Set(names.map((name) => name.trim()).filter(Boolean))).slice(0, 4)
|
||||
|
||||
@@ -283,8 +285,8 @@ export interface GroupReportMetadata {
|
||||
export interface GroupReportExportRequest {
|
||||
report: GroupDailyReport
|
||||
metadata: GroupReportMetadata
|
||||
/** 模板 ID:'v1' 经典 / 'v2' 当前。缺省或未知值用默认(v2) */
|
||||
templateId?: 'v1' | 'v2'
|
||||
/** v1 是默认经典模板,v2 仅保留旧调用兼容;另有五套新版产品模板。 */
|
||||
templateId?: ReportTemplateRequestId
|
||||
}
|
||||
|
||||
export interface GroupReportExportResult {
|
||||
@@ -307,3 +309,18 @@ export interface GroupReportExportResult {
|
||||
warnings?: string[]
|
||||
error?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 旧版历史日报没有保存 GroupDailyReport 时,从已生成 HTML 提取的模板占位值。
|
||||
* values 中的卡片字段是本地日报已经转义/渲染好的 HTML,只用于本地模板重排版。
|
||||
*/
|
||||
export interface GroupReportRenderSnapshot {
|
||||
groupName: string
|
||||
reportDate: string
|
||||
values: Record<string, string>
|
||||
}
|
||||
|
||||
export interface GroupReportRenderSnapshotExportRequest {
|
||||
snapshot: GroupReportRenderSnapshot
|
||||
templateId: ReportTemplateRequestId
|
||||
}
|
||||
@@ -94,7 +94,7 @@ export interface ImageCandidateQuery {
|
||||
sessionId: string
|
||||
startTime: number
|
||||
endTime: number
|
||||
/** 取 Top N,默认 3 */
|
||||
/** 最多取 N 张,默认 3;服务端会将其限制在 0–3 */
|
||||
limit?: number
|
||||
/** 由 renderer 从已加载消息中提取的图片候选(包含热度信息) */
|
||||
inputs?: Array<{
|
||||
@@ -107,4 +107,21 @@ export interface ImageCandidateQuery {
|
||||
responseCount: number
|
||||
interactionCount: number
|
||||
}>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A picture is considered hot only when it has observable follow-up activity.
|
||||
* A bare image message (or a single passive reply) is not enough to enter the
|
||||
* daily report's AI image selection. This keeps the "top 3" value an upper
|
||||
* bound rather than a quota that fills every available slot.
|
||||
*/
|
||||
export const isHotImageCandidate = (input: {
|
||||
responseCount: number
|
||||
interactionCount: number
|
||||
}): boolean =>
|
||||
input.responseCount >= 2 || (input.responseCount >= 1 && input.interactionCount >= 1)
|
||||
|
||||
export const calculateImageHeatScore = (input: {
|
||||
responseCount: number
|
||||
interactionCount: number
|
||||
}): number => input.responseCount * 3 + input.interactionCount * 2 + 1
|
||||
@@ -1,3 +1,10 @@
|
||||
import type {
|
||||
GroupDailyReport,
|
||||
GroupReportMetadata,
|
||||
GroupReportRenderSnapshot
|
||||
} from './group-report'
|
||||
import type { SelectableReportTemplateId } from './report-templates'
|
||||
|
||||
export type ReportAssetStatus = 'ready' | 'missing'
|
||||
|
||||
export interface GeneratedReportRecord {
|
||||
@@ -37,6 +44,11 @@ export interface GeneratedReportRecord {
|
||||
endedAt: string
|
||||
duration: number
|
||||
}[]
|
||||
/** 新版报告保存结构化快照,模板切换时只重新渲染,不再调用 AI。 */
|
||||
reportSnapshot?: GroupDailyReport
|
||||
reportMetadata?: GroupReportMetadata
|
||||
reportRenderSnapshot?: GroupReportRenderSnapshot
|
||||
templateId?: SelectableReportTemplateId
|
||||
}
|
||||
|
||||
export interface SaveGeneratedReportRequest {
|
||||
@@ -63,6 +75,27 @@ export interface SaveGeneratedReportRequest {
|
||||
endedAt: string
|
||||
duration: number
|
||||
}[]
|
||||
reportSnapshot?: GroupDailyReport
|
||||
reportMetadata?: GroupReportMetadata
|
||||
templateId?: SelectableReportTemplateId
|
||||
}
|
||||
|
||||
export interface UpdateGeneratedReportTemplateRequest {
|
||||
reportId: string
|
||||
templateId: SelectableReportTemplateId
|
||||
generatedImage?: string
|
||||
htmlPath?: string
|
||||
pngPath?: string
|
||||
}
|
||||
|
||||
export interface PrepareGeneratedReportTemplateSwitchRequest {
|
||||
reportId: string
|
||||
}
|
||||
|
||||
export interface PrepareGeneratedReportTemplateSwitchResult {
|
||||
success: boolean
|
||||
snapshot?: GroupReportRenderSnapshot
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface ReportHistoryResult {
|
||||
@@ -77,6 +110,8 @@ export interface SaveGeneratedReportResult {
|
||||
error?: string
|
||||
}
|
||||
|
||||
export type UpdateGeneratedReportTemplateResult = SaveGeneratedReportResult
|
||||
|
||||
export interface DeleteGeneratedReportResult {
|
||||
success: boolean
|
||||
deletedId?: string
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
export type ReportTemplateId =
|
||||
| 'mobile-feed'
|
||||
| 'mobile-magazine'
|
||||
| 'mobile-dashboard'
|
||||
| 'desktop-workspace'
|
||||
| 'desktop-editorial'
|
||||
|
||||
export type LegacyReportTemplateId = 'v1' | 'v2'
|
||||
export type SelectableReportTemplateId = 'v1' | ReportTemplateId
|
||||
export type ReportTemplateRequestId = ReportTemplateId | LegacyReportTemplateId
|
||||
export type ReportTemplatePlatform = 'default' | 'mobile' | 'desktop'
|
||||
|
||||
export interface ReportTemplateDefinition {
|
||||
id: SelectableReportTemplateId
|
||||
order: number
|
||||
platform: ReportTemplatePlatform
|
||||
label: string
|
||||
name: string
|
||||
tagline: string
|
||||
fileLabel: string
|
||||
cssClass: string
|
||||
resourceFile: string
|
||||
captureWidth: number
|
||||
maxCaptureWidth: number
|
||||
}
|
||||
|
||||
const SHARED_RESOURCE = 'daily_report_templates.html'
|
||||
|
||||
export const DEFAULT_REPORT_TEMPLATE: Readonly<ReportTemplateDefinition> = {
|
||||
id: 'v1',
|
||||
order: 0,
|
||||
platform: 'default',
|
||||
label: '默认模板',
|
||||
name: '经典日报',
|
||||
tagline: '熟悉的单栏日报版式,信息完整,适合直接生成与分享',
|
||||
fileLabel: '经典版',
|
||||
cssClass: 'template-classic',
|
||||
resourceFile: 'mobile_daily_report_v1.html',
|
||||
captureWidth: 430,
|
||||
maxCaptureWidth: 1200
|
||||
}
|
||||
|
||||
export const REPORT_TEMPLATES: readonly ReportTemplateDefinition[] = [
|
||||
{
|
||||
id: 'mobile-feed',
|
||||
order: 1,
|
||||
platform: 'mobile',
|
||||
label: 'Mobile 01',
|
||||
name: '微信信息流',
|
||||
tagline: '聊天头像、真实消息与 AI 重点整理并列呈现',
|
||||
fileLabel: '手机微信信息流',
|
||||
cssClass: 'template-mobile-feed',
|
||||
resourceFile: SHARED_RESOURCE,
|
||||
captureWidth: 430,
|
||||
maxCaptureWidth: 430
|
||||
},
|
||||
{
|
||||
id: 'mobile-magazine',
|
||||
order: 2,
|
||||
platform: 'mobile',
|
||||
label: 'Mobile 02',
|
||||
name: 'AI Magazine',
|
||||
tagline: '大标题、大数字与编辑式留白的科技日报',
|
||||
fileLabel: '手机AI杂志',
|
||||
cssClass: 'template-mobile-magazine',
|
||||
resourceFile: SHARED_RESOURCE,
|
||||
captureWidth: 430,
|
||||
maxCaptureWidth: 430
|
||||
},
|
||||
{
|
||||
id: 'mobile-dashboard',
|
||||
order: 3,
|
||||
platform: 'mobile',
|
||||
label: 'Mobile 03',
|
||||
name: 'AI Command Center',
|
||||
tagline: 'KPI、热度、排行与问答构成的群聊数据驾驶舱',
|
||||
fileLabel: '手机数据驾驶舱',
|
||||
cssClass: 'template-mobile-dashboard',
|
||||
resourceFile: SHARED_RESOURCE,
|
||||
captureWidth: 430,
|
||||
maxCaptureWidth: 430
|
||||
},
|
||||
{
|
||||
id: 'desktop-workspace',
|
||||
order: 4,
|
||||
platform: 'desktop',
|
||||
label: 'Desktop 01',
|
||||
name: '三栏 AI 工作台',
|
||||
tagline: '概览、核心讨论、成员与问答同时可见',
|
||||
fileLabel: '桌面三栏工作台',
|
||||
cssClass: 'template-desktop-workspace',
|
||||
resourceFile: SHARED_RESOURCE,
|
||||
captureWidth: 1440,
|
||||
maxCaptureWidth: 1920
|
||||
},
|
||||
{
|
||||
id: 'desktop-editorial',
|
||||
order: 5,
|
||||
platform: 'desktop',
|
||||
label: 'Desktop 02',
|
||||
name: 'Editorial 科技日报',
|
||||
tagline: '头条、专栏、引语与新闻式分隔构成的编辑版面',
|
||||
fileLabel: '桌面Editorial',
|
||||
cssClass: 'template-desktop-editorial',
|
||||
resourceFile: SHARED_RESOURCE,
|
||||
captureWidth: 1440,
|
||||
maxCaptureWidth: 1920
|
||||
}
|
||||
]
|
||||
|
||||
export const SELECTABLE_REPORT_TEMPLATES: readonly ReportTemplateDefinition[] = [
|
||||
DEFAULT_REPORT_TEMPLATE,
|
||||
...REPORT_TEMPLATES
|
||||
]
|
||||
|
||||
export const isReportTemplateId = (value: unknown): value is ReportTemplateId =>
|
||||
REPORT_TEMPLATES.some((template) => template.id === value)
|
||||
|
||||
export const isSelectableReportTemplateId = (
|
||||
value: unknown
|
||||
): value is SelectableReportTemplateId =>
|
||||
SELECTABLE_REPORT_TEMPLATES.some((template) => template.id === value)
|
||||
|
||||
export const getReportTemplate = (value?: string): ReportTemplateDefinition =>
|
||||
SELECTABLE_REPORT_TEMPLATES.find((template) => template.id === value) || DEFAULT_REPORT_TEMPLATE
|
||||
Reference in new issue
Block a user