fix: custom_providers base_url and dynamic deliver targets (#801)

- custom_providers: always use user's base_url instead of
  PROVIDER_PRESETS matching by name that overwrites local URLs
- JobFormModal: dynamically add connected platform channels
  (Telegram, Discord, Slack, WhatsApp, Matrix, WeChat, WeCom,
  Feishu, DingTalk) to job deliver target dropdown

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
WenhuaXia
2026-05-16 22:07:02 +08:00
committed by GitHub
parent 8571a7d0ac
commit f2c8ace7c2
2 changed files with 29 additions and 12 deletions
@@ -2,6 +2,7 @@
import { ref, onMounted, computed } from 'vue'
import { NModal, NForm, NFormItem, NInput, NButton, NSelect, NInputNumber, useMessage } from 'naive-ui'
import { useJobsStore } from '@/stores/hermes/jobs'
import { useSettingsStore } from '@/stores/hermes/settings'
import {
buildJobUpdateRequest,
getJob,
@@ -23,6 +24,7 @@ const emit = defineEmits<{
}>()
const jobsStore = useJobsStore()
const settingsStore = useSettingsStore()
const message = useMessage()
const showModal = ref(true)
@@ -50,10 +52,30 @@ const schedulePresets = computed(() => [
{ label: t('jobs.presetEveryMonth'), value: '0 9 1 * *' },
])
const targetOptions = computed(() => [
{ label: t('jobs.origin'), value: 'origin' },
{ label: t('jobs.local'), value: 'local' },
])
const targetOptions = computed(() => {
const options: Array<{ label: string; value: string }> = [
{ label: t('jobs.origin'), value: 'origin' },
{ label: t('jobs.local'), value: 'local' },
]
const channels = [
{ key: 'telegram', label: 'Telegram' },
{ key: 'discord', label: 'Discord' },
{ key: 'slack', label: 'Slack' },
{ key: 'whatsapp', label: 'WhatsApp' },
{ key: 'matrix', label: 'Matrix' },
{ key: 'weixin', label: 'WeChat' },
{ key: 'wecom', label: 'WeCom' },
{ key: 'feishu', label: 'Feishu' },
{ key: 'dingtalk', label: 'DingTalk' },
]
for (const ch of channels) {
const config = settingsStore.platforms[ch.key] || {}
if (Object.keys(config).length > 0) {
options.push({ label: ch.label, value: ch.key })
}
}
return options
})
const originalJob = ref<Job | null>(null)
@@ -277,16 +277,11 @@ export async function getAvailable(ctx: any) {
if (!cp.base_url) return null
const providerKey = `custom:${cp.name.trim().toLowerCase().replace(/ /g, '-')}`
const baseUrl = cp.base_url.replace(/\/+$/, '')
const bareKey = cp.name.trim().toLowerCase().replace(/ /g, '-')
const builtinPreset = PROVIDER_PRESETS.find(p => p.value === bareKey)
let models = builtinPreset?.models?.length ? [...builtinPreset.models] : [cp.model]
// Skip dynamic fetch for builtin presets — their model list is maintained in providers.ts
if (!builtinPreset && cp.api_key) {
let models = [cp.model]
if (cp.api_key) {
try { const fetched = await fetchProviderModels(baseUrl, cp.api_key); if (fetched.length > 0) models = [...new Set([cp.model, ...fetched])] } catch { }
}
const label = builtinPreset?.label || cp.name
const presetBaseUrl = builtinPreset?.base_url || ''
return { providerKey, label, base_url: presetBaseUrl || baseUrl, models, api_key: cp.api_key || '', builtin: !!builtinPreset }
return { providerKey, label: cp.name, base_url: baseUrl, models, api_key: cp.api_key || '' }
}),
)