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:
wizardchen
2026-06-23 14:58:45 +08:00
committed by lyingbug
parent 94ce8fedb1
commit e40ad802d7
21 changed files with 1328 additions and 131 deletions
@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="RSS">
<circle cx="14" cy="34" r="4" fill="#FF6600"/>
<path d="M10 22a18 18 0 0 1 18 18" fill="none" stroke="#FF6600" stroke-width="4" stroke-linecap="round"/>
<path d="M10 14a26 26 0 0 1 26 26" fill="none" stroke="#FF6600" stroke-width="4" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 361 B

@@ -7,9 +7,9 @@
<div class="setting-drawer-resize-line" />
</div>
</teleport>
<t-drawer v-model:visible="drawerVisible" :size="effectiveWidth" :z-index="2500" placement="right"
<t-drawer v-model:visible="drawerVisible" v-bind="drawerPassthroughAttrs" :size="effectiveWidth" :z-index="2500" placement="right"
attach="body" destroy-on-close
:class="['setting-drawer', { 'setting-drawer--resizing': drawerResizing }]">
:class="drawerClass">
<!--
Custom header. We replace TDesign's default header so we can put a leading
icon badge and an optional subtitle (description) right next to the title,
@@ -55,7 +55,7 @@
</template>
<script setup lang="ts">
import { computed, ref, onMounted, onUnmounted } from 'vue'
import { ref, computed, useAttrs, onMounted, onUnmounted } from 'vue'
import { useI18n } from 'vue-i18n'
interface Props {
@@ -90,6 +90,8 @@ interface Props {
hideFooter?: boolean
}
defineOptions({ inheritAttrs: false })
const props = withDefaults(defineProps<Props>(), {
description: '',
icon: '',
@@ -112,6 +114,12 @@ const emit = defineEmits<{
}>()
const { t } = useI18n()
const attrs = useAttrs()
const drawerPassthroughAttrs = computed(() => {
const { class: _class, ...rest } = attrs
return rest
})
// ---------- visibility ----------
const drawerVisible = computed({
@@ -172,6 +180,13 @@ const persistWidth = (width: number) => {
// ---------- Custom drag-resize (visible handle, same as doc-content) ----------
const drawerResizing = ref(false)
const drawerClass = computed(() => [
'setting-drawer',
attrs.class,
{ 'setting-drawer--resizing': drawerResizing.value },
])
let resizeStartX = 0
let resizeStartWidth = 0
+7
View File
@@ -5418,6 +5418,7 @@ export default {
editTitle: 'Edit Data Source',
nameLabel: 'Name',
namePlaceholder: 'Enter data source name',
sectionBasic: 'Basic information',
testConnection: 'Test Connection',
testSuccess: 'Connection successful',
testFailed: 'Connection failed',
@@ -5493,11 +5494,13 @@ export default {
feishu: 'Feishu',
notion: 'Notion',
yuque: 'Yuque',
rss: 'RSS / Atom Feed',
},
connectorDesc: {
feishu: 'Sync documents, spreadsheets and files from Feishu Wiki',
notion: 'Sync pages and databases from Notion',
yuque: 'Sync documents from Yuque knowledge bases',
rss: 'Sync articles from RSS / Atom feeds',
},
field: {
appId: 'App ID',
@@ -5506,6 +5509,10 @@ export default {
apiToken: 'API Token',
baseUrl: 'Base URL (optional)',
baseUrlHint: 'Leave empty to use the Yuque public cloud (https://www.yuque.com). For Yuque Enterprise or self-hosted deployments, enter your company domain (e.g. https://your-company.yuque.com).',
feedUrls: 'Feed URLs',
feedUrlsHint: 'One RSS / Atom feed URL per line; multiple feeds are supported.',
authHeaders: 'Custom headers (optional)',
authHeadersHint: 'For private feeds. One per line in "Name: Value" form, e.g. Authorization: Bearer xxxx',
},
comingSoon: 'Coming soon',
docHint: 'Get credentials at:',
+7
View File
@@ -5430,6 +5430,7 @@ export default {
editTitle: "데이터 소스 편집",
nameLabel: "이름",
namePlaceholder: "데이터 소스 이름 입력",
sectionBasic: "기본 정보",
testConnection: "연결 테스트",
testSuccess: "연결 성공",
testFailed: "연결 실패",
@@ -5505,11 +5506,13 @@ export default {
feishu: "페이슈 (Feishu)",
notion: "Notion",
yuque: "위큐 (Yuque)",
rss: "RSS / Atom 피드",
},
connectorDesc: {
feishu: "페이슈 위키에서 문서, 스프레드시트, 파일 동기화",
notion: "Notion에서 페이지 및 데이터베이스 동기화",
yuque: "위큐 지식베이스에서 문서 동기화",
rss: "RSS / Atom 피드에서 글 동기화",
},
field: {
appId: "App ID",
@@ -5518,6 +5521,10 @@ export default {
baseUrl: "Base URL",
apiToken: "API Token",
baseUrlHint: "비워두면 Yuque 퍼블릭 클라우드 https://www.yuque.com 를 사용합니다. Yuque Enterprise 또는 사설 배포를 사용하는 경우 기업 도메인(예: https://your-company.yuque.com)을 입력하세요",
feedUrls: "피드 주소",
feedUrlsHint: "한 줄에 하나씩 RSS / Atom 피드 주소를 입력하세요. 여러 개를 함께 입력할 수 있습니다.",
authHeaders: "사용자 지정 헤더 (선택)",
authHeadersHint: "비공개 피드 접근용. 한 줄에 하나씩 「이름: 값」 형식으로 입력하세요. 예: Authorization: Bearer xxxx",
},
comingSoon: "곧 지원 예정",
docHint: "다음에서 인증 정보를 받으세요:",
+7
View File
@@ -5252,6 +5252,7 @@ export default {
editTitle: 'Редактировать источник данных',
nameLabel: 'Название',
namePlaceholder: 'Введите название источника данных',
sectionBasic: 'Основная информация',
testConnection: 'Проверить подключение',
testSuccess: 'Подключение успешно',
testFailed: 'Подключение не удалось',
@@ -5327,11 +5328,13 @@ export default {
feishu: 'Feishu (Фэйшу)',
notion: 'Notion',
yuque: 'Yuque (Юйцюэ)',
rss: 'RSS / Atom лента',
},
connectorDesc: {
feishu: 'Синхронизация документов, таблиц и файлов из Feishu Wiki',
notion: 'Синхронизация страниц и баз данных из Notion',
yuque: 'Синхронизация документов из баз знаний Yuque',
rss: 'Синхронизация статей из лент RSS / Atom',
},
field: {
appId: 'App ID',
@@ -5340,6 +5343,10 @@ export default {
baseUrl: 'Base URL',
apiToken: 'API Token',
baseUrlHint: 'Оставьте пустым, чтобы использовать публичное облако Yuque https://www.yuque.com. Если вы используете Yuque Enterprise или приватное развёртывание, укажите корпоративный домен (например, https://your-company.yuque.com)',
feedUrls: 'Адреса лент',
feedUrlsHint: 'По одному адресу ленты RSS / Atom в строке; можно указать несколько.',
authHeaders: 'Пользовательские заголовки (необязательно)',
authHeadersHint: 'Для приватных лент. По одному в строке в формате «Имя: Значение», например Authorization: Bearer xxxx',
},
comingSoon: 'Скоро',
docHint: 'Получить учётные данные можно здесь:',
+7
View File
@@ -5436,6 +5436,7 @@ export default {
editTitle: "编辑数据源",
nameLabel: "名称",
namePlaceholder: "输入数据源名称",
sectionBasic: "基本信息",
testConnection: "测试连接",
testSuccess: "连接成功",
testFailed: "连接失败",
@@ -5511,11 +5512,13 @@ export default {
feishu: "飞书",
notion: "Notion",
yuque: "语雀",
rss: "RSS / Atom 订阅",
},
connectorDesc: {
feishu: "同步飞书知识库中的文档、表格、文件",
notion: "同步 Notion 中的页面和数据库",
yuque: "同步语雀知识库中的文档",
rss: "同步 RSS / Atom 订阅源中的文章",
},
field: {
appId: "App ID",
@@ -5524,6 +5527,10 @@ export default {
apiToken: "API Token",
baseUrl: "Base URL(可选)",
baseUrlHint: "留空将使用语雀公有云 https://www.yuque.com;如果你使用的是语雀企业版或私有部署,请填写企业域名(例如 https://your-company.yuque.com)",
feedUrls: "订阅源地址",
feedUrlsHint: "每行一个 RSS / Atom 订阅源地址,支持同时填写多个",
authHeaders: "自定义请求头(可选)",
authHeadersHint: "用于访问私有订阅源,每行一个,格式为「名称: 值」,例如 Authorization: Bearer xxxx",
},
comingSoon: "即将支持",
docHint: "在以下地址获取凭证:",
+6 -11
View File
@@ -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 ? '&#10003;' : 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]
}