hookehuyr

fix(CheckinDetailPage): 修复附件类型映射处理逻辑

处理附件类型数据时增加类型检查,支持数组和对象两种格式
添加类型映射转换,将英文类型转换为中文显示
...@@ -316,11 +316,28 @@ const getTaskDetail = async (month) => { ...@@ -316,11 +316,28 @@ const getTaskDetail = async (month) => {
316 taskDetail.value = data 316 taskDetail.value = data
317 317
318 // 获取作品类型数据 318 // 获取作品类型数据
319 - if (data.attachment_type.length) { 319 + if (data.attachment_type && data.attachment_type.length) {
320 + // 创建类型映射
321 + const typeMap = {
322 + 'text': '文本',
323 + 'image': '图片',
324 + 'audio': '音频',
325 + 'video': '视频'
326 + }
327 +
328 + // 如果是数组格式,转换为对象格式
329 + if (Array.isArray(data.attachment_type)) {
330 + attachmentTypeOptions.value = data.attachment_type.map(key => ({
331 + key,
332 + value: typeMap[key] || key
333 + }))
334 + } else {
335 + // 如果是对象格式,直接使用
320 attachmentTypeOptions.value = Object.entries(data.attachment_type).map(([key, value]) => ({ 336 attachmentTypeOptions.value = Object.entries(data.attachment_type).map(([key, value]) => ({
321 key, 337 key,
322 value 338 value
323 })) 339 }))
340 + }
324 } else { 341 } else {
325 // 显示4种类型 342 // 显示4种类型
326 attachmentTypeOptions.value = [ 343 attachmentTypeOptions.value = [
......