feat(datasource): add RSS feed connector with full-text ingestion
Enable private RSS feeds as a knowledge base data source with custom headers, article body fetching, and Markdown output for incremental sync.
This commit is contained in:
@@ -3948,20 +3948,15 @@ const handleSave = async () => {
|
||||
|
||||
.nav-badge {
|
||||
flex-shrink: 0;
|
||||
min-width: 18px;
|
||||
margin-left: 2px;
|
||||
padding: 0 6px;
|
||||
border-radius: 10px;
|
||||
border-radius: 8px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
.nav-item.active & {
|
||||
background: color-mix(in srgb, var(--td-brand-color) 18%, transparent);
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
font-size: 11px;
|
||||
line-height: 16px;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.section--prompts {
|
||||
|
||||
@@ -1565,20 +1565,15 @@ watch(
|
||||
|
||||
.nav-badge {
|
||||
flex-shrink: 0;
|
||||
min-width: 18px;
|
||||
margin-left: 2px;
|
||||
padding: 0 6px;
|
||||
border-radius: 10px;
|
||||
border-radius: 8px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
.nav-item.active & {
|
||||
background: color-mix(in srgb, var(--td-brand-color) 18%, transparent);
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
font-size: 11px;
|
||||
line-height: 16px;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.settings-content {
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
} from '@/api/datasource'
|
||||
import SettingDrawer from '@/components/settings/SettingDrawer.vue'
|
||||
import DataSourceTypeIcon from './DataSourceTypeIcon.vue'
|
||||
import { getDatasourceIconUrl } from './datasourceIcons'
|
||||
|
||||
const props = defineProps<{
|
||||
kbId: string
|
||||
@@ -102,10 +103,43 @@ function cancelReplaceCredentials() {
|
||||
replaceCredentialsMode.value = false
|
||||
pendingRemoveCredentials.value = false
|
||||
form.value.config.credentials = {}
|
||||
rssAuthHeaders.value = []
|
||||
testResult.value = credentialsConfigured.value ? 'success' : ''
|
||||
testErrorMsg.value = ''
|
||||
}
|
||||
|
||||
interface CustomHeaderItem {
|
||||
key: string
|
||||
value: string
|
||||
}
|
||||
|
||||
const rssAuthHeaders = ref<CustomHeaderItem[]>([])
|
||||
|
||||
function serializeAuthHeaders(items: CustomHeaderItem[]): string {
|
||||
return items
|
||||
.filter(h => h.key.trim())
|
||||
.map(h => `${h.key.trim()}: ${h.value}`)
|
||||
.join('\n')
|
||||
}
|
||||
|
||||
function syncRssAuthHeadersToCredentials() {
|
||||
if (form.value.type !== 'rss') return
|
||||
const serialized = serializeAuthHeaders(rssAuthHeaders.value)
|
||||
if (serialized) {
|
||||
form.value.config.credentials.auth_headers = serialized
|
||||
} else {
|
||||
delete form.value.config.credentials.auth_headers
|
||||
}
|
||||
}
|
||||
|
||||
function addRssAuthHeader() {
|
||||
rssAuthHeaders.value.push({ key: '', value: '' })
|
||||
}
|
||||
|
||||
function removeRssAuthHeader(idx: number) {
|
||||
rssAuthHeaders.value.splice(idx, 1)
|
||||
}
|
||||
|
||||
function needsConnectionTest(): boolean {
|
||||
return !(isEdit.value && credentialsConfigured.value && !replaceCredentialsMode.value)
|
||||
}
|
||||
@@ -289,7 +323,16 @@ interface ConnectorDef {
|
||||
permissionDocUrl: string
|
||||
permissionPageUrl: string
|
||||
requiredPermissions: string[]
|
||||
fields: { key: string; labelKey: string; placeholder: string; secret?: boolean; optional?: boolean; hintKey?: string }[]
|
||||
fields: {
|
||||
key: string
|
||||
labelKey: string
|
||||
placeholder: string
|
||||
secret?: boolean
|
||||
optional?: boolean
|
||||
hintKey?: string
|
||||
multiline?: boolean
|
||||
fieldType?: 'custom_headers'
|
||||
}[]
|
||||
}
|
||||
|
||||
const connectorDefs = computed<ConnectorDef[]>(() => [
|
||||
@@ -336,6 +379,18 @@ const connectorDefs = computed<ConnectorDef[]>(() => [
|
||||
{ key: 'base_url', labelKey: 'datasource.field.baseUrl', placeholder: 'https://www.yuque.com', optional: true, hintKey: 'datasource.field.baseUrlHint' },
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'rss',
|
||||
available: true,
|
||||
docUrl: '',
|
||||
permissionDocUrl: '',
|
||||
permissionPageUrl: '',
|
||||
requiredPermissions: [],
|
||||
fields: [
|
||||
{ key: 'feed_urls', labelKey: 'datasource.field.feedUrls', placeholder: 'https://example.com/feed.xml', multiline: true, hintKey: 'datasource.field.feedUrlsHint' },
|
||||
{ key: 'auth_headers', labelKey: 'datasource.field.authHeaders', placeholder: '', optional: true, hintKey: 'datasource.field.authHeadersHint', fieldType: 'custom_headers' },
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
@@ -366,6 +421,7 @@ watch(visible, async (v) => {
|
||||
loadedChildrenIds.value = new Set()
|
||||
loadingChildrenIds.value = new Set()
|
||||
treeFullyLoaded.value = false
|
||||
rssAuthHeaders.value = []
|
||||
|
||||
if (isEdit.value && props.dataSource) {
|
||||
// Reset edit/replace toggle every open so an aborted replace doesn't
|
||||
@@ -416,19 +472,34 @@ watch(
|
||||
{ deep: true },
|
||||
)
|
||||
|
||||
watch(
|
||||
rssAuthHeaders,
|
||||
() => {
|
||||
syncRssAuthHeadersToCredentials()
|
||||
if (needsConnectionTest()) {
|
||||
testResult.value = ''
|
||||
testErrorMsg.value = ''
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
)
|
||||
|
||||
function selectType(def: ConnectorDef) {
|
||||
if (!def.available) return
|
||||
form.value.type = def.type
|
||||
form.value.name = t(`datasource.connector.${def.type}`)
|
||||
form.value.config.credentials = {}
|
||||
rssAuthHeaders.value = []
|
||||
step.value = 1
|
||||
}
|
||||
|
||||
// --- Test connection (stateless, no DB write) ---
|
||||
async function testConnection() {
|
||||
syncRssAuthHeadersToCredentials()
|
||||
if (!isEdit.value || !credentialsConfigured.value || replaceCredentialsMode.value) {
|
||||
const fields = currentDef.value?.fields || []
|
||||
for (const f of fields) {
|
||||
if (f.optional) continue
|
||||
if (f.optional || f.fieldType === 'custom_headers') continue
|
||||
if (!form.value.config.credentials[f.key]) {
|
||||
MessagePlugin.warning(`${t(f.labelKey)} ${t('datasource.isRequired')}`)
|
||||
return
|
||||
@@ -602,13 +673,14 @@ function toggleResource(id: string) {
|
||||
}
|
||||
|
||||
function validateStep1Fields(): boolean {
|
||||
syncRssAuthHeadersToCredentials()
|
||||
if (isEdit.value && credentialsConfigured.value && !replaceCredentialsMode.value) {
|
||||
return true
|
||||
}
|
||||
|
||||
const fields = currentDef.value?.fields || []
|
||||
for (const f of fields) {
|
||||
if (f.optional) continue
|
||||
if (f.optional || f.fieldType === 'custom_headers') continue
|
||||
if (!form.value.config.credentials[f.key]) {
|
||||
MessagePlugin.warning(`${t(f.labelKey)} ${t('datasource.isRequired')}`)
|
||||
return false
|
||||
@@ -657,6 +729,7 @@ function buildConfigPayload(): Record<string, unknown> {
|
||||
// the whole submit on failure so we don't leave the row partially saved.
|
||||
async function commitCredentialsIfNeeded(dsId: string): Promise<boolean> {
|
||||
if (!isEdit.value || !replaceCredentialsMode.value) return true
|
||||
syncRssAuthHeadersToCredentials()
|
||||
const filled = Object.entries(form.value.config.credentials).filter(
|
||||
([, v]) => typeof v === 'string' ? v !== '' : v != null,
|
||||
)
|
||||
@@ -666,6 +739,7 @@ async function commitCredentialsIfNeeded(dsId: string): Promise<boolean> {
|
||||
credentialsConfigured.value = true
|
||||
replaceCredentialsMode.value = false
|
||||
form.value.config.credentials = {}
|
||||
rssAuthHeaders.value = []
|
||||
return true
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || e?.error || t('credential.saveFailed'))
|
||||
@@ -719,6 +793,10 @@ async function handleSubmit() {
|
||||
}
|
||||
|
||||
emit('saved')
|
||||
// Clear before close — otherwise the visible watcher treats the just-saved
|
||||
// row as an abandoned temp draft and DELETEs it (loadResources creates the
|
||||
// row early at step 2 with tempDsId).
|
||||
tempDsId.value = ''
|
||||
visible.value = false
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || e?.error || t('datasource.saveFailed'))
|
||||
@@ -822,6 +900,7 @@ const drawerConfirmText = computed(() => {
|
||||
v-model:visible="visible"
|
||||
:title="drawerTitle"
|
||||
:description="drawerDescription"
|
||||
:class="form.type ? `datasource-editor-drawer datasource-editor-drawer--${form.type}` : 'datasource-editor-drawer'"
|
||||
:hide-footer="step === 0"
|
||||
:confirm-text="drawerConfirmText"
|
||||
:confirm-loading="submitting || (step === 1 && testing)"
|
||||
@@ -830,8 +909,12 @@ const drawerConfirmText = computed(() => {
|
||||
@confirm="handleDrawerConfirm"
|
||||
@cancel="handleClose"
|
||||
>
|
||||
<template v-if="form.type" #headerIcon>
|
||||
<DataSourceTypeIcon :type="form.type" :size="20" />
|
||||
<template v-if="form.type && getDatasourceIconUrl(form.type)" #headerIcon>
|
||||
<img
|
||||
:src="getDatasourceIconUrl(form.type)"
|
||||
:alt="form.type"
|
||||
class="datasource-header-icon__img"
|
||||
>
|
||||
</template>
|
||||
|
||||
<template v-if="step === 1" #footer-left>
|
||||
@@ -879,7 +962,10 @@ const drawerConfirmText = computed(() => {
|
||||
:key="i"
|
||||
:class="['ds-step', { active: step === i, done: step > i }]"
|
||||
>
|
||||
<span class="ds-step-num">{{ step > i ? '✓' : i + 1 }}</span>
|
||||
<span class="ds-step-num">
|
||||
<t-icon v-if="step > i" name="check" class="ds-step-check" />
|
||||
<template v-else>{{ i + 1 }}</template>
|
||||
</span>
|
||||
<span class="ds-step-title">{{ title }}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -907,10 +993,10 @@ const drawerConfirmText = computed(() => {
|
||||
</section>
|
||||
|
||||
<!-- Step 1: Credentials -->
|
||||
<section v-if="step === 1" class="setting-drawer__section">
|
||||
<template v-if="step === 1">
|
||||
<div
|
||||
v-if="currentDef && currentDef.requiredPermissions.length > 0"
|
||||
class="ds-setup-guide"
|
||||
class="ds-setup-guide ds-setup-guide--standalone"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
@@ -970,29 +1056,33 @@ const drawerConfirmText = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ t('datasource.nameLabel') }}</label>
|
||||
<t-input v-model="form.name" :placeholder="t('datasource.namePlaceholder')" />
|
||||
</div>
|
||||
<section class="setting-drawer__section">
|
||||
<h4 class="setting-drawer__section-title">{{ t('datasource.sectionBasic') }}</h4>
|
||||
|
||||
<div v-if="currentDef?.docUrl" class="inline-alert">
|
||||
<t-icon name="info-circle-filled" class="inline-alert__icon" />
|
||||
<span class="inline-alert__text">{{ t('datasource.docHint') }}</span>
|
||||
<a
|
||||
:href="currentDef.docUrl"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
class="inline-alert__action doc-link"
|
||||
>
|
||||
{{ t('datasource.openDoc') }}
|
||||
<t-icon name="link" class="link-icon" />
|
||||
</a>
|
||||
</div>
|
||||
<div v-if="currentDef?.docUrl" class="inline-alert">
|
||||
<t-icon name="info-circle-filled" class="inline-alert__icon" />
|
||||
<span class="inline-alert__text">{{ t('datasource.docHint') }}</span>
|
||||
<a
|
||||
:href="currentDef.docUrl"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
class="inline-alert__action doc-link"
|
||||
>
|
||||
{{ t('datasource.openDoc') }}
|
||||
<t-icon name="link" class="link-icon" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ t('datasource.credentialsLabel') }}</label>
|
||||
<div class="form-item">
|
||||
<label class="form-label required">{{ t('datasource.nameLabel') }}</label>
|
||||
<t-input v-model="form.name" :placeholder="t('datasource.namePlaceholder')" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<template v-if="isEdit && credentialsConfigured && !replaceCredentialsMode">
|
||||
<section class="setting-drawer__section">
|
||||
<h4 class="setting-drawer__section-title">{{ t('datasource.credentialsLabel') }}</h4>
|
||||
|
||||
<div v-if="isEdit && credentialsConfigured && !replaceCredentialsMode" class="form-item">
|
||||
<div
|
||||
class="credential-faux-input"
|
||||
:class="{ 'is-confirm-remove': pendingRemoveCredentials }"
|
||||
@@ -1031,54 +1121,103 @@ const drawerConfirmText = computed(() => {
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else-if="isEdit && !credentialsConfigured && !replaceCredentialsMode"
|
||||
class="credential-faux-input is-empty"
|
||||
@click="enterReplaceCredentials"
|
||||
class="form-item"
|
||||
>
|
||||
<t-icon name="lock-on" class="credential-status-icon muted" />
|
||||
<span class="credential-faux-text muted">{{ t('credential.unconfigured') }}</span>
|
||||
<div class="credential-actions">
|
||||
<t-button size="small" variant="text" theme="primary" @click.stop="enterReplaceCredentials">
|
||||
{{ t('credential.configure') }}
|
||||
</t-button>
|
||||
<div
|
||||
class="credential-faux-input is-empty"
|
||||
@click="enterReplaceCredentials"
|
||||
>
|
||||
<t-icon name="lock-on" class="credential-status-icon muted" />
|
||||
<span class="credential-faux-text muted">{{ t('credential.unconfigured') }}</span>
|
||||
<div class="credential-actions">
|
||||
<t-button size="small" variant="text" theme="primary" @click.stop="enterReplaceCredentials">
|
||||
{{ t('credential.configure') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="credentialsInputVisible" class="credential-edit">
|
||||
<template v-else-if="credentialsInputVisible">
|
||||
<div
|
||||
v-for="field in currentDef?.fields || []"
|
||||
:key="field.key"
|
||||
class="credential-field"
|
||||
class="form-item"
|
||||
>
|
||||
<label
|
||||
v-if="(currentDef?.fields?.length || 0) > 1"
|
||||
class="credential-field-label"
|
||||
>
|
||||
{{ t(field.labelKey) }}
|
||||
<span v-if="!field.optional" class="required-mark">*</span>
|
||||
</label>
|
||||
<t-input
|
||||
v-model="form.config.credentials[field.key]"
|
||||
:placeholder="field.placeholder || t('credential.inputPlaceholder')"
|
||||
:type="field.secret ? 'password' : 'text'"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
>
|
||||
<template v-if="field.secret" #prefix-icon><t-icon name="lock-on" /></template>
|
||||
</t-input>
|
||||
<p v-if="field.hintKey" class="form-desc">{{ t(field.hintKey) }}</p>
|
||||
<template v-if="field.fieldType === 'custom_headers'">
|
||||
<div class="custom-headers-header">
|
||||
<label class="form-label" style="margin-bottom: 0;">{{ t(field.labelKey) }}</label>
|
||||
<t-button variant="text" size="small" theme="primary" @click="addRssAuthHeader">
|
||||
<template #icon><t-icon name="add" /></template>
|
||||
{{ t('model.editor.customHeadersAdd') }}
|
||||
</t-button>
|
||||
</div>
|
||||
<p v-if="field.hintKey" class="form-desc custom-headers-desc">{{ t(field.hintKey) }}</p>
|
||||
<div v-if="rssAuthHeaders.length > 0" class="custom-headers-list">
|
||||
<div v-for="(item, idx) in rssAuthHeaders" :key="idx" class="custom-header-row">
|
||||
<t-input
|
||||
v-model="item.key"
|
||||
:placeholder="t('model.editor.customHeadersKeyPlaceholder')"
|
||||
class="custom-header-key"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
<t-input
|
||||
v-model="item.value"
|
||||
:placeholder="t('model.editor.customHeadersValuePlaceholder')"
|
||||
class="custom-header-value"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
<t-button
|
||||
variant="text"
|
||||
shape="square"
|
||||
size="small"
|
||||
class="custom-header-remove"
|
||||
:aria-label="t('common.delete')"
|
||||
@click="removeRssAuthHeader(idx)"
|
||||
>
|
||||
<t-icon name="close" />
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<label class="form-label" :class="{ required: !field.optional }">
|
||||
{{ t(field.labelKey) }}
|
||||
</label>
|
||||
<t-textarea
|
||||
v-if="field.multiline"
|
||||
v-model="form.config.credentials[field.key]"
|
||||
:placeholder="field.placeholder || t('credential.inputPlaceholder')"
|
||||
:autosize="{ minRows: 2, maxRows: 6 }"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
<t-input
|
||||
v-else
|
||||
v-model="form.config.credentials[field.key]"
|
||||
:placeholder="field.placeholder || t('credential.inputPlaceholder')"
|
||||
:type="field.secret ? 'password' : 'text'"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
>
|
||||
<template v-if="field.secret" #prefix-icon><t-icon name="lock-on" /></template>
|
||||
</t-input>
|
||||
<p v-if="field.hintKey" class="form-desc">{{ t(field.hintKey) }}</p>
|
||||
</template>
|
||||
</div>
|
||||
<div v-if="isEdit && replaceCredentialsMode" class="credential-edit-actions">
|
||||
<t-button size="small" variant="text" @click="cancelReplaceCredentials">
|
||||
{{ t('common.cancel') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<!-- Step 2: Select resources -->
|
||||
<section v-if="step === 2" class="setting-drawer__section ds-resource-section">
|
||||
@@ -1280,7 +1419,7 @@ const drawerConfirmText = computed(() => {
|
||||
@import './datasource-surface.less';
|
||||
.ds-steps {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
gap: 8px;
|
||||
margin-bottom: 20px;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
padding-bottom: 14px;
|
||||
@@ -1289,22 +1428,32 @@ const drawerConfirmText = computed(() => {
|
||||
.ds-step {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
.ds-step-title {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ds-step.active {
|
||||
color: var(--td-brand-color);
|
||||
font-weight: 600;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.ds-step.done {
|
||||
color: var(--td-text-color-secondary);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.ds-step-num {
|
||||
flex-shrink: 0;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 50%;
|
||||
@@ -1312,7 +1461,10 @@ const drawerConfirmText = computed(() => {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 12px;
|
||||
border: 1px solid currentColor;
|
||||
font-weight: 600;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
color: var(--td-text-color-placeholder);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.ds-step.active .ds-step-num {
|
||||
@@ -1322,9 +1474,13 @@ const drawerConfirmText = computed(() => {
|
||||
}
|
||||
|
||||
.ds-step.done .ds-step-num {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-success-color);
|
||||
border-color: color-mix(in srgb, var(--td-success-color) 35%, var(--td-component-stroke));
|
||||
background: color-mix(in srgb, var(--td-brand-color) 12%, transparent);
|
||||
color: var(--td-brand-color);
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.ds-step-check {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.ds-loading-center {
|
||||
@@ -1422,6 +1578,10 @@ const drawerConfirmText = computed(() => {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.ds-setup-guide--standalone {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.ds-setup-guide__toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -1594,25 +1754,6 @@ const drawerConfirmText = computed(() => {
|
||||
margin: 0 2px;
|
||||
}
|
||||
|
||||
.credential-edit {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.credential-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.credential-field-label {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.credential-edit-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
@@ -1625,7 +1766,7 @@ const drawerConfirmText = computed(() => {
|
||||
}
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 16px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.form-item--flat {
|
||||
@@ -1644,11 +1785,15 @@ const drawerConfirmText = computed(() => {
|
||||
font-weight: 500;
|
||||
margin-bottom: 6px;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
line-height: 1.4;
|
||||
|
||||
.required-mark {
|
||||
color: var(--td-error-color);
|
||||
margin-left: 2px;
|
||||
&.required::before {
|
||||
content: '*';
|
||||
color: var(--td-error-color);
|
||||
margin-right: 4px;
|
||||
font-weight: 500;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.form-desc {
|
||||
@@ -1936,6 +2081,55 @@ const drawerConfirmText = computed(() => {
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.custom-headers-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.custom-headers-desc {
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
.custom-headers-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.custom-header-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
.custom-header-key {
|
||||
flex: 0 0 38%;
|
||||
}
|
||||
|
||||
.custom-header-value {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.custom-header-remove {
|
||||
flex-shrink: 0;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
color: var(--td-text-color-placeholder);
|
||||
border-radius: 6px;
|
||||
transition: all 0.18s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-error-color-light);
|
||||
color: var(--td-error-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ds-empty-retry {
|
||||
padding: 0;
|
||||
border: none;
|
||||
@@ -2001,3 +2195,20 @@ const drawerConfirmText = computed(() => {
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
|
||||
}
|
||||
</style>
|
||||
|
||||
<!--
|
||||
Drawer header logo — same white badge as list cards / StorageEngineSettings.
|
||||
-->
|
||||
<style lang="less">
|
||||
.datasource-editor-drawer .setting-drawer__header-icon:has(.datasource-header-icon__img) {
|
||||
background: var(--td-bg-color-container, #fff);
|
||||
box-shadow: inset 0 0 0 1px var(--td-component-stroke);
|
||||
}
|
||||
|
||||
.datasource-header-icon__img {
|
||||
display: block;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
object-fit: contain;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -202,11 +202,11 @@ onBeforeUnmount(stopPolling)
|
||||
v-for="ds in dataSources"
|
||||
:key="ds.id"
|
||||
:type="canManageDataSource ? 'button' : undefined"
|
||||
:class="['ds-card', { 'ds-card--clickable': canManageDataSource }]"
|
||||
:class="['ds-card', `ds-card--${ds.type}`, { 'ds-card--clickable': canManageDataSource }]"
|
||||
@click="canManageDataSource ? openEdit(ds) : undefined"
|
||||
>
|
||||
<div class="ds-card__badge">
|
||||
<DataSourceTypeIcon :type="ds.type" :size="22" />
|
||||
<DataSourceTypeIcon :type="ds.type" variant="badge" />
|
||||
</div>
|
||||
<div class="ds-card__body">
|
||||
<div class="ds-card__header">
|
||||
@@ -452,10 +452,23 @@ onBeforeUnmount(stopPolling)
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
|
||||
margin-top: 1px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
background: rgba(7, 192, 95, 0.12);
|
||||
color: #07c05f;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
&--feishu .ds-card__badge,
|
||||
&--notion .ds-card__badge,
|
||||
&--yuque .ds-card__badge,
|
||||
&--rss .ds-card__badge {
|
||||
background: var(--td-bg-color-container, #fff);
|
||||
box-shadow: inset 0 0 0 1px var(--td-component-stroke);
|
||||
}
|
||||
|
||||
&__body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import feishuIcon from '@/assets/img/datasource-feishu.ico'
|
||||
import notionIcon from '@/assets/img/datasource-notion.ico'
|
||||
import yuqueIcon from '@/assets/img/datasource-yuque.ico'
|
||||
import { getDatasourceIconUrl, datasourceIconMap } from './datasourceIcons'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
type: string
|
||||
size?: number
|
||||
/** inline: 类型选择等小尺寸场景;badge: 嵌入 ds-card__badge 等父级徽章容器 */
|
||||
variant?: 'inline' | 'badge'
|
||||
}>(), {
|
||||
size: 20,
|
||||
variant: 'inline',
|
||||
})
|
||||
|
||||
const iconMap: Record<string, string> = {
|
||||
feishu: feishuIcon,
|
||||
notion: notionIcon,
|
||||
yuque: yuqueIcon,
|
||||
}
|
||||
const iconMap = datasourceIconMap
|
||||
|
||||
function fallbackText(type: string) {
|
||||
switch (type) {
|
||||
@@ -33,13 +30,15 @@ function fallbackText(type: string) {
|
||||
<template>
|
||||
<span
|
||||
class="ds-type-icon"
|
||||
:style="{ width: `${size}px`, height: `${size}px` }"
|
||||
:class="`ds-type-icon--${variant}`"
|
||||
:style="variant === 'inline' ? { width: `${size}px`, height: `${size}px` } : undefined"
|
||||
>
|
||||
<img
|
||||
v-if="iconMap[type]"
|
||||
:src="iconMap[type]"
|
||||
:alt="type"
|
||||
:style="{ width: `${size}px`, height: `${size}px` }"
|
||||
class="ds-type-icon__img"
|
||||
:style="variant === 'inline' ? { width: `${size}px`, height: `${size}px` } : undefined"
|
||||
>
|
||||
<span v-else class="ds-type-icon-fallback">{{ fallbackText(type) }}</span>
|
||||
</span>
|
||||
@@ -52,18 +51,41 @@ function fallbackText(type: string) {
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ds-type-icon--inline {
|
||||
border-radius: 6px;
|
||||
background: var(--td-bg-color-component);
|
||||
}
|
||||
|
||||
.ds-type-icon img {
|
||||
.ds-type-icon--inline .ds-type-icon__img {
|
||||
display: block;
|
||||
object-fit: cover;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.ds-type-icon-fallback {
|
||||
.ds-type-icon--inline .ds-type-icon-fallback {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
.ds-type-icon--badge {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.ds-type-icon--badge .ds-type-icon__img {
|
||||
display: block;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.ds-type-icon--badge .ds-type-icon-fallback {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import feishuIcon from '@/assets/img/datasource-feishu.ico'
|
||||
import notionIcon from '@/assets/img/datasource-notion.ico'
|
||||
import yuqueIcon from '@/assets/img/datasource-yuque.ico'
|
||||
import rssIcon from '@/assets/img/datasource-rss.svg'
|
||||
|
||||
export const datasourceIconMap: Record<string, string> = {
|
||||
feishu: feishuIcon,
|
||||
notion: notionIcon,
|
||||
yuque: yuqueIcon,
|
||||
rss: rssIcon,
|
||||
}
|
||||
|
||||
export function getDatasourceIconUrl(type: string): string | undefined {
|
||||
return datasourceIconMap[type]
|
||||
}
|
||||
Reference in New Issue
Block a user