feat(frontend): enable Yuque datasource option with optional base_url
Flip the Yuque tile to available, add a base_url field (optional) for users on private Yuque deployments, and populate the permission doc/page links. Introduces an optional flag on ConnectorDef.fields so the Test Connection validator skips empty optional fields; required fields get a visible * mark. Also adds an optional hintKey on ConnectorDef.fields for per-field guidance text, a Yuque-specific prereq guide, and a base_url hint explaining when to leave it empty vs fill it for Yuque Enterprise / self-hosted deployments.
This commit is contained in:
@@ -3689,6 +3689,8 @@ export default {
|
||||
appSecret: 'App Secret',
|
||||
integrationToken: 'Integration Token',
|
||||
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).',
|
||||
},
|
||||
comingSoon: 'Coming soon',
|
||||
docHint: 'Get credentials at:',
|
||||
@@ -3697,6 +3699,14 @@ export default {
|
||||
pleaseTestFirst: 'Please test connection first',
|
||||
prereqTitle: 'Complete these steps before connecting (all required)',
|
||||
prereqBarText: 'First time? Click to see Feishu app setup guide',
|
||||
prereqBarText_yuque: 'First time? Click to see the Yuque token setup guide',
|
||||
prereqStep1Brief_yuque: 'Create a Yuque personal token',
|
||||
prereqStep1Desc_yuque: 'Sign in to Yuque → avatar → Settings → Token → New Token',
|
||||
prereqStep2Brief_yuque: 'Grant the token required permissions',
|
||||
prereqStep2Desc_yuque: 'Check at least repo:read and doc:read (read knowledge base and document content)',
|
||||
prereqStep3Brief_yuque: '(Optional) Enter Base URL for enterprise deployments',
|
||||
prereqStep3Desc_yuque: 'Leave empty for public cloud; for Yuque Enterprise or self-hosted, enter your company domain.',
|
||||
prereqOpenConsole_yuque: 'Open Yuque Token settings',
|
||||
prereqBotBrief: 'Add "Bot" capability to your app',
|
||||
prereqBotDesc: 'Open Platform > Add App Capability > Bot > create version and publish',
|
||||
prereqBotLabel: '1. Add "Bot" capability to your app (otherwise the app won\'t appear in wiki member search):',
|
||||
@@ -3729,6 +3739,7 @@ export default {
|
||||
resourceType: {
|
||||
wikiSpace: 'Wiki Space',
|
||||
docCategory: 'Document Category',
|
||||
book: 'Yuque Book',
|
||||
},
|
||||
neverSynced: 'Never synced',
|
||||
justNow: 'Just now',
|
||||
|
||||
@@ -3686,6 +3686,8 @@ export default {
|
||||
appSecret: "App Secret",
|
||||
integrationToken: "Integration Token",
|
||||
apiToken: "API Token",
|
||||
baseUrl: "Base URL(可选)",
|
||||
baseUrlHint: "留空将使用语雀公有云 https://www.yuque.com;如果你使用的是语雀企业版或私有部署,请填写企业域名(例如 https://your-company.yuque.com)",
|
||||
},
|
||||
comingSoon: "即将支持",
|
||||
docHint: "在以下地址获取凭证:",
|
||||
@@ -3694,6 +3696,14 @@ export default {
|
||||
pleaseTestFirst: "请先测试连接",
|
||||
prereqTitle: "使用前请先完成以下配置(缺一不可)",
|
||||
prereqBarText: "首次使用?点击查看飞书应用配置指引",
|
||||
prereqBarText_yuque: "首次使用?点击查看语雀 Token 配置指引",
|
||||
prereqStep1Brief_yuque: "创建语雀个人 Token",
|
||||
prereqStep1Desc_yuque: "登录语雀 → 个人头像 → 设置 → Token → 新建 Token",
|
||||
prereqStep2Brief_yuque: "为 Token 勾选所需权限",
|
||||
prereqStep2Desc_yuque: "至少勾选 repo:read 和 doc:read(读取知识库和文档内容)",
|
||||
prereqStep3Brief_yuque: "(可选)企业版填写 Base URL",
|
||||
prereqStep3Desc_yuque: "公有云用户无需填写;语雀企业版或私有部署请填写企业域名",
|
||||
prereqOpenConsole_yuque: "前往语雀 Token 设置",
|
||||
prereqBotBrief: "为应用添加「机器人」能力",
|
||||
prereqBotDesc: "开放平台 → 添加应用能力 → 机器人 → 创建版本并发布",
|
||||
prereqBotLabel: "1. 为应用添加「机器人」能力(否则知识库中搜不到该应用):",
|
||||
@@ -3726,6 +3736,7 @@ export default {
|
||||
resourceType: {
|
||||
wikiSpace: "知识库空间",
|
||||
docCategory: "文档分类",
|
||||
book: "语雀知识库",
|
||||
},
|
||||
neverSynced: "未同步",
|
||||
justNow: "刚刚",
|
||||
|
||||
@@ -149,7 +149,7 @@ interface ConnectorDef {
|
||||
permissionDocUrl: string
|
||||
permissionPageUrl: string
|
||||
requiredPermissions: string[]
|
||||
fields: { key: string; labelKey: string; placeholder: string; secret?: boolean }[]
|
||||
fields: { key: string; labelKey: string; placeholder: string; secret?: boolean; optional?: boolean; hintKey?: string }[]
|
||||
}
|
||||
|
||||
const connectorDefs = computed<ConnectorDef[]>(() => [
|
||||
@@ -183,13 +183,17 @@ const connectorDefs = computed<ConnectorDef[]>(() => [
|
||||
},
|
||||
{
|
||||
type: 'yuque',
|
||||
available: false,
|
||||
docUrl: 'https://www.yuque.com/settings/tokens',
|
||||
permissionDocUrl: '',
|
||||
permissionPageUrl: '',
|
||||
requiredPermissions: [],
|
||||
available: true,
|
||||
docUrl: 'https://www.yuque.com/yuque/developer/api',
|
||||
permissionDocUrl: 'https://www.yuque.com/yuque/developer/api',
|
||||
permissionPageUrl: 'https://www.yuque.com/settings/tokens',
|
||||
requiredPermissions: [
|
||||
'repo:read',
|
||||
'doc:read',
|
||||
],
|
||||
fields: [
|
||||
{ key: 'api_token', labelKey: 'datasource.field.apiToken', placeholder: '', secret: true },
|
||||
{ key: 'base_url', labelKey: 'datasource.field.baseUrl', placeholder: 'https://www.yuque.com', optional: true, hintKey: 'datasource.field.baseUrlHint' },
|
||||
],
|
||||
},
|
||||
])
|
||||
@@ -244,6 +248,7 @@ function selectType(def: ConnectorDef) {
|
||||
async function testConnection() {
|
||||
const fields = currentDef.value?.fields || []
|
||||
for (const f of fields) {
|
||||
if (f.optional) continue
|
||||
if (!form.value.config.credentials[f.key]) {
|
||||
MessagePlugin.warning(`${t(f.labelKey)} ${t('datasource.isRequired')}`)
|
||||
return
|
||||
@@ -373,6 +378,7 @@ function toggleResource(id: string) {
|
||||
function validateStep1Fields(): boolean {
|
||||
const fields = currentDef.value?.fields || []
|
||||
for (const f of fields) {
|
||||
if (f.optional) continue
|
||||
if (!form.value.config.credentials[f.key]) {
|
||||
MessagePlugin.warning(`${t(f.labelKey)} ${t('datasource.isRequired')}`)
|
||||
return false
|
||||
@@ -458,6 +464,7 @@ async function handleClose() {
|
||||
const resourceTypeLabelMap: Record<string, string> = {
|
||||
wiki_space: 'datasource.resourceType.wikiSpace',
|
||||
doc_category: 'datasource.resourceType.docCategory',
|
||||
book: 'datasource.resourceType.book',
|
||||
}
|
||||
|
||||
function resourceTypeLabel(type: string): string {
|
||||
@@ -549,7 +556,7 @@ const stepTitles = computed(() => [
|
||||
</div>
|
||||
</div>
|
||||
<a :href="currentDef.permissionPageUrl" target="_blank" rel="noopener" class="ds-prereq-link">
|
||||
{{ t('datasource.prereqOpenConsole') }}
|
||||
{{ t(`datasource.prereqOpenConsole_${form.type}`, t('datasource.prereqOpenConsole')) }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -565,12 +572,16 @@ const stepTitles = computed(() => [
|
||||
</div>
|
||||
|
||||
<div v-for="field in currentDef?.fields || []" :key="field.key" class="form-item">
|
||||
<label class="form-label">{{ t(field.labelKey) }}</label>
|
||||
<label class="form-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"
|
||||
:type="field.secret ? 'password' : 'text'"
|
||||
/>
|
||||
<div v-if="field.hintKey" class="form-hint">{{ t(field.hintKey) }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
@@ -871,7 +882,9 @@ const stepTitles = computed(() => [
|
||||
|
||||
.form-item { margin-bottom: 16px; }
|
||||
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--td-text-color-primary); }
|
||||
.required-mark { color: var(--td-error-color); margin-left: 2px; }
|
||||
.form-tip { font-size: 12px; color: var(--td-text-color-placeholder); margin: 4px 0 12px; }
|
||||
.form-hint { font-size: 12px; color: var(--td-text-color-placeholder); margin-top: 6px; line-height: 1.5; }
|
||||
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
|
||||
.test-ok { color: var(--td-success-color); font-size: 13px; display: flex; align-items: center; gap: 4px; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user