@@ -67,10 +67,39 @@ const notificationTypes = [
6767 { value: ' 其它' , title: t (' notificationSwitch.other' ) },
6868]
6969
70+ function ensureWechatConfigDefaults(notification : NotificationConf ) {
71+ if (notification .type !== ' wechat' ) {
72+ return
73+ }
74+ if (! notification .config ) {
75+ notification .config = {}
76+ }
77+ if (! notification .config .WECHAT_MODE ) {
78+ notification .config .WECHAT_MODE = ' app'
79+ }
80+ if (! notification .config .WECHAT_BOT_WS_URL ) {
81+ notification .config .WECHAT_BOT_WS_URL = ' wss://openws.work.weixin.qq.com'
82+ }
83+ }
84+
85+ const isWechatBotMode = computed ({
86+ get : () => notificationInfo .value .config ?.WECHAT_MODE === ' bot' ,
87+ set : value => {
88+ if (! notificationInfo .value .config ) {
89+ notificationInfo .value .config = {}
90+ }
91+ notificationInfo .value .config .WECHAT_MODE = value ? ' bot' : ' app'
92+ if (value && ! notificationInfo .value .config .WECHAT_BOT_WS_URL ) {
93+ notificationInfo .value .config .WECHAT_BOT_WS_URL = ' wss://openws.work.weixin.qq.com'
94+ }
95+ },
96+ })
97+
7098// 打开详情弹窗
7199function openNotificationInfoDialog() {
72100 // 替换成深复制,避免修改时影响原数据
73101 notificationInfo .value = cloneDeep (props .notification )
102+ ensureWechatConfigDefaults (notificationInfo .value )
74103 notificationInfoDialog .value = true
75104}
76105
@@ -86,6 +115,7 @@ function saveNotificationInfo() {
86115 $toast .error (t (' notification.channel' ) + ` 【${notificationInfo .value .name }】 ` + t (' common.exists' ))
87116 return
88117 }
118+ ensureWechatConfigDefaults (notificationInfo .value )
89119 notificationInfoDialog .value = false
90120 emit (' change' , notificationInfo .value , props .notification .name )
91121 emit (' done' )
@@ -190,69 +220,129 @@ function onClose() {
190220 />
191221 </VCol >
192222 <VCol cols =" 12" md =" 6" >
193- <VTextField
194- v-model =" notificationInfo.config.WECHAT_CORPID"
195- :label =" t('notification.wechat.corpId')"
196- :hint =" t('notification.wechat.corpIdHint')"
197- persistent-hint
198- prepend-inner-icon =" mdi-domain"
199- />
200- </VCol >
201- <VCol cols =" 12" md =" 6" >
202- <VTextField
203- v-model =" notificationInfo.config.WECHAT_APP_ID"
204- :label =" t('notification.wechat.appId')"
205- :hint =" t('notification.wechat.appIdHint')"
206- persistent-hint
207- prepend-inner-icon =" mdi-application"
208- />
209- </VCol >
210- <VCol cols =" 12" md =" 6" >
211- <VTextField
212- v-model =" notificationInfo.config.WECHAT_APP_SECRET"
213- :label =" t('notification.wechat.appSecret')"
214- :hint =" t('notification.wechat.appSecretHint')"
215- persistent-hint
216- prepend-inner-icon =" mdi-key"
217- />
218- </VCol >
219- <VCol cols =" 12" md =" 6" >
220- <VTextField
221- v-model =" notificationInfo.config.WECHAT_PROXY"
222- :label =" t('notification.wechat.proxy')"
223- :hint =" t('notification.wechat.proxyHint')"
224- persistent-hint
225- prepend-inner-icon =" mdi-server-network"
226- />
227- </VCol >
228- <VCol cols =" 12" md =" 6" >
229- <VTextField
230- v-model =" notificationInfo.config.WECHAT_TOKEN"
231- :label =" t('notification.wechat.token')"
232- :hint =" t('notification.wechat.tokenHint')"
233- persistent-hint
234- prepend-inner-icon =" mdi-key-variant"
235- />
236- </VCol >
237- <VCol cols =" 12" md =" 6" >
238- <VTextField
239- v-model =" notificationInfo.config.WECHAT_ENCODING_AESKEY"
240- :label =" t('notification.wechat.encodingAesKey')"
241- :hint =" t('notification.wechat.encodingAesKeyHint')"
242- persistent-hint
243- prepend-inner-icon =" mdi-lock"
244- />
245- </VCol >
246- <VCol cols =" 12" md =" 6" >
247- <VTextField
248- v-model =" notificationInfo.config.WECHAT_ADMINS"
249- :label =" t('notification.wechat.admins')"
250- :placeholder =" t('notification.wechat.adminsPlaceholder')"
251- :hint =" t('notification.wechat.adminsHint')"
252- persistent-hint
253- prepend-inner-icon =" mdi-account-supervisor"
254- />
255- </VCol >
223+ <VSwitch
224+ v-model =" isWechatBotMode"
225+ :label =" t('notification.wechat.useBotMode')"
226+ :hint =" t('notification.wechat.useBotModeHint')"
227+ persistent-hint
228+ color =" primary"
229+ />
230+ </VCol >
231+ <template v-if =" isWechatBotMode " >
232+ <VCol cols =" 12" md =" 6" >
233+ <VTextField
234+ v-model =" notificationInfo.config.WECHAT_BOT_ID"
235+ :label =" t('notification.wechat.botId')"
236+ :hint =" t('notification.wechat.botIdHint')"
237+ persistent-hint
238+ prepend-inner-icon =" mdi-robot"
239+ />
240+ </VCol >
241+ <VCol cols =" 12" md =" 6" >
242+ <VTextField
243+ v-model =" notificationInfo.config.WECHAT_BOT_SECRET"
244+ :label =" t('notification.wechat.botSecret')"
245+ :hint =" t('notification.wechat.botSecretHint')"
246+ persistent-hint
247+ prepend-inner-icon =" mdi-key"
248+ />
249+ </VCol >
250+ <VCol cols =" 12" md =" 6" >
251+ <VTextField
252+ v-model =" notificationInfo.config.WECHAT_BOT_CHAT_ID"
253+ :label =" t('notification.wechat.botChatId')"
254+ :placeholder =" t('notification.wechat.botChatIdPlaceholder')"
255+ :hint =" t('notification.wechat.botChatIdHint')"
256+ persistent-hint
257+ prepend-inner-icon =" mdi-chat-processing"
258+ />
259+ </VCol >
260+ <VCol cols =" 12" md =" 6" >
261+ <VTextField
262+ v-model =" notificationInfo.config.WECHAT_BOT_WS_URL"
263+ :label =" t('notification.wechat.botWsUrl')"
264+ :hint =" t('notification.wechat.botWsUrlHint')"
265+ persistent-hint
266+ prepend-inner-icon =" mdi-lan-connect"
267+ />
268+ </VCol >
269+ <VCol cols =" 12" md =" 6" >
270+ <VTextField
271+ v-model =" notificationInfo.config.WECHAT_ADMINS"
272+ :label =" t('notification.wechat.admins')"
273+ :placeholder =" t('notification.wechat.adminsPlaceholder')"
274+ :hint =" t('notification.wechat.adminsHint')"
275+ persistent-hint
276+ prepend-inner-icon =" mdi-account-supervisor"
277+ />
278+ </VCol >
279+ </template >
280+ <template v-else >
281+ <VCol cols =" 12" md =" 6" >
282+ <VTextField
283+ v-model =" notificationInfo.config.WECHAT_CORPID"
284+ :label =" t('notification.wechat.corpId')"
285+ :hint =" t('notification.wechat.corpIdHint')"
286+ persistent-hint
287+ prepend-inner-icon =" mdi-domain"
288+ />
289+ </VCol >
290+ <VCol cols =" 12" md =" 6" >
291+ <VTextField
292+ v-model =" notificationInfo.config.WECHAT_APP_ID"
293+ :label =" t('notification.wechat.appId')"
294+ :hint =" t('notification.wechat.appIdHint')"
295+ persistent-hint
296+ prepend-inner-icon =" mdi-application"
297+ />
298+ </VCol >
299+ <VCol cols =" 12" md =" 6" >
300+ <VTextField
301+ v-model =" notificationInfo.config.WECHAT_APP_SECRET"
302+ :label =" t('notification.wechat.appSecret')"
303+ :hint =" t('notification.wechat.appSecretHint')"
304+ persistent-hint
305+ prepend-inner-icon =" mdi-key"
306+ />
307+ </VCol >
308+ <VCol cols =" 12" md =" 6" >
309+ <VTextField
310+ v-model =" notificationInfo.config.WECHAT_PROXY"
311+ :label =" t('notification.wechat.proxy')"
312+ :hint =" t('notification.wechat.proxyHint')"
313+ persistent-hint
314+ prepend-inner-icon =" mdi-server-network"
315+ />
316+ </VCol >
317+ <VCol cols =" 12" md =" 6" >
318+ <VTextField
319+ v-model =" notificationInfo.config.WECHAT_TOKEN"
320+ :label =" t('notification.wechat.token')"
321+ :hint =" t('notification.wechat.tokenHint')"
322+ persistent-hint
323+ prepend-inner-icon =" mdi-key-variant"
324+ />
325+ </VCol >
326+ <VCol cols =" 12" md =" 6" >
327+ <VTextField
328+ v-model =" notificationInfo.config.WECHAT_ENCODING_AESKEY"
329+ :label =" t('notification.wechat.encodingAesKey')"
330+ :hint =" t('notification.wechat.encodingAesKeyHint')"
331+ persistent-hint
332+ prepend-inner-icon =" mdi-lock"
333+ />
334+ </VCol >
335+ <VCol cols =" 12" md =" 6" >
336+ <VTextField
337+ v-model =" notificationInfo.config.WECHAT_ADMINS"
338+ :label =" t('notification.wechat.admins')"
339+ :placeholder =" t('notification.wechat.adminsPlaceholder')"
340+ :hint =" t('notification.wechat.adminsHint')"
341+ persistent-hint
342+ prepend-inner-icon =" mdi-account-supervisor"
343+ />
344+ </VCol >
345+ </template >
256346 </VRow >
257347 <VRow v-else-if =" notificationInfo.type == 'telegram'" >
258348 <VCol cols =" 12" md =" 6" >
0 commit comments