feat(datasource): add WeCom document integration and callback setup
- Implemented WeCom document connector to sync smart documents and WeDrive files into WeKnora. - Added detailed documentation for WeCom integration, including setup instructions for callback URL and API access. - Enhanced frontend localization to support WeCom-specific messages and instructions. - Updated data source management UI to include WeCom configuration options and callback URL handling. - Improved error handling and validation for WeCom API interactions.
This commit is contained in:
@@ -3392,10 +3392,14 @@ export default {
|
||||
resourceLoadFailed: 'Failed to load resources',
|
||||
noResources: 'No wiki spaces found',
|
||||
noResourcesDesc: 'The app needs wiki access via a group chat to fetch content',
|
||||
noResourcesDesc_wecom_doc: 'Ensure the app is added as a "Callable App" in Admin Console > Collaboration > Docs > API',
|
||||
retryLoadResources: 'Retry',
|
||||
guideStep1: 'Create a group chat in Feishu, then add your app as a bot in the group settings',
|
||||
guideStep2: 'Open wiki "Settings" > "Member Settings" > "Add Member", search for the group chat and add it',
|
||||
guideStep3: 'Ensure the group chat role is at least "Can Read", then come back and click Retry',
|
||||
guideStep1_wecom_doc: 'Add the app as a "Callable App" in Admin Console > Collaboration > Docs > API',
|
||||
guideStep2_wecom_doc: 'Ensure the app "Visible Scope" includes the members/departments to sync',
|
||||
guideStep3_wecom_doc: 'Fill in Corp ID and Secret, then click retry',
|
||||
permissionDocLink: 'View Feishu wiki permission docs',
|
||||
syncScheduleLabel: 'Sync schedule',
|
||||
conflictLabel: 'Conflict strategy',
|
||||
@@ -3465,9 +3469,22 @@ export default {
|
||||
},
|
||||
comingSoon: 'Coming soon',
|
||||
docHint: 'Get credentials at:',
|
||||
wecomCallbackTitle: 'Callback URL Setup (unlocks "Callable Apps" setting)',
|
||||
wecomCallbackDesc: 'WeCom admin requires configuring a "Message Receiving Server URL" before you can set "Trusted IPs" and "Callable Apps". Enter the Token and EncodingAESKey from WeCom admin here, save, then paste the generated callback URL into WeCom admin.',
|
||||
wecomCallbackUrl: 'Callback URL (paste into WeCom admin "Message Receiving Server URL")',
|
||||
wecomCallbackSaveFirst: 'Save the data source first to generate the callback URL',
|
||||
copyUrl: 'Copy URL',
|
||||
copied: 'Copied',
|
||||
pleaseTestFirst: 'Please test connection first',
|
||||
prereqTitle: 'Complete these steps before connecting (all required)',
|
||||
prereqBarText: 'First time? Click to see Feishu app setup guide',
|
||||
prereqBarText_wecom_doc: 'First time? Click to expand WeCom app setup guide',
|
||||
prereqStep1Brief_wecom_doc: 'Configure Callback URL (unlocks further settings)',
|
||||
prereqStep1Desc_wecom_doc: 'Save data source first → Expand "Callback URL Setup" below → Enter Token/EncodingAESKey from WeCom admin → Paste generated URL into WeCom admin "Message Receiving Server URL"',
|
||||
prereqStep2Brief_wecom_doc: 'Authorize app for Docs API',
|
||||
prereqStep2Desc_wecom_doc: 'Admin Console → Collaboration → Docs → Scroll to API section at bottom → Add your app to "Callable Apps"',
|
||||
prereqStep3Brief_wecom_doc: 'Confirm app visible scope',
|
||||
prereqStep3Desc_wecom_doc: 'Admin Console → App Management → App detail → Ensure "Visible Scope" includes target members/departments',
|
||||
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):',
|
||||
@@ -3497,6 +3514,11 @@ export default {
|
||||
},
|
||||
addCard: 'Add Data Source',
|
||||
wikiSpace: 'Wiki Space',
|
||||
resourceType: {
|
||||
wikiSpace: 'Wiki Space',
|
||||
docCategory: 'Document Category',
|
||||
wedriveSpace: 'WeDrive Space',
|
||||
},
|
||||
neverSynced: 'Never synced',
|
||||
justNow: 'Just now',
|
||||
minutesAgo: '{n}m ago',
|
||||
|
||||
@@ -3480,6 +3480,7 @@ export default {
|
||||
yuque: "위큐 (Yuque)",
|
||||
github: "GitHub",
|
||||
web_crawler: "웹 크롤러",
|
||||
wecom_doc: "WeCom 문서",
|
||||
},
|
||||
connectorDesc: {
|
||||
feishu: "페이슈 위키에서 문서, 스프레드시트, 파일 동기화",
|
||||
@@ -3488,6 +3489,7 @@ export default {
|
||||
yuque: "위큐 지식베이스에서 문서 동기화",
|
||||
github: "GitHub 리포지토리에서 문서 및 위키 동기화",
|
||||
web_crawler: "사이트맵을 통해 웹사이트 크롤링",
|
||||
wecom_doc: "WeCom(기업 위챗)에서 문서 동기화",
|
||||
},
|
||||
field: {
|
||||
appId: "App ID",
|
||||
@@ -3498,6 +3500,8 @@ export default {
|
||||
apiToken: "API Token",
|
||||
personalToken: "Personal Access Token",
|
||||
sitemapUrl: "사이트맵 URL",
|
||||
corpId: "Corp ID",
|
||||
corpSecret: "Corp Secret",
|
||||
},
|
||||
comingSoon: "곧 지원 예정",
|
||||
docHint: "다음에서 인증 정보를 받으세요:",
|
||||
|
||||
@@ -3387,6 +3387,7 @@ export default {
|
||||
yuque: 'Yuque (Юйцюэ)',
|
||||
github: 'GitHub',
|
||||
web_crawler: 'Веб-краулер',
|
||||
wecom_doc: 'WeCom Документы',
|
||||
},
|
||||
connectorDesc: {
|
||||
feishu: 'Синхронизация документов, таблиц и файлов из Feishu Wiki',
|
||||
@@ -3395,6 +3396,7 @@ export default {
|
||||
yuque: 'Синхронизация документов из баз знаний Yuque',
|
||||
github: 'Синхронизация документов и вики из репозиториев GitHub',
|
||||
web_crawler: 'Сканирование веб-сайтов через Sitemap',
|
||||
wecom_doc: 'Синхронизация документов из WeCom (корпоративный WeChat)',
|
||||
},
|
||||
field: {
|
||||
appId: 'App ID',
|
||||
@@ -3405,6 +3407,8 @@ export default {
|
||||
apiToken: 'API Token',
|
||||
personalToken: 'Personal Access Token',
|
||||
sitemapUrl: 'Sitemap URL',
|
||||
corpId: 'Corp ID',
|
||||
corpSecret: 'Corp Secret',
|
||||
},
|
||||
comingSoon: 'Скоро',
|
||||
docHint: 'Получить учётные данные можно здесь:',
|
||||
|
||||
@@ -3390,10 +3390,14 @@ export default {
|
||||
resourceLoadFailed: "加载资源列表失败",
|
||||
noResources: "未找到可同步的知识库空间",
|
||||
noResourcesDesc: "应用需要通过群聊获得知识库访问权限才能拉取内容",
|
||||
noResourcesDesc_wecom_doc: "请确认已在管理后台「协作→文档→API」中将应用添加为「可调用接口的应用」",
|
||||
retryLoadResources: "重新加载",
|
||||
guideStep1: "在飞书中创建一个群聊,在群设置「群机器人」中添加你的应用",
|
||||
guideStep2: "打开知识库「设置」→「成员设置」→ 添加成员,搜索该群聊名称并添加",
|
||||
guideStep3: "确保群聊角色至少为「可阅读」,然后回到这里点重新加载",
|
||||
guideStep1_wecom_doc: "在管理后台「协作→文档→API」中将自建应用添加为「可调用接口的应用」",
|
||||
guideStep2_wecom_doc: "确认应用「可见范围」包含了需要同步文档的成员或部门",
|
||||
guideStep3_wecom_doc: "填入 Corp ID 和 Secret 后点击重新加载",
|
||||
permissionDocLink: "查看飞书知识库权限配置文档",
|
||||
syncScheduleLabel: "同步频率",
|
||||
conflictLabel: "冲突策略",
|
||||
@@ -3463,9 +3467,22 @@ export default {
|
||||
},
|
||||
comingSoon: "即将支持",
|
||||
docHint: "在以下地址获取凭证:",
|
||||
wecomCallbackTitle: "回调 URL 配置(解锁「可调用接口的应用」设置)",
|
||||
wecomCallbackDesc: "企微管理后台要求配置「接收消息服务器URL」后才能设置「企业可信IP」和「可调用接口的应用」。在此填入 Token 和 EncodingAESKey(从企微后台获取),保存后将生成的回调 URL 粘贴到企微后台。",
|
||||
wecomCallbackUrl: "回调 URL(粘贴到企微后台「接收消息服务器URL」)",
|
||||
wecomCallbackSaveFirst: "请先保存数据源,保存后会生成回调 URL",
|
||||
copyUrl: "复制 URL",
|
||||
copied: "已复制",
|
||||
pleaseTestFirst: "请先测试连接",
|
||||
prereqTitle: "使用前请先完成以下配置(缺一不可)",
|
||||
prereqBarText: "首次使用?点击查看飞书应用配置指引",
|
||||
prereqBarText_wecom_doc: "首次使用?点击展开企微应用配置指引",
|
||||
prereqStep1Brief_wecom_doc: "配置回调 URL(解锁后续设置)",
|
||||
prereqStep1Desc_wecom_doc: "先保存数据源 → 展开下方「回调 URL 配置」→ 填入企微后台的 Token/EncodingAESKey → 将生成的 URL 粘贴到企微后台「接收消息服务器URL」",
|
||||
prereqStep2Brief_wecom_doc: "授权应用调用文档 API",
|
||||
prereqStep2Desc_wecom_doc: "管理后台 → 协作 → 文档 → 滚动到底部 API 区域 → 将自建应用添加到「可调用接口的应用」",
|
||||
prereqStep3Brief_wecom_doc: "确认应用可见范围",
|
||||
prereqStep3Desc_wecom_doc: "管理后台 → 应用管理 → 自建应用详情 → 确保「可见范围」包含需要同步文档的成员或部门",
|
||||
prereqBotBrief: "为应用添加「机器人」能力",
|
||||
prereqBotDesc: "开放平台 → 添加应用能力 → 机器人 → 创建版本并发布",
|
||||
prereqBotLabel: "1. 为应用添加「机器人」能力(否则知识库中搜不到该应用):",
|
||||
@@ -3495,6 +3512,11 @@ export default {
|
||||
},
|
||||
addCard: "添加数据源",
|
||||
wikiSpace: "知识库空间",
|
||||
resourceType: {
|
||||
wikiSpace: "知识库空间",
|
||||
docCategory: "文档分类",
|
||||
wedriveSpace: "微盘空间",
|
||||
},
|
||||
neverSynced: "未同步",
|
||||
justNow: "刚刚",
|
||||
minutesAgo: "{n} 分钟前",
|
||||
|
||||
@@ -53,6 +53,8 @@ const testErrorMsg = ref('')
|
||||
|
||||
// Collapsible prereq in Step 1
|
||||
const prereqExpanded = ref(false)
|
||||
// WeCom callback section
|
||||
const callbackExpanded = ref(false)
|
||||
|
||||
// Temp data source for resource listing
|
||||
const tempDsId = ref('')
|
||||
@@ -119,13 +121,13 @@ const connectorDefs = computed<ConnectorDef[]>(() => [
|
||||
},
|
||||
{
|
||||
type: 'wecom_doc',
|
||||
available: false,
|
||||
docUrl: 'https://developer.work.weixin.qq.com/',
|
||||
available: true,
|
||||
docUrl: 'https://work.weixin.qq.com/wework_admin/frame#apps',
|
||||
permissionDocUrl: '',
|
||||
permissionPageUrl: '',
|
||||
requiredPermissions: [],
|
||||
permissionPageUrl: 'https://work.weixin.qq.com/wework_admin/frame#apps',
|
||||
requiredPermissions: ['wedoc:callable_app'],
|
||||
fields: [
|
||||
{ key: 'corp_id', labelKey: 'datasource.field.corpId', placeholder: '' },
|
||||
{ key: 'corp_id', labelKey: 'datasource.field.corpId', placeholder: 'ww_xxxx' },
|
||||
{ key: 'corp_secret', labelKey: 'datasource.field.corpSecret', placeholder: '', secret: true },
|
||||
],
|
||||
},
|
||||
@@ -142,6 +144,7 @@ watch(visible, (v) => {
|
||||
testErrorMsg.value = ''
|
||||
tempDsId.value = ''
|
||||
prereqExpanded.value = false
|
||||
callbackExpanded.value = false
|
||||
resources.value = []
|
||||
selectedResourceIds.value = []
|
||||
|
||||
@@ -315,6 +318,27 @@ async function handleClose() {
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
const resourceTypeLabelMap: Record<string, string> = {
|
||||
wiki_space: 'datasource.resourceType.wikiSpace',
|
||||
doc_category: 'datasource.resourceType.docCategory',
|
||||
wedrive_space: 'datasource.resourceType.wedriveSpace',
|
||||
}
|
||||
|
||||
function resourceTypeLabel(type: string): string {
|
||||
const key = resourceTypeLabelMap[type]
|
||||
return key ? t(key) : type
|
||||
}
|
||||
|
||||
const wecomCallbackUrl = computed(() => {
|
||||
if (!tempDsId.value) return ''
|
||||
return `${window.location.origin}/api/v1/wecom/callback/${tempDsId.value}`
|
||||
})
|
||||
|
||||
function copyCallbackUrl() {
|
||||
navigator.clipboard.writeText(wecomCallbackUrl.value)
|
||||
MessagePlugin.success(t('datasource.copied'))
|
||||
}
|
||||
|
||||
const stepTitles = computed(() => [
|
||||
t('datasource.step.selectType'),
|
||||
t('datasource.step.credentials'),
|
||||
@@ -367,31 +391,34 @@ const stepTitles = computed(() => [
|
||||
<!-- Compact collapsible prereq hint -->
|
||||
<div v-if="currentDef && currentDef.requiredPermissions.length > 0" class="ds-prereq-bar" @click="prereqExpanded = !prereqExpanded">
|
||||
<t-icon name="help-circle" size="14px" />
|
||||
<span>{{ t('datasource.prereqBarText') }}</span>
|
||||
<span>{{ t(`datasource.prereqBarText_${form.type}`, t('datasource.prereqBarText')) }}</span>
|
||||
<t-icon :name="prereqExpanded ? 'chevron-up' : 'chevron-down'" size="14px" class="ds-prereq-arrow" />
|
||||
</div>
|
||||
<div v-if="prereqExpanded && currentDef" class="ds-prereq-detail">
|
||||
<div class="ds-prereq-item">
|
||||
<span class="ds-prereq-num">1</span>
|
||||
<div>
|
||||
<div class="ds-prereq-item-title">{{ t('datasource.prereqBotBrief') }}</div>
|
||||
<div class="ds-prereq-item-desc">{{ t('datasource.prereqBotDesc') }}</div>
|
||||
<div class="ds-prereq-item-title">{{ t(`datasource.prereqStep1Brief_${form.type}`, t('datasource.prereqBotBrief')) }}</div>
|
||||
<div class="ds-prereq-item-desc">{{ t(`datasource.prereqStep1Desc_${form.type}`, t('datasource.prereqBotDesc')) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ds-prereq-item">
|
||||
<span class="ds-prereq-num">2</span>
|
||||
<div>
|
||||
<div class="ds-prereq-item-title">{{ t('datasource.prereqPermBrief') }}</div>
|
||||
<div class="ds-prereq-item-title">{{ t(`datasource.prereqStep2Brief_${form.type}`, t('datasource.prereqPermBrief')) }}</div>
|
||||
<div class="ds-prereq-item-desc">
|
||||
<code v-for="perm in currentDef.requiredPermissions" :key="perm" class="ds-perm-tag">{{ perm }}</code>
|
||||
<template v-if="!t(`datasource.prereqStep2Desc_${form.type}`)">
|
||||
<code v-for="perm in currentDef.requiredPermissions" :key="perm" class="ds-perm-tag">{{ perm }}</code>
|
||||
</template>
|
||||
<template v-else>{{ t(`datasource.prereqStep2Desc_${form.type}`) }}</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ds-prereq-item">
|
||||
<span class="ds-prereq-num">3</span>
|
||||
<div>
|
||||
<div class="ds-prereq-item-title">{{ t('datasource.prereqMemberBrief') }}</div>
|
||||
<div class="ds-prereq-item-desc">{{ t('datasource.prereqMemberDesc') }}</div>
|
||||
<div class="ds-prereq-item-title">{{ t(`datasource.prereqStep3Brief_${form.type}`, t('datasource.prereqMemberBrief')) }}</div>
|
||||
<div class="ds-prereq-item-desc">{{ t(`datasource.prereqStep3Desc_${form.type}`, t('datasource.prereqMemberDesc')) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<a :href="currentDef.permissionPageUrl" target="_blank" rel="noopener" class="ds-prereq-link">
|
||||
@@ -419,6 +446,34 @@ const stepTitles = computed(() => [
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- WeCom callback URL setup (only for wecom_doc, shown as collapsible) -->
|
||||
<div v-if="form.type === 'wecom_doc'" class="ds-callback-section">
|
||||
<div class="ds-callback-header" @click="callbackExpanded = !callbackExpanded">
|
||||
<t-icon name="link" size="14px" />
|
||||
<span>{{ t('datasource.wecomCallbackTitle') }}</span>
|
||||
<t-icon :name="callbackExpanded ? 'chevron-up' : 'chevron-down'" size="14px" class="ds-prereq-arrow" />
|
||||
</div>
|
||||
<div v-if="callbackExpanded" class="ds-callback-body">
|
||||
<p class="ds-callback-desc">{{ t('datasource.wecomCallbackDesc') }}</p>
|
||||
<div class="form-item">
|
||||
<label class="form-label">Token</label>
|
||||
<t-input v-model="form.config.settings.callback_token" placeholder="Token" />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">EncodingAESKey</label>
|
||||
<t-input v-model="form.config.settings.callback_aes_key" placeholder="EncodingAESKey" />
|
||||
</div>
|
||||
<div v-if="tempDsId" class="ds-callback-url">
|
||||
<label class="form-label">{{ t('datasource.wecomCallbackUrl') }}</label>
|
||||
<t-input readonly :value="wecomCallbackUrl" />
|
||||
<t-button size="small" variant="outline" @click="copyCallbackUrl" style="margin-top:4px">
|
||||
{{ t('datasource.copyUrl') }}
|
||||
</t-button>
|
||||
</div>
|
||||
<p v-else class="ds-callback-hint">{{ t('datasource.wecomCallbackSaveFirst') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<t-button variant="outline" :loading="testing" @click="testConnection">
|
||||
{{ t('datasource.testConnection') }}
|
||||
@@ -455,7 +510,7 @@ const stepTitles = computed(() => [
|
||||
<div class="ds-resource-info">
|
||||
<div class="ds-resource-name">{{ r.name }}</div>
|
||||
<div class="ds-resource-meta">
|
||||
<span class="ds-resource-type">{{ r.type === 'wiki_space' ? t('datasource.wikiSpace') : r.type }}</span>
|
||||
<span class="ds-resource-type">{{ resourceTypeLabel(r.type) }}</span>
|
||||
<span v-if="r.description" class="ds-resource-desc">{{ r.description }}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -465,19 +520,19 @@ const stepTitles = computed(() => [
|
||||
<div v-else class="ds-resource-empty">
|
||||
<t-icon name="info-circle" size="32px" style="color: var(--td-warning-color); margin-bottom: 8px;" />
|
||||
<p class="ds-empty-title">{{ t('datasource.noResources') }}</p>
|
||||
<p class="ds-empty-desc">{{ t('datasource.noResourcesDesc') }}</p>
|
||||
<p class="ds-empty-desc">{{ t(`datasource.noResourcesDesc_${form.type}`, t('datasource.noResourcesDesc')) }}</p>
|
||||
<div class="ds-guide-steps">
|
||||
<div class="ds-guide-step">
|
||||
<span class="ds-guide-num">1</span>
|
||||
<span>{{ t('datasource.guideStep1') }}</span>
|
||||
<span>{{ t(`datasource.guideStep1_${form.type}`, t('datasource.guideStep1')) }}</span>
|
||||
</div>
|
||||
<div class="ds-guide-step">
|
||||
<span class="ds-guide-num">2</span>
|
||||
<span>{{ t('datasource.guideStep2') }}</span>
|
||||
<span>{{ t(`datasource.guideStep2_${form.type}`, t('datasource.guideStep2')) }}</span>
|
||||
</div>
|
||||
<div class="ds-guide-step">
|
||||
<span class="ds-guide-num">3</span>
|
||||
<span>{{ t('datasource.guideStep3') }}</span>
|
||||
<span>{{ t(`datasource.guideStep3_${form.type}`, t('datasource.guideStep3')) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ds-empty-actions">
|
||||
@@ -681,6 +736,47 @@ const stepTitles = computed(() => [
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
/* --- WeCom callback section --- */
|
||||
.ds-callback-section {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.ds-callback-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 8px 12px;
|
||||
background: var(--td-bg-color-component);
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
.ds-callback-header:hover {
|
||||
background: var(--td-bg-color-container-hover);
|
||||
}
|
||||
.ds-callback-body {
|
||||
border: 1px solid var(--td-border-level-2-color);
|
||||
border-radius: 0 0 8px 8px;
|
||||
padding: 14px;
|
||||
margin-top: -2px;
|
||||
}
|
||||
.ds-callback-desc {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin-bottom: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.ds-callback-url {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.ds-callback-hint {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
margin-top: 8px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* --- Step 1: doc link & form --- */
|
||||
.ds-doc-link {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user