Merge upstream main and resolve conflicts
This commit is contained in:
@@ -89,13 +89,14 @@
|
||||
<!-- Platform -->
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('agentEditor.im.platform') }}</label>
|
||||
<t-radio-group v-model="formData.platform" :disabled="!!editingChannel">
|
||||
<t-radio-group v-model="formData.platform" :disabled="!!editingChannel" @change="onPlatformChange">
|
||||
<t-radio-button value="wecom">{{ $t('agentEditor.im.wecom') }}</t-radio-button>
|
||||
<t-radio-button value="feishu">{{ $t('agentEditor.im.feishu') }}</t-radio-button>
|
||||
<t-radio-button value="slack">{{ $t('agentEditor.im.slack') }}</t-radio-button>
|
||||
<t-radio-button value="telegram">{{ $t('agentEditor.im.telegram') }}</t-radio-button>
|
||||
<t-radio-button value="dingtalk">{{ $t('agentEditor.im.dingtalk') }}</t-radio-button>
|
||||
<t-radio-button value="mattermost">{{ $t('agentEditor.im.mattermost') }}</t-radio-button>
|
||||
<t-radio-button value="wechat">{{ $t('agentEditor.im.wechat') }}</t-radio-button>
|
||||
</t-radio-group>
|
||||
</div>
|
||||
|
||||
@@ -105,8 +106,8 @@
|
||||
<t-input v-model="formData.name" :placeholder="$t('agentEditor.im.channelNamePlaceholder')" />
|
||||
</div>
|
||||
|
||||
<!-- Mode -->
|
||||
<div class="form-item">
|
||||
<!-- Mode (hidden for WeChat) -->
|
||||
<div v-if="formData.platform !== 'wechat'" class="form-item">
|
||||
<label class="form-label">{{ $t('agentEditor.im.mode') }}</label>
|
||||
<t-radio-group v-model="formData.mode">
|
||||
<t-radio-button value="websocket" :disabled="formData.platform === 'mattermost'">WebSocket</t-radio-button>
|
||||
@@ -116,8 +117,8 @@
|
||||
<p v-else class="form-hint">{{ $t('agentEditor.im.modeHint') }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Output mode -->
|
||||
<div class="form-item">
|
||||
<!-- Output mode (hidden for WeChat) -->
|
||||
<div v-if="formData.platform !== 'wechat'" class="form-item">
|
||||
<label class="form-label">{{ $t('agentEditor.im.outputMode') }}</label>
|
||||
<t-radio-group v-model="formData.output_mode">
|
||||
<t-radio-button value="stream">{{ $t('agentEditor.im.outputStream') }}</t-radio-button>
|
||||
@@ -173,6 +174,11 @@
|
||||
<label class="form-label">Bot Secret</label>
|
||||
<t-input v-model="formData.credentials.bot_secret" type="password" placeholder="Bot Secret" />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">WebSocket Endpoint</label>
|
||||
<t-input v-model="formData.credentials.ws_endpoint" placeholder="wss://openws.work.weixin.qq.com" />
|
||||
<p class="form-hint">{{ $t('agentEditor.im.wecomWSEndpointHint') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="form-item">
|
||||
@@ -195,6 +201,11 @@
|
||||
<label class="form-label">Corp Agent ID</label>
|
||||
<t-input-number v-model="formData.credentials.corp_agent_id" placeholder="Corp Agent ID" style="width: 100%;" />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">API Base URL</label>
|
||||
<t-input v-model="formData.credentials.api_base_url" placeholder="https://qyapi.weixin.qq.com" />
|
||||
<p class="form-hint">{{ $t('agentEditor.im.wecomAPIBaseURLHint') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -339,16 +350,62 @@
|
||||
<p class="form-hint">{{ $t('agentEditor.im.mattermostPostToMainHint') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<!-- WeChat credentials (QR code binding) -->
|
||||
<template v-if="formData.platform === 'wechat'">
|
||||
<p class="form-hint">{{ $t('agentEditor.im.wechatHint') }}</p>
|
||||
|
||||
<!-- Already bound state -->
|
||||
<div v-if="wechatBound" class="wechat-bound-status">
|
||||
<t-icon name="check-circle-filled" class="bound-icon" />
|
||||
<span>{{ $t('agentEditor.im.wechatBindSuccess') }}</span>
|
||||
<t-button size="small" variant="outline" theme="default" @click="startWeChatBinding">
|
||||
{{ $t('agentEditor.im.wechatRebind') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<!-- QR code binding flow -->
|
||||
<div v-else class="wechat-qr-section">
|
||||
<!-- Initial state: show bind button -->
|
||||
<div v-if="!wechatQRImgUrl" class="wechat-bind-action">
|
||||
<t-button theme="default" variant="outline" :loading="wechatLoading" @click="startWeChatBinding">
|
||||
<template #icon><t-icon name="scan" /></template>
|
||||
{{ $t('agentEditor.im.wechatScanBind') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<!-- QR code displayed -->
|
||||
<div v-else class="wechat-qr-display">
|
||||
<div class="qr-container">
|
||||
<img :src="wechatQRImgUrl" alt="WeChat QR Code" class="qr-image" />
|
||||
<div v-if="wechatQRStatus === 'expired'" class="qr-expired-overlay" @click="startWeChatBinding">
|
||||
<t-icon name="refresh" class="refresh-icon" />
|
||||
<span>{{ $t('agentEditor.im.wechatQRExpired') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="qr-hint">
|
||||
<template v-if="wechatQRStatus === 'scaned'">
|
||||
{{ $t('agentEditor.im.wechatBinding') }}
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ $t('agentEditor.im.wechatScanning') }}
|
||||
</template>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</t-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from 'vue';
|
||||
import { ref, onMounted, watch, onUnmounted, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { MessagePlugin } from 'tdesign-vue-next';
|
||||
import { listIMChannels, createIMChannel, updateIMChannel, deleteIMChannel, toggleIMChannel } from '@/api/agent';
|
||||
import {
|
||||
listIMChannels, createIMChannel, updateIMChannel, deleteIMChannel, toggleIMChannel,
|
||||
getWeChatQRCode, pollWeChatQRCodeStatus,
|
||||
} from '@/api/agent';
|
||||
import { listKnowledgeBases } from '@/api/knowledge-base';
|
||||
import type { IMChannel } from '@/api/agent';
|
||||
|
||||
@@ -366,12 +423,21 @@ const editingChannel = ref<IMChannel | null>(null);
|
||||
// Knowledge base options for file-to-KB feature
|
||||
const knowledgeBases = ref<{ id: string; name: string }[]>([]);
|
||||
|
||||
// WeChat QR code binding state
|
||||
const wechatQRContent = ref(''); // raw text to encode as QR code
|
||||
const wechatQRImgUrl = ref(''); // generated QR image URL
|
||||
const wechatQRCode = ref(''); // opaque token for polling status
|
||||
const wechatQRStatus = ref<string>('');
|
||||
const wechatLoading = ref(false);
|
||||
let wechatPollActive = false;
|
||||
let wechatPollTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
const defaultCredentials = (): Record<string, any> => ({});
|
||||
|
||||
const formData = ref({
|
||||
platform: 'wecom' as 'wecom' | 'feishu' | 'slack' | 'telegram' | 'dingtalk' | 'mattermost',
|
||||
platform: 'wecom' as 'wecom' | 'feishu' | 'slack' | 'telegram' | 'dingtalk' | 'mattermost' | 'wechat',
|
||||
name: '',
|
||||
mode: 'websocket' as 'webhook' | 'websocket',
|
||||
mode: 'websocket' as 'webhook' | 'websocket' | 'longpoll',
|
||||
output_mode: 'stream' as 'stream' | 'full',
|
||||
session_mode: 'user' as 'user' | 'thread',
|
||||
knowledge_base_id: '',
|
||||
@@ -401,6 +467,101 @@ watch(
|
||||
}
|
||||
},
|
||||
);
|
||||
// Whether WeChat credentials are already bound
|
||||
const wechatBound = computed(() => {
|
||||
return formData.value.platform === 'wechat' &&
|
||||
formData.value.credentials.bot_token &&
|
||||
formData.value.credentials.ilink_bot_id;
|
||||
});
|
||||
|
||||
|
||||
function onPlatformChange(val: string | number | boolean) {
|
||||
formData.value.credentials = defaultCredentials();
|
||||
stopWeChatPolling();
|
||||
wechatQRContent.value = '';
|
||||
wechatQRImgUrl.value = '';
|
||||
wechatQRCode.value = '';
|
||||
wechatQRStatus.value = '';
|
||||
// WeChat uses fixed mode/output
|
||||
if (val === 'wechat') {
|
||||
formData.value.mode = 'longpoll';
|
||||
formData.value.output_mode = 'full';
|
||||
} else {
|
||||
formData.value.mode = 'websocket';
|
||||
formData.value.output_mode = 'stream';
|
||||
}
|
||||
}
|
||||
|
||||
async function startWeChatBinding() {
|
||||
stopWeChatPolling();
|
||||
wechatLoading.value = true;
|
||||
wechatQRContent.value = '';
|
||||
wechatQRImgUrl.value = '';
|
||||
wechatQRStatus.value = '';
|
||||
|
||||
try {
|
||||
const res = await getWeChatQRCode();
|
||||
// qrcode_url is the text content to encode as QR code (e.g. a weixin:// URL)
|
||||
wechatQRContent.value = res.data.qrcode_url;
|
||||
wechatQRCode.value = res.data.qrcode;
|
||||
wechatQRStatus.value = 'wait';
|
||||
|
||||
// Generate QR code image via public API (no extra npm dependency needed)
|
||||
wechatQRImgUrl.value = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(res.data.qrcode_url)}`;
|
||||
|
||||
// Start long-polling for scan status
|
||||
startStatusPolling();
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || 'Failed to generate QR code');
|
||||
} finally {
|
||||
wechatLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function startStatusPolling() {
|
||||
wechatPollActive = true;
|
||||
pollOnce();
|
||||
}
|
||||
|
||||
async function pollOnce() {
|
||||
if (!wechatPollActive) return;
|
||||
try {
|
||||
const statusRes = await pollWeChatQRCodeStatus(wechatQRCode.value);
|
||||
if (!wechatPollActive) return;
|
||||
wechatQRStatus.value = statusRes.data.status;
|
||||
|
||||
if (statusRes.data.status === 'confirmed' && statusRes.data.credentials) {
|
||||
formData.value.credentials = {
|
||||
bot_token: statusRes.data.credentials.bot_token,
|
||||
ilink_bot_id: statusRes.data.credentials.ilink_bot_id,
|
||||
ilink_user_id: statusRes.data.credentials.ilink_user_id,
|
||||
};
|
||||
stopWeChatPolling();
|
||||
wechatQRContent.value = '';
|
||||
wechatQRImgUrl.value = '';
|
||||
MessagePlugin.success(t('agentEditor.im.wechatBindSuccess'));
|
||||
return;
|
||||
}
|
||||
if (statusRes.data.status === 'expired') {
|
||||
stopWeChatPolling();
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
// transient error
|
||||
}
|
||||
// Schedule next poll with a short delay (the backend already long-polled ~35s)
|
||||
if (wechatPollActive) {
|
||||
wechatPollTimer = setTimeout(pollOnce, 500);
|
||||
}
|
||||
}
|
||||
|
||||
function stopWeChatPolling() {
|
||||
wechatPollActive = false;
|
||||
if (wechatPollTimer) {
|
||||
clearTimeout(wechatPollTimer);
|
||||
wechatPollTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadChannels() {
|
||||
loading.value = true;
|
||||
@@ -419,7 +580,7 @@ async function loadChannels() {
|
||||
}
|
||||
|
||||
function getCallbackUrl(channel: IMChannel): string {
|
||||
const base = import.meta.env.VITE_IS_DOCKER ? window.location.origin : 'http://127.0.0.1:8080';
|
||||
const base = window.location.origin;
|
||||
return `${base}/api/v1/im/callback/${channel.id}`;
|
||||
}
|
||||
|
||||
@@ -461,6 +622,11 @@ function editChannel(channel: IMChannel) {
|
||||
|
||||
function resetForm() {
|
||||
editingChannel.value = null;
|
||||
stopWeChatPolling();
|
||||
wechatQRContent.value = '';
|
||||
wechatQRImgUrl.value = '';
|
||||
wechatQRCode.value = '';
|
||||
wechatQRStatus.value = '';
|
||||
formData.value = {
|
||||
platform: 'wecom',
|
||||
name: '',
|
||||
@@ -474,6 +640,12 @@ function resetForm() {
|
||||
|
||||
async function handleSave() {
|
||||
try {
|
||||
// For WeChat, validate that credentials are bound
|
||||
if (formData.value.platform === 'wechat' && !formData.value.credentials.bot_token) {
|
||||
MessagePlugin.warning(t('agentEditor.im.wechatScanBind'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (editingChannel.value) {
|
||||
await updateIMChannel(editingChannel.value.id, {
|
||||
name: formData.value.name,
|
||||
@@ -527,6 +699,10 @@ async function handleDelete(id: string) {
|
||||
onMounted(() => {
|
||||
loadChannels();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
stopWeChatPolling();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
@@ -670,6 +846,11 @@ onMounted(() => {
|
||||
background: rgba(25, 42, 77, 0.08);
|
||||
color: #192a4d;
|
||||
}
|
||||
|
||||
&.wechat {
|
||||
background: rgba(7, 193, 96, 0.08);
|
||||
color: #07c160;
|
||||
}
|
||||
}
|
||||
|
||||
.channel-name {
|
||||
@@ -815,4 +996,86 @@ onMounted(() => {
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
// --- WeChat QR code binding ---
|
||||
.wechat-bound-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 12px 16px;
|
||||
background: rgba(7, 193, 96, 0.06);
|
||||
border: 1px solid rgba(7, 193, 96, 0.2);
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
color: var(--td-text-color-primary);
|
||||
|
||||
.bound-icon {
|
||||
font-size: 18px;
|
||||
color: #07c160;
|
||||
}
|
||||
}
|
||||
|
||||
.wechat-qr-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.wechat-bind-action {
|
||||
padding: 24px 0;
|
||||
}
|
||||
|
||||
.wechat-qr-display {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.qr-container {
|
||||
position: relative;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
// QR code images are always black-on-white; force white background
|
||||
// so the code remains scannable in dark mode.
|
||||
background: #fff;
|
||||
|
||||
.qr-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
}
|
||||
|
||||
.qr-expired-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
|
||||
.refresh-icon {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.qr-hint {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -15,7 +15,7 @@ import AgentSelector from './AgentSelector.vue';
|
||||
import { getCaretCoordinates } from '@/utils/caret';
|
||||
import { listModels, type ModelConfig } from '@/api/model';
|
||||
import { listAgents, type CustomAgent, BUILTIN_QUICK_ANSWER_ID, BUILTIN_SMART_REASONING_ID } from '@/api/agent';
|
||||
import { getTenantWebSearchConfig } from '@/api/web-search';
|
||||
import { listWebSearchProviders, type WebSearchProviderEntity } from '@/api/web-search-provider';
|
||||
import { getConversationConfig, updateConversationConfig, type ConversationConfig } from '@/api/system';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import AttachmentUpload, { type AttachmentFile } from './AttachmentUpload.vue';
|
||||
@@ -197,6 +197,11 @@ const agentWebSearchEnabled = computed(() => {
|
||||
return currentAgentConfig.value?.web_search_enabled ?? true;
|
||||
});
|
||||
|
||||
const agentWebSearchProviderId = computed(() => {
|
||||
if (!hasAgentConfig.value) return '';
|
||||
return currentAgentConfig.value?.web_search_provider_id || '';
|
||||
});
|
||||
|
||||
// 网络搜索是否被智能体禁用(只读状态)- 只有明确设置为 false 时才禁用
|
||||
const isWebSearchDisabledByAgent = computed(() => {
|
||||
return hasAgentConfig.value && agentWebSearchEnabled.value === false;
|
||||
@@ -287,7 +292,6 @@ const isAgentEnabled = computed(() => settingsStore.isAgentEnabled);
|
||||
const isWebSearchEnabled = computed(() => settingsStore.isWebSearchEnabled);
|
||||
const selectedKbIds = computed(() => settingsStore.settings.selectedKnowledgeBases || []);
|
||||
const selectedFileIds = computed(() => settingsStore.settings.selectedFiles || []);
|
||||
const isWebSearchConfigured = ref(false);
|
||||
|
||||
// 获取已选择的知识库信息
|
||||
const knowledgeBases = ref<Array<{ id: string; name: string; type?: 'document' | 'faq'; knowledge_count?: number; chunk_count?: number }>>([]);
|
||||
@@ -526,19 +530,29 @@ watch(selectedFileIds, () => {
|
||||
loadFiles();
|
||||
}, { immediate: true });
|
||||
|
||||
const webSearchProviders = ref<WebSearchProviderEntity[]>([]);
|
||||
|
||||
const isWebSearchConfigured = computed(() => {
|
||||
const agentProviderId = agentWebSearchProviderId.value;
|
||||
if (agentProviderId) {
|
||||
return webSearchProviders.value.some(p => p.id === agentProviderId);
|
||||
}
|
||||
|
||||
return webSearchProviders.value.some(p => p.is_default);
|
||||
});
|
||||
|
||||
const loadWebSearchConfig = async () => {
|
||||
try {
|
||||
const response: any = await getTenantWebSearchConfig();
|
||||
const config = response?.data;
|
||||
const configured = !!(config && config.provider);
|
||||
isWebSearchConfigured.value = configured;
|
||||
const response = await listWebSearchProviders();
|
||||
const providers = (response as any)?.data;
|
||||
webSearchProviders.value = Array.isArray(providers) ? providers : [];
|
||||
|
||||
if (!configured && settingsStore.isWebSearchEnabled) {
|
||||
if (!isWebSearchConfigured.value && settingsStore.isWebSearchEnabled) {
|
||||
settingsStore.toggleWebSearch(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load web search config:', error);
|
||||
isWebSearchConfigured.value = false;
|
||||
webSearchProviders.value = [];
|
||||
if (settingsStore.isWebSearchEnabled) {
|
||||
settingsStore.toggleWebSearch(false);
|
||||
}
|
||||
|
||||
@@ -317,6 +317,18 @@ const fallbackProviderOptions = computed(() => [
|
||||
description: t('model.editor.providers.openai.description'),
|
||||
modelTypes: ['chat', 'embedding', 'vllm', 'asr']
|
||||
},
|
||||
{
|
||||
value: 'azure_openai',
|
||||
label: t('model.editor.providers.azure_openai.label'),
|
||||
defaultUrls: {
|
||||
chat: 'https://{resource}.openai.azure.com',
|
||||
embedding: 'https://{resource}.openai.azure.com',
|
||||
vllm: 'https://{resource}.openai.azure.com',
|
||||
asr: 'https://{resource}.openai.azure.com'
|
||||
},
|
||||
description: t('model.editor.providers.azure_openai.description'),
|
||||
modelTypes: ['chat', 'embedding', 'vllm', 'asr']
|
||||
},
|
||||
{
|
||||
value: 'aliyun',
|
||||
label: t('model.editor.providers.aliyun.label'),
|
||||
@@ -810,7 +822,8 @@ const checkRemoteAPI = async () => {
|
||||
result = await checkRemoteModel({
|
||||
modelName: formData.value.modelName,
|
||||
baseUrl: formData.value.baseUrl,
|
||||
apiKey: formData.value.apiKey || ''
|
||||
apiKey: formData.value.apiKey || '',
|
||||
provider: formData.value.provider
|
||||
})
|
||||
break
|
||||
|
||||
@@ -846,7 +859,8 @@ const checkRemoteAPI = async () => {
|
||||
result = await checkRemoteModel({
|
||||
modelName: formData.value.modelName,
|
||||
baseUrl: formData.value.baseUrl,
|
||||
apiKey: formData.value.apiKey || ''
|
||||
apiKey: formData.value.apiKey || '',
|
||||
provider: formData.value.provider
|
||||
})
|
||||
break
|
||||
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
<t-icon name="control-platform" class="menu-icon" />
|
||||
<span>{{ $t('settings.modelManagement') }}</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="handleQuickNav('ollama')">
|
||||
<t-icon name="server" class="menu-icon" />
|
||||
<span>Ollama</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="handleQuickNav('websearch')">
|
||||
<svg
|
||||
width="16"
|
||||
@@ -47,16 +43,21 @@
|
||||
<t-icon name="tools" class="menu-icon" />
|
||||
<span>{{ $t('settings.mcpService') }}</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="handleQuickNav('api')">
|
||||
<t-icon name="secured" class="menu-icon" />
|
||||
<span>{{ $t('settings.apiInfo') }}</span>
|
||||
</div>
|
||||
<div class="menu-divider"></div>
|
||||
<div class="menu-item" @click="handleSettings">
|
||||
<t-icon name="setting" class="menu-icon" />
|
||||
<span>{{ $t('general.allSettings') }}</span>
|
||||
</div>
|
||||
<div class="menu-divider"></div>
|
||||
<div class="menu-item" @click="openApiDoc">
|
||||
<t-icon name="book" class="menu-icon" />
|
||||
<div class="menu-item" @click="openClawhubSkill">
|
||||
<span class="menu-icon menu-icon--emoji" role="img" :aria-label="$t('common.clawhubSkill')">🦞</span>
|
||||
<span class="menu-text-with-icon">
|
||||
<span>{{ $t('tenant.apiDocument') }}</span>
|
||||
<span>{{ $t('common.clawhubSkill') }}</span>
|
||||
<span class="menu-new-badge">{{ $t('common.newBadge') }}</span>
|
||||
<svg class="menu-external-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path
|
||||
fill="currentColor"
|
||||
@@ -65,10 +66,11 @@
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="openWebsite">
|
||||
<t-icon name="home" class="menu-icon" />
|
||||
<div class="menu-item" @click="openChromeExtension">
|
||||
<t-icon name="extension" class="menu-icon" />
|
||||
<span class="menu-text-with-icon">
|
||||
<span>{{ $t('common.website') }}</span>
|
||||
<span>{{ $t('common.chromeExtension') }}</span>
|
||||
<span class="menu-new-badge">{{ $t('common.newBadge') }}</span>
|
||||
<svg class="menu-external-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path
|
||||
fill="currentColor"
|
||||
@@ -77,10 +79,15 @@
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="openGithub">
|
||||
<div
|
||||
class="menu-item"
|
||||
:title="$t('common.githubStarTip')"
|
||||
@click="openGithub"
|
||||
>
|
||||
<t-icon name="logo-github" class="menu-icon" />
|
||||
<span class="menu-text-with-icon">
|
||||
<span>GitHub</span>
|
||||
<span>{{ $t('common.github') }}</span>
|
||||
<t-icon name="star-filled" class="menu-github-star-icon" size="14px" aria-hidden="true" />
|
||||
<svg class="menu-external-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path
|
||||
fill="currentColor"
|
||||
@@ -89,11 +96,13 @@
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="menu-divider"></div>
|
||||
<div class="menu-item danger" @click="handleLogout">
|
||||
<t-icon name="logout" class="menu-icon" />
|
||||
<span>{{ $t('auth.logout') }}</span>
|
||||
</div>
|
||||
<template v-if="!authStore.isLiteMode">
|
||||
<div class="menu-divider"></div>
|
||||
<div class="menu-item danger" @click="handleLogout">
|
||||
<t-icon name="logout" class="menu-icon" />
|
||||
<span>{{ $t('auth.logout') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</Transition>
|
||||
</div>
|
||||
@@ -159,16 +168,20 @@ const handleSettings = () => {
|
||||
router.push('/platform/settings')
|
||||
}
|
||||
|
||||
// 打开 API 文档
|
||||
const openApiDoc = () => {
|
||||
const CHROME_EXTENSION_URL =
|
||||
'https://chromewebstore.google.com/detail/jpemjbopikggjlmikmclgbmkhhopjdgd?utm_source=item-share-cb'
|
||||
|
||||
const CLAWHUB_SKILL_URL = 'https://clawhub.ai/lyingbug/weknora'
|
||||
|
||||
// 打开 WeKnora Chrome 插件(Chrome应用商店)
|
||||
const openChromeExtension = () => {
|
||||
menuVisible.value = false
|
||||
window.open('https://github.com/Tencent/WeKnora/blob/main/docs/api/README.md', '_blank')
|
||||
window.open(CHROME_EXTENSION_URL, '_blank')
|
||||
}
|
||||
|
||||
// 打开官网
|
||||
const openWebsite = () => {
|
||||
const openClawhubSkill = () => {
|
||||
menuVisible.value = false
|
||||
window.open('https://weknora.weixin.qq.com/', '_blank')
|
||||
window.open(CLAWHUB_SKILL_URL, '_blank')
|
||||
}
|
||||
|
||||
// 打开 GitHub
|
||||
@@ -407,6 +420,18 @@ onUnmounted(() => {
|
||||
height: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&--emoji {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 15px;
|
||||
line-height: 1;
|
||||
flex-shrink: 0;
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-text-with-icon {
|
||||
@@ -417,13 +442,33 @@ onUnmounted(() => {
|
||||
color: inherit;
|
||||
min-width: 0;
|
||||
|
||||
span {
|
||||
> span:first-of-type {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-new-badge {
|
||||
flex-shrink: 0;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
padding: 2px 5px;
|
||||
border-radius: 4px;
|
||||
background: var(--td-brand-color-light);
|
||||
color: var(--td-brand-color);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.menu-github-star-icon {
|
||||
flex-shrink: 0;
|
||||
color: var(--td-warning-color);
|
||||
}
|
||||
|
||||
.menu-external-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
|
||||
@@ -690,6 +690,24 @@ const getParentContent = (item: any) => {
|
||||
return parentContextCache.value.get(item.parent_chunk_id) || '';
|
||||
};
|
||||
|
||||
const summaryExpanded = ref(false);
|
||||
const summaryRef = ref<HTMLElement>();
|
||||
const summaryOverflow = ref(false);
|
||||
|
||||
const checkSummaryOverflow = () => {
|
||||
nextTick(() => {
|
||||
const el = summaryRef.value;
|
||||
if (!el) { summaryOverflow.value = false; return; }
|
||||
summaryOverflow.value = el.scrollHeight > el.clientHeight + 1;
|
||||
});
|
||||
};
|
||||
|
||||
watch(() => props.details?.description, () => {
|
||||
summaryExpanded.value = false;
|
||||
checkSummaryOverflow();
|
||||
});
|
||||
watch(summaryRef, () => checkSummaryOverflow());
|
||||
|
||||
const downloadFile = () => {
|
||||
downKnowledgeDetails(props.details.id)
|
||||
.then((result) => {
|
||||
@@ -734,7 +752,7 @@ const handleDetailsScroll = () => {
|
||||
</script>
|
||||
<template>
|
||||
<div class="doc_content" ref="mdContentWrap">
|
||||
<t-drawer :visible="visible" :zIndex="2000" :closeBtn="true" @close="handleClose">
|
||||
<t-drawer :visible="visible" :zIndex="2000" :closeBtn="true" :footer="false" @close="handleClose">
|
||||
<template #header>
|
||||
<div class="drawer-header">
|
||||
<span class="header-title">{{ getDisplayTitle() }}</span>
|
||||
@@ -784,7 +802,12 @@ const handleDetailsScroll = () => {
|
||||
<!-- 文档摘要 -->
|
||||
<div v-if="details.description" class="summary_box">
|
||||
<span class="label">{{ $t('knowledgeBase.documentSummary') }}</span>
|
||||
<div class="summary_content">{{ details.description }}</div>
|
||||
<div class="summary_wrapper" :class="{ 'summary_clickable': summaryOverflow || summaryExpanded }" @click="(summaryOverflow || summaryExpanded) && (summaryExpanded = !summaryExpanded)">
|
||||
<div ref="summaryRef" :class="['summary_content', { 'summary_collapsed': !summaryExpanded }]">{{ details.description }}</div>
|
||||
<div v-if="(summaryOverflow && !summaryExpanded) || summaryExpanded" class="summary_fade" :class="{ 'summary_fade_expanded': summaryExpanded }">
|
||||
<t-icon :name="summaryExpanded ? 'chevron-up' : 'chevron-down'" size="14px" class="summary_fade_icon" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="details.summary_status === 'pending' || details.summary_status === 'processing'" class="summary_box">
|
||||
<span class="label">{{ $t('knowledgeBase.documentSummary') }}</span>
|
||||
@@ -948,10 +971,6 @@ const handleDetailsScroll = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<t-button @click="handleClose">{{ $t('common.confirm') }}</t-button>
|
||||
<t-button theme="default" @click="handleClose">{{ $t('common.cancel') }}</t-button>
|
||||
</template>
|
||||
</t-drawer>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1056,15 +1075,50 @@ const handleDetailsScroll = () => {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.summary_content {
|
||||
padding: 12px;
|
||||
.summary_wrapper {
|
||||
position: relative;
|
||||
background: var(--td-bg-color-container-hover);
|
||||
border-radius: 4px;
|
||||
|
||||
&.summary_clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.summary_content {
|
||||
padding: 12px;
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
word-break: break-word;
|
||||
white-space: pre-wrap;
|
||||
|
||||
&.summary_collapsed {
|
||||
max-height: 4.5em;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.summary_fade {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding-bottom: 4px;
|
||||
pointer-events: none;
|
||||
|
||||
&:not(.summary_fade_expanded) {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 28px;
|
||||
background: linear-gradient(transparent, var(--td-bg-color-container-hover) 80%);
|
||||
border-radius: 0 0 4px 4px;
|
||||
align-items: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
.summary_fade_icon {
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
.summary_loading {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<div class="logo_row" v-if="!uiStore.sidebarCollapsed">
|
||||
<div class="logo_box" @click="router.push('/platform/knowledge-bases')" style="cursor: pointer;">
|
||||
<img class="logo" src="@/assets/img/weknora.png" alt="">
|
||||
<sup v-if="isLiteEdition" class="lite-badge">Lite</sup>
|
||||
</div>
|
||||
<div class="sidebar-toggle"
|
||||
@click="uiStore.toggleSidebar"
|
||||
@@ -60,6 +61,14 @@
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<div ref="submenuscrollContainer" @scroll="handleScroll" class="submenu" v-if="item.children && !uiStore.sidebarCollapsed">
|
||||
<!-- 骨架屏占位 -->
|
||||
<template v-if="loading && groupedSessions.length === 0">
|
||||
<div v-for="n in 5" :key="'skel-'+n" class="submenu_item_p">
|
||||
<div class="submenu_item">
|
||||
<t-skeleton animation="gradient" style="margin-left:18px;width:80%" :row-col="[{ width: '100%', height: '16px' }]" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-for="(group, groupIndex) in groupedSessions" :key="groupIndex">
|
||||
<div class="timeline_header">{{ group.label }}</div>
|
||||
<div class="submenu_item_p" v-for="(subitem, subindex) in group.items" :key="subitem.id">
|
||||
@@ -137,6 +146,7 @@ import { MessagePlugin, DialogPlugin, Icon as TIcon } from "tdesign-vue-next";
|
||||
import UserMenu from '@/components/UserMenu.vue';
|
||||
import TenantSelector from '@/components/TenantSelector.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { getSystemInfo } from '@/api/system';
|
||||
|
||||
const { t } = useI18n();
|
||||
const usemenuStore = useMenuStore();
|
||||
@@ -155,8 +165,9 @@ const submenuscrollContainer = ref(null);
|
||||
const totalPages = computed(() => Math.ceil(total.value / page_size.value));
|
||||
const hasMore = computed(() => currentPage.value < totalPages.value);
|
||||
type MenuItem = { title: string; icon: string; path: string; childrenPath?: string; children?: any[] };
|
||||
const { menuArr } = storeToRefs(usemenuStore);
|
||||
const { menuArr, visibleMenuArr } = storeToRefs(usemenuStore);
|
||||
let activeSubmenu = ref<string>('');
|
||||
const isLiteEdition = ref(false);
|
||||
|
||||
// 批量管理状态
|
||||
const batchMode = ref(false)
|
||||
@@ -250,15 +261,15 @@ const getIconActiveState = (itemPath: string) => {
|
||||
};
|
||||
};
|
||||
|
||||
// 分离上下两部分菜单
|
||||
// 分离上下两部分菜单(使用 visibleMenuArr 以便 lite 模式过滤 logout)
|
||||
const topMenuItems = computed<MenuItem[]>(() => {
|
||||
return (menuArr.value as unknown as MenuItem[]).filter((item: MenuItem) =>
|
||||
return (visibleMenuArr.value as unknown as MenuItem[]).filter((item: MenuItem) =>
|
||||
item.path === 'knowledge-bases' || item.path === 'knowledge-search' || item.path === 'agents' || item.path === 'organizations' || item.path === 'creatChat'
|
||||
);
|
||||
});
|
||||
|
||||
const bottomMenuItems = computed<MenuItem[]>(() => {
|
||||
return (menuArr.value as unknown as MenuItem[]).filter((item: MenuItem) => {
|
||||
return (visibleMenuArr.value as unknown as MenuItem[]).filter((item: MenuItem) => {
|
||||
if (item.path === 'knowledge-bases' || item.path === 'knowledge-search' || item.path === 'agents' || item.path === 'organizations' || item.path === 'creatChat') {
|
||||
return false;
|
||||
}
|
||||
@@ -539,6 +550,14 @@ onMounted(async () => {
|
||||
currentSecondpath.value = `chat/${route.params.chatid}`;
|
||||
}
|
||||
|
||||
isLiteEdition.value = authStore.isLiteMode
|
||||
getSystemInfo().then(res => {
|
||||
if (res.data?.edition === 'lite') {
|
||||
isLiteEdition.value = true
|
||||
authStore.setLiteMode(true)
|
||||
}
|
||||
}).catch(() => {})
|
||||
|
||||
// 初始化知识库信息
|
||||
const kbId = (route.params as any)?.kbId as string
|
||||
if (kbId && isInKnowledgeBase.value) {
|
||||
@@ -761,6 +780,11 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
|
||||
transition: width 0.25s ease, min-width 0.25s ease;
|
||||
position: relative;
|
||||
|
||||
// macOS Wails 桌面:红绿灯位于 HiddenInset 标题栏区域,需让出顶部空间
|
||||
html.wails-desktop & {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
&--collapsed {
|
||||
min-width: 60px;
|
||||
width: 60px;
|
||||
@@ -832,10 +856,21 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
|
||||
.logo{
|
||||
width: 134px;
|
||||
height: auto;
|
||||
}
|
||||
.lite-badge {
|
||||
margin-left: 2px;
|
||||
align-self: flex-start;
|
||||
margin-top: 2px;
|
||||
font-size: 9px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-placeholder);
|
||||
user-select: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.logo_img {
|
||||
@@ -998,6 +1033,11 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
@keyframes menuItemFadeIn {
|
||||
from { opacity: 0; transform: translateX(-4px); }
|
||||
to { opacity: 1; transform: translateX(0); }
|
||||
}
|
||||
|
||||
.timeline_header {
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
@@ -1007,6 +1047,7 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
|
||||
margin-top: 8px;
|
||||
line-height: 20px;
|
||||
user-select: none;
|
||||
animation: menuItemFadeIn 0.25s ease-out;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 4px;
|
||||
@@ -1017,6 +1058,7 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
|
||||
height: 44px;
|
||||
padding: 4px 0px 4px 0px;
|
||||
box-sizing: border-box;
|
||||
animation: menuItemFadeIn 0.25s ease-out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user