chore: Update .gitignore and Makefile for development enhancements

- Added 'logs/' and '*.pid' to .gitignore to exclude log files and process ID files from version control.
- Expanded Makefile with new development commands for easier local environment management, including 'dev-start', 'dev-stop', 'dev-restart', 'dev-logs', 'dev-status', 'dev-app', and 'dev-frontend'.
- Updated README_CN.md to include instructions for the new development mode and commands for improved developer experience.
This commit is contained in:
wizardchen
2025-11-07 15:52:52 +08:00
parent 655df49d7d
commit d387fd672f
24 changed files with 2447 additions and 644 deletions
+62 -4
View File
@@ -1,14 +1,17 @@
<script setup lang="ts">
import { ref, defineEmits, onMounted, defineProps, computed, watch, nextTick } from "vue";
import { useRoute } from 'vue-router';
import { ref, defineEmits, onMounted, defineProps, computed, watch, nextTick, h } from "vue";
import { useRoute, useRouter } from 'vue-router';
import { onBeforeRouteUpdate } from 'vue-router';
import { MessagePlugin } from "tdesign-vue-next";
import { useSettingsStore } from '@/stores/settings';
import { useUIStore } from '@/stores/ui';
import { listKnowledgeBases } from '@/api/knowledge-base';
import KnowledgeBaseSelector from './KnowledgeBaseSelector.vue';
const route = useRoute();
const router = useRouter();
const settingsStore = useSettingsStore();
const uiStore = useUIStore();
let query = ref("");
const showKbSelector = ref(false);
const atButtonRef = ref<HTMLElement>();
@@ -98,6 +101,45 @@ const onKeydown = (val: string, event: { e: { preventDefault(): unknown; keyCode
}
const toggleAgentMode = () => {
// 如果要启用 Agent,先检查是否就绪
// 注意:isAgentReady 是从 store 中计算的,需要确保 store 中的配置是最新的
if (!isAgentEnabled.value) {
// 尝试启用 Agent,先检查是否就绪
const agentReady = settingsStore.isAgentReady
if (!agentReady) {
// 创建带跳转链接的自定义消息
const messageContent = h('div', { style: 'display: flex; align-items: center; gap: 8px; flex-wrap: wrap;' }, [
h('span', { style: 'flex: 1; min-width: 0;' }, 'Agent 未就绪,请先在设置中完成 Agent 配置(思考模型、Rerank 模型和允许的工具)'),
h('a', {
href: '#',
onClick: (e: Event) => {
e.preventDefault();
// 使用 uiStore 打开设置并跳转到 agent 部分
uiStore.openSettings('agent');
// 如果当前不在设置页面,导航到设置页面
if (route.path !== '/platform/settings') {
router.push('/platform/settings');
}
},
style: 'color: #07C05F; text-decoration: none; font-weight: 500; cursor: pointer; white-space: nowrap; flex-shrink: 0;',
onMouseenter: (e: Event) => {
(e.target as HTMLElement).style.textDecoration = 'underline';
},
onMouseleave: (e: Event) => {
(e.target as HTMLElement).style.textDecoration = 'none';
}
}, '去设置 →')
]);
MessagePlugin.warning({
content: messageContent,
duration: 5000
});
return
}
}
// 正常切换 Agent 状态
settingsStore.toggleAgent(!isAgentEnabled.value);
const message = isAgentEnabled.value ? 'Agent 模式已启用' : 'Agent 模式已禁用';
MessagePlugin.success(message);
@@ -126,10 +168,16 @@ onBeforeRouteUpdate((to, from, next) => {
<!-- 左侧控制按钮 -->
<div class="control-left">
<!-- Agent 模式按钮 -->
<t-tooltip :content="isAgentEnabled ? 'Agent 模式(已启用)' : 'Agent 模式(已禁用)'" placement="top">
<t-tooltip
:content="isAgentEnabled ? 'Agent 模式(已启用)' : (settingsStore.isAgentReady ? 'Agent 模式(已禁用,点击启用)' : 'Agent 未就绪,请先完成配置')"
placement="top"
>
<div
class="control-btn agent-btn"
:class="{ 'active': isAgentEnabled }"
:class="{
'active': isAgentEnabled,
'disabled': !isAgentEnabled && !settingsStore.isAgentReady
}"
@click="toggleAgentMode"
>
<img
@@ -309,6 +357,16 @@ const getImgSrc = (url: string) => {
background: rgba(7, 192, 95, 0.15);
}
}
&.disabled {
opacity: 0.5;
cursor: not-allowed;
&:hover {
background: #f5f5f5;
transform: none;
}
}
}
.control-icon {
@@ -164,6 +164,7 @@ const updateDropdownPosition = () => {
const vw = window.innerWidth
const topFallback = Math.max(80, window.innerHeight / 2 - 160)
dropdownStyle.value = {
position: 'fixed',
width: `${dropdownWidth}px`,
left: `${Math.round((vw - dropdownWidth) / 2)}px`,
top: `${Math.round(topFallback)}px`
@@ -175,12 +176,13 @@ const updateDropdownPosition = () => {
return
}
// 获取 anchor 的 bounding rect
// 获取 anchor 的 bounding rect(相对于视口)
let rect: DOMRect | null = null
try {
if (typeof anchor.getBoundingClientRect === 'function') {
// 强制重新计算布局,确保获取最新位置
rect = anchor.getBoundingClientRect()
} else if (anchor.width && anchor.left) {
} else if (anchor.width !== undefined && anchor.left !== undefined) {
// 已经是 DOMRect
rect = anchor as DOMRect
}
@@ -188,7 +190,7 @@ const updateDropdownPosition = () => {
console.error('[KnowledgeBaseSelector] Error getting bounding rect:', e)
}
if (!rect) {
if (!rect || rect.width === 0 || rect.height === 0) {
applyFallback()
return
}
@@ -196,8 +198,9 @@ const updateDropdownPosition = () => {
const vw = window.innerWidth
const vh = window.innerHeight
// 左对齐到触发元素
let left = Math.round(rect.left)
// 左对齐到触发元素的左边缘
// 使用 Math.floor 而不是 Math.round,避免像素对齐问题
let left = Math.floor(rect.left)
// 边界处理:不超出视口左右(留 16px margin)
const minLeft = 16
@@ -214,35 +217,42 @@ const updateDropdownPosition = () => {
// 判断应该向上还是向下弹出
if (spaceBelow >= dropdownHeight + offsetY + 16) {
// 下方空间充足,向下弹出
top = Math.round(rect.bottom + offsetY)
top = Math.floor(rect.bottom + offsetY)
} else if (spaceAbove >= dropdownHeight + offsetY + 16) {
// 下方不够但上方充足,向上弹出
top = Math.round(rect.top - dropdownHeight - offsetY)
top = Math.floor(rect.top - dropdownHeight - offsetY)
} else {
// 上下都不够,选择空间较大的一侧
if (spaceAbove > spaceBelow) {
// 上方空间更大,贴着顶部
top = Math.max(16, Math.round(rect.top - dropdownHeight - offsetY))
top = Math.max(16, Math.floor(rect.top - dropdownHeight - offsetY))
} else {
// 下方空间更大,贴着底部或按钮下方
top = Math.round(rect.bottom + offsetY)
top = Math.floor(rect.bottom + offsetY)
// 确保不超出视口底部
if (top + dropdownHeight > vh - 16) {
top = Math.max(16, vh - dropdownHeight - 16)
top = Math.max(16, Math.floor(vh - dropdownHeight - 16))
}
}
}
// 使用 fixed 定位
// 使用 fixed 定位,确保没有 transform 或其他样式影响
dropdownStyle.value = {
position: 'fixed',
width: `${dropdownWidth}px`,
left: `${left}px`,
top: `${top}px`,
maxHeight: `${Math.min(dropdownHeight, vh - 32)}px` // 添加最大高度限制
maxHeight: `${Math.min(dropdownHeight, vh - 32)}px`, // 添加最大高度限制
transform: 'none', // 确保没有 transform 影响定位
margin: '0', // 确保没有 margin 影响定位
padding: '0' // 确保没有 padding 影响定位
}
}
// 事件监听器引用,用于清理
let resizeHandler: (() => void) | null = null
let scrollHandler: (() => void) | null = null
// 当 visible 变化时处理
watch(() => props.visible, async (v) => {
if (v) {
@@ -253,20 +263,33 @@ watch(() => props.visible, async (v) => {
requestAnimationFrame(() => {
updateDropdownPosition()
// 再次确保位置正确(应对动画或其他延迟渲染)
setTimeout(() => {
requestAnimationFrame(() => {
updateDropdownPosition()
}, 50)
// 最后一次确保位置正确
setTimeout(() => {
updateDropdownPosition()
}, 100)
})
})
// 确保 focus
nextTick(() => searchInput.value?.focus())
// 监听 resize/scroll 做微调
window.addEventListener('resize', updateDropdownPosition)
window.addEventListener('scroll', updateDropdownPosition, true)
// 监听 resize/scroll 做微调(使用 passive 提高性能)
resizeHandler = () => updateDropdownPosition()
scrollHandler = () => updateDropdownPosition()
window.addEventListener('resize', resizeHandler, { passive: true })
window.addEventListener('scroll', scrollHandler, { passive: true, capture: true })
} else {
searchQuery.value = ''
highlightedIndex.value = 0
window.removeEventListener('resize', updateDropdownPosition)
window.removeEventListener('scroll', updateDropdownPosition, true)
// 清理事件监听器
if (resizeHandler) {
window.removeEventListener('resize', resizeHandler)
resizeHandler = null
}
if (scrollHandler) {
window.removeEventListener('scroll', scrollHandler, { capture: true })
scrollHandler = null
}
}
})
</script>
+201 -74
View File
@@ -31,64 +31,66 @@
<!-- Ollama 本地模型选择器 -->
<div v-if="formData.source === 'local'" class="form-item">
<label class="form-label required">模型名称</label>
<t-select
v-model="formData.modelName"
:loading="loadingOllamaModels"
:class="{ 'downloading': downloading }"
:style="downloading ? `--progress: ${downloadProgress}%` : ''"
filterable
:filter="handleModelFilter"
placeholder="搜索模型..."
@focus="loadOllamaModels"
@visible-change="handleDropdownVisibleChange"
>
<!-- 已下载的模型 -->
<t-option
v-for="model in filteredOllamaModels"
:key="model.name"
:value="model.name"
:label="model.name"
<div class="model-select-row">
<t-select
v-model="formData.modelName"
:loading="loadingOllamaModels"
:class="{ 'downloading': downloading }"
:style="downloading ? `--progress: ${downloadProgress}%` : ''"
filterable
:filter="handleModelFilter"
placeholder="搜索模型..."
@focus="loadOllamaModels"
@visible-change="handleDropdownVisibleChange"
>
<div class="model-option">
<t-icon name="check-circle-filled" class="downloaded-icon" />
<span class="model-name">{{ model.name }}</span>
<span class="model-size">{{ formatModelSize(model.size) }}</span>
</div>
</t-option>
<!-- 已下载的模型 -->
<t-option
v-for="model in filteredOllamaModels"
:key="model.name"
:value="model.name"
:label="model.name"
>
<div class="model-option">
<t-icon name="check-circle-filled" class="downloaded-icon" />
<span class="model-name">{{ model.name }}</span>
<span class="model-size">{{ formatModelSize(model.size) }}</span>
</div>
</t-option>
<!-- 下载新模型选项(仅当搜索词不在列表中时显示) -->
<t-option
v-if="showDownloadOption"
:value="`__download__${searchKeyword}`"
:label="`下载: ${searchKeyword}`"
class="download-option"
>
<div class="model-option download">
<t-icon name="download" class="download-icon" />
<span class="model-name">下载: {{ searchKeyword }}</span>
</div>
</t-option>
<!-- 下载进度后缀 -->
<template v-if="downloading" #suffix>
<div class="download-suffix">
<t-icon name="loading" class="spinning" />
<span class="progress-text">{{ downloadProgress.toFixed(1) }}%</span>
</div>
</template>
</t-select>
<!-- 下载新模型选项(仅当搜索词不在列表中时显示) -->
<t-option
v-if="showDownloadOption"
:value="`__download__${searchKeyword}`"
:label="`下载: ${searchKeyword}`"
class="download-option"
<!-- 刷新按钮 -->
<t-button
variant="text"
size="small"
:loading="loadingOllamaModels"
@click="refreshOllamaModels"
class="refresh-btn"
>
<div class="model-option download">
<t-icon name="download" class="download-icon" />
<span class="model-name">下载: {{ searchKeyword }}</span>
</div>
</t-option>
<!-- 下载进度后缀 -->
<template v-if="downloading" #suffix>
<div class="download-suffix">
<t-icon name="loading" class="spinning" />
<span class="progress-text">{{ downloadProgress.toFixed(1) }}%</span>
</div>
</template>
</t-select>
<!-- 刷新按钮 -->
<t-button
variant="text"
size="small"
:loading="loadingOllamaModels"
@click="refreshOllamaModels"
class="refresh-btn"
>
<t-icon name="refresh" />
刷新列表
</t-button>
<t-icon name="refresh" />
刷新列表
</t-button>
</div>
</div>
<!-- Remote API 和 VLLM 保持原有的 input -->
@@ -153,12 +155,31 @@
<!-- Embedding 专用:维度 -->
<div v-if="modelType === 'embedding'" class="form-item">
<label class="form-label">向量维度</label>
<t-input-number
v-model="formData.dimension"
:min="128"
:max="4096"
placeholder="如:1536"
/>
<div class="dimension-control">
<t-input
v-model.number="formData.dimension"
type="number"
:min="128"
:max="4096"
placeholder="如:1536"
:disabled="formData.source === 'local' && checking"
/>
<!-- Ollama 本地模型:自动检测维度按钮 -->
<t-button
v-if="formData.source === 'local' && formData.modelName"
variant="outline"
size="small"
:loading="checking"
@click="checkOllamaDimension"
class="dimension-check-btn"
>
<t-icon name="refresh" />
检测维度
</t-button>
</div>
<p v-if="dimensionChecked && dimensionMessage" class="dimension-hint" :class="{ success: dimensionSuccess }">
{{ dimensionMessage }}
</p>
</div>
<!-- 设为默认 -->
@@ -231,6 +252,9 @@ const checking = ref(false)
const remoteChecked = ref(false)
const remoteAvailable = ref(false)
const remoteMessage = ref('')
const dimensionChecked = ref(false)
const dimensionSuccess = ref(false)
const dimensionMessage = ref('')
// Ollama 模型状态
const ollamaModelList = ref<OllamaModelInfo[]>([])
@@ -248,7 +272,7 @@ const formData = ref<ModelFormData>({
modelName: '',
baseUrl: '',
apiKey: '',
dimension: 1536,
dimension: undefined,
interfaceType: 'ollama',
isDefault: false
})
@@ -338,7 +362,7 @@ const resetForm = () => {
modelName: '',
baseUrl: '',
apiKey: '',
dimension: props.modelType === 'embedding' ? 1536 : undefined,
dimension: undefined, // 默认不填,让用户手动输入或通过检测按钮获取
interfaceType: undefined,
isDefault: false
}
@@ -347,6 +371,9 @@ const resetForm = () => {
remoteChecked.value = false
remoteAvailable.value = false
remoteMessage.value = ''
dimensionChecked.value = false
dimensionSuccess.value = false
dimensionMessage.value = ''
}
// 监听来源变化,重置校验状态(已合并到下面的 watch)
@@ -436,6 +463,45 @@ const checkModelStatus = async () => {
}
}
// 检查 Ollama 本地 Embedding 模型维度
const checkOllamaDimension = async () => {
if (!formData.value.modelName || formData.value.source !== 'local' || props.modelType !== 'embedding') {
return
}
checking.value = true
dimensionChecked.value = false
dimensionMessage.value = ''
try {
const result = await testEmbeddingModel({
source: 'local',
modelName: formData.value.modelName,
dimension: formData.value.dimension
})
dimensionChecked.value = true
dimensionSuccess.value = result.available || false
if (result.available && result.dimension) {
formData.value.dimension = result.dimension
dimensionMessage.value = `检测成功,向量维度:${result.dimension}`
MessagePlugin.success(dimensionMessage.value)
} else {
dimensionMessage.value = result.message || '检测失败,请手动输入维度'
MessagePlugin.warning(dimensionMessage.value)
}
} catch (error: any) {
console.error('检测 Ollama 模型维度失败:', error)
dimensionChecked.value = true
dimensionSuccess.value = false
dimensionMessage.value = error.message || '检测失败,请手动输入维度'
MessagePlugin.error(dimensionMessage.value)
} finally {
checking.value = false
}
}
// 检查 Remote API 连接(根据模型类型调用不同的接口)
const checkRemoteAPI = async () => {
if (!formData.value.modelName || !formData.value.baseUrl) {
@@ -570,18 +636,31 @@ const handleConfirm = async () => {
}
}
// 监听模型选择变化(处理下载逻辑)
watch(() => formData.value.modelName, async (newValue) => {
if (!newValue || !newValue.startsWith('__download__')) return
// 监听模型选择变化(处理下载逻辑和自动维度检测提示)
watch(() => formData.value.modelName, async (newValue, oldValue) => {
if (!newValue) return
// 提取模型名称
const modelName = newValue.replace('__download__', '')
// 处理下载逻辑
if (newValue.startsWith('__download__')) {
// 提取模型名称
const modelName = newValue.replace('__download__', '')
// 重置选择(避免显示 __download__ 前缀)
formData.value.modelName = ''
// 开始下载
await startDownload(modelName)
return
}
// 重置选择(避免显示 __download__ 前缀)
formData.value.modelName = ''
// 开始下载
await startDownload(modelName)
// 如果是 embedding 模型且选择的是 Ollama 本地模型,且模型名称发生了实际变化
if (props.modelType === 'embedding' &&
formData.value.source === 'local' &&
newValue !== oldValue &&
oldValue !== '') {
// 提示用户可以检测维度
MessagePlugin.info('模型已选择,点击"检测维度"按钮自动获取向量维度')
}
})
// 开始下载模型
@@ -658,6 +737,9 @@ watch(() => formData.value.source, () => {
remoteChecked.value = false
remoteAvailable.value = false
remoteMessage.value = ''
dimensionChecked.value = false
dimensionSuccess.value = false
dimensionMessage.value = ''
// 清理下载状态
searchKeyword.value = ''
@@ -670,6 +752,13 @@ watch(() => formData.value.source, () => {
currentDownloadModel.value = ''
})
// 监听模型名称变化,清理维度检测状态
watch(() => formData.value.modelName, () => {
dimensionChecked.value = false
dimensionSuccess.value = false
dimensionMessage.value = ''
})
// 取消
const handleCancel = () => {
dialogVisible.value = false
@@ -1000,10 +1089,21 @@ const handleCancel = () => {
}
}
.model-select-row {
display: flex;
align-items: center;
gap: 8px;
.t-select {
flex: 1;
}
}
.refresh-btn {
margin-top: 4px;
margin-top: 0;
font-size: 12px;
color: #666666;
flex-shrink: 0;
&:hover {
color: #07C05F;
@@ -1014,5 +1114,32 @@ const handleCancel = () => {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
// 维度控制样式
.dimension-control {
display: flex;
align-items: center;
gap: 8px;
:deep(.t-input) {
flex: 1;
}
}
.dimension-check-btn {
flex-shrink: 0;
font-size: 12px;
}
.dimension-hint {
margin: 8px 0 0 0;
font-size: 13px;
line-height: 1.5;
color: #e34d59;
&.success {
color: #07C05F;
}
}
</style>
+8
View File
@@ -84,6 +84,14 @@ export const useSettingsStore = defineStore("settings", {
// Agent 是否启用
isAgentEnabled: (state) => state.settings.isAgentEnabled || false,
// Agent 是否就绪(配置完整)
isAgentReady: (state) => {
const config = state.settings.agentConfig || defaultSettings.agentConfig
return config.thinkingModelId !== '' &&
config.rerankModelId !== '' &&
config.allowedTools.length > 0
},
// 获取 Agent 配置
agentConfig: (state) => state.settings.agentConfig || defaultSettings.agentConfig,
+238 -79
View File
@@ -3,23 +3,40 @@
<div class="section-header">
<h2>Agent 配置</h2>
<p class="section-description">配置 AI Agent 的默认行为和参数,这些设置将应用于所有启用 Agent 模式的对话</p>
<!-- Agent 状态显示 -->
<div class="agent-status-row">
<div class="status-label">
<label>Agent 状态</label>
</div>
<div class="status-control">
<div class="status-badge" :class="{ ready: isAgentReady }">
<t-icon
v-if="isAgentReady"
name="check-circle-filled"
class="status-icon"
/>
<t-icon
v-else
name="error-circle-filled"
class="status-icon"
/>
<span class="status-text">
{{ isAgentReady ? '可用' : '未就绪' }}
</span>
</div>
<span v-if="!isAgentReady" class="status-hint">
{{ agentStatusMessage }}
</span>
<p v-if="!isAgentReady" class="status-tip">
<t-icon name="info-circle" class="tip-icon" />
配置完成后,Agent 状态将自动变为"可用",此时可在对话界面开启 Agent 模式
</p>
</div>
</div>
</div>
<div class="settings-group">
<!-- 启用 Agent 模式 -->
<div class="setting-row">
<div class="setting-info">
<label>启用 Agent 模式</label>
<p class="desc">启用后,AI 将能够使用工具进行多步推理和跨知识库搜索</p>
</div>
<div class="setting-control">
<t-switch
v-model="localAgentEnabled"
@change="handleAgentToggle"
size="large"
/>
</div>
</div>
<!-- 最大迭代次数 -->
<div class="setting-row">
@@ -35,8 +52,7 @@
:max="30"
:step="1"
:marks="{ 1: '1', 5: '5', 10: '10', 15: '15', 20: '20', 25: '25', 30: '30' }"
@change="handleMaxIterationsChange"
:disabled="!localAgentEnabled"
@change="handleMaxIterationsChangeDebounced"
style="width: 200px;"
/>
<span class="value-display">{{ localMaxIterations }}</span>
@@ -141,7 +157,6 @@
:step="0.1"
:marks="{ 0: '0', 0.5: '0.5', 1: '1' }"
@change="handleTemperatureChange"
:disabled="!localAgentEnabled"
style="width: 200px;"
/>
<span class="value-display">{{ localTemperature.toFixed(1) }}</span>
@@ -161,7 +176,6 @@
multiple
placeholder="请选择工具..."
@change="handleAllowedToolsChange"
:disabled="!localAgentEnabled"
style="width: 400px;"
>
<t-option
@@ -181,7 +195,7 @@
</template>
<script setup lang="ts">
import { ref, onMounted, watch } from 'vue'
import { ref, onMounted, watch, computed, nextTick } from 'vue'
import { useRouter } from 'vue-router'
import { useSettingsStore } from '@/stores/settings'
import { MessagePlugin } from 'tdesign-vue-next'
@@ -192,13 +206,41 @@ const settingsStore = useSettingsStore()
const router = useRouter()
// 本地状态
const localAgentEnabled = ref(false)
const localMaxIterations = ref(5)
const localTemperature = ref(0.7)
const localThinkingModelId = ref('')
const localRerankModelId = ref('')
const localAllowedTools = ref<string[]>([])
// 计算 Agent 是否就绪
const isAgentReady = computed(() => {
// 必须有思考模型、Rerank 模型 且 至少选择一个工具
return localThinkingModelId.value !== '' &&
localRerankModelId.value !== '' &&
localAllowedTools.value.length > 0
})
// Agent 状态提示消息
const agentStatusMessage = computed(() => {
const missing: string[] = []
if (!localThinkingModelId.value) {
missing.push('思考模型')
}
if (!localRerankModelId.value) {
missing.push('Rerank 模型')
}
if (localAllowedTools.value.length === 0) {
missing.push('允许的工具')
}
if (missing.length === 0) {
return ''
}
return `请配置${missing.join('、')}`
})
// 模型列表状态
const chatModels = ref<ModelConfig[]>([])
const rerankModels = ref<ModelConfig[]>([])
@@ -227,8 +269,8 @@ onMounted(async () => {
const config = res.data
// 更新本地状态(在初始化期间,不会触发保存)
localAgentEnabled.value = config.enabled
localMaxIterations.value = config.max_iterations
lastSavedValue = config.max_iterations // 初始化时记录已保存的值
localTemperature.value = config.temperature
localThinkingModelId.value = config.thinking_model_id
localRerankModelId.value = config.rerank_model_id
@@ -241,23 +283,29 @@ onMounted(async () => {
}
// 同步到store(只更新本地存储,不触发API保存)
settingsStore.toggleAgent(config.enabled)
// 注意:不自动设置 isAgentEnabled,保持用户之前的选择
// enabled 状态应该由用户手动控制,而不是根据配置自动设置
settingsStore.updateAgentConfig({
maxIterations: config.max_iterations,
temperature: config.temperature,
thinkingModelId: config.thinking_model_id,
rerankModelId: config.rerank_model_id
rerankModelId: config.rerank_model_id,
allowedTools: config.allowed_tools || []
})
// 初始化完成
isInitializing.value = false
// 等待下一个 tick,确保所有响应式更新完成
await nextTick()
// 再等待一帧,确保所有事件监听器都已设置好
requestAnimationFrame(() => {
// 初始化完成,现在可以允许保存操作
isInitializing.value = false
})
} catch (error) {
console.error('加载Agent配置失败:', error)
MessagePlugin.error('加载Agent配置失败')
configLoaded.value = false // 加载失败时重置标记,允许重试
// 失败时从store加载
localAgentEnabled.value = settingsStore.isAgentEnabled
localMaxIterations.value = settingsStore.agentConfig.maxIterations
localTemperature.value = settingsStore.agentConfig.temperature
localThinkingModelId.value = settingsStore.agentConfig.thinkingModelId
@@ -289,59 +337,63 @@ const getErrorMessage = (error: any): string => {
}
}
// 处理 Agent 开关
const handleAgentToggle = async (value: boolean) => {
// 如果正在初始化,不触发保存(但用户手动切换开关应该允许)
// 注意:这个可能不需要检查,因为用户手动切换开关应该保存
// 但为了安全,如果初始化时开关状态变化,也不保存
if (isInitializing.value) return
try {
// 构建完整配置
const config: AgentConfig = {
enabled: value,
max_iterations: localMaxIterations.value,
reflection_enabled: false,
allowed_tools: localAllowedTools.value,
temperature: localTemperature.value,
thinking_model_id: localThinkingModelId.value,
rerank_model_id: localRerankModelId.value
}
await updateAgentConfig(config)
settingsStore.toggleAgent(value)
MessagePlugin.success(value ? 'Agent 模式已启用' : 'Agent 模式已禁用')
} catch (error) {
console.error('保存Agent配置失败:', error)
MessagePlugin.error(getErrorMessage(error))
// 回滚
localAgentEnabled.value = !value
}
}
// 防抖定时器
let maxIterationsDebounceTimer: any = null
// 上次保存的值,用于避免重复保存相同值
let lastSavedValue: number | null = null
// 处理最大迭代次数变化
const handleMaxIterationsChange = async (value: number) => {
// 处理最大迭代次数变化(防抖版本,点击和拖动都使用这个)
const handleMaxIterationsChangeDebounced = (value: number) => {
// 如果正在初始化,不触发保存
if (isInitializing.value) return
try {
const config: AgentConfig = {
enabled: localAgentEnabled.value,
max_iterations: value,
reflection_enabled: false,
allowed_tools: localAllowedTools.value,
temperature: localTemperature.value,
thinking_model_id: localThinkingModelId.value,
rerank_model_id: localRerankModelId.value
// 确保 value 是数字类型
const numValue = typeof value === 'number' ? value : Number(value)
if (isNaN(numValue)) {
console.error('Invalid max_iterations value:', value)
return
}
// 如果值没有变化,不保存
if (lastSavedValue === numValue) {
return
}
// 清除之前的定时器
if (maxIterationsDebounceTimer) {
clearTimeout(maxIterationsDebounceTimer)
}
// 设置新的定时器,300ms 后保存(减少延迟,提升响应速度)
maxIterationsDebounceTimer = setTimeout(async () => {
// 再次检查值是否变化(可能在等待期间值又变了)
if (lastSavedValue === numValue) {
maxIterationsDebounceTimer = null
return
}
await updateAgentConfig(config)
settingsStore.updateAgentConfig({ maxIterations: value })
MessagePlugin.success('最大迭代次数已保存')
} catch (error) {
console.error('保存失败:', error)
MessagePlugin.error(getErrorMessage(error))
}
try {
const config: AgentConfig = {
enabled: isAgentReady.value, // 自动根据配置状态设置
max_iterations: numValue, // 确保是数字类型
reflection_enabled: false,
allowed_tools: localAllowedTools.value,
temperature: localTemperature.value,
thinking_model_id: localThinkingModelId.value,
rerank_model_id: localRerankModelId.value
}
await updateAgentConfig(config)
settingsStore.updateAgentConfig({ maxIterations: numValue })
lastSavedValue = numValue // 记录已保存的值
MessagePlugin.success('最大迭代次数已保存')
} catch (error) {
console.error('保存失败:', error)
MessagePlugin.error(getErrorMessage(error))
} finally {
maxIterationsDebounceTimer = null
}
}, 300)
}
// 统一加载所有模型(只调用一次API)
@@ -385,7 +437,7 @@ const handleThinkingModelChange = async (value: string) => {
try {
const config: AgentConfig = {
enabled: localAgentEnabled.value,
enabled: isAgentReady.value, // 自动根据配置状态设置
max_iterations: localMaxIterations.value,
reflection_enabled: false,
allowed_tools: localAllowedTools.value,
@@ -395,7 +447,8 @@ const handleThinkingModelChange = async (value: string) => {
}
await updateAgentConfig(config)
settingsStore.updateAgentConfig({ thinkingModelId: localThinkingModelId.value })
// 更新 store,确保 isAgentReady 能正确计算
settingsStore.updateAgentConfig({ thinkingModelId: value })
MessagePlugin.success('思考模型已保存')
} catch (error) {
console.error('保存失败:', error)
@@ -417,7 +470,7 @@ const handleRerankModelChange = async (value: string) => {
try {
const config: AgentConfig = {
enabled: localAgentEnabled.value,
enabled: isAgentReady.value, // 自动根据配置状态设置
max_iterations: localMaxIterations.value,
reflection_enabled: false,
allowed_tools: localAllowedTools.value,
@@ -497,7 +550,7 @@ const handleTemperatureChange = async (value: number) => {
try {
const config: AgentConfig = {
enabled: localAgentEnabled.value,
enabled: isAgentReady.value, // 自动根据配置状态设置
max_iterations: localMaxIterations.value,
reflection_enabled: false,
allowed_tools: localAllowedTools.value,
@@ -522,7 +575,7 @@ const handleAllowedToolsChange = async (value: string[]) => {
try {
const config: AgentConfig = {
enabled: localAgentEnabled.value,
enabled: isAgentReady.value, // 自动根据配置状态设置
max_iterations: localMaxIterations.value,
reflection_enabled: false,
allowed_tools: value,
@@ -541,6 +594,18 @@ const handleAllowedToolsChange = async (value: string[]) => {
localAllowedTools.value = settingsStore.agentConfig.allowedTools
}
}
// 监听 Agent 就绪状态变化,同步到 store
watch(isAgentReady, (newValue, oldValue) => {
if (!isInitializing.value) {
// 如果配置从"就绪"变为"未就绪",且 Agent 当前是启用状态,自动关闭
if (!newValue && oldValue && settingsStore.isAgentEnabled) {
settingsStore.toggleAgent(false)
MessagePlugin.warning('Agent 配置不完整,已自动关闭 Agent 模式')
}
// 注意:配置从"未就绪"变为"就绪"时,不自动启用(让用户自己决定是否启用)
}
})
</script>
<style lang="less" scoped>
@@ -561,9 +626,103 @@ const handleAllowedToolsChange = async (value: string[]) => {
.section-description {
font-size: 14px;
color: #666666;
margin: 0;
margin: 0 0 20px 0;
line-height: 1.5;
}
.agent-status-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 20px 0;
border-bottom: 1px solid #e5e7eb;
margin-top: 8px;
.status-label {
flex: 1;
max-width: 65%;
padding-right: 24px;
label {
font-size: 15px;
font-weight: 500;
color: #333333;
display: block;
margin-bottom: 4px;
}
}
.status-control {
flex-shrink: 0;
min-width: 280px;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 8px;
.status-badge {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 12px;
border-radius: 4px;
font-size: 14px;
font-weight: 500;
&.ready {
background: #f0fdf4;
color: #16a34a;
.status-icon {
color: #16a34a;
font-size: 16px;
}
}
&:not(.ready) {
background: #fff7ed;
color: #ea580c;
.status-icon {
color: #ea580c;
font-size: 16px;
}
}
.status-text {
line-height: 1.4;
}
}
.status-hint {
font-size: 13px;
color: #666666;
text-align: right;
line-height: 1.5;
max-width: 280px;
}
.status-tip {
margin: 8px 0 0 0;
font-size: 12px;
color: #999999;
text-align: right;
line-height: 1.5;
max-width: 280px;
display: flex;
align-items: flex-start;
gap: 4px;
justify-content: flex-end;
.tip-icon {
font-size: 14px;
color: #999999;
flex-shrink: 0;
margin-top: 2px;
}
}
}
}
}
.settings-group {
+38 -15
View File
@@ -33,7 +33,7 @@
<t-input
v-model="displayApiKey"
readonly
:type="showApiKey ? 'text' : 'password'"
type="text"
style="width: 100%; font-family: monospace; font-size: 12px;"
/>
<t-button
@@ -59,17 +59,13 @@
<div class="setting-row">
<div class="setting-info">
<label>API 文档</label>
<p class="desc">查看完整的 API 调用文档和示例</p>
</div>
<div class="setting-control">
<t-button
size="small"
theme="default"
variant="outline"
@click="openApiDoc"
>
查看文档
</t-button>
<p class="desc">
查看完整的 API 调用文档和示例,
<a @click="openApiDoc" class="doc-link">
打开文档
<t-icon name="link" class="link-icon" />
</a>
</p>
</div>
</div>
@@ -139,7 +135,14 @@ const showApiKey = ref(false)
// 计算属性
const displayApiKey = computed(() => {
if (!tenantInfo.value?.api_key) return ''
return tenantInfo.value.api_key
if (showApiKey.value) {
return tenantInfo.value.api_key
}
let masked = ''
for (let i = 0; i < tenantInfo.value.api_key.length; i++) {
masked += '•'
}
return masked
})
// 方法
@@ -168,13 +171,13 @@ const openApiDoc = () => {
}
const copyApiKey = async () => {
if (!displayApiKey.value) {
if (!tenantInfo.value?.api_key) {
MessagePlugin.warning('暂无 API Key')
return
}
try {
await navigator.clipboard.writeText(displayApiKey.value)
await navigator.clipboard.writeText(tenantInfo.value.api_key)
MessagePlugin.success('API Key 已复制到剪贴板')
} catch (err) {
MessagePlugin.error('复制失败,请手动复制')
@@ -278,6 +281,26 @@ onMounted(() => {
margin: 0;
line-height: 1.5;
}
.doc-link {
color: #07C05F;
text-decoration: none;
font-weight: 500;
display: inline-flex;
align-items: center;
gap: 4px;
cursor: pointer;
transition: all 0.2s ease;
&:hover {
color: #05a04f;
text-decoration: underline;
}
.link-icon {
font-size: 12px;
}
}
}
.setting-control {
@@ -24,25 +24,6 @@
</t-select>
</div>
</div>
<!-- 外观主题 -->
<div class="setting-row">
<div class="setting-info">
<label>外观</label>
<p class="desc">选择界面主题样式</p>
</div>
<div class="setting-control">
<t-select
v-model="localTheme"
placeholder="选择主题"
@change="handleThemeChange"
style="width: 280px;"
>
<t-option value="light" label="明亮">明亮</t-option>
<t-option value="dark" label="暗色">暗色</t-option>
</t-select>
</div>
</div>
</div>
</div>
</template>
@@ -1,216 +0,0 @@
<template>
<div class="kb-settings">
<div class="section-header">
<h2>知识库设置</h2>
<p class="section-description">配置文档处理和索引的默认参数</p>
</div>
<div class="settings-group">
<!-- Chunk 大小 -->
<div class="setting-row">
<div class="setting-info">
<label>默认 Chunk 大小</label>
<p class="desc">文档分块的默认字符数(100-2000)</p>
</div>
<div class="setting-control">
<div class="slider-with-value">
<t-slider
v-model="localChunkSize"
:min="100"
:max="2000"
:step="50"
:marks="{ 100: '100', 1000: '1000', 2000: '2000' }"
@change="handleChunkSizeChange"
style="width: 200px;"
/>
<span class="value-display">{{ localChunkSize }}</span>
</div>
</div>
</div>
<!-- Chunk Overlap -->
<div class="setting-row">
<div class="setting-info">
<label>Chunk Overlap</label>
<p class="desc">相邻文档块之间的重叠字符数(0-500)</p>
</div>
<div class="setting-control">
<div class="slider-with-value">
<t-slider
v-model="localChunkOverlap"
:min="0"
:max="500"
:step="20"
:marks="{ 0: '0', 250: '250', 500: '500' }"
@change="handleChunkOverlapChange"
style="width: 200px;"
/>
<span class="value-display">{{ localChunkOverlap }}</span>
</div>
</div>
</div>
<!-- 文档语言检测 -->
<div class="setting-row">
<div class="setting-info">
<label>文档语言检测</label>
<p class="desc">自动检测文档语言以优化分词效果</p>
</div>
<div class="setting-control">
<t-switch
v-model="localLanguageDetection"
@change="handleLanguageDetectionChange"
size="large"
/>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
// 本地状态
const localChunkSize = ref(500)
const localChunkOverlap = ref(100)
const localLanguageDetection = ref(true)
// 初始化加载
onMounted(() => {
// 从 localStorage 加载知识库设置
const savedSettings = localStorage.getItem('WeKnora_kb_settings')
if (savedSettings) {
try {
const parsed = JSON.parse(savedSettings)
localChunkSize.value = parsed.chunkSize || 500
localChunkOverlap.value = parsed.chunkOverlap || 100
localLanguageDetection.value = parsed.languageDetection !== false
} catch (e) {
console.error('加载知识库设置失败:', e)
}
}
})
// 保存设置到 localStorage
const saveSettings = () => {
const settings = {
chunkSize: localChunkSize.value,
chunkOverlap: localChunkOverlap.value,
languageDetection: localLanguageDetection.value
}
localStorage.setItem('WeKnora_kb_settings', JSON.stringify(settings))
}
// 处理 Chunk 大小变化
const handleChunkSizeChange = () => {
saveSettings()
MessagePlugin.success('Chunk 大小已保存')
}
// 处理 Chunk Overlap 变化
const handleChunkOverlapChange = () => {
// 确保 overlap 不超过 chunk size
if (localChunkOverlap.value > localChunkSize.value) {
localChunkOverlap.value = Math.floor(localChunkSize.value / 2)
MessagePlugin.warning('Overlap 不能超过 Chunk 大小,已自动调整')
}
saveSettings()
MessagePlugin.success('Chunk Overlap 已保存')
}
// 处理语言检测开关
const handleLanguageDetectionChange = () => {
saveSettings()
MessagePlugin.success(`文档语言检测已${localLanguageDetection.value ? '启用' : '禁用'}`)
}
</script>
<style lang="less" scoped>
.kb-settings {
width: 100%;
}
.section-header {
margin-bottom: 32px;
h2 {
font-size: 20px;
font-weight: 600;
color: #333333;
margin: 0 0 8px 0;
}
.section-description {
font-size: 14px;
color: #666666;
margin: 0;
line-height: 1.5;
}
}
.settings-group {
display: flex;
flex-direction: column;
gap: 0;
}
.setting-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 20px 0;
border-bottom: 1px solid #e5e7eb;
&:last-child {
border-bottom: none;
}
}
.setting-info {
flex: 1;
max-width: 65%;
padding-right: 24px;
label {
font-size: 15px;
font-weight: 500;
color: #333333;
display: block;
margin-bottom: 4px;
}
.desc {
font-size: 13px;
color: #666666;
margin: 0;
line-height: 1.5;
}
}
.setting-control {
flex-shrink: 0;
min-width: 280px;
display: flex;
justify-content: flex-end;
align-items: center;
}
.slider-with-value {
display: flex;
align-items: center;
gap: 16px;
width: 100%;
justify-content: flex-end;
.value-display {
font-size: 14px;
font-weight: 500;
color: #333333;
min-width: 40px;
text-align: right;
}
}
</style>
+153 -190
View File
@@ -6,59 +6,78 @@
</div>
<div class="settings-group">
<!-- 启用 Ollama -->
<!-- Ollama 服务状态 -->
<div class="setting-row">
<div class="setting-info">
<label>启用 Ollama</label>
<p class="desc">启用后可以使用本地 Ollama 模型</p>
<label>Ollama 服务状态</label>
<p class="desc">自动检测本地 Ollama 服务是否可用。如果服务未运行或地址配置错误,将显示"不可用"状态</p>
</div>
<div class="setting-control">
<t-switch
v-model="localEnabled"
@change="handleEnableToggle"
size="large"
/>
<div class="status-display">
<t-tag
v-if="testing"
theme="default"
variant="light"
>
<t-icon name="loading" class="status-icon spinning" />
检测中
</t-tag>
<t-tag
v-else-if="connectionStatus === true"
theme="success"
variant="light"
>
<t-icon name="check-circle-filled" />
可用
</t-tag>
<t-tag
v-else-if="connectionStatus === false"
theme="danger"
variant="light"
>
<t-icon name="close-circle-filled" />
不可用
</t-tag>
<t-tag
v-else
theme="default"
variant="light"
>
<t-icon name="help-circle" />
未检测
</t-tag>
<t-button
size="small"
variant="outline"
:loading="testing"
@click="testConnection"
>
<t-icon name="refresh" />
重新检测
</t-button>
</div>
</div>
</div>
<!-- Ollama 服务地址 -->
<div class="setting-row">
<div class="setting-info">
<label>Ollama 服务地址</label>
<p class="desc">本地 Ollama 服务的 API 地址</p>
<label>服务地址</label>
<p class="desc">本地 Ollama 服务的 API 地址,由系统自动检测。如需修改,请在 .env 配置文件中设置</p>
</div>
<div class="setting-control">
<div class="url-control-group">
<t-input
v-model="localBaseUrl"
placeholder="http://localhost:11434"
:disabled="!localEnabled"
disabled
style="flex: 1;"
/>
<div v-if="localEnabled" class="status-indicator">
<t-icon
v-if="testing"
name="loading"
class="status-icon spinning"
/>
<t-icon
v-else-if="connectionStatus === true"
name="check-circle-filled"
class="status-icon success"
title="连接成功"
/>
<t-icon
v-else-if="connectionStatus === false"
name="close-circle-filled"
class="status-icon error"
title="连接失败"
/>
</div>
</div>
<t-alert
v-if="connectionStatus === false && localEnabled"
theme="error"
message="连接失败,请检查 Ollama 是否运行"
v-if="connectionStatus === false"
theme="warning"
message="连接失败,请检查 Ollama 是否运行或服务地址是否正确"
style="margin-top: 8px;"
/>
</div>
@@ -66,8 +85,51 @@
</div>
<!-- 下载新模型 -->
<div v-if="connectionStatus === true" class="model-category-section">
<div class="category-header">
<div class="header-info">
<h3>下载新模型</h3>
<p>
输入模型名称下载,
<a href="https://ollama.com/search" target="_blank" rel="noopener noreferrer" class="model-link">
浏览 Ollama 模型库
<t-icon name="link" class="link-icon" />
</a>
</p>
</div>
</div>
<div class="download-content">
<div class="input-group">
<t-input
v-model="downloadModelName"
placeholder="如:qwen2.5:0.5b"
style="flex: 1;"
/>
<t-button
theme="primary"
size="small"
:loading="downloading"
:disabled="!downloadModelName.trim()"
@click="downloadModel"
>
下载
</t-button>
</div>
<div v-if="downloadProgress > 0" class="download-progress">
<div class="progress-info">
<span>正在下载: {{ downloadModelName }}</span>
<span>{{ downloadProgress.toFixed(2) }}%</span>
</div>
<t-progress :percentage="downloadProgress" size="small" />
</div>
</div>
</div>
<!-- 已下载的模型 -->
<div v-if="localEnabled && connectionStatus" class="model-category-section">
<div v-if="connectionStatus === true" class="model-category-section">
<div class="category-header">
<div class="header-info">
<h3>已下载的模型</h3>
@@ -102,59 +164,6 @@
<p class="empty-text">暂无已下载的模型</p>
</div>
</div>
<!-- 下载新模型 -->
<div v-if="localEnabled && connectionStatus" class="model-category-section">
<div class="category-header">
<div class="header-info">
<h3>下载新模型</h3>
<p>输入模型名称下载,或点击推荐模型快速下载</p>
</div>
</div>
<div class="download-content">
<div class="input-group">
<t-input
v-model="downloadModelName"
placeholder="如:qwen2.5:0.5b"
style="flex: 1;"
/>
<t-button
theme="primary"
size="small"
:loading="downloading"
:disabled="!downloadModelName.trim()"
@click="downloadModel"
>
下载
</t-button>
</div>
<div v-if="downloadProgress > 0" class="download-progress">
<div class="progress-info">
<span>正在下载: {{ downloadModelName }}</span>
<span>{{ downloadProgress.toFixed(2) }}%</span>
</div>
<t-progress :percentage="downloadProgress" size="small" />
</div>
<div class="recommended-models">
<div class="recommended-label">推荐模型:</div>
<div class="model-tags">
<t-tag
v-for="model in popularModels"
:key="model"
theme="default"
variant="outline"
class="model-tag"
@click="quickDownload(model)"
>
{{ model }}
</t-tag>
</div>
</div>
</div>
</div>
</div>
</template>
@@ -166,7 +175,6 @@ import { checkOllamaStatus, listOllamaModels, downloadOllamaModel, getDownloadPr
const settingsStore = useSettingsStore()
const localEnabled = ref(settingsStore.settings.ollamaConfig?.enabled ?? true)
const localBaseUrl = ref(settingsStore.settings.ollamaConfig?.baseUrl ?? '')
const testing = ref(false)
@@ -177,32 +185,8 @@ const downloading = ref(false)
const downloadModelName = ref('')
const downloadProgress = ref(0)
// 推荐的流行模型
const popularModels = [
'qwen2.5:0.5b',
'qwen2.5:1.5b',
'llama3.2:1b',
'llama3.2:3b',
'gemma2:2b',
'phi3:mini'
]
// 处理启用/禁用
const handleEnableToggle = (value: boolean) => {
settingsStore.updateOllamaConfig({ enabled: value })
MessagePlugin.success(value ? 'Ollama 已启用' : 'Ollama 已禁用')
if (value) {
testConnection()
} else {
connectionStatus.value = null
}
}
// 测试连接
const testConnection = async () => {
if (!localEnabled.value) return
testing.value = true
connectionStatus.value = null
@@ -334,12 +318,6 @@ const downloadModel = async () => {
}
}
// 快速下载推荐模型
const quickDownload = (modelName: string) => {
downloadModelName.value = modelName
downloadModel()
}
// 初始化 Ollama 服务地址
const initOllamaBaseUrl = async () => {
try {
@@ -356,12 +334,10 @@ const initOllamaBaseUrl = async () => {
localBaseUrl.value = 'http://localhost:11434'
}
// 如果启用了,直接使用初始化时获取的状态,避免重复调用
if (localEnabled.value) {
// 直接使用初始化时获取的状态,避免重复调用
connectionStatus.value = result.available
if (result.available) {
refreshModels()
}
}
return result
@@ -425,8 +401,7 @@ onMounted(async () => {
.setting-info {
flex: 1;
max-width: 65%;
padding-right: 24px;
padding-right: 32px;
label {
font-size: 15px;
@@ -440,53 +415,46 @@ onMounted(async () => {
font-size: 13px;
color: #666666;
margin: 0;
line-height: 1.5;
line-height: 1.6;
}
}
.setting-control {
flex-shrink: 0;
min-width: 420px;
min-width: 360px;
max-width: 360px;
display: flex;
flex-direction: column;
align-items: flex-end;
}
.status-display {
display: flex;
align-items: center;
gap: 12px;
.status-icon.spinning {
animation: spin 1s linear infinite;
}
}
.url-control-group {
width: 100%;
display: flex;
align-items: center;
gap: 8px;
.status-indicator {
display: flex;
align-items: center;
gap: 4px;
.status-icon {
font-size: 18px;
&.success {
color: #07C05F;
}
&.error {
color: #e34d59;
}
&.spinning {
animation: spin 1s linear infinite;
}
}
}
}
.model-category-section {
margin-bottom: 24px;
border: 1px solid #e5e7eb;
border-radius: 8px;
padding: 24px;
background: #ffffff;
margin-top: 32px;
margin-bottom: 32px;
padding-top: 32px;
border-top: 1px solid #e5e7eb;
&:first-of-type {
margin-top: 24px;
padding-top: 24px;
}
&:last-child {
margin-bottom: 0;
@@ -497,24 +465,43 @@ onMounted(async () => {
display: flex;
align-items: flex-start;
justify-content: space-between;
margin-bottom: 20px;
margin-bottom: 24px;
.header-info {
flex: 1;
h3 {
font-size: 16px;
font-size: 17px;
font-weight: 600;
color: #333333;
margin: 0 0 4px 0;
margin: 0 0 6px 0;
}
p {
font-size: 14px;
color: #666666;
font-size: 13px;
color: #999999;
margin: 0;
line-height: 1.5;
}
.model-link {
color: #07C05F;
text-decoration: none;
font-weight: 500;
display: inline-flex;
align-items: center;
gap: 4px;
transition: all 0.2s ease;
&:hover {
color: #05a04f;
text-decoration: underline;
}
.link-icon {
font-size: 12px;
}
}
}
}
@@ -523,8 +510,8 @@ onMounted(async () => {
align-items: center;
justify-content: center;
gap: 8px;
padding: 60px;
color: #666666;
padding: 48px 0;
color: #999999;
font-size: 14px;
}
@@ -582,52 +569,28 @@ onMounted(async () => {
.input-group {
display: flex;
gap: 8px;
align-items: center;
}
.download-progress {
padding: 12px;
background: #f5f7fa;
border-radius: 6px;
padding: 16px;
background: #f8f9fa;
border-radius: 8px;
border: 1px solid #e5e7eb;
.progress-info {
display: flex;
justify-content: space-between;
margin-bottom: 8px;
margin-bottom: 10px;
font-size: 13px;
color: #333333;
}
}
.recommended-models {
.recommended-label {
font-size: 13px;
color: #666666;
margin: 0 0 10px 0;
font-weight: 500;
}
.model-tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
.model-tag {
cursor: pointer;
transition: all 0.2s;
font-size: 12px;
&:hover {
background: #07C05F;
color: #ffffff;
border-color: #07C05F;
}
}
}
}
}
.empty-state {
padding: 80px 0;
padding: 48px 0;
text-align: center;
.empty-text {
-7
View File
@@ -73,11 +73,6 @@
<OllamaSettings />
</div>
<!-- 知识库设置 -->
<div v-if="currentSection === 'knowledge'" class="section">
<KnowledgeBaseSettings />
</div>
<!-- Agent 配置 -->
<div v-if="currentSection === 'agent'" class="section">
<AgentSettings />
@@ -116,7 +111,6 @@ import TenantInfo from './TenantInfo.vue'
import ApiInfo from './ApiInfo.vue'
import GeneralSettings from './GeneralSettings.vue'
import ModelSettings from './ModelSettings.vue'
import KnowledgeBaseSettings from './KnowledgeBaseSettings.vue'
import OllamaSettings from './OllamaSettings.vue'
const route = useRoute()
@@ -141,7 +135,6 @@ const navItems = [
]
},
{ key: 'ollama', icon: 'server', label: 'Ollama' },
{ key: 'knowledge', icon: 'folder-open', label: '知识库' },
{ key: 'agent', icon: 'chat', label: 'Agent 配置' },
{ key: 'system', icon: 'info-circle', label: '系统信息' },
{ key: 'tenant', icon: 'user-circle', label: '租户信息' },