feat: 支持选择推送通道类型
This commit is contained in:
+14
-1
@@ -183,7 +183,20 @@
|
||||
<aside class="channel-list-panel" aria-label="推送渠道列表">
|
||||
<div class="panel-header panel-header--light">
|
||||
<span>channels</span>
|
||||
<button class="button button--secondary button--compact" id="pushAddButton" type="button">新增</button>
|
||||
<div class="channel-add">
|
||||
<select class="text-input select-input channel-add__select" id="pushAddTypeSelect" aria-label="新增推送类型">
|
||||
<option value="dingtalk">钉钉机器人</option>
|
||||
<option value="feishu">飞书机器人</option>
|
||||
<option value="telegram">Telegram Bot</option>
|
||||
<option value="pushplus">PushPlus</option>
|
||||
<option value="serverchan">Server酱</option>
|
||||
<option value="post_json">POST JSON</option>
|
||||
<option value="bark">Bark</option>
|
||||
<option value="get">GET</option>
|
||||
<option value="custom">自定义 POST</option>
|
||||
</select>
|
||||
<button class="button button--secondary button--compact" id="pushAddButton" type="button">新增</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="channel-list" id="pushChannelList"></div>
|
||||
</aside>
|
||||
|
||||
@@ -731,6 +731,27 @@ body.modal-open {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.channel-list-panel .panel-header {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
align-items: start;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.channel-add {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.channel-add__select {
|
||||
min-height: 32px;
|
||||
min-width: 0;
|
||||
padding: 6px 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.channel-list {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
|
||||
+11
-3
@@ -9,6 +9,7 @@ const elements = {
|
||||
pushSettingsButton: document.querySelector('#pushSettingsButton'),
|
||||
pushModal: document.querySelector('#pushModal'),
|
||||
pushModalClose: document.querySelector('#pushModalClose'),
|
||||
pushAddTypeSelect: document.querySelector('#pushAddTypeSelect'),
|
||||
pushAddButton: document.querySelector('#pushAddButton'),
|
||||
pushDeleteButton: document.querySelector('#pushDeleteButton'),
|
||||
pushSaveButton: document.querySelector('#pushSaveButton'),
|
||||
@@ -452,7 +453,8 @@ function selectPushChannel(index) {
|
||||
|
||||
function addPushChannel() {
|
||||
syncCurrentPushChannel();
|
||||
state.pushChannels.push(createDefaultPushChannel());
|
||||
const type = elements.pushAddTypeSelect?.value || 'dingtalk';
|
||||
state.pushChannels.push(createDefaultPushChannel(type));
|
||||
state.selectedPushChannel = state.pushChannels.length - 1;
|
||||
renderPushSettings();
|
||||
setPushStatus('');
|
||||
@@ -565,15 +567,21 @@ async function testPushChannel() {
|
||||
|
||||
function handlePushTypeChange() {
|
||||
const controls = getPushControls();
|
||||
const channel = state.pushChannels[state.selectedPushChannel];
|
||||
const previousType = channel?.type || 'dingtalk';
|
||||
const previousDefaultName = createDefaultPushChannel(previousType).name;
|
||||
const type = controls.type.value;
|
||||
const nextDefaultName = createDefaultPushChannel(type).name;
|
||||
const currentName = controls.name.value.trim();
|
||||
|
||||
updatePushFieldVisibility(type);
|
||||
if (!controls.name.value.trim()) {
|
||||
controls.name.value = `${getPushTypeLabel(type)}通知`;
|
||||
if (!currentName || currentName === previousDefaultName) {
|
||||
controls.name.value = nextDefaultName;
|
||||
}
|
||||
if (type === 'custom' && !controls.customBody.value.trim()) {
|
||||
controls.customBody.value = createDefaultPushChannel('custom').customBody;
|
||||
}
|
||||
syncCurrentPushChannel();
|
||||
}
|
||||
|
||||
async function refreshLogs() {
|
||||
|
||||
Reference in New Issue
Block a user