feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
import { assertPlainPayload } from './request-normalizers.js'
|
||||
|
||||
export const FEEDBACK_TYPE_OPTIONS = Object.freeze([
|
||||
Object.freeze({ value: 'bug', label: '功能问题' }),
|
||||
Object.freeze({ value: 'advice', label: '使用建议' }),
|
||||
Object.freeze({ value: 'complaint', label: '投诉反馈' }),
|
||||
Object.freeze({ value: 'other', label: '其他' })
|
||||
])
|
||||
|
||||
const feedbackTypes = new Set(FEEDBACK_TYPE_OPTIONS.map(({ value }) => value))
|
||||
|
||||
export const normalizeFeedbackPayload = (payload) => {
|
||||
const allowedFields = new Set(['feedbackType', 'feedbackContent', 'contactInfo'])
|
||||
assertPlainPayload(payload, allowedFields, '反馈请求')
|
||||
@@ -23,9 +14,6 @@ export const normalizeFeedbackPayload = (payload) => {
|
||||
}
|
||||
const normalizedText = payload[optionalField].trim()
|
||||
if (!normalizedText) continue
|
||||
if (optionalField === 'feedbackType' && !feedbackTypes.has(normalizedText)) {
|
||||
throw new TypeError('feedbackType 必须为 advice、bug、complaint 或 other')
|
||||
}
|
||||
normalizedPayload[optionalField] = normalizedText
|
||||
}
|
||||
return normalizedPayload
|
||||
|
||||
Reference in New Issue
Block a user