fix: 完善个人中心卡片管理

This commit is contained in:
2026-08-03 16:49:31 +08:00
parent 8fb24f94ab
commit 3f8ff30bbc
8 changed files with 192 additions and 2 deletions

View File

@@ -36,6 +36,7 @@ const helpCardHistory = ref<TeacherHelpCard[]>([]);
const shareDraftHistory = ref<ShareDraft[]>([]);
const reportHistory = ref<PeriodicReport[]>([]);
const personalCenterLoading = ref(false);
const cardOperationPending = ref(false);
const finishingTopic = ref(false);
const generatingHelpCard = ref(false);
const generatingShareDraft = ref(false);
@@ -322,6 +323,62 @@ async function copyShareDraft() {
}
}
async function copyHistoryHelpCard(card: TeacherHelpCard) {
try {
await copyText(card.content);
const updated = await api.markHelpCardCopied(card.id);
helpCardHistory.value = helpCardHistory.value.map((item) => item.id === updated.id ? updated : item);
showToast("求助卡已复制,可再次粘贴给老师");
} catch (error) {
handleError(error, "复制失败,请稍后重试");
}
}
async function copyHistoryShareDraft(draft: ShareDraft) {
try {
await copyText(draft.content);
const updated = await api.markShareDraftCopied(draft.id);
shareDraftHistory.value = shareDraftHistory.value.map((item) => item.id === updated.id ? updated : item);
showToast("分享稿已复制,可再次粘贴到班级群");
} catch (error) {
handleError(error, "复制失败,请稍后重试");
}
}
async function deleteHistoryHelpCard(cardId: number, done: (success: boolean) => void) {
if (cardOperationPending.value) return;
cardOperationPending.value = true;
try {
await api.deleteHelpCard(cardId);
helpCardHistory.value = helpCardHistory.value.filter((item) => item.id !== cardId);
if (helpCard.value?.id === cardId) helpCard.value = null;
showToast("求助卡已删除");
done(true);
} catch (error) {
done(false);
handleError(error, "求助卡删除失败");
} finally {
cardOperationPending.value = false;
}
}
async function deleteHistoryShareDraft(draftId: number, done: (success: boolean) => void) {
if (cardOperationPending.value) return;
cardOperationPending.value = true;
try {
await api.deleteShareDraft(draftId);
shareDraftHistory.value = shareDraftHistory.value.filter((item) => item.id !== draftId);
if (shareDraft.value?.id === draftId) shareDraft.value = null;
showToast("分享稿已删除");
done(true);
} catch (error) {
done(false);
handleError(error, "分享稿删除失败");
} finally {
cardOperationPending.value = false;
}
}
async function openPersonalCenter(section: "overview" | "review" | "records" = "overview") {
personalCenterSection.value = section;
personalCenterOpen.value = true;
@@ -522,8 +579,13 @@ async function copyText(text: string) {
:reports="reportHistory"
:help-cards="helpCardHistory"
:share-drafts="shareDraftHistory"
:operation-pending="cardOperationPending"
@close="personalCenterOpen = false"
@logout="personalCenterOpen = false; logoutDialogOpen = true"
@copy-help-card="copyHistoryHelpCard"
@copy-share-draft="copyHistoryShareDraft"
@delete-help-card="deleteHistoryHelpCard"
@delete-share-draft="deleteHistoryShareDraft"
/>
<AppDialog v-if="helpCardDialogOpen" title="老师求助卡" labelled-by="help-card-title" @close="helpCardDialogOpen = false">