import TagInput from '../TagInput'; import BoardIconDisplay from '../BoardIconDisplay'; import { getBoardThemeIndex } from '../../utils/boardTheme'; import type { Board, ForumLimitsPublic } from '../../api/types'; export type PostType = 'normal' | 'question' | 'poll' | 'bounty' | 'lottery'; const SPECIAL_TYPE_LABELS: Record<'poll' | 'bounty' | 'lottery', string> = { poll: '投票', bounty: '悬赏', lottery: '抽奖', }; interface Props { isEdit: boolean; postType: PostType; onPostTypeChange: (type: PostType) => void; boards: Board[]; boardId: string; onBoardChange: (boardId: string) => void; tags: string; onTagsChange: (tags: string) => void; limits: ForumLimitsPublic; } /** * 发帖页发布设置模块:帖子类型、板块、标签三行配置。 * 受控组件,所有状态由父级持有。 */ export default function ComposeContextBar({ isEdit, postType, onPostTypeChange, boards, boardId, onBoardChange, tags, onTagsChange, limits, }: Props) { const isSpecialEdit = isEdit && (postType === 'poll' || postType === 'bounty' || postType === 'lottery'); return (
类型
{isSpecialEdit ? ( ) : ( <> {!isEdit && ( <> )} )}
{postType === 'question' && ( 问答可标记解决状态 )} {postType === 'poll' && ( {isEdit ? '投票选项发布后不可修改' : '发布后选项不可修改'} )} {postType === 'bounty' && ( 发布成功即扣除积分;有人回复后不可自行取消,需采纳或联系管理员 )} {postType === 'lottery' && ( 回帖参与,手动开奖 )}
板块
{boards.map(b => { const themeIdx = getBoardThemeIndex(b); const isActive = String(b.id) === boardId; return ( ); })}
标签 0 ? limits.post_tags_max : undefined} />
); }