后端迁移会话凭证渲染模块
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import fs from 'node:fs/promises'
|
||||
|
||||
import { BAIDU_BEIJING_TIME_URL, type RedeemProofMode } from './session-proof-constants.js'
|
||||
|
||||
type RedeemResultFilePayload = {
|
||||
proofMode: RedeemProofMode
|
||||
sessionId?: string
|
||||
activityUrl: string
|
||||
code: string
|
||||
finalResult?: {
|
||||
role?: {
|
||||
area?: string
|
||||
}
|
||||
[key: string]: unknown
|
||||
} | null
|
||||
attempts?: unknown[]
|
||||
screenshotPath: string
|
||||
htmlPath?: string
|
||||
redeemPageScreenshotPath?: string
|
||||
beijingTimeScreenshotPath?: string
|
||||
beijingTimePageUrl?: string
|
||||
beijingTimeError?: string
|
||||
}
|
||||
|
||||
export async function writeRedeemResultFile(
|
||||
resultPath: string,
|
||||
{
|
||||
proofMode,
|
||||
sessionId,
|
||||
activityUrl,
|
||||
code,
|
||||
finalResult,
|
||||
attempts,
|
||||
screenshotPath,
|
||||
htmlPath = '',
|
||||
redeemPageScreenshotPath = '',
|
||||
beijingTimeScreenshotPath = '',
|
||||
beijingTimePageUrl = BAIDU_BEIJING_TIME_URL,
|
||||
beijingTimeError = '',
|
||||
}: RedeemResultFilePayload,
|
||||
): Promise<void> {
|
||||
await fs.writeFile(
|
||||
resultPath,
|
||||
JSON.stringify(
|
||||
{
|
||||
proofMode,
|
||||
sessionId,
|
||||
activityUrl,
|
||||
code,
|
||||
area: finalResult?.role?.area || '',
|
||||
final: finalResult,
|
||||
attempts,
|
||||
redeemPageScreenshotPath,
|
||||
beijingTimeScreenshotPath,
|
||||
beijingTimePageUrl,
|
||||
beijingTimeError,
|
||||
screenshotPath,
|
||||
htmlPath,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
'utf8',
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user