fix: 收紧智能体聊天历史访问范围
- 普通账号仅可访问本人 Agent 会话 - 超级管理员保留全量查询并限制筛选入口
This commit is contained in:
@@ -4,6 +4,7 @@ import type { ChatTimeTimelineItem } from '@easyflow/types';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
import { useEasyFlowDrawer } from '@easyflow/common-ui';
|
||||
import { useUserStore } from '@easyflow/stores';
|
||||
import {
|
||||
ChatTimeHistoryMapper,
|
||||
ChatTimeTimelineBuilder,
|
||||
@@ -28,6 +29,7 @@ import { api } from '#/api/request';
|
||||
import ChatHistoryDetailDrawer from '#/components/chat-history/ChatHistoryDetailDrawer.vue';
|
||||
import ListPageShell from '#/components/page/ListPageShell.vue';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const agentOptions = ref<any[]>([]);
|
||||
const agentLoading = ref(false);
|
||||
const sessions = ref<any[]>([]);
|
||||
@@ -91,6 +93,9 @@ const hasMoreMessages = computed(
|
||||
const selectedSessionId = computed(() =>
|
||||
String(currentSession.value?.id || ''),
|
||||
);
|
||||
const isSuperAdmin = computed(() =>
|
||||
userStore.userRoles.includes('super_admin'),
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
await Promise.all([fetchAgents(), fetchSessions()]);
|
||||
@@ -119,7 +124,9 @@ async function fetchSessions() {
|
||||
const [, res] = await tryit(api.get)('/api/v1/chatHistory/sessions', {
|
||||
params: {
|
||||
assistantId: query.value.assistantId,
|
||||
userAccount: query.value.userAccount || undefined,
|
||||
userAccount: isSuperAdmin.value
|
||||
? query.value.userAccount || undefined
|
||||
: undefined,
|
||||
startTime: query.value.timeRange?.[0],
|
||||
endTime: query.value.timeRange?.[1],
|
||||
pageNumber: query.value.pageNumber,
|
||||
@@ -394,6 +401,7 @@ function closeDetail() {
|
||||
@change="handleSearch"
|
||||
/>
|
||||
<ElInput
|
||||
v-if="isSuperAdmin"
|
||||
v-model="query.userAccount"
|
||||
class="chat-history-page__filter-control is-input"
|
||||
placeholder="搜索聊天用户"
|
||||
@@ -472,7 +480,12 @@ function closeDetail() {
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
|
||||
<ElTableColumn prop="userAccount" label="聊天用户" min-width="160">
|
||||
<ElTableColumn
|
||||
v-if="isSuperAdmin"
|
||||
prop="userAccount"
|
||||
label="聊天用户"
|
||||
min-width="160"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span class="chat-history-page__user-cell">
|
||||
{{ row.userAccount || '-' }}
|
||||
|
||||
Reference in New Issue
Block a user