diff --git a/src/api/api-models.ts b/src/api/api-models.ts index 1289d71..21a0e4d 100644 --- a/src/api/api-models.ts +++ b/src/api/api-models.ts @@ -358,7 +358,7 @@ export interface QAInfo { sender: UserBasicInfo target: UserBasicInfo question: { message: string; image?: string } - answer?: { message: string; image?: string } + answer?: { message: string; image?: string, createdAt: number } isReaded?: boolean isSenderRegisted: boolean isPublic: boolean diff --git a/src/components/QuestionItem.vue b/src/components/QuestionItem.vue index bdf0086..6a1d9b2 100644 --- a/src/components/QuestionItem.vue +++ b/src/components/QuestionItem.vue @@ -11,6 +11,21 @@ const useQA = useQuestionBox() const isViolation = props.item.reviewResult?.isApproved == false const showContent = ref(!isViolation) + +// 计算得分颜色的函数 +function getScoreColor(score: number | undefined): string { + if (score === undefined) { + return 'grey'; // 如果没有分数,返回灰色 + } + // 将分数限制在 0 到 100 之间 + const clampedScore = Math.max(0, Math.min(100, score)); + // 插值计算色相: 0 (红色) for score 0, 120 (绿色) for score 100 + const hue = 120 * (clampedScore / 100); // 反转插值逻辑 + // 固定饱和度和亮度 (可根据需要调整) + const saturation = 50; + const lightness = 45; // 稍暗以提高与白色文本的对比度 + return `hsl(${hue}, ${saturation}%, ${lightness}%)`; +} - - - - {{ item.question?.message }} - - + + {{ item.question?.message }}