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:
@@ -2,6 +2,7 @@
|
|||||||
import { ref, onMounted, computed } from 'vue'
|
import { ref, onMounted, computed } from 'vue'
|
||||||
import { NModal, NForm, NFormItem, NInput, NButton, NSelect, NInputNumber, useMessage } from 'naive-ui'
|
import { NModal, NForm, NFormItem, NInput, NButton, NSelect, NInputNumber, useMessage } from 'naive-ui'
|
||||||
import { useJobsStore } from '@/stores/hermes/jobs'
|
import { useJobsStore } from '@/stores/hermes/jobs'
|
||||||
|
import { useSettingsStore } from '@/stores/hermes/settings'
|
||||||
import {
|
import {
|
||||||
buildJobUpdateRequest,
|
buildJobUpdateRequest,
|
||||||
getJob,
|
getJob,
|
||||||
@@ -23,6 +24,7 @@ const emit = defineEmits<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
const jobsStore = useJobsStore()
|
const jobsStore = useJobsStore()
|
||||||
|
const settingsStore = useSettingsStore()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
|
||||||
const showModal = ref(true)
|
const showModal = ref(true)
|
||||||
@@ -50,10 +52,30 @@ const schedulePresets = computed(() => [
|
|||||||
{ label: t('jobs.presetEveryMonth'), value: '0 9 1 * *' },
|
{ label: t('jobs.presetEveryMonth'), value: '0 9 1 * *' },
|
||||||
])
|
])
|
||||||
|
|
||||||
const targetOptions = computed(() => [
|
const targetOptions = computed(() => {
|
||||||
{ label: t('jobs.origin'), value: 'origin' },
|
const options: Array<{ label: string; value: string }> = [
|
||||||
{ label: t('jobs.local'), value: 'local' },
|
{ 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)
|
const originalJob = ref<Job | null>(null)
|
||||||
|
|
||||||
|
|||||||
@@ -277,16 +277,11 @@ export async function getAvailable(ctx: any) {
|
|||||||
if (!cp.base_url) return null
|
if (!cp.base_url) return null
|
||||||
const providerKey = `custom:${cp.name.trim().toLowerCase().replace(/ /g, '-')}`
|
const providerKey = `custom:${cp.name.trim().toLowerCase().replace(/ /g, '-')}`
|
||||||
const baseUrl = cp.base_url.replace(/\/+$/, '')
|
const baseUrl = cp.base_url.replace(/\/+$/, '')
|
||||||
const bareKey = cp.name.trim().toLowerCase().replace(/ /g, '-')
|
let models = [cp.model]
|
||||||
const builtinPreset = PROVIDER_PRESETS.find(p => p.value === bareKey)
|
if (cp.api_key) {
|
||||||
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) {
|
|
||||||
try { const fetched = await fetchProviderModels(baseUrl, cp.api_key); if (fetched.length > 0) models = [...new Set([cp.model, ...fetched])] } catch { }
|
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
|
return { providerKey, label: cp.name, base_url: baseUrl, models, api_key: cp.api_key || '' }
|
||||||
const presetBaseUrl = builtinPreset?.base_url || ''
|
|
||||||
return { providerKey, label, base_url: presetBaseUrl || baseUrl, models, api_key: cp.api_key || '', builtin: !!builtinPreset }
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user