Browse Source

feat(profile): add comment notification preference toggle

Expose commentNotifyEnabled in profile page state, load it from /api/config/me with true fallback, and persist updates when saving profile settings.

Made-with: Cursor
main
npmrun 3 weeks ago
parent
commit
80bea6b985
  1. 18
      app/pages/me/profile/index.vue

18
app/pages/me/profile/index.vue

@ -39,6 +39,7 @@ const state = reactive({
linksJson: '[]',
publicHomeHeaderTitle: '',
publicHomeHeaderIconUrl: '',
commentNotifyEnabled: true,
})
const loading = ref(true)
@ -195,6 +196,8 @@ async function load() {
state.publicHomeHeaderTitle = typeof cfg.publicHomeHeaderTitle === 'string' ? cfg.publicHomeHeaderTitle : ''
state.publicHomeHeaderIconUrl =
typeof cfg.publicHomeHeaderIconUrl === 'string' ? cfg.publicHomeHeaderIconUrl : ''
state.commentNotifyEnabled =
typeof cfg.commentNotifyEnabled === 'boolean' ? cfg.commentNotifyEnabled : true
} finally {
loading.value = false
}
@ -239,6 +242,11 @@ async function save() {
notify: false,
body: { key: 'publicHomeHeaderIconUrl', value: state.publicHomeHeaderIconUrl },
}),
fetchData('/api/config/me', {
method: 'PUT',
notify: false,
body: { key: 'commentNotifyEnabled', value: state.commentNotifyEnabled },
}),
])
toast.add({ title: '资料已保存', color: 'success' })
try {
@ -305,6 +313,16 @@ async function save() {
label="在发现卡片上显示上述地址"
/>
</div>
<div class="space-y-2 rounded-lg border border-default bg-elevated/20 p-4">
<h2 class="text-sm font-semibold text-highlighted">
通知偏好
</h2>
<UCheckbox
v-model="state.commentNotifyEnabled"
label="收到新评论时发送邮件通知"
description="关闭后将不再接收评论相关邮件提醒。"
/>
</div>
<UFormField label="昵称" name="nickname">
<UInput v-model="state.nickname" />
</UFormField>

Loading…
Cancel
Save