Store notification delivery settings in database

This commit is contained in:
biss committed 2026-11-21 19:45:06 +08:00
1 parent ce8e7021a9
commit 0231c468a4
14 files changed
+13255 -13

No files matched your search

+22 -1
View File
@@ -7,12 +7,24 @@ import { refreshBranding } from '../config/branding'
const form = reactive({ brandName: '', institutionName: '', productName: '', shortName: '', tagline: '', description: '', issuingOffice: '', documentNumberPrefix: '', gradeAppealWindowDays: 14 })
const loading = ref(false)
const saving = ref(false)
const notification = reactive({ emailEnabled: false, emailFromAddress: '', emailFromName: '', maxAttempts: 5 })
const savingNotification = ref(false)
async function load() {
loading.value = true
try { const { data } = await http.get('/business-settings'); Object.assign(form, data) }
try {
const [businessResponse, notificationResponse] = await Promise.all([http.get('/business-settings'), http.get('/notification-settings')])
Object.assign(form, businessResponse.data)
Object.assign(notification, notificationResponse.data)
}
catch (error) { ElMessage.error(apiErrorMessage(error)) }
finally { loading.value = false }
}
async function saveNotification() {
savingNotification.value = true
try { await http.put('/notification-settings', notification); ElMessage.success('通知设置已保存') }
catch (error) { ElMessage.error(apiErrorMessage(error)) }
finally { savingNotification.value = false }
}
async function save() {
saving.value = true
try { await http.put('/business-settings', form); ElMessage.success('设置已保存'); void refreshBranding().catch(() => {}) }
@@ -41,6 +53,15 @@ onMounted(load)
<el-form-item label="证明编号前缀"><el-input v-model="form.documentNumberPrefix" maxlength="32" /></el-form-item>
<el-button type="primary" native-type="submit" :loading="saving">保存设置</el-button>
</el-form>
<el-form label-position="top" @submit.prevent="saveNotification">
<h2>邮件通知</h2>
<p>SMTP 服务器和凭据由部署环境配置。关闭后,已排队的邮件暂停投递;关闭期间生成的通知不会补发邮件。修改通常在下一次投递扫描时生效。</p>
<el-form-item label="启用邮件投递"><el-switch v-model="notification.emailEnabled" /></el-form-item>
<el-form-item label="发件地址"><el-input v-model="notification.emailFromAddress" maxlength="320" /></el-form-item>
<el-form-item label="发件人名称"><el-input v-model="notification.emailFromName" maxlength="100" /></el-form-item>
<el-form-item label="最大投递尝试次数(邮件与 Web Push)"><el-input-number v-model="notification.maxAttempts" :min="1" :max="20" /></el-form-item>
<el-button type="primary" native-type="submit" :loading="savingNotification">保存通知设置</el-button>
</el-form>
</section>
</template>