未初始化设置时 recipients 为 null,前端严格解析判为无效,导致周报页显示“响应无效”。 后端统一返回空数组,前端同时兼容历史的 null。
This commit is contained in:
@@ -43,7 +43,8 @@ const num = (v: unknown): number => (typeof v === 'number' && Number.isSafeInteg
|
||||
|
||||
export function parseWeeklyMailSettings(value: unknown): WeeklyMailSettings {
|
||||
const v = obj(value)
|
||||
if (!Array.isArray(v.recipients) || v.recipients.some((item) => typeof item !== 'string')) return bad()
|
||||
const recipients = v.recipients === null ? [] : v.recipients
|
||||
if (!Array.isArray(recipients) || recipients.some((item) => typeof item !== 'string')) return bad()
|
||||
if (typeof v.enabled !== 'boolean' || typeof v.has_password !== 'boolean') return bad()
|
||||
const weekday = num(v.weekday),
|
||||
hour = num(v.hour),
|
||||
@@ -54,7 +55,7 @@ export function parseWeeklyMailSettings(value: unknown): WeeklyMailSettings {
|
||||
port,
|
||||
username: str(v.username),
|
||||
from: str(v.from),
|
||||
recipients: v.recipients as string[],
|
||||
recipients: recipients as string[],
|
||||
weekday,
|
||||
hour,
|
||||
enabled: v.enabled,
|
||||
|
||||
Reference in New Issue
Block a user