feat: localize notifications and student check-in

This commit is contained in:
biss committed 2026-11-01 20:48:57 +08:00
1 parent a3b4fc86ee
commit cbcd41182c
5 files changed
+130 -128

No files matched your search

+95 -95
View File
@@ -76,15 +76,15 @@ const recipientFilters = reactive({
keyword: '',
})
const categories: Record<string, { label: string; className: string }> = {
General: { label: '一般通知', className: 'general' },
Approval: { label: '审核待办', className: 'approval' },
Schedule: { label: '课程变动', className: 'schedule' },
Grade: { label: '成绩通知', className: 'grade' },
Attendance: { label: '考勤消息', className: 'attendance' },
CourseSelection: { label: '选课消息', className: 'selection' },
Warning: { label: '学业预警', className: 'warning' },
}
const categories = computed<Record<string, { label: string; className: string }>>(() => ({
General: { label: t('notificationBatch.k0'), className: 'general' },
Approval: { label: t('notificationBatch.k1'), className: 'approval' },
Schedule: { label: t('notificationBatch.k2'), className: 'schedule' },
Grade: { label: t('notificationBatch.k3'), className: 'grade' },
Attendance: { label: t('notificationBatch.k4'), className: 'attendance' },
CourseSelection: { label: t('notificationBatch.k5'), className: 'selection' },
Warning: { label: t('notificationBatch.k6'), className: 'warning' },
}))
const selectedTask = computed(() =>
composer.value?.teachingTasks?.find(
@@ -102,15 +102,15 @@ const audienceName = computed(() => {
if (composer.value?.audienceType === 'TeachingTask') {
return selectedTask.value
? `${selectedTask.value.taskNumber} · ${selectedTask.value.courseName}`
: '请选择教学班'
: t('notificationBatch.k7')
}
if (recipientMode.value === 'Filtered') return '当前筛选结果'
if (recipientMode.value === 'Filtered') return t('notificationBatch.k8')
if (recipientMode.value === 'Selected') {
return selectedRecipients.value.length
? `指定的 ${selectedRecipients.value.length} 名收件人`
: '尚未选择收件人'
? t('notificationBatch.k71', { count: selectedRecipients.value.length })
: t('notificationBatch.k9')
}
return composer.value?.audienceName ?? '正在读取发信范围'
return composer.value?.audienceName ?? t('notificationBatch.k10')
})
const visibleClasses = computed(() =>
(composer.value?.administrativeClasses ?? []).filter(
@@ -129,11 +129,11 @@ const editorTextLength = computed(() => {
})
function categoryLabel(value: string) {
return categories[value]?.label ?? '系统消息'
return categories.value[value]?.label ?? t('notificationBatch.k11')
}
function categoryClass(value: string) {
return categories[value]?.className ?? 'general'
return categories.value[value]?.className ?? 'general'
}
async function load(reset = false) {
@@ -300,7 +300,7 @@ function toggleRecipient(recipient: any) {
}
const maximum = composer.value?.maximumSelectedRecipients ?? 500
if (selectedRecipients.value.length >= maximum) {
ElMessage.warning(`单次最多指定 ${maximum} 名收件人`)
ElMessage.warning(t('notificationBatch.k72', { count: maximum }))
return
}
selectedRecipients.value = [...selectedRecipients.value, recipient]
@@ -346,7 +346,7 @@ async function markAllRead() {
notification.isRead = true
})
unreadCount.value = 0
ElMessage.success('全部消息已标为已读')
ElMessage.success(t('notificationBatch.k12'))
} catch (error) {
ElMessage.error(apiErrorMessage(error))
} finally {
@@ -356,31 +356,31 @@ async function markAllRead() {
async function sendMessage() {
if (!messageForm.title.trim()) {
ElMessage.warning('请填写消息标题')
ElMessage.warning(t('notificationBatch.k13'))
return
}
if (!editorTextLength.value) {
ElMessage.warning('请填写消息正文')
ElMessage.warning(t('notificationBatch.k14'))
return
}
if (composer.value?.audienceType === 'TeachingTask' &&
!messageForm.teachingTaskId) {
ElMessage.warning('请选择接收消息的教学班')
ElMessage.warning(t('notificationBatch.k15'))
return
}
if (!recipientCount.value) {
ElMessage.warning('当前范围内没有可接收消息的账号')
ElMessage.warning(t('notificationBatch.k16'))
return
}
try {
await ElMessageBox.confirm(
`消息将发送给“${audienceName.value}”的 ${recipientCount.value} 个账号,发送后不可撤回。`,
'确认发送消息',
t('notificationBatch.k73', { audience: audienceName.value, count: recipientCount.value }),
t('notificationBatch.k17'),
{
type: 'warning',
confirmButtonText: '确认发送',
cancelButtonText: '继续编辑',
confirmButtonText: t('notificationBatch.k18'),
cancelButtonText: t('notificationBatch.k19'),
},
)
sending.value = true
@@ -405,7 +405,7 @@ async function sendMessage() {
? selectedRecipients.value.map(item => item.id)
: [],
})
ElMessage.success(`已发送给 ${data.recipientCount} 个账号`)
ElMessage.success(t('notificationBatch.k74', { count: data.recipientCount }))
messageForm.title = ''
messageForm.content = ''
selectedRecipients.value = []
@@ -426,13 +426,13 @@ onMounted(() => load())
<div class="page-stack message-center">
<section class="page-intro message-intro">
<div>
<span class="section-kicker">消息中心</span>
<h2>消息中心</h2>
<p>系统通知、审核待办、课程变动与成绩消息统一汇总,重要信息不再散落在业务页面。</p>
<span class="section-kicker">{{ t('notificationBatch.k20') }}</span>
<h2>{{ t('notificationBatch.k20') }}</h2>
<p>{{ t('notificationBatch.k21') }}</p>
</div>
<div class="intro-actions">
<div class="unread-summary" :class="{ quiet: !unreadCount }">
<span>未读消息</span>
<span>{{ t('notificationBatch.k22') }}</span>
<b>{{ unreadCount }}</b>
</div>
<el-button
@@ -441,31 +441,31 @@ onMounted(() => load())
:icon="EditPen"
@click="changeTab('compose')"
>
发消息
{{ t('notificationBatch.k23') }}
</el-button>
<el-button
:icon="Check"
:loading="markingAllRead"
:disabled="!unreadCount"
:title="unreadCount ? '将全部未读消息标为已读' : '当前没有未读消息'"
:title="unreadCount ? t('notificationBatch.k24') : t('notificationBatch.k25')"
@click="markAllRead"
>
全部已读
{{ t('notificationBatch.k26') }}
</el-button>
<el-button v-if="activeTab !== 'settings'" :icon="Refresh" @click="activeTab === 'sent' ? loadSent() : load()">
刷新
{{ t('notificationBatch.k27') }}
</el-button>
</div>
</section>
<section class="center-switcher" aria-label="消息中心功能">
<section class="center-switcher" :aria-label="t('notificationBatch.k28')">
<button
type="button"
:class="{ active: activeTab === 'inbox' }"
@click="changeTab('inbox')"
>
<el-icon><Bell /></el-icon>
收件箱
{{ t('notificationBatch.k29') }}
<span v-if="unreadCount">{{ unreadCount }}</span>
</button>
<button
@@ -475,7 +475,7 @@ onMounted(() => load())
@click="changeTab('compose')"
>
<el-icon><Promotion /></el-icon>
发消息
{{ t('notificationBatch.k23') }}
</button>
<button
v-if="canSend"
@@ -484,7 +484,7 @@ onMounted(() => load())
@click="changeTab('sent')"
>
<el-icon><Message /></el-icon>
已发送
{{ t('notificationBatch.k30') }}
</button>
<button
type="button"
@@ -492,7 +492,7 @@ onMounted(() => load())
@click="changeTab('settings')"
>
<el-icon><Setting /></el-icon>
通知设置
{{ t('notificationBatch.k31') }}
</button>
</section>
@@ -515,11 +515,11 @@ onMounted(() => load())
v-model="keyword"
clearable
:prefix-icon="Search"
placeholder="搜索标题或正文"
:placeholder="t('notificationBatch.k32')"
@keyup.enter="load(true)"
@clear="load(true)"
/>
<el-checkbox v-model="unreadOnly" @change="load(true)">仅看未读</el-checkbox>
<el-checkbox v-model="unreadOnly" @change="load(true)">{{ t('notificationBatch.k33') }}</el-checkbox>
</section>
<section v-loading="loading" class="message-list">
@@ -541,8 +541,8 @@ onMounted(() => load())
<header>
<div class="message-labels">
<span class="category-label">{{ categoryLabel(notification.category) }}</span>
<span v-if="notification.isManual" class="manual-label">人工发送</span>
<span v-if="!notification.isRead" class="unread-label">未读</span>
<span v-if="notification.isManual" class="manual-label">{{ t('notificationBatch.k34') }}</span>
<span v-if="!notification.isRead" class="unread-label">{{ t('notificationBatch.k35') }}</span>
</div>
<time>{{ new Date(notification.createdAt).toLocaleString(getDisplayLocale()) }}</time>
</header>
@@ -554,27 +554,27 @@ onMounted(() => load())
/>
</div>
<footer>
<span>来自 {{ notification.senderName }}</span>
<span>{{ t('notificationBatch.k75', { name: notification.senderName }) }}</span>
<span v-if="notification.audienceName">
接收范围:{{ notification.audienceName }}
{{ t('notificationBatch.k76', { audience: notification.audienceName }) }}
</span>
<span v-if="notification.linkUrl" class="open-link">查看详情 →</span>
<span v-if="notification.linkUrl" class="open-link">{{ t('notificationBatch.k36') }}</span>
</footer>
</div>
</article>
<el-empty
v-if="!loading && !notifications.length"
:description="unreadOnly ? '当前筛选范围内没有未读消息' : '当前筛选范围内没有消息'"
:description="unreadOnly ? t('notificationBatch.k37') : t('notificationBatch.k38')"
/>
</section>
<div v-if="inboxCursors.length || inboxHasMore" class="message-pager">
<el-button :disabled="!inboxCursors.length || loading" @click="previousInboxPage">
上一批
{{ t('notificationBatch.k39') }}
</el-button>
<span>第 {{ page }} 批</span>
<span>{{ t('notificationBatch.k77', { page: page }) }}</span>
<el-button type="primary" :disabled="!inboxHasMore || loading" @click="nextInboxPage">
下一批
{{ t('notificationBatch.k40') }}
</el-button>
</div>
</template>
@@ -586,14 +586,14 @@ onMounted(() => load())
>
<header class="compose-overview">
<div>
<span class="panel-kicker">发送范围</span>
<h3>编写并发送消息</h3>
<p>收件范围始终受当前账号的数据权限约束,发送后不可撤回。</p>
<span class="panel-kicker">{{ t('notificationBatch.k41') }}</span>
<h3>{{ t('notificationBatch.k42') }}</h3>
<p>{{ t('notificationBatch.k43') }}</p>
</div>
<div class="delivery-summary">
<span>{{ audienceName }}</span>
<b>{{ recipientCount }}</b>
<small>个接收账号</small>
<small>{{ t('notificationBatch.k44') }}</small>
</div>
</header>
@@ -604,7 +604,7 @@ onMounted(() => load())
<el-icon><User /></el-icon>
<span>01</span>
</div>
<h3>选择收件人</h3>
<h3>{{ t('notificationBatch.k45') }}</h3>
</div>
<template v-if="isAdministratorComposer">
@@ -612,9 +612,9 @@ onMounted(() => load())
:model-value="recipientMode"
class="recipient-mode"
:options="[
{ label: '权限范围群发', value: 'Scope' },
{ label: '按条件群发', value: 'Filtered' },
{ label: '指定收件人', value: 'Selected' },
{ label: t('notificationBatch.k46'), value: 'Scope' },
{ label: t('notificationBatch.k47'), value: 'Filtered' },
{ label: t('notificationBatch.k48'), value: 'Selected' },
]"
@change="changeRecipientMode"
/>
@@ -622,8 +622,8 @@ onMounted(() => load())
<div v-if="recipientMode !== 'Scope'" class="recipient-filter">
<div class="filter-heading">
<el-icon><Filter /></el-icon>
<span>筛选候选账号</span>
<small>共 {{ recipientTotal }} 个匹配账号</small>
<span>{{ t('notificationBatch.k49') }}</span>
<small>{{ t('notificationBatch.k78', { count: recipientTotal }) }}</small>
</div>
<div class="filter-grid">
<el-select
@@ -644,7 +644,7 @@ onMounted(() => load())
<el-select
v-model="recipientFilters.role"
clearable
placeholder="全部身份"
:placeholder="t('notificationBatch.k50')"
@change="loadRecipients(true)"
>
<el-option
@@ -665,14 +665,14 @@ onMounted(() => load())
v-for="item in visibleClasses"
:key="item.id"
:value="item.id"
:label="`${item.grade}级 · ${item.name}`"
:label="t('notificationBatch.k79', { year: item.grade, name: item.name })"
/>
</el-select>
<el-select
v-model="recipientFilters.teachingTaskId"
clearable
filterable
placeholder="全部教学班"
:placeholder="t('notificationBatch.k51')"
@change="loadRecipients(true)"
>
<el-option
@@ -686,12 +686,12 @@ onMounted(() => load())
v-model="recipientFilters.keyword"
clearable
:prefix-icon="Search"
placeholder="姓名、学号、工号或账号"
:placeholder="t('notificationBatch.k52')"
@keyup.enter="loadRecipients(true)"
@clear="loadRecipients(true)"
/>
<el-button :icon="Search" @click="loadRecipients(true)">
查询
{{ t('notificationBatch.k53') }}
</el-button>
</div>
</div>
@@ -699,7 +699,7 @@ onMounted(() => load())
<div v-if="recipientMode === 'Scope'" class="scope-notice">
<strong>{{ composer.audienceName }}</strong>
<span>
将覆盖当前权限范围内全部已启用账号;如无需群发,请切换到条件筛选或指定收件人。
{{ t('notificationBatch.k54') }}
</span>
</div>
@@ -731,20 +731,20 @@ onMounted(() => load())
</small>
</span>
<span class="recipient-meta">
{{ recipient.collegeName || '校级账号' }}
{{ recipient.collegeName || t('notificationBatch.k55') }}
</span>
<span v-if="recipientMode === 'Selected'" class="recipient-check">
{{ isRecipientSelected(recipient) ? '已选择' : '选择' }}
{{ isRecipientSelected(recipient) ? t('notificationBatch.k56') : t('notificationBatch.k57') }}
</span>
</button>
<el-empty
v-if="!recipientLoading && !recipientItems.length"
description="没有符合条件的可用账号"
:description="t('notificationBatch.k58')"
/>
</div>
<div v-if="recipientCursors.length || recipientHasMore" class="cursor-pager">
<el-button size="small" :disabled="!recipientCursors.length || recipientLoading" @click="previousRecipientPage">{{ t('businessLabels.previous') }}</el-button>
<span>第 {{ recipientPage }} 批</span>
<span>{{ t('notificationBatch.k77', { page: recipientPage }) }}</span>
<el-button size="small" type="primary" :disabled="!recipientHasMore || recipientLoading" @click="nextRecipientPage">{{ t('businessLabels.next') }}</el-button>
</div>
</div>
@@ -754,8 +754,8 @@ onMounted(() => load())
class="selected-recipient-strip"
>
<header>
<b>已选 {{ selectedRecipients.length }} 人</b>
<button type="button" @click="selectedRecipients = []">清空</button>
<b>{{ t('notificationBatch.k80', { count: selectedRecipients.length }) }}</b>
<button type="button" @click="selectedRecipients = []">{{ t('notificationBatch.k59') }}</button>
</header>
<div>
<span
@@ -765,14 +765,14 @@ onMounted(() => load())
{{ recipient.displayName }}
<button
type="button"
:aria-label="`移除 ${recipient.displayName}`"
:aria-label="t('notificationBatch.k81', { name: recipient.displayName })"
@click="removeSelectedRecipient(recipient.id)"
>
×
</button>
</span>
<small v-if="selectedRecipients.length > 12">
另有 {{ selectedRecipients.length - 12 }} 人
{{ t('notificationBatch.k82', { count: selectedRecipients.length - 12 }) }}
</small>
</div>
</div>
@@ -780,28 +780,28 @@ onMounted(() => load())
<el-form-item
v-else
label="接收教学班"
:label="t('notificationBatch.k60')"
required
>
<el-select
v-model="messageForm.teachingTaskId"
filterable
placeholder="选择本人任教的教学班"
:placeholder="t('notificationBatch.k61')"
>
<el-option
v-for="task in composer?.teachingTasks ?? []"
:key="task.id"
:value="task.id"
:label="`${task.taskNumber} · ${task.courseName}(${task.recipientCount} 人)`"
:label="`${task.taskNumber} · ${task.courseName} (${t('notificationBatch.k83', { count: task.recipientCount })})`"
>
<div class="task-option">
<span>{{ task.taskNumber }} · {{ task.courseName }}</span>
<small>{{ task.termName }} · {{ task.recipientCount }} 人</small>
<small>{{ task.termName }} · {{ t('notificationBatch.k83', { count: task.recipientCount }) }}</small>
</div>
</el-option>
</el-select>
<small class="field-help">
任课教师只能向本人所带教学班的有效学生账号发送消息。
{{ t('notificationBatch.k62') }}
</small>
</el-form-item>
</section>
@@ -812,40 +812,40 @@ onMounted(() => load())
<el-icon><EditPen /></el-icon>
<span>02</span>
</div>
<h3>编辑消息内容</h3>
<h3>{{ t('notificationBatch.k63') }}</h3>
</div>
<div class="compose-heading">
<div>
<span>普通通知</span>
<small>成绩、选课等业务通知仍由对应流程自动发送</small>
<span>{{ t('notificationBatch.k64') }}</span>
<small>{{ t('notificationBatch.k65') }}</small>
</div>
</div>
<el-form-item label="消息标题" required>
<el-form-item :label="t('notificationBatch.k66')" required>
<el-input
v-model="messageForm.title"
maxlength="200"
show-word-limit
placeholder="用一句话说明需要关注的事项"
:placeholder="t('notificationBatch.k67')"
/>
</el-form-item>
<el-form-item label="消息正文" required class="editor-form-item">
<el-form-item :label="t('notificationBatch.k68')" required class="editor-form-item">
<NotificationRichTextEditor
v-model="messageForm.content"
/>
<div class="editor-footnote">
<span>支持表格、超链接和外链图片;图片请填写 HTTPS 地址,不上传本地文件。</span>
<span>{{ t('notificationBatch.k69') }}</span>
<b :class="{ warning: messageForm.content.length > 18000 }">
{{ editorTextLength }} 字 · 源码 {{ messageForm.content.length }}/20000
{{ t('notificationBatch.k84', { chars: editorTextLength, length: messageForm.content.length }) }}
</b>
</div>
</el-form-item>
<div class="compose-actions">
<span>
将发送给 <b>{{ recipientCount }}</b> 个账号
{{ t('notificationBatch.k85', { count: recipientCount }) }}
<small>{{ audienceName }}</small>
</span>
<el-button
@@ -854,7 +854,7 @@ onMounted(() => load())
:loading="sending"
@click="sendMessage"
>
确认发送
{{ t('notificationBatch.k18') }}
</el-button>
</div>
</el-form>
@@ -874,19 +874,19 @@ onMounted(() => load())
<RichMessageContent :content="item.content" rich />
<footer>
<span>{{ item.audienceName }}</span>
<b>{{ item.recipientCount }} 个接收账号</b>
<b>{{ t('notificationBatch.k86', { count: item.recipientCount }) }}</b>
</footer>
</article>
<el-empty v-if="!loading && !sentMessages.length" description="还没有发送记录" />
<el-empty v-if="!loading && !sentMessages.length" :description="t('notificationBatch.k70')" />
</section>
<div v-if="sentCursors.length || sentHasMore" class="message-pager">
<el-button :disabled="!sentCursors.length || loading" @click="previousSentPage">
上一批
{{ t('notificationBatch.k39') }}
</el-button>
<span>第 {{ sentPage }} 批</span>
<span>{{ t('notificationBatch.k77', { page: sentPage }) }}</span>
<el-button type="primary" :disabled="!sentHasMore || loading" @click="nextSentPage">
下一批
{{ t('notificationBatch.k40') }}
</el-button>
</div>
</template>