v0.3.34: 每日汇报增加推送通道选择UI
This commit is contained in:
@@ -346,9 +346,10 @@ export async function getAllNotifierProviders(): Promise<Record<string, { name:
|
||||
|
||||
export async function testNotifyChannel(
|
||||
channelType: string,
|
||||
configId?: number
|
||||
configId?: number,
|
||||
params?: Record<string, any>
|
||||
): Promise<{ success: boolean; message: string }> {
|
||||
const { data } = await api.post('/admin/notify/test', { channelType, configId })
|
||||
const { data } = await api.post('/admin/notify/test', { channelType, configId, params })
|
||||
return data
|
||||
}
|
||||
|
||||
|
||||
@@ -522,22 +522,50 @@
|
||||
</div>
|
||||
</div>
|
||||
<el-divider content-position="left">全局事件开关</el-divider>
|
||||
<div style="display:flex; flex-direction:column; gap:6px;">
|
||||
<div style="display:flex; align-items:center; gap:8px;">
|
||||
<el-switch v-model="globalNotifyForm.events.on_save_success" active-text="转存成功" />
|
||||
<el-button size="small" text type="primary" @click="openTemplateEditor('on_save_success')">✏️ 编辑模板</el-button>
|
||||
<div style="display:grid; grid-template-columns:repeat(2,1fr); gap:10px;">
|
||||
<div class="event-card" :class="{ active: globalNotifyForm.events.on_save_success }" style="padding:10px 14px; border-radius:8px; border:1px solid var(--el-border-color-light); transition:all .2s;">
|
||||
<div style="display:flex; align-items:center; justify-content:space-between;">
|
||||
<span style="display:flex; align-items:center; gap:6px; font-size:14px; font-weight:500;">
|
||||
<span>✅</span> 转存成功
|
||||
</span>
|
||||
<el-switch v-model="globalNotifyForm.events.on_save_success" size="small" />
|
||||
</div>
|
||||
<div style="margin-top:4px;">
|
||||
<el-button size="small" text type="primary" @click="openTemplateEditor('on_save_success')">✏️ 编辑模板</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex; align-items:center; gap:8px;">
|
||||
<el-switch v-model="globalNotifyForm.events.on_save_fail" active-text="转存失败" />
|
||||
<el-button size="small" text type="primary" @click="openTemplateEditor('on_save_fail')">✏️ 编辑模板</el-button>
|
||||
<div class="event-card" :class="{ active: globalNotifyForm.events.on_save_fail }" style="padding:10px 14px; border-radius:8px; border:1px solid var(--el-border-color-light); transition:all .2s;">
|
||||
<div style="display:flex; align-items:center; justify-content:space-between;">
|
||||
<span style="display:flex; align-items:center; gap:6px; font-size:14px; font-weight:500;">
|
||||
<span>⚠️</span> 转存失败
|
||||
</span>
|
||||
<el-switch v-model="globalNotifyForm.events.on_save_fail" size="small" />
|
||||
</div>
|
||||
<div style="margin-top:4px;">
|
||||
<el-button size="small" text type="primary" @click="openTemplateEditor('on_save_fail')">✏️ 编辑模板</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex; align-items:center; gap:8px;">
|
||||
<el-switch v-model="globalNotifyForm.events.on_cookie_expire" active-text="Cookie过期" />
|
||||
<el-button size="small" text type="primary" @click="openTemplateEditor('on_cookie_expire')">✏️ 编辑模板</el-button>
|
||||
<div class="event-card" :class="{ active: globalNotifyForm.events.on_cookie_expire }" style="padding:10px 14px; border-radius:8px; border:1px solid var(--el-border-color-light); transition:all .2s;">
|
||||
<div style="display:flex; align-items:center; justify-content:space-between;">
|
||||
<span style="display:flex; align-items:center; gap:6px; font-size:14px; font-weight:500;">
|
||||
<span>🍪</span> Cookie过期
|
||||
</span>
|
||||
<el-switch v-model="globalNotifyForm.events.on_cookie_expire" size="small" />
|
||||
</div>
|
||||
<div style="margin-top:4px;">
|
||||
<el-button size="small" text type="primary" @click="openTemplateEditor('on_cookie_expire')">✏️ 编辑模板</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex; align-items:center; gap:8px;">
|
||||
<el-switch v-model="globalNotifyForm.events.on_cleanup" active-text="清理完成" />
|
||||
<el-button size="small" text type="primary" @click="openTemplateEditor('on_cleanup')">✏️ 编辑模板</el-button>
|
||||
<div class="event-card" :class="{ active: globalNotifyForm.events.on_cleanup }" style="padding:10px 14px; border-radius:8px; border:1px solid var(--el-border-color-light); transition:all .2s;">
|
||||
<div style="display:flex; align-items:center; justify-content:space-between;">
|
||||
<span style="display:flex; align-items:center; gap:6px; font-size:14px; font-weight:500;">
|
||||
<span>🧹</span> 清理完成
|
||||
</span>
|
||||
<el-switch v-model="globalNotifyForm.events.on_cleanup" size="small" />
|
||||
</div>
|
||||
<div style="margin-top:4px;">
|
||||
<el-button size="small" text type="primary" @click="openTemplateEditor('on_cleanup')">✏️ 编辑模板</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-tip" style="margin-top:8px;">全局推送作为兜底通道。设置了推送用户的网盘配置走用户推送,未设置的走全局推送。</div>
|
||||
@@ -683,6 +711,12 @@
|
||||
<el-switch v-model="dailyReportForm.includeUsers" active-text="用户数" :disabled="!dailyReportForm.enabled" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="推送通道">
|
||||
<el-select v-model="dailyReportForm.channels" multiple placeholder="留空=全部全局通道" :disabled="!dailyReportForm.enabled" style="width:100%;max-width:480px">
|
||||
<el-option v-for="(np, nk) in notifyProviders" :key="nk" :label="np.label" :value="nk" />
|
||||
</el-select>
|
||||
<div class="form-tip">留空则发送至全部已启用的全局通道</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="上次发送">
|
||||
<span>{{ dailyReportLastRun || '从未发送' }}</span>
|
||||
</el-form-item>
|
||||
@@ -812,6 +846,7 @@ const dailyReportForm = reactive({
|
||||
includeSaves: true,
|
||||
includeStorage: true,
|
||||
includeUsers: true,
|
||||
channels: [] as string[],
|
||||
})
|
||||
const dailyReportPreviewing = ref(false)
|
||||
const dailyReportSending = ref(false)
|
||||
@@ -1187,7 +1222,12 @@ async function testGlobalChannel(channelName: string) {
|
||||
if (!ch || !ch._enabled) return
|
||||
ch._testing = true
|
||||
try {
|
||||
const result = await testNotifyChannel(channelName)
|
||||
// 过滤掉前端标记字段,只传实际参数
|
||||
const params: Record<string, any> = {}
|
||||
for (const [k, v] of Object.entries(ch)) {
|
||||
if (!k.startsWith('_')) params[k] = v
|
||||
}
|
||||
const result = await testNotifyChannel(channelName, undefined, params)
|
||||
if (result.success) {
|
||||
ElMessage.success(result.message)
|
||||
} else {
|
||||
@@ -1993,5 +2033,14 @@ async function handleRemoveLogo() {
|
||||
.dot-ok { background: #67c23a; }
|
||||
.dot-err { background: #f56c6c; }
|
||||
|
||||
/* 事件开关卡片高亮 */
|
||||
.event-card.active {
|
||||
border-color: var(--el-color-primary) !important;
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
.event-card {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user