feat: 更新问答信息和问题管理组件

- 在 QAInfo 接口中为答案添加了创建时间字段。
- 在 QuestionItem 组件中增加了得分颜色计算函数,优化了得分显示逻辑。
- 更新了问题管理视图,增强了问题的筛选和显示功能,支持更灵活的用户交互。
- 改进了分享卡片的样式和功能,提升了用户体验。
- 增强了 OBS 组件的预览功能,提供了更直观的展示效果。
This commit is contained in:
2025-04-21 01:57:10 +08:00
parent aa2d63a33c
commit 89f9cad9a7
6 changed files with 1141 additions and 769 deletions

View File

@@ -23,7 +23,11 @@ export const useQuestionBox = defineStore('QuestionBox', () => {
const recieveQuestions = ref<QAInfo[]>([])
const sendQuestions = ref<QAInfo[]>([])
const trashQuestions = ref<QAInfo[]>([])
const trashQuestions = computed(() => {
return recieveQuestions.value.filter(
(q) => q.reviewResult && q.reviewResult.isApproved == false
)
})
const tags = ref<QATagInfo[]>([])
const reviewing = ref(0)
@@ -37,6 +41,7 @@ export const useQuestionBox = defineStore('QuestionBox', () => {
return false
}*/
return (
(!q.reviewResult || q.reviewResult.isApproved == true) &&
(q.isFavorite || !onlyFavorite.value) &&
(q.isPublic || !onlyPublic.value) &&
(!q.isReaded || !onlyUnread.value) &&
@@ -66,16 +71,9 @@ export const useQuestionBox = defineStore('QuestionBox', () => {
if (data.data.questions.length > 0) {
recieveQuestions.value = new List(data.data.questions)
.OrderBy((d) => d.isReaded)
//.ThenByDescending(d => d.isFavorite)
.Where(
(d) => !d.reviewResult || d.reviewResult.isApproved == true
) //只显示审核通过的
.ThenByDescending((d) => d.sendAt)
.ToArray()
reviewing.value = data.data.reviewCount
trashQuestions.value = data.data.questions.filter(
(d) => d.reviewResult && d.reviewResult.isApproved == false
)
const displayId =
accountInfo.value?.settings.questionDisplay.currentQuestion
@@ -378,6 +376,20 @@ export const useQuestionBox = defineStore('QuestionBox', () => {
message.error('拉黑失败: ' + err)
})
}
async function markAsNormal(question: QAInfo) {
await QueryGetAPI(QUESTION_API_URL + 'mark-as-normal', {
id: question.id
})
.then((data) => {
if (data.code == 200) {
message.success('已标记为正常')
question.reviewResult!.isApproved = true
}
})
.catch((err) => {
message.error('标记失败: ' + err)
})
}
async function setCurrentQuestion(item: QAInfo | undefined) {
const isCurrent = displayQuestion.value?.id == item?.id
if (!isCurrent) {
@@ -433,6 +445,7 @@ export const useQuestionBox = defineStore('QuestionBox', () => {
favorite,
setPublic,
blacklist,
markAsNormal,
setCurrentQuestion,
getViolationString
}

View File

@@ -224,7 +224,11 @@ export const useWebFetcher = defineStore('WebFetcher', () => {
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets
})
.withAutomaticReconnect([0, 2000, 10000, 30000]) // 自动重连策略
.withAutomaticReconnect({
nextRetryDelayInMilliseconds: retryContext => {
return retryContext.elapsedMilliseconds < 60 * 1000 ? 10 * 1000 : 30 * 1000;
}
}) // 自动重连策略
.withHubProtocol(new msgpack.MessagePackHubProtocol()) // 使用 MessagePack 协议
.build();
@@ -249,7 +253,7 @@ export const useWebFetcher = defineStore('WebFetcher', () => {
console.error(prefix.value + `与服务器连接关闭: ${error?.message || '未知原因'}. 自动重连将处理.`);
state.value = 'connecting'; // 标记为连接中,等待自动重连
signalRConnectionId.value = undefined;
// withAutomaticReconnect 会处理重连,这里不需要手动调用 reconnect
await connection.start();
} else if (disconnectedByServer) {
console.log(prefix.value + `连接已被服务器关闭.`);
//Stop(); // 服务器要求断开,则彻底停止
@@ -369,12 +373,6 @@ export const useWebFetcher = defineStore('WebFetcher', () => {
* 定期将队列中的事件发送到服务器
*/
async function sendEvents() {
if (updateCount % 60 == 0) {
// 每60秒更新一次连接信息
if (signalRClient.value) {
await sendSelfInfo(signalRClient.value);
}
}
updateCount++;
// 确保 SignalR 已连接
if (!signalRClient.value || signalRClient.value.state !== signalR.HubConnectionState.Connected) {
@@ -384,6 +382,12 @@ export const useWebFetcher = defineStore('WebFetcher', () => {
if (events.length === 0) {
return;
}
if (updateCount % 60 == 0) {
// 每60秒更新一次连接信息
if (signalRClient.value) {
await sendSelfInfo(signalRClient.value);
}
}
// 批量处理事件每次最多发送20条
const batchSize = 30;