@@ -38,16 +51,31 @@
-
+
@@ -73,6 +101,7 @@
import { ref, onMounted, onActivated, onUnmounted, nextTick, reactive, computed } from 'vue';
import { useConfigStore } from '@/stores/config';
import { useUserStore } from '@/stores/user';
+import { useDatabaseStore } from '@/stores/database';
import { useThrottleFn } from '@vueuse/core';
import { message } from 'ant-design-vue';
import {
@@ -81,13 +110,20 @@ import {
ReloadOutlined,
ClearOutlined,
SettingOutlined,
- SyncOutlined
+ SyncOutlined,
+ CheckCircleOutlined,
+ PlusCircleOutlined,
+ UserOutlined,
+ DatabaseOutlined,
+ RobotOutlined
} from '@ant-design/icons-vue';
import dayjs from 'dayjs';
-import { logApi } from '@/apis/admin_api';
+import { logApi, systemConfigApi } from '@/apis/admin_api';
+import { chatApi } from '@/apis/auth_api';
const configStore = useConfigStore()
const userStore = useUserStore();
+const databaseStore = useDatabaseStore();
const config = configStore.config;
// 权限检查
@@ -126,7 +162,8 @@ let autoRefreshInterval = null;
// 解析日志行
const parseLogLine = (line) => {
- const match = line.match(/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}) - (\w+) - ([^-]+) - (.+)$/);
+ // 支持两种时间戳格式:带毫秒和不带毫秒
+ const match = line.match(/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:,\d{3})?)\s*-\s*(\w+)\s*-\s*([^-]+?)\s*-\s*(.+)$/);
if (match) {
return {
timestamp: match[1],
@@ -142,8 +179,14 @@ const parseLogLine = (line) => {
// 格式化时间戳
const formatTimestamp = (timestamp) => {
try {
- // 将 "2025-03-10 08:26:37,269" 格式转换为 "2025-03-10 08:26:37.269"
- const normalizedTimestamp = timestamp.replace(',', '.');
+ // 处理带毫秒的格式:将 "2025-03-10 08:26:37,269" 转换为 "2025-03-10 08:26:37.269"
+ let normalizedTimestamp = timestamp.replace(',', '.');
+
+ // 如果没有毫秒,添加 .000
+ if (!/\.\d{3}$/.test(normalizedTimestamp)) {
+ normalizedTimestamp += '.000';
+ }
+
const date = dayjs(normalizedTimestamp);
return date.isValid() ? date.format('HH:mm:ss.SSS') : timestamp;
} catch (err) {
@@ -204,6 +247,24 @@ const filterLogs = () => {
// 过滤会通过computed自动触发
};
+// 日志级别选择相关方法
+const isLogLevelSelected = (level) => {
+ return state.selectedLevels.includes(level);
+};
+
+const toggleLogLevel = (level) => {
+ const currentLevels = [...state.selectedLevels];
+ const index = currentLevels.indexOf(level);
+
+ if (index > -1) {
+ currentLevels.splice(index, 1);
+ } else {
+ currentLevels.push(level);
+ }
+
+ state.selectedLevels = currentLevels;
+};
+
// 自动刷新
const toggleAutoRefresh = (value) => {
if (!checkAdminPermission()) return;
@@ -285,16 +346,80 @@ onUnmounted(() => {
document.removeEventListener('msfullscreenchange', handleFullscreenChange);
});
-const printConfig = () => {
+// 打印系统配置
+const printSystemConfig = () => {
if (!checkAdminPermission()) return;
- console.log('Current config:', config);
+ console.log('=== 系统配置 ===');
+ console.log(config);
+};
+
+// 打印用户信息
+const printUserInfo = () => {
+ if (!checkAdminPermission()) return;
+ console.log('=== 用户信息 ===');
+ const userInfo = {
+ token: userStore.token ? '*** (已隐藏)' : null,
+ userId: userStore.userId,
+ username: userStore.username,
+ userRole: userStore.userRole,
+ isLoggedIn: userStore.isLoggedIn,
+ isAdmin: userStore.isAdmin,
+ isSuperAdmin: userStore.isSuperAdmin
+ };
+ console.log(JSON.stringify(userInfo, null, 2));
+};
+
+// 打印知识库信息
+const printDatabaseInfo = async () => {
+ if (!checkAdminPermission()) return;
+
+ try {
+ console.log('=== 知识库信息 ===');
+
+ // 直接调用API获取最新的数据库信息
+ await databaseStore.refreshDatabase();
+
+ } catch (error) {
+ console.error('获取知识库信息失败:', error);
+ message.error('获取知识库信息失败: ' + error.message);
+ }
+};
+
+// 打印智能体配置
+const printAgentConfig = async () => {
+ if (!checkAdminPermission()) return;
+
+ try {
+ console.log('=== 智能体配置 ===');
+
+ // 获取智能体列表
+ const agentsData = await chatApi.getAgents();
+ console.log('智能体列表:', JSON.stringify(agentsData.agents, null, 2));
+
+ // 获取默认智能体
+ const defaultAgent = await chatApi.getDefaultAgent();
+ console.log('默认智能体:', JSON.stringify(defaultAgent, null, 2));
+
+ // 获取每个智能体的配置
+ for (const agent of agentsData.agents) {
+ try {
+ const agentConfig = await systemConfigApi.getAgentConfig(agent.name);
+ console.log(`智能体 "${agent.name}" 配置:`, JSON.stringify(agentConfig, null, 2));
+ } catch (err) {
+ console.log(`智能体 "${agent.name}" 配置获取失败:`, err.message);
+ }
+ }
+
+ } catch (error) {
+ console.error('获取智能体配置失败:', error);
+ message.error('获取智能体配置失败: ' + error.message);
+ }
};
diff --git a/web/src/layouts/AppLayout.vue b/web/src/layouts/AppLayout.vue
index 21b8f52e..9555da41 100644
--- a/web/src/layouts/AppLayout.vue
+++ b/web/src/layouts/AppLayout.vue
@@ -1,18 +1,18 @@