From 790c5794e9e590a5b5b6e4ccbfb2931240517d6b Mon Sep 17 00:00:00 2001 From: john Date: Sun, 19 Jul 2026 18:34:55 +0800 Subject: [PATCH] feat: add image_make controls to admin --- src/admin/pages/AssetGatewayPage.tsx | 45 +++++++++++++++++++++-- src/api/client.ts | 1 + src/index.css | 54 ++++++++++++++++++++++++++++ src/types.ts | 6 ++++ 4 files changed, 104 insertions(+), 2 deletions(-) diff --git a/src/admin/pages/AssetGatewayPage.tsx b/src/admin/pages/AssetGatewayPage.tsx index 474be31..628f0b8 100644 --- a/src/admin/pages/AssetGatewayPage.tsx +++ b/src/admin/pages/AssetGatewayPage.tsx @@ -12,6 +12,7 @@ type PluginDraft = { provider: string; llmProviderKeyId: string; llmModel: string; + purposes: Record; }; function draftFromPlugin(plugin: AssetPluginConfig): PluginDraft { @@ -20,6 +21,7 @@ function draftFromPlugin(plugin: AssetPluginConfig): PluginDraft { provider: plugin.provider ?? '', llmProviderKeyId: plugin.llmProviderKeyId ?? '', llmModel: plugin.llmModel ?? '', + purposes: { ...(plugin.purposes ?? {}) }, }; } @@ -61,6 +63,16 @@ export function AssetGatewayPage() { setDrafts((current) => ({ ...current, [pluginId]: { ...current[pluginId], ...patch } })); }; + const updatePurpose = (pluginId: string, purposeId: string, enabled: boolean) => { + setDrafts((current) => ({ + ...current, + [pluginId]: { + ...current[pluginId], + purposes: { ...(current[pluginId]?.purposes ?? {}), [purposeId]: enabled }, + }, + })); + }; + const saveGlobal = async (enabled: boolean) => { setBusy('global'); setMessage(null); setError(null); try { @@ -81,6 +93,7 @@ export function AssetGatewayPage() { provider: draft.provider || null, llmProviderKeyId: draft.llmProviderKeyId || null, llmModel: draft.llmModel || null, + purposes: draft.purposes, }); setConfig(result.config); setDrafts(Object.fromEntries(result.config.plugins.map((item) => [item.pluginId, draftFromPlugin(item)]))); @@ -126,11 +139,21 @@ export function AssetGatewayPage() {
- - {plugin.supportsLlm ? <> + {plugin.pluginId === 'asset-generate' && draft.provider === 'image_make' ? ( +
+ image_make 独立管理本地模型,不读取统一模型中心密钥。 +
+ ) : plugin.supportsLlm ? <> :
确定性处理 · 不调用 LLM
} + {plugin.pluginId === 'asset-generate' && plugin.purposeCatalog?.length ? ( +
+ image_make 生效范围 +
+ {plugin.purposeCatalog.map((purpose) => ( + + ))} +
+

信息流缩略图仍由 MindSpace 从封面源图派生,不会重复调用生图模型。

+
+ ) : null}
{draft.enabled ? '待保存为启用' : '默认安全关闭'}
; diff --git a/src/api/client.ts b/src/api/client.ts index e79ee89..04fe530 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -307,6 +307,7 @@ export async function updateAssetPluginConfig( provider?: string | null; llmProviderKeyId?: string | null; llmModel?: string | null; + purposes?: Record; }, ): Promise<{ ok: boolean; config: AssetGatewayConfig }> { return portalFetch(`/admin-api/asset-gateway/plugins/${encodeURIComponent(pluginId)}`, { diff --git a/src/index.css b/src/index.css index 1fd88e8..8b09409 100644 --- a/src/index.css +++ b/src/index.css @@ -1080,6 +1080,60 @@ body, min-width: 0; } +.asset-image-make-note, +.asset-no-llm { + padding: 9px 10px; + border-radius: var(--radius-sm); + background: rgba(132, 110, 255, .1); + color: var(--color-text-muted); + font-size: 11px; + line-height: 1.5; +} + +.asset-purpose-fieldset { + min-width: 0; + margin: 2px 0 0; + padding: 10px; + border: 1px solid var(--color-border); + border-radius: var(--radius-sm); +} + +.asset-purpose-fieldset legend { + padding: 0 5px; + color: var(--color-text-muted); + font-size: 11px; +} + +.asset-purpose-fieldset > p { + margin: 8px 0 0; + color: var(--color-text-muted); + font-size: 10px; + line-height: 1.45; +} + +.asset-purpose-grid { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 7px; +} + +.asset-purpose-grid label { + display: flex; + align-items: flex-start; + gap: 7px; + padding: 7px; + border-radius: var(--radius-xs); + background: rgba(255, 255, 255, .035); +} + +.asset-purpose-grid small { + display: block; + margin-top: 2px; + color: var(--color-text-muted); + font-size: 9px; + word-break: break-all; +} + .asset-plugin-footer { display: flex; align-items: center; diff --git a/src/types.ts b/src/types.ts index 33627ee..b8801e1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -208,6 +208,12 @@ export type AssetPluginConfig = { llmProviderId: string | null; llmModel: string | null; updatedAt: number | null; + purposes?: Record; + purposeCatalog?: Array<{ + id: string; + label: string; + presetId: string; + }>; }; export type AssetGatewayConfig = {