mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-06 08:06:50 +00:00
feat(monitor): support ollama_cloud in the channel monitor UI
Frontend half of increment 5-2 (mirrors backend 39b8649df): - Add ollama_cloud to the Provider union, channelMonitor constants (PROVIDER_OLLAMA_CLOUD, PROVIDERS, DEFAULT_OLLAMA_CLOUD_ENDPOINT = https://ollama.com; the probe adapter appends /v1/chat/completions, same source as the backend DefaultOllamaCloudBaseURL), the monitor form provider grid / endpoint preset, the filter bar, and the template manager tabs. ollama_cloud supports all three check modes and chat_completions only, so no antigravity-style restriction and no default-model preset (backend only defaults grok's model). - Extend providerLabel/badge/picker/gradient (stone palette, aligned with utils/platformColors.ts), the user MonitorCard icon tint, and the ProviderIcon exhaustive map with the official llama mark. - i18n: monitorCommon.providers.ollama_cloud and admin.groups.platforms.ollama_cloud in en+zh. - ChannelsView: add ollama_cloud to platformOrder and compositePlatforms (backend isConcreteRequestPlatform already includes it); no per-platform extra config needed - matching opencode_go, which also carries none in the channel form. - Update the stale ChannelMonitorView.grok.spec.ts provider count 8 -> 11 (the grid already had 10 before this change and the spec was failing on the clean baseline).
This commit is contained in:
1 parent
f5deed85e5
commit
f8f6355280
14 files changed
+45
-7
No files matched your search
@@ -16,6 +16,7 @@ export type Provider =
|
||||
| 'deepseek'
|
||||
| 'minimax'
|
||||
| 'opencode_go'
|
||||
| 'ollama_cloud'
|
||||
export type MonitorStatus = 'operational' | 'degraded' | 'failed' | 'error'
|
||||
export type BodyOverrideMode = 'off' | 'merge' | 'replace'
|
||||
export type APIMode = 'chat_completions' | 'responses'
|
||||
|
||||
@@ -77,6 +77,7 @@ import {
|
||||
PROVIDER_DEEPSEEK,
|
||||
PROVIDER_MINIMAX,
|
||||
PROVIDER_OPENCODE_GO,
|
||||
PROVIDER_OLLAMA_CLOUD,
|
||||
} from '@/constants/channelMonitor'
|
||||
|
||||
defineProps<{
|
||||
@@ -108,6 +109,7 @@ const providerFilterOptions = computed(() => [
|
||||
{ value: PROVIDER_DEEPSEEK, label: t('monitorCommon.providers.deepseek') },
|
||||
{ value: PROVIDER_MINIMAX, label: t('monitorCommon.providers.minimax') },
|
||||
{ value: PROVIDER_OPENCODE_GO, label: t('monitorCommon.providers.opencode_go') },
|
||||
{ value: PROVIDER_OLLAMA_CLOUD, label: t('monitorCommon.providers.ollama_cloud') },
|
||||
])
|
||||
|
||||
const enabledFilterOptions = computed(() => [
|
||||
|
||||
@@ -271,6 +271,7 @@ import {
|
||||
PROVIDER_DEEPSEEK,
|
||||
PROVIDER_MINIMAX,
|
||||
PROVIDER_OPENCODE_GO,
|
||||
PROVIDER_OLLAMA_CLOUD,
|
||||
API_MODE_CHAT_COMPLETIONS,
|
||||
API_MODE_RESPONSES,
|
||||
CHECK_MODE_PROBE,
|
||||
@@ -283,6 +284,7 @@ import {
|
||||
DEFAULT_DEEPSEEK_ENDPOINT,
|
||||
DEFAULT_MINIMAX_ENDPOINT,
|
||||
DEFAULT_OPENCODE_GO_ENDPOINT,
|
||||
DEFAULT_OLLAMA_CLOUD_ENDPOINT,
|
||||
DEFAULT_INTERVAL_SECONDS,
|
||||
} from '@/constants/channelMonitor'
|
||||
|
||||
@@ -479,6 +481,7 @@ const providerOptions = computed<ProviderOption[]>(() => [
|
||||
{ value: PROVIDER_DEEPSEEK, label: t('monitorCommon.providers.deepseek') },
|
||||
{ value: PROVIDER_MINIMAX, label: t('monitorCommon.providers.minimax') },
|
||||
{ value: PROVIDER_OPENCODE_GO, label: t('monitorCommon.providers.opencode_go') },
|
||||
{ value: PROVIDER_OLLAMA_CLOUD, label: t('monitorCommon.providers.ollama_cloud') },
|
||||
])
|
||||
|
||||
// 国产 provider 预填的官方 endpoint(仅探活侧;配额模式 endpoint 可留空)。
|
||||
@@ -488,6 +491,7 @@ const PROVIDER_DEFAULT_ENDPOINTS: Partial<Record<Provider, string>> = {
|
||||
[PROVIDER_DEEPSEEK]: DEFAULT_DEEPSEEK_ENDPOINT,
|
||||
[PROVIDER_MINIMAX]: DEFAULT_MINIMAX_ENDPOINT,
|
||||
[PROVIDER_OPENCODE_GO]: DEFAULT_OPENCODE_GO_ENDPOINT,
|
||||
[PROVIDER_OLLAMA_CLOUD]: DEFAULT_OLLAMA_CLOUD_ENDPOINT,
|
||||
}
|
||||
|
||||
interface CheckModeOption {
|
||||
|
||||
@@ -255,6 +255,7 @@ import {
|
||||
PROVIDER_DEEPSEEK,
|
||||
PROVIDER_MINIMAX,
|
||||
PROVIDER_OPENCODE_GO,
|
||||
PROVIDER_OLLAMA_CLOUD,
|
||||
PROVIDERS,
|
||||
API_MODE_CHAT_COMPLETIONS,
|
||||
API_MODE_RESPONSES,
|
||||
@@ -282,6 +283,7 @@ const providerTabs = computed<{ value: Provider; label: string }[]>(() => [
|
||||
{ value: PROVIDER_DEEPSEEK, label: t('monitorCommon.providers.deepseek') },
|
||||
{ value: PROVIDER_MINIMAX, label: t('monitorCommon.providers.minimax') },
|
||||
{ value: PROVIDER_OPENCODE_GO, label: t('monitorCommon.providers.opencode_go') },
|
||||
{ value: PROVIDER_OLLAMA_CLOUD, label: t('monitorCommon.providers.ollama_cloud') },
|
||||
])
|
||||
|
||||
const activeProvider = ref<Provider>(PROVIDER_ANTHROPIC)
|
||||
|
||||
@@ -91,7 +91,7 @@ import MonitorAvailabilityRow from './MonitorAvailabilityRow.vue'
|
||||
import MonitorTimeline from './MonitorTimeline.vue'
|
||||
import MonitorQuotaView from '@/components/common/MonitorQuotaView.vue'
|
||||
|
||||
// 图标配色与 utils/platformColors.ts 的平台色对齐(新 4 家)。
|
||||
// 图标配色与 utils/platformColors.ts 的平台色对齐(新 4 家 + ollama_cloud)。
|
||||
const PROVIDER_TINT: Record<string, string> = {
|
||||
openai: 'text-emerald-600 dark:text-emerald-300',
|
||||
anthropic: 'text-orange-600 dark:text-orange-300',
|
||||
@@ -102,6 +102,7 @@ const PROVIDER_TINT: Record<string, string> = {
|
||||
zhipu: 'text-indigo-600 dark:text-indigo-300',
|
||||
deepseek: 'text-teal-600 dark:text-teal-300',
|
||||
opencode_go: 'text-amber-700 dark:text-amber-300',
|
||||
ollama_cloud: 'text-stone-600 dark:text-stone-300',
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
@@ -88,6 +88,12 @@ const PROVIDER_ICONS: Record<Provider, IconData> = {
|
||||
'M16 6H8v12h8V6zm4 16H4V2h16v20z',
|
||||
],
|
||||
},
|
||||
// ollama_cloud 官方 logo mark(llama)搬自 PlatformIcon.vue / ModelIcon.vue,保持同步。
|
||||
ollama_cloud: {
|
||||
paths: [
|
||||
'M7.905 1.09c.216.085.411.225.588.41.295.306.544.744.734 1.263.191.522.315 1.1.362 1.68a5.054 5.054 0 012.049-.636l.051-.004c.87-.07 1.73.087 2.48.474.101.053.2.11.297.17.05-.569.172-1.134.36-1.644.19-.52.439-.957.733-1.264a1.67 1.67 0 01.589-.41c.257-.1.53-.118.796-.042.401.114.745.368 1.016.737.248.337.434.769.561 1.287.23.934.27 2.163.115 3.645l.053.04.026.019c.757.576 1.284 1.397 1.563 2.35.435 1.487.216 3.155-.534 4.088l-.018.021.002.003c.417.762.67 1.567.724 2.4l.002.03c.064 1.065-.2 2.137-.814 3.19l-.007.01.01.024c.472 1.157.62 2.322.438 3.486l-.006.039a.651.651 0 01-.747.536.648.648 0 01-.54-.742c.167-1.033.01-2.069-.48-3.123a.643.643 0 01.04-.617l.004-.006c.604-.924.854-1.83.8-2.72-.046-.779-.325-1.544-.8-2.273a.644.644 0 01.18-.886l.009-.006c.243-.159.467-.565.58-1.12a4.229 4.229 0 00-.095-1.974c-.205-.7-.58-1.284-1.105-1.683-.595-.454-1.383-.673-2.38-.61a.653.653 0 01-.632-.371c-.314-.665-.772-1.141-1.343-1.436a3.288 3.288 0 00-1.772-.332c-1.245.099-2.343.801-2.67 1.686a.652.652 0 01-.61.425c-1.067.002-1.893.252-2.497.703-.522.39-.878.935-1.066 1.588a4.07 4.07 0 00-.068 1.886c.112.558.331 1.02.582 1.269l.008.007c.212.207.257.53.109.785-.36.622-.629 1.549-.673 2.44-.05 1.018.186 1.902.719 2.536l.016.019a.643.643 0 01.095.69c-.576 1.236-.753 2.252-.562 3.052a.652.652 0 01-1.269.298c-.243-1.018-.078-2.184.473-3.498l.014-.035-.008-.012a4.339 4.339 0 01-.598-1.309l-.005-.019a5.764 5.764 0 01-.177-1.785c.044-.91.278-1.842.622-2.59l.012-.026-.002-.002c-.293-.418-.51-.953-.63-1.545l-.005-.024a5.352 5.352 0 01.093-2.49c.262-.915.777-1.701 1.536-2.269.06-.045.123-.09.186-.132-.159-1.493-.119-2.73.112-3.67.127-.518.314-.95.562-1.287.27-.368.614-.622 1.015-.737.266-.076.54-.059.797.042zm4.116 9.09c.936 0 1.8.313 2.446.855.63.527 1.005 1.235 1.005 1.94 0 .888-.406 1.58-1.133 2.022-.62.375-1.451.557-2.403.557-1.009 0-1.871-.259-2.493-.734-.617-.47-.963-1.13-.963-1.845 0-.707.398-1.417 1.056-1.946.668-.537 1.55-.849 2.485-.849zm0 .896a3.07 3.07 0 00-1.916.65c-.461.37-.722.835-.722 1.25 0 .428.21.829.61 1.134.455.347 1.124.548 1.943.548.799 0 1.473-.147 1.932-.426.463-.28.7-.686.7-1.257 0-.423-.246-.89-.683-1.256-.484-.405-1.14-.643-1.864-.643zm.662 1.21l.004.004c.12.151.095.37-.056.49l-.292.23v.446a.375.375 0 01-.376.373.375.375 0 01-.376-.373v-.46l-.271-.218a.347.347 0 01-.052-.49.353.353 0 01.494-.051l.215.172.22-.174a.353.353 0 01.49.051zm-5.04-1.919c.478 0 .867.39.867.871a.87.87 0 01-.868.871.87.87 0 01-.867-.87.87.87 0 01.867-.872zm8.706 0c.48 0 .868.39.868.871a.87.87 0 01-.868.871.87.87 0 01-.867-.87.87.87 0 01.867-.872zM7.44 2.3l-.003.002a.659.659 0 00-.285.238l-.005.006c-.138.189-.258.467-.348.832-.17.692-.216 1.631-.124 2.782.43-.128.899-.208 1.404-.237l.01-.001.019-.034c.046-.082.095-.161.148-.239.123-.771.022-1.692-.253-2.444-.134-.364-.297-.65-.453-.813a.628.628 0 00-.107-.09L7.44 2.3zm9.174.04l-.002.001a.628.628 0 00-.107.09c-.156.163-.32.45-.453.814-.29.794-.387 1.776-.23 2.572l.058.097.008.014h.03a5.184 5.184 0 011.466.212c.086-1.124.038-2.043-.128-2.722-.09-.365-.21-.643-.349-.832l-.004-.006a.659.659 0 00-.285-.239h-.004z',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
PROVIDER_DEEPSEEK,
|
||||
PROVIDER_MINIMAX,
|
||||
PROVIDER_OPENCODE_GO,
|
||||
PROVIDER_OLLAMA_CLOUD,
|
||||
PROVIDERS,
|
||||
STATUS_OPERATIONAL,
|
||||
STATUS_DEGRADED,
|
||||
@@ -107,7 +108,7 @@ export function useChannelMonitorFormat() {
|
||||
case PROVIDER_GROK:
|
||||
return 'bg-zinc-100 text-zinc-700 dark:bg-zinc-500/15 dark:text-zinc-300'
|
||||
// 配色与 utils/platformColors.ts 的平台色对齐:antigravity=purple /
|
||||
// kimi=pink / zhipu=indigo / deepseek=teal。
|
||||
// kimi=pink / zhipu=indigo / deepseek=teal / ollama_cloud=stone。
|
||||
case PROVIDER_ANTIGRAVITY:
|
||||
return 'bg-purple-100 text-purple-700 dark:bg-purple-500/15 dark:text-purple-300'
|
||||
case PROVIDER_KIMI:
|
||||
@@ -120,6 +121,8 @@ export function useChannelMonitorFormat() {
|
||||
return 'bg-rose-100 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300'
|
||||
case PROVIDER_OPENCODE_GO:
|
||||
return 'bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-300'
|
||||
case PROVIDER_OLLAMA_CLOUD:
|
||||
return 'bg-stone-100 text-stone-700 dark:bg-stone-500/15 dark:text-stone-300'
|
||||
default:
|
||||
return NEUTRAL_BADGE
|
||||
}
|
||||
@@ -188,6 +191,10 @@ export function useChannelMonitorFormat() {
|
||||
return active
|
||||
? 'border-amber-500 bg-amber-50 text-amber-800 dark:bg-amber-500/15 dark:text-amber-300 dark:border-amber-400'
|
||||
: 'border-gray-200 bg-white text-gray-600 hover:border-amber-300 hover:text-amber-700 dark:border-dark-700 dark:bg-dark-800 dark:text-gray-400 dark:hover:border-amber-500/50'
|
||||
case PROVIDER_OLLAMA_CLOUD:
|
||||
return active
|
||||
? 'border-stone-500 bg-stone-50 text-stone-700 dark:bg-stone-500/15 dark:text-stone-300 dark:border-stone-400'
|
||||
: 'border-gray-200 bg-white text-gray-600 hover:border-stone-300 hover:text-stone-700 dark:border-dark-700 dark:bg-dark-800 dark:text-gray-400 dark:hover:border-stone-500/50'
|
||||
default:
|
||||
return active
|
||||
? 'border-gray-400 bg-gray-50 text-gray-700 dark:border-dark-500 dark:bg-dark-700 dark:text-gray-200'
|
||||
@@ -276,6 +283,8 @@ export function providerGradient(provider: string): string {
|
||||
return 'bg-gradient-to-br from-rose-50 to-rose-100 dark:from-rose-500/10 dark:to-rose-500/20'
|
||||
case PROVIDER_OPENCODE_GO:
|
||||
return 'bg-gradient-to-br from-amber-50 to-amber-100 dark:from-amber-500/10 dark:to-amber-500/20'
|
||||
case PROVIDER_OLLAMA_CLOUD:
|
||||
return 'bg-gradient-to-br from-stone-50 to-stone-200 dark:from-stone-500/10 dark:to-stone-500/20'
|
||||
default:
|
||||
return 'bg-gradient-to-br from-gray-100 to-gray-200 dark:from-dark-700 dark:to-dark-600'
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ export const PROVIDER_ZHIPU: Provider = 'zhipu'
|
||||
export const PROVIDER_DEEPSEEK: Provider = 'deepseek'
|
||||
export const PROVIDER_MINIMAX: Provider = 'minimax'
|
||||
export const PROVIDER_OPENCODE_GO: Provider = 'opencode_go'
|
||||
export const PROVIDER_OLLAMA_CLOUD: Provider = 'ollama_cloud'
|
||||
|
||||
export const DEFAULT_GROK_ENDPOINT = 'https://api.x.ai'
|
||||
export const DEFAULT_GROK_MODEL = 'grok-4.5'
|
||||
@@ -29,6 +30,9 @@ export const DEFAULT_ZHIPU_ENDPOINT = 'https://open.bigmodel.cn'
|
||||
export const DEFAULT_DEEPSEEK_ENDPOINT = 'https://api.deepseek.com'
|
||||
export const DEFAULT_MINIMAX_ENDPOINT = 'https://api.minimaxi.com'
|
||||
export const DEFAULT_OPENCODE_GO_ENDPOINT = 'https://opencode.ai/zen/go/v1'
|
||||
// ollama_cloud 官方 OpenAI 兼容端点:探活 adapter 追加 /v1/chat/completions,
|
||||
// 与后端 DefaultOllamaCloudBaseURL (https://ollama.com/v1) 同源。
|
||||
export const DEFAULT_OLLAMA_CLOUD_ENDPOINT = 'https://ollama.com'
|
||||
|
||||
export const CHECK_MODE_PROBE: CheckMode = 'probe'
|
||||
export const CHECK_MODE_QUOTA: CheckMode = 'quota'
|
||||
@@ -48,6 +52,7 @@ export const PROVIDERS: readonly Provider[] = [
|
||||
PROVIDER_DEEPSEEK,
|
||||
PROVIDER_MINIMAX,
|
||||
PROVIDER_OPENCODE_GO,
|
||||
PROVIDER_OLLAMA_CLOUD,
|
||||
]
|
||||
|
||||
/** 仅支持配额模式(无探活 adapter)的 provider。 */
|
||||
|
||||
@@ -984,6 +984,7 @@ export default {
|
||||
deepseek: 'DeepSeek',
|
||||
minimax: 'MiniMax',
|
||||
opencode_go: 'OpenCode',
|
||||
ollama_cloud: 'Ollama Cloud',
|
||||
composite: 'Composite',
|
||||
},
|
||||
deleteConfirm:
|
||||
|
||||
@@ -474,7 +474,8 @@ export default {
|
||||
zhipu: 'Zhipu GLM',
|
||||
deepseek: 'DeepSeek',
|
||||
minimax: 'MiniMax',
|
||||
opencode_go: 'OpenCode'
|
||||
opencode_go: 'OpenCode',
|
||||
ollama_cloud: 'Ollama Cloud'
|
||||
},
|
||||
// Check modes (how a monitor performs its checks)
|
||||
checkMode: {
|
||||
|
||||
@@ -917,6 +917,7 @@ export default {
|
||||
deepseek: 'DeepSeek',
|
||||
minimax: 'MiniMax',
|
||||
opencode_go: 'OpenCode',
|
||||
ollama_cloud: 'Ollama Cloud',
|
||||
composite: 'Composite',
|
||||
},
|
||||
saving: '保存中...',
|
||||
|
||||
@@ -479,7 +479,8 @@ export default {
|
||||
zhipu: '智谱 GLM',
|
||||
deepseek: 'DeepSeek',
|
||||
minimax: 'MiniMax',
|
||||
opencode_go: 'OpenCode'
|
||||
opencode_go: 'OpenCode',
|
||||
ollama_cloud: 'Ollama Cloud'
|
||||
},
|
||||
// 检查模式(监控条目的工作方式)
|
||||
checkMode: {
|
||||
|
||||
@@ -763,9 +763,10 @@ const form = reactive({
|
||||
let abortController: AbortController | null = null
|
||||
|
||||
// ── Platform config ──
|
||||
const platformOrder: GroupPlatform[] = ['anthropic', 'openai', 'gemini', 'antigravity', 'grok', 'kimi', 'zhipu', 'deepseek', 'minimax', 'opencode_go']
|
||||
const platformOrder: GroupPlatform[] = ['anthropic', 'openai', 'gemini', 'antigravity', 'grok', 'kimi', 'zhipu', 'deepseek', 'minimax', 'opencode_go', 'ollama_cloud']
|
||||
// Composite pricing/mapping may target every concrete schedulable provider.
|
||||
const compositePlatforms: GroupPlatform[] = ['anthropic', 'openai', 'gemini', 'antigravity', 'grok', 'kimi', 'zhipu', 'deepseek', 'minimax', 'opencode_go']
|
||||
// (Backend isConcreteRequestPlatform includes ollama_cloud.)
|
||||
const compositePlatforms: GroupPlatform[] = ['anthropic', 'openai', 'gemini', 'antigravity', 'grok', 'kimi', 'zhipu', 'deepseek', 'minimax', 'opencode_go', 'ollama_cloud']
|
||||
|
||||
// ── Helpers ──
|
||||
function formatDate(value: string): string {
|
||||
|
||||
@@ -100,8 +100,11 @@ describe('channel monitor Grok provider', () => {
|
||||
await flushPromises()
|
||||
|
||||
expect(PROVIDERS).toContain(PROVIDER_GROK)
|
||||
// Provider grid mirrors the full backend oneof list (migration 239 CHECK):
|
||||
// openai/anthropic/gemini/grok/antigravity/kimi/zhipu/deepseek/minimax/
|
||||
// opencode_go/ollama_cloud.
|
||||
const providerButtons = wrapper.findAll('[data-testid^="monitor-provider-"]')
|
||||
expect(providerButtons).toHaveLength(8)
|
||||
expect(providerButtons).toHaveLength(11)
|
||||
expect(providerButtons[0].element.parentElement?.className).toContain('grid-cols-2')
|
||||
expect(providerButtons[0].element.parentElement?.className).toContain('sm:grid-cols-4')
|
||||
|
||||
|
||||
Reference in new issue
Block a user