finish
All checks were successful
Deploy to Server / deploy (push) Successful in 19s

This commit is contained in:
jeremygan2021
2026-03-22 22:52:36 +08:00
parent 77b8376878
commit ec67bed6f4
2 changed files with 20 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
import { View, Text, Button, Image, Input, Textarea, Picker } from '@tarojs/components'
import Taro, { useLoad, useShareAppMessage, useShareTimeline, useRouter } from '@tarojs/taro'
import { useState } from 'react'
import { getProjectDetail, createProject, updateProject, uploadProjectFile, submitProject, uploadMedia, getCompetitions, deleteProjectFile } from '../../api'
import { getProjectDetail, createProject, updateProject, uploadProjectFile, submitProject, uploadMedia, getCompetitions, deleteProjectFile, getMyEnrollments } from '../../api'
import './project.scss'
export default function ProjectEdit() {
@@ -56,12 +56,21 @@ export default function ProjectEdit() {
const fetchCompetitions = async () => {
try {
const res = await getCompetitions()
if (res && res.results) {
setCompetitions(res.results)
const res = await getMyEnrollments()
if (res && res.length > 0) {
const approvedEnrollments = res.filter((enrollment: any) => enrollment.status === 'approved')
const competitions = approvedEnrollments.map((enrollment: any) => ({
id: enrollment.competition,
title: enrollment.competition_title || '',
status: enrollment.status
}))
setCompetitions(competitions)
} else {
setCompetitions([])
}
} catch (e) {
console.error('获取比赛列表失败', e)
setCompetitions([])
}
}
@@ -317,11 +326,11 @@ export default function ProjectEdit() {
style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '10px', background: '#f8f8f8', marginBottom: '8px', borderRadius: '4px' }}
onClick={() => handlePreviewFile(file)}
>
<Text className='file-name' style={{ flex: 1, fontSize: '14px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{file.name || '未知文件'}</Text>
<Text className='file-name' style={{ flex: 1, fontSize: '14px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', color: '#333' }}>{file.name || '未知文件'}</Text>
<Text className='delete' style={{ color: '#ff4d4f', marginLeft: '10px', fontSize: '14px' }} onClick={(e) => { e.stopPropagation(); handleDeleteFile(file.id) }}></Text>
</View>
))}
{(!project.files || project.files.length === 0) && <Text style={{ color: '#999', fontSize: '12px' }}> (PDF/PPT/)</Text>}
{(!project.files || project.files.length === 0) && <Text style={{ color: '#666', fontSize: '12px' }}> (PDF/PPT/)</Text>}
</View>
</View>