feat(storage): add multi-instance storage backends per workspace
Introduce tenant-scoped storage backend registry so workspaces can register multiple storage instances and bind each knowledge base to a specific backend, with migration from legacy tenant-level storage config and new settings UI.
This commit is contained in:
@@ -142,6 +142,7 @@ export interface KBModelConfigRequest {
|
||||
enabled: boolean
|
||||
}
|
||||
/** 存储引擎选择:"local" | "minio" | "cos" | "obs" 等,影响文档上传与文档内图片存储 */
|
||||
storageBackendId?: string
|
||||
storageProvider?: string
|
||||
nodeExtract: {
|
||||
enabled: boolean
|
||||
|
||||
@@ -65,6 +65,9 @@ export function createKnowledgeBase(data: {
|
||||
// store. Immutable after creation — UpdateKnowledgeBase intentionally
|
||||
// does not accept this field.
|
||||
vector_store_id?: string;
|
||||
// Concrete tenant-owned storage instance. When omitted, the tenant default
|
||||
// backend is bound by the server at creation time.
|
||||
storage_backend_id?: string;
|
||||
vlm_config?: {
|
||||
enabled: boolean;
|
||||
model_id?: string;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { get, post, put, del } from '@/utils/request'
|
||||
|
||||
export interface StorageBackendConfig {
|
||||
mode?: string
|
||||
endpoint?: string
|
||||
region?: string
|
||||
access_key_id?: string
|
||||
secret_access_key?: string
|
||||
bucket_name?: string
|
||||
path_prefix?: string
|
||||
app_id?: string
|
||||
use_ssl?: boolean
|
||||
force_path_style?: boolean
|
||||
use_temp_bucket?: boolean
|
||||
temp_bucket_name?: string
|
||||
temp_region?: string
|
||||
}
|
||||
|
||||
export interface StorageBackend {
|
||||
id: string
|
||||
tenant_id?: number
|
||||
name: string
|
||||
provider: string
|
||||
config: StorageBackendConfig
|
||||
source: 'user' | 'env'
|
||||
status: 'active' | 'disabled'
|
||||
legacy_alias?: boolean
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
}
|
||||
|
||||
export interface StorageBackendListResponse {
|
||||
success: boolean
|
||||
data: StorageBackend[]
|
||||
default_storage_backend_id?: string | null
|
||||
}
|
||||
|
||||
export const listStorageBackends = (): Promise<StorageBackendListResponse> => get('/api/v1/storage-backends')
|
||||
export const listStorageBackendTypes = (): Promise<{ success: boolean; data: string[] }> => get('/api/v1/storage-backends/types')
|
||||
export const createStorageBackend = (data: Partial<StorageBackend>) => post('/api/v1/storage-backends', data)
|
||||
export const updateStorageBackend = (id: string, data: Partial<StorageBackend>) => put(`/api/v1/storage-backends/${id}`, data)
|
||||
export const deleteStorageBackend = (id: string) => del(`/api/v1/storage-backends/${id}`)
|
||||
export const setDefaultStorageBackend = (id: string) => put(`/api/v1/storage-backends/${id}/default`, {})
|
||||
export const testStorageBackend = (data: Partial<StorageBackend>) => post('/api/v1/storage-backends/test', data)
|
||||
export const testStorageBackendByID = (id: string) => post(`/api/v1/storage-backends/${id}/test`, {})
|
||||
@@ -79,6 +79,7 @@ export type TenantAPIKeyCapability =
|
||||
| 'manage_datasources'
|
||||
| 'manage_channels'
|
||||
| 'manage_vector_stores'
|
||||
| 'manage_storage_backends'
|
||||
| 'manage_web_search'
|
||||
| 'run_evaluations'
|
||||
| 'manage_members'
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<title>Local storage</title>
|
||||
<rect x="3" y="4" width="18" height="7" rx="2" fill="#5C6678"/>
|
||||
<rect x="3" y="13" width="18" height="7" rx="2" fill="#434C5E"/>
|
||||
<rect x="5.5" y="7.1" width="13" height="0.8" rx="0.4" fill="#8A94A6"/>
|
||||
<rect x="5.5" y="16.1" width="13" height="0.8" rx="0.4" fill="#8A94A6"/>
|
||||
<circle cx="7.2" cy="7.5" r="0.9" fill="#6B7280"/>
|
||||
<circle cx="7.2" cy="16.5" r="0.9" fill="#6B7280"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 499 B |
@@ -6240,6 +6240,8 @@ export default {
|
||||
capabilityManageChannelsHint: 'Manage agent embed channels, IM channels, and WeChat QR binding flows.',
|
||||
capabilityManageVectorStores: 'Manage retrieval infrastructure',
|
||||
capabilityManageVectorStoresHint: 'Manage vector-store configuration plus parser, document reader, and storage engine connectivity checks.',
|
||||
capabilityManageStorageBackends: 'Manage storage backends',
|
||||
capabilityManageStorageBackendsHint: 'Manage object/file storage backend instances (e.g. S3-compatible or local file storage): their CRUD lifecycle, connectivity tests, and the tenant default selection.',
|
||||
capabilityManageWebSearch: 'Manage web search',
|
||||
capabilityManageWebSearchHint: 'Manage web-search provider configurations, credentials, and connection tests.',
|
||||
capabilityRunEvaluations: 'Run evaluations',
|
||||
|
||||
@@ -6244,6 +6244,8 @@ export default {
|
||||
capabilityManageChannelsHint: "에이전트 임베드 채널, IM 채널 및 WeChat QR 바인딩 흐름을 관리합니다.",
|
||||
capabilityManageVectorStores: "검색 인프라 관리",
|
||||
capabilityManageVectorStoresHint: "벡터 스토어 설정과 파서, 문서 리더, 스토리지 엔진 연결 검사를 관리합니다.",
|
||||
capabilityManageStorageBackends: "스토리지 백엔드 관리",
|
||||
capabilityManageStorageBackendsHint: "객체/파일 스토리지 백엔드 인스턴스(예: S3 호환 또는 로컬 파일 스토리지)의 CRUD, 연결 테스트 및 테넌트 기본 스토리지 설정을 관리합니다.",
|
||||
capabilityManageWebSearch: "웹 검색 관리",
|
||||
capabilityManageWebSearchHint: "웹 검색 공급자 설정, 자격 증명 및 연결 테스트를 관리합니다.",
|
||||
capabilityRunEvaluations: "평가 실행",
|
||||
|
||||
@@ -6065,6 +6065,8 @@ export default {
|
||||
capabilityManageChannelsHint: 'Управление embed-каналами агентов, IM-каналами и привязкой WeChat через QR-код.',
|
||||
capabilityManageVectorStores: 'Управление инфраструктурой поиска',
|
||||
capabilityManageVectorStoresHint: 'Управление векторными хранилищами и проверками парсеров, чтения документов и storage engine.',
|
||||
capabilityManageStorageBackends: 'Управление хранилищами (backends)',
|
||||
capabilityManageStorageBackendsHint: 'Управление экземплярами объектных/файловых хранилищ (например, S3-совместимых или локальных): их CRUD, проверки подключения и выбор хранилища по умолчанию для арендатора.',
|
||||
capabilityManageWebSearch: 'Управление веб-поиском',
|
||||
capabilityManageWebSearchHint: 'Управление провайдерами веб-поиска, учётными данными и проверками подключения.',
|
||||
capabilityRunEvaluations: 'Запуск оценок',
|
||||
|
||||
@@ -6265,6 +6265,8 @@ export default {
|
||||
capabilityManageChannelsHint: "允许管理智能体的嵌入渠道、IM 渠道和微信扫码绑定流程。",
|
||||
capabilityManageVectorStores: "管理检索基础设施",
|
||||
capabilityManageVectorStoresHint: "允许管理向量库配置,以及解析器、文档读取器和存储引擎连通性检查。",
|
||||
capabilityManageStorageBackends: "管理存储后端",
|
||||
capabilityManageStorageBackendsHint: "允许管理对象/文件存储后端实例(如 S3 兼容或本地文件存储)的增删改查、连通性测试及租户默认存储设置。",
|
||||
capabilityManageWebSearch: "管理联网搜索",
|
||||
capabilityManageWebSearchHint: "允许管理联网搜索供应商配置、凭据和连接测试。",
|
||||
capabilityRunEvaluations: "运行评测",
|
||||
|
||||
@@ -645,6 +645,7 @@ const API_KEY_CAPABILITIES: TenantAPIKeyCapability[] = [
|
||||
'manage_datasources',
|
||||
'manage_models',
|
||||
'manage_vector_stores',
|
||||
'manage_storage_backends',
|
||||
'manage_web_search',
|
||||
'manage_channels',
|
||||
'run_evaluations',
|
||||
@@ -699,6 +700,7 @@ const apiKeyCapabilityGroups: ApiKeyCapabilityGroup[] = [
|
||||
capabilities: [
|
||||
{ value: 'manage_models', labelKey: 'integrations.api.capabilityManageModels', hintKey: 'integrations.api.capabilityManageModelsHint' },
|
||||
{ value: 'manage_vector_stores', labelKey: 'integrations.api.capabilityManageVectorStores', hintKey: 'integrations.api.capabilityManageVectorStoresHint' },
|
||||
{ value: 'manage_storage_backends', labelKey: 'integrations.api.capabilityManageStorageBackends', hintKey: 'integrations.api.capabilityManageStorageBackendsHint' },
|
||||
{ value: 'manage_web_search', labelKey: 'integrations.api.capabilityManageWebSearch', hintKey: 'integrations.api.capabilityManageWebSearchHint' },
|
||||
{ value: 'manage_channels', labelKey: 'integrations.api.capabilityManageChannels', hintKey: 'integrations.api.capabilityManageChannelsHint' },
|
||||
{ value: 'run_evaluations', labelKey: 'integrations.api.capabilityRunEvaluations', hintKey: 'integrations.api.capabilityRunEvaluationsHint' },
|
||||
@@ -786,6 +788,7 @@ function keyCapabilityLabels(key: TenantAPIKey): string[] {
|
||||
manage_datasources: t('integrations.api.capabilityManageDatasources'),
|
||||
manage_channels: t('integrations.api.capabilityManageChannels'),
|
||||
manage_vector_stores: t('integrations.api.capabilityManageVectorStores'),
|
||||
manage_storage_backends: t('integrations.api.capabilityManageStorageBackends'),
|
||||
manage_web_search: t('integrations.api.capabilityManageWebSearch'),
|
||||
run_evaluations: t('integrations.api.capabilityRunEvaluations'),
|
||||
manage_members: t('integrations.api.capabilityManageMembers'),
|
||||
|
||||
@@ -254,8 +254,10 @@
|
||||
<!-- 存储引擎 -->
|
||||
<div v-if="!isFAQ && formData && currentSection === 'storage'" class="section">
|
||||
<KBStorageSettings
|
||||
:storage-backend-id="formData.storageBackendId"
|
||||
:storage-provider="formData.storageProvider"
|
||||
:has-files="mode === 'edit' && hasFiles"
|
||||
@update:storage-backend-id="handleStorageBackendUpdate"
|
||||
@update:storage-provider="handleStorageProviderUpdate"
|
||||
/>
|
||||
</div>
|
||||
@@ -711,6 +713,7 @@ const initFormData = (type: 'document' | 'faq' = 'document') => {
|
||||
languages: [] as string[],
|
||||
tableMetadataInstructions: ''
|
||||
},
|
||||
storageBackendId: '' as string,
|
||||
storageProvider: '' as string,
|
||||
multimodalConfig: {
|
||||
enabled: false,
|
||||
@@ -832,6 +835,7 @@ const loadKBData = async () => {
|
||||
languages: kb.chunking_config?.languages || [],
|
||||
tableMetadataInstructions: kb.chunking_config?.table_metadata_instructions || ''
|
||||
},
|
||||
storageBackendId: (kb.storage_backend_id || '') as string,
|
||||
storageProvider: (kb.storage_provider_config?.provider || kb.storage_config?.provider || 'local') as string,
|
||||
multimodalConfig: {
|
||||
enabled: !!kb.vlm_config?.enabled,
|
||||
@@ -1025,6 +1029,12 @@ const handleStorageProviderUpdate = (value: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleStorageBackendUpdate = (value: string) => {
|
||||
if (formData.value) {
|
||||
formData.value.storageBackendId = value
|
||||
}
|
||||
}
|
||||
|
||||
async function loadTenantDefaultStorageProvider(force = false) {
|
||||
try {
|
||||
await editorResources.ensureStorageEngine(force)
|
||||
@@ -1177,8 +1187,11 @@ const buildSubmitData = () => {
|
||||
language: formData.value.asrConfig?.language || ''
|
||||
}
|
||||
|
||||
// 存储引擎:仅传 provider,参数从全局设置读取
|
||||
// Write to storage_provider_config (authoritative) + storage_config (legacy dual-write)
|
||||
// storage_backend_id is authoritative. Keep provider projection for old clients
|
||||
// and for rolling upgrades where a node has not picked up the new schema yet.
|
||||
if (formData.value.storageBackendId) {
|
||||
data.storage_backend_id = formData.value.storageBackendId
|
||||
}
|
||||
const storageProvider = resolvedStorageProvider()
|
||||
data.storage_provider_config = {
|
||||
provider: storageProvider
|
||||
@@ -1362,6 +1375,7 @@ const doSubmit = async () => {
|
||||
multimodal: {
|
||||
enabled: !!data.vlm_config?.enabled
|
||||
},
|
||||
storageBackendId: formData.value?.storageBackendId || '',
|
||||
storageProvider: data.storage_provider_config?.provider || data.storage_config?.provider || 'local',
|
||||
nodeExtract: {
|
||||
enabled: data.extract_config?.enabled || false,
|
||||
|
||||
@@ -2,48 +2,28 @@
|
||||
<div class="kb-storage-settings">
|
||||
<div class="section-header">
|
||||
<h2>{{ $t('kbSettings.storage.title') }}</h2>
|
||||
<p class="section-description">
|
||||
{{ $t('kbSettings.storage.description') }}
|
||||
</p>
|
||||
<p class="section-description">选择此知识库绑定的具体存储实例。</p>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="loading-inline">
|
||||
<t-loading size="small" />
|
||||
<span>{{ $t('kbSettings.storage.loading') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="loading-inline"><t-loading size="small" /><span>加载中...</span></div>
|
||||
<div v-else class="settings-group">
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('kbSettings.storage.engineLabel') }}</label>
|
||||
<p class="desc">{{ $t('kbSettings.storage.engineDesc') }}</p>
|
||||
<label>存储实例</label>
|
||||
<p class="desc">同一种存储类型可以配置多个不同 Endpoint、Bucket 或凭据的实例。</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-select
|
||||
v-model="localProvider"
|
||||
size="medium"
|
||||
:placeholder="$t('kbSettings.storage.selectPlaceholder')"
|
||||
style="width: 100%; min-width: 220px;"
|
||||
@change="handleChange"
|
||||
>
|
||||
<t-option
|
||||
v-for="opt in engineOptions"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
:label="opt.label"
|
||||
:disabled="opt.disabled"
|
||||
>
|
||||
<t-select v-model="localID" style="width:100%;min-width:260px" :disabled="!!props.hasFiles" @change="handleChange">
|
||||
<t-option v-for="backend in backends" :key="backend.id" :value="backend.id" :label="backend.name">
|
||||
<span class="select-option">
|
||||
<span>{{ opt.label }}</span>
|
||||
<t-tag v-if="opt.disabled && opt.allowed === false" theme="danger" variant="light" size="small">{{ $t('kbSettings.storage.unavailable') }}</t-tag>
|
||||
<t-tag v-else-if="opt.disabled" theme="warning" variant="light" size="small">{{ $t('kbSettings.storage.notConfigured') }}</t-tag>
|
||||
<t-tag v-else-if="opt.available === false" theme="danger" variant="light" size="small">{{ $t('kbSettings.storage.unavailable') }}</t-tag>
|
||||
<span>{{ backend.name }}</span>
|
||||
<t-tag theme="primary" variant="light" size="small">{{ backend.provider.toUpperCase() }}</t-tag>
|
||||
<t-tag v-if="backend.id === defaultID" variant="light" size="small">默认</t-tag>
|
||||
</span>
|
||||
</t-option>
|
||||
</t-select>
|
||||
<p v-if="props.hasFiles" class="option-hint change-warning">{{ $t('kbSettings.storage.changeWarning') }}</p>
|
||||
<p v-else-if="selectedOption?.desc" class="option-hint">{{ selectedOption.desc }}</p>
|
||||
<a v-if="showGoSettings" href="javascript:void(0)" class="go-settings" @click.prevent="goToStorageSettings">{{ $t('kbSettings.storage.goGlobalSettings') }}</a>
|
||||
<p v-if="props.hasFiles" class="option-hint change-warning">知识库中已有文件,需通过存储迁移流程才能更换实例。</p>
|
||||
<p v-else-if="selected" class="option-hint">{{ selected.config.endpoint || selected.config.bucket_name || selected.config.path_prefix || '本地存储' }}</p>
|
||||
<a href="javascript:void(0)" class="go-settings" @click.prevent="goToSettings">管理存储实例</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -51,274 +31,39 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { type StorageEngineStatusItem } from '@/api/system'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { listStorageBackends, type StorageBackend } from '@/api/storage-backend'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { useEditorResourcesStore } from '@/stores/editorResources'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const props = defineProps<{
|
||||
storageProvider: string
|
||||
hasFiles?: boolean
|
||||
}>()
|
||||
|
||||
const props = defineProps<{ storageBackendId?: string; storageProvider?: string; hasFiles?: boolean }>()
|
||||
const emit = defineEmits<{
|
||||
'update:storageBackendId': [value: string]
|
||||
'update:storageProvider': [value: string]
|
||||
}>()
|
||||
|
||||
const uiStore = useUIStore()
|
||||
const editorResources = useEditorResourcesStore()
|
||||
// Keep empty until tenant default_provider is loaded — do not pre-fill 'local'.
|
||||
const localProvider = ref(props.storageProvider)
|
||||
const loading = ref(true)
|
||||
const engineStatus = ref<StorageEngineStatusItem[]>([])
|
||||
const defaultProvider = ref('local')
|
||||
const allowedProviders = ref<string[]>([])
|
||||
const hasAnyConfig = ref(false)
|
||||
|
||||
const engineOptions = computed(() => {
|
||||
const statusByName = new Map(engineStatus.value.map((engine) => [engine.name, engine]))
|
||||
const allowedSet = new Set(allowedProviders.value)
|
||||
const hasStatus = engineStatus.value.length > 0
|
||||
const hasAllowedList = allowedProviders.value.length > 0
|
||||
const resolveState = (name: string, fallbackAvailable = false) => {
|
||||
const status = statusByName.get(name)
|
||||
const allowed = status?.allowed ?? (hasAllowedList ? allowedSet.has(name) : !hasStatus)
|
||||
const available = status?.available ?? fallbackAvailable
|
||||
return {
|
||||
allowed,
|
||||
available,
|
||||
disabled: !allowed || !available,
|
||||
}
|
||||
}
|
||||
|
||||
const local = resolveState('local', true)
|
||||
const minio = resolveState('minio')
|
||||
const cos = resolveState('cos')
|
||||
const tos = resolveState('tos')
|
||||
const s3 = resolveState('s3')
|
||||
const oss = resolveState('oss')
|
||||
const ks3 = resolveState('ks3')
|
||||
const obs = resolveState('obs')
|
||||
|
||||
return [
|
||||
{
|
||||
value: 'local',
|
||||
label: t('kbSettings.storage.engineLocal'),
|
||||
desc: t('kbSettings.storage.engineLocalDesc'),
|
||||
...local,
|
||||
},
|
||||
{
|
||||
value: 'minio',
|
||||
label: 'MinIO',
|
||||
desc: t('kbSettings.storage.engineMinioDesc'),
|
||||
...minio,
|
||||
},
|
||||
{
|
||||
value: 'cos',
|
||||
label: t('kbSettings.storage.engineCos'),
|
||||
desc: t('kbSettings.storage.engineCosDesc'),
|
||||
...cos,
|
||||
},
|
||||
{
|
||||
value: 'tos',
|
||||
label: t('kbSettings.storage.engineTos'),
|
||||
desc: t('kbSettings.storage.engineTosDesc'),
|
||||
...tos,
|
||||
},
|
||||
{
|
||||
value: 's3',
|
||||
label: t('kbSettings.storage.engineS3'),
|
||||
desc: t('kbSettings.storage.engineS3Desc'),
|
||||
...s3,
|
||||
},
|
||||
{
|
||||
value: 'oss',
|
||||
label: t('kbSettings.storage.engineOss'),
|
||||
desc: t('kbSettings.storage.engineOssDesc'),
|
||||
...oss,
|
||||
},
|
||||
{
|
||||
value: 'ks3',
|
||||
label: t('kbSettings.storage.engineKs3'),
|
||||
desc: t('kbSettings.storage.engineKs3Desc'),
|
||||
...ks3,
|
||||
},
|
||||
{
|
||||
value: 'obs',
|
||||
label: t('kbSettings.storage.engineObs'),
|
||||
desc: t('kbSettings.storage.engineObsDesc'),
|
||||
...obs,
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
const showGoSettings = computed(() =>
|
||||
engineOptions.value.some(o => o.disabled)
|
||||
)
|
||||
|
||||
const selectedOption = computed(() =>
|
||||
engineOptions.value.find(o => o.value === localProvider.value)
|
||||
)
|
||||
const loading = ref(false), backends = ref<StorageBackend[]>([]), defaultID = ref(''), localID = ref(props.storageBackendId || '')
|
||||
const selected = computed(() => backends.value.find(item => item.id === localID.value))
|
||||
|
||||
function handleChange() {
|
||||
emit('update:storageProvider', localProvider.value)
|
||||
emit('update:storageBackendId', localID.value)
|
||||
emit('update:storageProvider', selected.value?.provider || props.storageProvider || '')
|
||||
}
|
||||
|
||||
function ensureAllowedProvider() {
|
||||
const resolved = editorResources.resolveUsableStorageProvider(localProvider.value)
|
||||
if (resolved === localProvider.value) return
|
||||
localProvider.value = resolved
|
||||
emit('update:storageProvider', localProvider.value)
|
||||
}
|
||||
|
||||
function goToStorageSettings() {
|
||||
uiStore.closeKBEditor?.()
|
||||
uiStore.openSettings?.('storage')
|
||||
}
|
||||
|
||||
async function load(force = false) {
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
await editorResources.ensureStorageEngine(force)
|
||||
const engines = editorResources.storageStatus
|
||||
engineStatus.value = engines
|
||||
allowedProviders.value = editorResources.storageAllowedProviders
|
||||
defaultProvider.value = editorResources.resolveUsableStorageProvider(
|
||||
editorResources.storageConfig?.default_provider,
|
||||
)
|
||||
const d = editorResources.storageConfig
|
||||
hasAnyConfig.value = !!(d?.local?.path_prefix || d?.minio?.bucket_name || d?.cos?.bucket_name || d?.tos?.bucket_name || d?.s3?.bucket_name || d?.oss?.bucket_name || d?.ks3?.bucket_name || d?.obs?.bucket_name)
|
||||
const parentUnset = !props.storageProvider
|
||||
if (parentUnset) {
|
||||
localProvider.value = defaultProvider.value
|
||||
emit('update:storageProvider', localProvider.value)
|
||||
} else {
|
||||
localProvider.value = props.storageProvider
|
||||
}
|
||||
ensureAllowedProvider()
|
||||
} catch {
|
||||
engineStatus.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
const response = await listStorageBackends()
|
||||
backends.value = (response.data || []).filter(item => item.status === 'active')
|
||||
defaultID.value = response.default_storage_backend_id || ''
|
||||
if (!localID.value) localID.value = defaultID.value || backends.value[0]?.id || ''
|
||||
if (localID.value) handleChange()
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
// Sync only when parent sets an explicit provider (edit mode). Create mode leaves
|
||||
// storageProvider empty until load() applies tenant default_provider.
|
||||
watch(() => props.storageProvider, (v) => {
|
||||
if (v) {
|
||||
localProvider.value = v
|
||||
}
|
||||
})
|
||||
|
||||
function goToSettings() { uiStore.closeKBEditor?.(); uiStore.openSettings?.('storage') }
|
||||
watch(() => props.storageBackendId, value => { if (value) localID.value = value })
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.kb-storage-settings {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 20px;
|
||||
|
||||
h2 {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
margin: 0 0 6px 0;
|
||||
}
|
||||
|
||||
.section-description {
|
||||
font-size: 14px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-inline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.settings-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.setting-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
padding: 16px 0;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: 0 0 40%;
|
||||
max-width: 40%;
|
||||
padding-right: 24px;
|
||||
|
||||
label {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex: 0 0 55%;
|
||||
max-width: 55%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.select-option {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.option-hint {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
margin: 0;
|
||||
line-height: 1.4;
|
||||
|
||||
&.locked-hint {
|
||||
color: var(--td-warning-color);
|
||||
}
|
||||
|
||||
&.change-warning {
|
||||
color: var(--td-warning-color);
|
||||
}
|
||||
}
|
||||
|
||||
.go-settings {
|
||||
font-size: 13px;
|
||||
color: var(--td-brand-color, #0052d9);
|
||||
margin-top: 8px;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
<style scoped lang="less">
|
||||
.section-header{margin-bottom:20px}.section-header h2{font-size:20px;margin:0 0 6px}.section-description,.desc,.option-hint{color:var(--td-text-color-secondary)}
|
||||
.setting-row{display:flex;justify-content:space-between;gap:28px}.setting-info{flex:1}.setting-control{width:45%;min-width:300px}.select-option{display:flex;align-items:center;gap:8px}.option-hint{font-size:12px;margin:8px 0}.change-warning{color:var(--td-warning-color)}.go-settings{font-size:13px;color:var(--td-brand-color)}.loading-inline{display:flex;gap:8px}
|
||||
</style>
|
||||
|
||||
@@ -196,7 +196,7 @@ import WebSearchSettings from './WebSearchSettings.vue'
|
||||
import ChatHistorySettings from './ChatHistorySettings.vue'
|
||||
import VectorStoreSettings from './VectorStoreSettings.vue'
|
||||
import ParserEngineSettings from './ParserEngineSettings.vue'
|
||||
import StorageEngineSettings from './StorageEngineSettings.vue'
|
||||
import StorageEngineSettings from './StorageBackendSettings.vue'
|
||||
import WeKnoraCloudSettings from './WeKnoraCloudSettings.vue'
|
||||
import TenantMembers from './TenantMembers.vue'
|
||||
import SystemSettings from '@/views/system/SystemSettings.vue'
|
||||
|
||||
@@ -0,0 +1,772 @@
|
||||
<template>
|
||||
<div class="storage-backend-settings">
|
||||
<div class="section-header">
|
||||
<div class="section-header__top">
|
||||
<div>
|
||||
<h2>{{ t('settings.storage.title') }}</h2>
|
||||
<p class="section-description">管理文件与图片使用的存储实例;同一种类型可以配置多个实例。</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<t-loading :loading="loading" size="small" class="backend-list-loading">
|
||||
<t-empty
|
||||
v-if="!loading && backends.length === 0 && !authStore.hasRole('admin')"
|
||||
description="尚未配置存储实例"
|
||||
/>
|
||||
<div v-else-if="!loading" class="backend-grid">
|
||||
<div
|
||||
v-for="backend in backends"
|
||||
:key="backend.id"
|
||||
class="backend-card"
|
||||
:class="[
|
||||
`backend-card--${backend.provider}`,
|
||||
{ 'backend-card--clickable': canEdit(backend) },
|
||||
]"
|
||||
:role="canEdit(backend) ? 'button' : undefined"
|
||||
:tabindex="canEdit(backend) ? 0 : undefined"
|
||||
@click="onCardClick($event, backend)"
|
||||
@keydown.enter="onCardClick($event, backend)"
|
||||
>
|
||||
<div
|
||||
class="backend-card__badge"
|
||||
:class="badgeClass(backend.provider)"
|
||||
:style="badgeStyle(backend.provider)"
|
||||
:aria-label="backend.provider"
|
||||
>
|
||||
<img
|
||||
v-if="resolveLogo(backend.provider)?.mode === 'color'"
|
||||
:src="resolveLogo(backend.provider)!.url"
|
||||
:alt="backend.provider"
|
||||
class="backend-card__badge-img"
|
||||
/>
|
||||
<template v-else-if="!resolveLogo(backend.provider)">{{ providerInitial(backend.provider) }}</template>
|
||||
</div>
|
||||
<div class="backend-card__body">
|
||||
<div class="backend-card__header">
|
||||
<h3 class="backend-card__title">{{ backend.name }}</h3>
|
||||
<t-tag v-if="backend.id === defaultID" theme="primary" variant="light" size="small">默认</t-tag>
|
||||
<div v-if="hasActions(backend)" class="backend-card__actions" @click.stop>
|
||||
<t-dropdown
|
||||
:options="getBackendOptions(backend)"
|
||||
placement="bottom-right"
|
||||
attach="body"
|
||||
trigger="click"
|
||||
@click="(data: any) => handleMenuAction(data.value, backend)"
|
||||
>
|
||||
<t-button variant="text" shape="square" size="small" class="backend-card__action-btn">
|
||||
<t-icon name="ellipsis" />
|
||||
</t-button>
|
||||
</t-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
<p class="backend-card__subtitle">
|
||||
<span>{{ backend.provider.toUpperCase() }}</span>
|
||||
<template v-if="backendMeta(backend)">
|
||||
<span class="backend-card__sep">·</span>
|
||||
<span class="backend-card__meta">{{ backendMeta(backend) }}</span>
|
||||
</template>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="authStore.hasRole('admin')"
|
||||
type="button"
|
||||
class="backend-card backend-card--add"
|
||||
@click="openCreate"
|
||||
>
|
||||
<span class="backend-card--add__icon" aria-hidden="true">
|
||||
<add-icon />
|
||||
</span>
|
||||
<span class="backend-card--add__label">添加存储实例</span>
|
||||
</button>
|
||||
</div>
|
||||
</t-loading>
|
||||
|
||||
<SettingDrawer
|
||||
v-model:visible="visible"
|
||||
:title="editing ? '编辑存储实例' : '添加存储实例'"
|
||||
:class="`storage-backend-drawer storage-backend-drawer--${form.provider}`"
|
||||
:confirm-loading="saving"
|
||||
@confirm="save"
|
||||
@cancel="visible = false"
|
||||
>
|
||||
<template #headerIcon>
|
||||
<img
|
||||
v-if="currentLogo?.mode === 'color'"
|
||||
:src="currentLogo.url"
|
||||
:alt="form.provider"
|
||||
class="header-icon__img"
|
||||
/>
|
||||
<span
|
||||
v-else-if="currentLogo?.mode === 'mono'"
|
||||
class="header-icon__mono"
|
||||
:style="monoLogoStyle"
|
||||
/>
|
||||
<span v-else class="header-icon__text">{{ providerInitial(form.provider) }}</span>
|
||||
</template>
|
||||
<template #subtitle>
|
||||
<span>{{ editing ? '修改此存储实例的连接配置。' : '为文件与图片新增一个存储实例。' }}</span>
|
||||
</template>
|
||||
|
||||
<t-form :data="form" layout="vertical">
|
||||
<section class="setting-drawer__section">
|
||||
<h4 class="setting-drawer__section-title">基本信息</h4>
|
||||
<div class="form-item">
|
||||
<label class="form-label required">名称</label>
|
||||
<t-input v-model="form.name" placeholder="例如:生产 COS、归档 COS" clearable />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label required">存储类型</label>
|
||||
<t-select v-model="form.provider" :disabled="!!editing" @change="resetConfig">
|
||||
<t-option
|
||||
v-for="provider in providers"
|
||||
:key="provider"
|
||||
:value="provider"
|
||||
:label="provider.toUpperCase()"
|
||||
/>
|
||||
</t-select>
|
||||
</div>
|
||||
<div v-if="form.provider === 'minio'" class="form-item">
|
||||
<label class="form-label">部署模式</label>
|
||||
<div class="source-options" role="radiogroup">
|
||||
<button
|
||||
type="button"
|
||||
class="source-option"
|
||||
:class="{ 'is-active': form.config.mode !== 'docker' }"
|
||||
:disabled="!!editing"
|
||||
@click="form.config.mode = 'remote'"
|
||||
>
|
||||
<t-icon name="cloud" class="source-option__icon" />
|
||||
<span class="source-option__label">远程实例</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="source-option"
|
||||
:class="{ 'is-active': form.config.mode === 'docker' }"
|
||||
:disabled="!!editing"
|
||||
@click="form.config.mode = 'docker'"
|
||||
>
|
||||
<t-icon name="server" class="source-option__icon" />
|
||||
<span class="source-option__label">环境变量</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="setting-drawer__section">
|
||||
<h4 class="setting-drawer__section-title">连接配置</h4>
|
||||
<div v-if="needsEndpoint" class="form-item">
|
||||
<label class="form-label required">Endpoint</label>
|
||||
<t-input
|
||||
v-model="form.config.endpoint"
|
||||
:disabled="!!editing"
|
||||
:placeholder="form.provider === 'minio' ? 'storage.example.com:9000' : 'https://storage.example.com'"
|
||||
clearable
|
||||
/>
|
||||
</div>
|
||||
<div v-if="needsRegion" class="form-item">
|
||||
<label class="form-label required">Region</label>
|
||||
<t-input v-model="form.config.region" :disabled="!!editing" clearable />
|
||||
</div>
|
||||
<template v-if="needsCredentials">
|
||||
<div class="form-item">
|
||||
<label class="form-label required">Access Key / Secret ID</label>
|
||||
<t-input v-model="form.config.access_key_id" placeholder="***" clearable>
|
||||
<template #prefix-icon><t-icon name="lock-on" /></template>
|
||||
</t-input>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label required">Secret Key</label>
|
||||
<t-input v-model="form.config.secret_access_key" type="password" placeholder="***" clearable>
|
||||
<template #prefix-icon><t-icon name="lock-on" /></template>
|
||||
</t-input>
|
||||
</div>
|
||||
</template>
|
||||
<div v-if="form.provider !== 'local'" class="form-item">
|
||||
<label class="form-label required">Bucket</label>
|
||||
<t-input v-model="form.config.bucket_name" :disabled="!!editing" clearable />
|
||||
</div>
|
||||
<div v-if="form.provider === 'cos'" class="form-item">
|
||||
<label class="form-label">App ID</label>
|
||||
<t-input v-model="form.config.app_id" :disabled="!!editing" placeholder="可选" clearable />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="setting-drawer__section">
|
||||
<h4 class="setting-drawer__section-title">高级选项</h4>
|
||||
<div class="form-item">
|
||||
<label class="form-label">路径前缀</label>
|
||||
<t-input v-model="form.config.path_prefix" :disabled="!!editing" placeholder="weknora/" clearable />
|
||||
</div>
|
||||
<div v-if="form.provider === 'minio'" class="form-item">
|
||||
<div class="vision-toggle">
|
||||
<t-switch v-model="form.config.use_ssl" />
|
||||
<span class="form-desc form-desc--inline">使用 HTTPS 访问 MinIO</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="form.provider === 's3'" class="form-item">
|
||||
<div class="vision-toggle">
|
||||
<t-switch v-model="form.config.force_path_style" />
|
||||
<span class="form-desc form-desc--inline">使用 Path Style</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="form.provider === 'oss'" class="form-item">
|
||||
<div class="vision-toggle">
|
||||
<t-switch v-model="form.config.use_temp_bucket" />
|
||||
<span class="form-desc form-desc--inline">使用临时桶</span>
|
||||
</div>
|
||||
</div>
|
||||
<template v-if="['cos', 'tos'].includes(form.provider) || (form.provider === 'oss' && form.config.use_temp_bucket)">
|
||||
<div class="form-item">
|
||||
<label class="form-label">临时桶</label>
|
||||
<t-input v-model="form.config.temp_bucket_name" placeholder="可选,用于临时文件" clearable />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">临时桶 Region</label>
|
||||
<t-input v-model="form.config.temp_region" placeholder="留空时使用主 Region" clearable />
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
</t-form>
|
||||
|
||||
<template #footer-left>
|
||||
<t-button variant="outline" :loading="testing" @click="testRaw">
|
||||
<template #icon>
|
||||
<t-icon v-if="!testing && rawTestResult === 'ok'" name="check-circle-filled" class="status-icon available" />
|
||||
<t-icon v-else-if="!testing && rawTestResult === 'error'" name="close-circle-filled" class="status-icon unavailable" />
|
||||
</template>
|
||||
测试连接
|
||||
</t-button>
|
||||
</template>
|
||||
</SettingDrawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { DialogPlugin, MessagePlugin } from 'tdesign-vue-next'
|
||||
import { AddIcon } from 'tdesign-icons-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import SettingDrawer from '@/components/settings/SettingDrawer.vue'
|
||||
import { providerLogo } from './providerLogos'
|
||||
import {
|
||||
createStorageBackend, deleteStorageBackend, listStorageBackends, listStorageBackendTypes,
|
||||
setDefaultStorageBackend, testStorageBackend, testStorageBackendByID, updateStorageBackend,
|
||||
type StorageBackend, type StorageBackendConfig,
|
||||
} from '@/api/storage-backend'
|
||||
|
||||
const { t } = useI18n()
|
||||
const authStore = useAuthStore()
|
||||
const loading = ref(false), saving = ref(false), testing = ref(false), visible = ref(false)
|
||||
const backends = ref<StorageBackend[]>([]), providers = ref<string[]>([]), defaultID = ref('')
|
||||
const editing = ref<StorageBackend | null>(null)
|
||||
const rawTestResult = ref<'ok' | 'error' | null>(null)
|
||||
const blankConfig = (): StorageBackendConfig => ({ mode: 'remote', endpoint: '', region: '', access_key_id: '', secret_access_key: '', bucket_name: '', path_prefix: '', use_ssl: true })
|
||||
const form = reactive<{ name: string; provider: string; config: StorageBackendConfig }>({ name: '', provider: 'local', config: blankConfig() })
|
||||
const needsEndpoint = computed(() => !['local', 'cos'].includes(form.provider) && !(form.provider === 'minio' && form.config.mode === 'docker'))
|
||||
const needsRegion = computed(() => !['local', 'minio'].includes(form.provider))
|
||||
const needsCredentials = computed(() => form.provider !== 'local' && !(form.provider === 'minio' && form.config.mode === 'docker'))
|
||||
|
||||
const resolveLogo = (provider: string) => providerLogo('storage', provider)
|
||||
const providerInitial = (provider: string) => (provider || '?').trim().charAt(0).toUpperCase() || '?'
|
||||
const badgeClass = (provider: string) => {
|
||||
const mode = resolveLogo(provider)?.mode
|
||||
return {
|
||||
'backend-card__badge--logo': !!mode,
|
||||
'backend-card__badge--color': mode === 'color',
|
||||
'backend-card__badge--mono': mode === 'mono',
|
||||
}
|
||||
}
|
||||
const badgeStyle = (provider: string): Record<string, string> => {
|
||||
const logo = resolveLogo(provider)
|
||||
return logo?.mode === 'mono' ? { '--logo-url': `url("${logo.url}")` } : {}
|
||||
}
|
||||
|
||||
const currentLogo = computed(() => providerLogo('storage', form.provider))
|
||||
const monoLogoStyle = computed((): Record<string, string> => {
|
||||
const logo = currentLogo.value
|
||||
if (!logo || logo.mode !== 'mono') return {}
|
||||
return { '--logo-url': `url("${logo.url}")` }
|
||||
})
|
||||
|
||||
function backendMeta(backend: StorageBackend): string {
|
||||
return backend.config.endpoint || backend.config.bucket_name || backend.config.path_prefix || '本地存储'
|
||||
}
|
||||
|
||||
const canEdit = (backend: StorageBackend) => authStore.hasRole('admin') && backend.source !== 'env'
|
||||
const canDelete = (backend: StorageBackend) => authStore.hasRole('admin') && backend.source !== 'env' && !backend.legacy_alias
|
||||
const canSetDefault = (backend: StorageBackend) => backend.id !== defaultID.value && authStore.hasRole('admin')
|
||||
// 测试连接对所有可见用户开放,因此每张卡至少有一个动作。
|
||||
const hasActions = (_backend: StorageBackend) => true
|
||||
|
||||
function getBackendOptions(backend: StorageBackend) {
|
||||
const options: { content: string; value: string; theme?: string }[] = []
|
||||
options.push({ content: '测试连接', value: 'test' })
|
||||
if (canSetDefault(backend)) options.push({ content: '设为默认', value: 'default' })
|
||||
if (canEdit(backend)) options.push({ content: '编辑', value: 'edit' })
|
||||
if (canDelete(backend)) options.push({ content: '删除', value: 'delete', theme: 'error' })
|
||||
return options
|
||||
}
|
||||
|
||||
function handleMenuAction(value: string, backend: StorageBackend) {
|
||||
if (value === 'test') testSaved(backend)
|
||||
else if (value === 'default') makeDefault(backend)
|
||||
else if (value === 'edit') openEdit(backend)
|
||||
else if (value === 'delete') remove(backend)
|
||||
}
|
||||
|
||||
function onCardClick(event: Event, backend: StorageBackend) {
|
||||
if (!canEdit(backend)) return
|
||||
const target = event.target as HTMLElement | null
|
||||
if (target?.closest('.backend-card__actions')) return
|
||||
openEdit(backend)
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const [list, types] = await Promise.all([listStorageBackends(), listStorageBackendTypes()])
|
||||
backends.value = list.data || []; defaultID.value = list.default_storage_backend_id || ''; providers.value = types.data || []
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
function resetConfig() { form.config = blankConfig(); rawTestResult.value = null }
|
||||
function openCreate() { editing.value = null; form.name = ''; form.provider = providers.value[0] || 'local'; form.config = blankConfig(); rawTestResult.value = null; visible.value = true }
|
||||
function openEdit(backend: StorageBackend) { editing.value = backend; form.name = backend.name; form.provider = backend.provider; form.config = { ...blankConfig(), ...backend.config }; rawTestResult.value = null; visible.value = true }
|
||||
async function testRaw() {
|
||||
testing.value = true
|
||||
rawTestResult.value = null
|
||||
try {
|
||||
const r: any = editing.value ? await testStorageBackendByID(editing.value.id) : await testStorageBackend(form)
|
||||
if (r.success) { rawTestResult.value = 'ok'; MessagePlugin.success('连接成功') }
|
||||
else { rawTestResult.value = 'error'; MessagePlugin.error(r.error || '连接失败') }
|
||||
} finally { testing.value = false }
|
||||
}
|
||||
async function testSaved(backend: StorageBackend) { const r: any = await testStorageBackendByID(backend.id); r.success ? MessagePlugin.success('连接成功') : MessagePlugin.error(r.error || '连接失败') }
|
||||
async function save() {
|
||||
if (!form.name.trim()) { MessagePlugin.warning('请输入名称'); return }
|
||||
saving.value = true
|
||||
try {
|
||||
const payload = { name: form.name.trim(), provider: form.provider, config: { ...form.config } }
|
||||
if (editing.value) await updateStorageBackend(editing.value.id, payload); else await createStorageBackend(payload)
|
||||
MessagePlugin.success('保存成功'); visible.value = false; await load()
|
||||
} catch (e: any) { MessagePlugin.error(e?.message || '保存失败') } finally { saving.value = false }
|
||||
}
|
||||
async function makeDefault(backend: StorageBackend) { await setDefaultStorageBackend(backend.id); defaultID.value = backend.id; MessagePlugin.success('默认存储已更新') }
|
||||
function remove(backend: StorageBackend) {
|
||||
const dialog = DialogPlugin.confirm({ header: '删除存储实例', body: `确定删除“${backend.name}”吗?`, onConfirm: async () => { dialog.destroy(); try { await deleteStorageBackend(backend.id); await load(); MessagePlugin.success('已删除') } catch (e: any) { MessagePlugin.error(e?.message || '删除失败') } }, onCancel: () => dialog.destroy() })
|
||||
}
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.storage-backend-settings {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 28px;
|
||||
|
||||
h2 {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.section-description {
|
||||
font-size: 14px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
}
|
||||
|
||||
.section-header__top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.backend-list-loading {
|
||||
min-height: 120px;
|
||||
}
|
||||
|
||||
.backend-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
|
||||
gap: 12px;
|
||||
|
||||
.backend-card--add {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.backend-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 10px;
|
||||
background: var(--td-bg-color-container);
|
||||
transition: border-color 0.18s ease, box-shadow 0.18s ease;
|
||||
min-width: 0;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--td-brand-color-3, var(--td-brand-color));
|
||||
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
|
||||
}
|
||||
|
||||
&--clickable {
|
||||
cursor: pointer;
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--td-brand-color);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
&--add {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 68px;
|
||||
border-style: dashed;
|
||||
background: transparent;
|
||||
color: var(--td-text-color-placeholder);
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
text-align: center;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
color: var(--td-brand-color);
|
||||
border-color: var(--td-brand-color);
|
||||
background: color-mix(in srgb, var(--td-brand-color) 6%, transparent);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--td-brand-color);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 8px;
|
||||
background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
|
||||
color: var(--td-brand-color);
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.backend-card__badge {
|
||||
flex-shrink: 0;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 9px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 1px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
background: rgba(0, 82, 217, 0.1);
|
||||
color: #0052D9;
|
||||
}
|
||||
|
||||
.backend-card .backend-card__badge--logo {
|
||||
background: var(--td-bg-color-container, #fff);
|
||||
box-shadow: inset 0 0 0 1px var(--td-component-stroke);
|
||||
}
|
||||
|
||||
.backend-card .backend-card__badge--mono::before {
|
||||
content: '';
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-color: currentColor;
|
||||
-webkit-mask-image: var(--logo-url);
|
||||
-webkit-mask-position: center;
|
||||
-webkit-mask-repeat: no-repeat;
|
||||
-webkit-mask-size: contain;
|
||||
mask-image: var(--logo-url);
|
||||
mask-position: center;
|
||||
mask-repeat: no-repeat;
|
||||
mask-size: contain;
|
||||
}
|
||||
|
||||
.backend-card__badge-img {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
object-fit: contain;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.backend-card--local .backend-card__badge { background: rgba(70, 70, 70, 0.1); color: #464646; }
|
||||
.backend-card--minio .backend-card__badge { background: rgba(225, 38, 38, 0.12); color: #C0382B; }
|
||||
.backend-card--cos .backend-card__badge { background: rgba(0, 82, 217, 0.1); color: #0052D9; }
|
||||
.backend-card--tos .backend-card__badge { background: rgba(0, 137, 255, 0.12); color: #0089FF; }
|
||||
.backend-card--s3 .backend-card__badge { background: rgba(255, 153, 0, 0.12); color: #D97706; }
|
||||
.backend-card--oss .backend-card__badge { background: rgba(255, 90, 0, 0.12); color: #E55A00; }
|
||||
.backend-card--ks3 .backend-card__badge { background: rgba(7, 192, 95, 0.12); color: #07A050; }
|
||||
.backend-card--obs .backend-card__badge { background: rgba(206, 17, 38, 0.1); color: #CE1126; }
|
||||
|
||||
.backend-card__body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.backend-card__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.backend-card__title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
color: var(--td-text-color-primary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.backend-card__subtitle {
|
||||
margin: 2px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: var(--td-text-color-secondary);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.backend-card__sep {
|
||||
margin: 0 6px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.backend-card__meta {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.backend-card__actions {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.backend-card__action-btn {
|
||||
flex-shrink: 0;
|
||||
padding: 2px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.backend-card:hover .backend-card__action-btn,
|
||||
.backend-card:focus-within .backend-card__action-btn {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
// ---- 抽屉头部图标 ----
|
||||
.header-icon__img {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
object-fit: contain;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.header-icon__mono {
|
||||
display: inline-block;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-color: currentColor;
|
||||
-webkit-mask-image: var(--logo-url);
|
||||
-webkit-mask-position: center;
|
||||
-webkit-mask-repeat: no-repeat;
|
||||
-webkit-mask-size: contain;
|
||||
mask-image: var(--logo-url);
|
||||
mask-position: center;
|
||||
mask-repeat: no-repeat;
|
||||
mask-size: contain;
|
||||
}
|
||||
|
||||
.header-icon__text {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
// ---- 抽屉表单 ----
|
||||
.form-item {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
line-height: 1.4;
|
||||
|
||||
&.required::before {
|
||||
content: '*';
|
||||
color: var(--td-error-color);
|
||||
margin-right: 4px;
|
||||
font-weight: 500;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.form-desc {
|
||||
margin: 4px 0 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: var(--td-text-color-placeholder);
|
||||
|
||||
&--inline {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.t-input),
|
||||
:deep(.t-select),
|
||||
:deep(.t-textarea) {
|
||||
width: 100%;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.vision-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
// ---- MinIO 部署模式 pill segmented ----
|
||||
.source-options {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 3px;
|
||||
background: var(--td-bg-color-component);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.source-option {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 5px 12px;
|
||||
height: 28px;
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
line-height: 1;
|
||||
transition: all 0.15s ease;
|
||||
|
||||
&:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
&:hover:not(.is-active):not(:disabled) {
|
||||
color: var(--td-text-color-primary);
|
||||
background: var(--td-bg-color-container-hover);
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
background: var(--td-bg-color-container);
|
||||
border-color: var(--td-brand-color);
|
||||
color: var(--td-brand-color);
|
||||
font-weight: 500;
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
||||
}
|
||||
}
|
||||
|
||||
.source-option__icon {
|
||||
font-size: 14px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.source-option__label {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.status-icon {
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
|
||||
&.available {
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
&.unavailable {
|
||||
color: var(--td-error-color);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<!--
|
||||
Non-scoped: drawer header icon coloring per provider, mirroring the list
|
||||
card badge colors. Namespaced under .storage-backend-drawer--{id}.
|
||||
-->
|
||||
<style lang="less">
|
||||
.storage-backend-drawer .setting-drawer__header-icon:has(.header-icon__img) {
|
||||
background: var(--td-bg-color-container, #fff);
|
||||
box-shadow: inset 0 0 0 1px var(--td-component-stroke);
|
||||
}
|
||||
|
||||
.storage-backend-drawer--local .setting-drawer__header-icon { background: rgba(70, 70, 70, 0.1); color: #464646; }
|
||||
.storage-backend-drawer--minio .setting-drawer__header-icon { background: rgba(225, 38, 38, 0.12); color: #C0382B; }
|
||||
.storage-backend-drawer--cos .setting-drawer__header-icon { background: rgba(0, 82, 217, 0.1); color: #0052D9; }
|
||||
.storage-backend-drawer--tos .setting-drawer__header-icon { background: rgba(0, 137, 255, 0.12); color: #0089FF; }
|
||||
.storage-backend-drawer--s3 .setting-drawer__header-icon { background: rgba(255, 153, 0, 0.12); color: #D97706; }
|
||||
.storage-backend-drawer--oss .setting-drawer__header-icon { background: rgba(255, 90, 0, 0.12); color: #E55A00; }
|
||||
.storage-backend-drawer--ks3 .setting-drawer__header-icon { background: rgba(7, 192, 95, 0.12); color: #07A050; }
|
||||
.storage-backend-drawer--obs .setting-drawer__header-icon { background: rgba(206, 17, 38, 0.1); color: #CE1126; }
|
||||
</style>
|
||||
@@ -113,7 +113,7 @@
|
||||
- color logo(如 MinIO/AWS): 直接 <img>,保留品牌彩色
|
||||
- mono logo(mask-image): 通过 ::before + currentColor 染色,颜色由
|
||||
.storage-engine-drawer--{id} :deep(.setting-drawer__header-icon) 决定
|
||||
- 无 logo(local): 渲染首字母作为 monogram
|
||||
- 无 logo: 渲染首字母作为 monogram
|
||||
-->
|
||||
<template v-if="currentEngine" #headerIcon>
|
||||
<img
|
||||
|
||||
Reference in New Issue
Block a user