feat: 续费提醒告警(Telegram/邮件多渠道+续费检查+每日定时+前端控制)
This commit is contained in:
+37
-1
@@ -550,6 +550,18 @@ const SettingsView = {
|
||||
<button @click="save" class="text-sm px-4 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700">{{ settings.saved ? '已保存' : '保存' }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-800 p-4">
|
||||
<h3 class="font-semibold text-sm mb-2">通知与续费提醒</h3>
|
||||
<div class="text-xs text-slate-500 mb-3">已配置渠道:
|
||||
<span v-if="notifyChannels.length" class="text-emerald-600 dark:text-emerald-400">{{ notifyChannels.join('、') }}</span>
|
||||
<span v-else class="text-slate-400">未配置(在 .env 设置 TELEGRAM_*/SMTP_*)</span>
|
||||
</div>
|
||||
<div class="flex gap-2 flex-wrap">
|
||||
<button @click="testNotify" class="text-sm px-3 py-1.5 rounded-lg border border-slate-300 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-800">测试通知</button>
|
||||
<button @click="checkRenewals" class="text-sm px-3 py-1.5 rounded-lg bg-blue-600 text-white hover:bg-blue-700">检查续费并提醒</button>
|
||||
</div>
|
||||
<div v-if="notifyResult" class="mt-3 text-xs px-3 py-2 rounded-lg bg-slate-50 dark:bg-slate-800/50 whitespace-pre-wrap break-words">{{ notifyResult }}</div>
|
||||
</div>
|
||||
<div class="bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-800 p-4">
|
||||
<h3 class="font-semibold text-sm mb-2">外观</h3>
|
||||
<label class="flex items-center gap-2 text-sm">
|
||||
@@ -557,7 +569,31 @@ const SettingsView = {
|
||||
</label>
|
||||
</div>
|
||||
</div>`,
|
||||
setup() { return { store, settings, save: saveSettings, applyDark }; },
|
||||
setup() {
|
||||
const notifyChannels = ref([]);
|
||||
const notifyResult = ref('');
|
||||
onMounted(async () => {
|
||||
try { const r = await Api.get('/notify/channels'); notifyChannels.value = r.channels || []; } catch (e) { /* ignore */ }
|
||||
});
|
||||
async function testNotify() {
|
||||
notifyResult.value = '发送中…';
|
||||
try {
|
||||
const r = await Api.post('/notify/test', {});
|
||||
notifyResult.value = r.notifications.map(n => '[' + n.channel + '] ' + (n.ok ? '成功' : '失败:' + n.message)).join('\n');
|
||||
} catch (e) { notifyResult.value = '失败:' + e.message; }
|
||||
}
|
||||
async function checkRenewals() {
|
||||
notifyResult.value = '检查中…';
|
||||
try {
|
||||
const r = await Api.post('/notify/renewals?send=true', {});
|
||||
let text = '即将到期 ' + r.expiring_count + ' 项(阈值 ' + r.threshold_days + ' 天)';
|
||||
if (r.expiring.length) text += '\n' + r.expiring.map(i => '• ' + i.name + ' [' + i.provider + '] ' + i.days + ' 天后').join('\n');
|
||||
if (r.notifications && r.notifications.length) text += '\n\n通知:' + r.notifications.map(n => '[' + n.channel + '] ' + (n.ok ? '成功' : '失败:' + n.message)).join(',');
|
||||
notifyResult.value = text;
|
||||
} catch (e) { notifyResult.value = '失败:' + e.message; }
|
||||
}
|
||||
return { store, settings, save: saveSettings, applyDark, notifyChannels, notifyResult, testNotify, checkRenewals };
|
||||
},
|
||||
};
|
||||
|
||||
/* ================= 资产编辑模态框 ================= */
|
||||
|
||||
Reference in New Issue
Block a user