feat(权限优化)1.AI对话中点击快捷标签问题时,明明已经配置了默认默写为什么还会提示配置?必须点击一下保存并关闭才可以这个不对,只要配置了就可以问答不需要再让用户过来点击一次!如图一、二所示
deploy-hxtesting / build-and-deploy (push) Successful in 1m20s
deploy-hxtesting / build-and-deploy (push) Successful in 1m20s
2.知识库中的企业培训(课件)、企业培训(试题)、配置中心、组织架构、共享空间如图三所示可查看权限归属到超级管理员权限中!如何对
This commit is contained in:
1 parent
353f60a175
commit
043e0485e2
14 files changed
+368
-74
No files matched your search
@@ -393,6 +393,7 @@ const getAgentNotReadyReasonKeysFor = (agent: CustomAgent, sourceTenantId?: stri
|
||||
return getAgentNotReadyReasonKeys(agent.config, modelsList.value, {
|
||||
isAgentMode,
|
||||
isSharedAgent,
|
||||
isBuiltin: agent.is_builtin,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -2598,6 +2598,7 @@ const collectAgentNotReadyReasons = (
|
||||
const keys = getAgentNotReadyReasonKeys(agent.config, allModels.value, {
|
||||
isAgentMode,
|
||||
isSharedAgent,
|
||||
isBuiltin: agent.is_builtin,
|
||||
});
|
||||
return {
|
||||
keys,
|
||||
|
||||
@@ -605,12 +605,14 @@ const moreToolItems = computed<MenuItem[]>(() => {
|
||||
const items = MORE_TOOLS_ORDER
|
||||
.map(path => all.find((item: MenuItem) => item.path === path))
|
||||
.filter((item): item is MenuItem => !!item);
|
||||
// 末位固定追加「配置中心」「组织架构」;「共享空间」还原至最底
|
||||
// (入口定义与显隐规则仍在 menu store:仅空间 admin/owner 可见,随能力清单显隐)
|
||||
// 末位追加「配置中心」「组织架构」(000163 权限收口:仅平台超级管理员可见,
|
||||
// 页面另由路由 requiresSystemAdmin 守卫兜底);「共享空间」还原至最底
|
||||
// (入口定义与显隐规则仍在 menu store:仅超管可见,随能力清单显隐)
|
||||
// 职称角色入口已移除:职称角色/企微账号维护并入「组织架构」页,旧路由
|
||||
// /platform/training/members 由路由重定向兜底
|
||||
const orgShareItem = all.find((item: MenuItem) => item.path === 'organizations');
|
||||
return [...items, RULES_TOOL_ITEM, ORG_CENTER_TOOL_ITEM, ...(orgShareItem ? [orgShareItem] : [])];
|
||||
const adminOnlyItems = authStore.isSystemAdmin ? [RULES_TOOL_ITEM, ORG_CENTER_TOOL_ITEM] : [];
|
||||
return [...items, ...adminOnlyItems, ...(orgShareItem ? [orgShareItem] : [])];
|
||||
});
|
||||
|
||||
// 菜单图标统一映射:顶层项与「更多工具」子项共用
|
||||
|
||||
@@ -208,10 +208,11 @@ const router = createRouter({
|
||||
{
|
||||
// 组织架构:租户级共享组织架构(部门 + 员工档案),
|
||||
// 业务模块(企业培训等)按需引用,部门岗位只维护一份。
|
||||
// 000163 权限收口:仅平台超级管理员可查看(菜单入口同步收口)。
|
||||
path: "org-center",
|
||||
name: "orgCenter",
|
||||
component: () => import("../views/org-center/OrgCenter.vue"),
|
||||
meta: { requiresInit: true, requiresAuth: true }
|
||||
meta: { requiresInit: true, requiresAuth: true, requiresSystemAdmin: true }
|
||||
},
|
||||
{
|
||||
path: "agents",
|
||||
@@ -258,7 +259,8 @@ const router = createRouter({
|
||||
path: "organizations",
|
||||
name: "organizationList",
|
||||
component: () => import("../views/organization/OrganizationList.vue"),
|
||||
meta: { requiresInit: true, requiresAuth: true, requiredCapability: 'organizations' }
|
||||
// 000163 权限收口:共享空间仅平台超级管理员可查看(菜单入口同步收口)。
|
||||
meta: { requiresInit: true, requiresAuth: true, requiredCapability: 'organizations', requiresSystemAdmin: true }
|
||||
},
|
||||
// Compatibility redirects for /platform/system/* URLs. System
|
||||
// administration surfaces live as dedicated sections inside the
|
||||
@@ -468,6 +470,13 @@ router.beforeEach(async (to, from, next) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 培训路由按 tab 共用(training/:tab),「配置中心」(rules) 页签单独收口:
|
||||
// 仅平台超级管理员可查看,其余用户弹回培训工作台(000163)。
|
||||
if (to.name === 'trainingTab' && String(to.params.tab) === 'rules' && !authStore.isSystemAdmin) {
|
||||
next('/platform/training/dashboard')
|
||||
return
|
||||
}
|
||||
|
||||
next()
|
||||
})
|
||||
|
||||
|
||||
@@ -76,9 +76,8 @@ export const useMenuStore = defineStore('menuStore', () => {
|
||||
|
||||
const liteHiddenPaths = new Set(['logout', 'organizations'])
|
||||
|
||||
// 共享空间 (organizations) 仅对当前空间的 admin / owner 暴露入口。
|
||||
// viewer / contributor 即便在共享空间里拥有资源,也无需自行管理共享关系,
|
||||
// 入口在侧栏只会徒增噪音;后端 RBAC 才是权限的最终来源(见 middleware/rbac.go)。
|
||||
// 共享空间 (organizations) 仅对平台超级管理员暴露入口(000163 权限收口:
|
||||
// 原为空间 admin/owner 可见)。后端 RBAC 才是权限的最终来源(见 middleware/rbac.go)。
|
||||
const visibleMenuArr = computed(() => {
|
||||
const authStore = useAuthStore()
|
||||
const deploymentCapabilities = useDeploymentCapabilitiesStore()
|
||||
@@ -86,7 +85,7 @@ export const useMenuStore = defineStore('menuStore', () => {
|
||||
if (authStore.isLiteMode && liteHiddenPaths.has(item.path)) {
|
||||
return false
|
||||
}
|
||||
if (item.path === 'organizations' && !authStore.hasRole('admin')) {
|
||||
if (item.path === 'organizations' && !authStore.isSystemAdmin) {
|
||||
return false
|
||||
}
|
||||
if (!deploymentCapabilities.isSupported(item.requiredCapability)) {
|
||||
|
||||
@@ -9,10 +9,29 @@ import {
|
||||
resolveAgentNotReadyHighlight,
|
||||
} from './agent-readiness.ts'
|
||||
|
||||
test('does not treat an unrelated built-in chat model as agent configuration', () => {
|
||||
test('an empty model_id falls back to the workspace default chat model', () => {
|
||||
// Built-in agents are seeded without model_id; the run resolves the
|
||||
// workspace default, so they are ready as long as one exists.
|
||||
assert.equal(agentHasConfiguredChatModel(
|
||||
{},
|
||||
[{ id: 'builtin-chat', type: 'KnowledgeQA' }],
|
||||
), true)
|
||||
})
|
||||
|
||||
test('an empty model_id is not ready when the workspace has no KnowledgeQA model', () => {
|
||||
assert.equal(agentHasConfiguredChatModel(
|
||||
{},
|
||||
[{ id: 'embed-1', type: 'Embedding' }],
|
||||
), false)
|
||||
assert.equal(agentHasConfiguredChatModel({}, []), false)
|
||||
})
|
||||
|
||||
test('an empty model_id stays unready for shared agents', () => {
|
||||
// The model belongs to the source tenant; existence is validated backend-side.
|
||||
assert.equal(agentHasConfiguredChatModel(
|
||||
{},
|
||||
[{ id: 'builtin-chat', type: 'KnowledgeQA' }],
|
||||
true,
|
||||
), false)
|
||||
})
|
||||
|
||||
@@ -110,25 +129,62 @@ test('resolveAgentNotReadyHighlight returns the first missing item', () => {
|
||||
assert.equal(resolveAgentNotReadyHighlight([]), undefined)
|
||||
})
|
||||
|
||||
test('getAgentNotReadyReasonKeys flags missing chat model', () => {
|
||||
test('getAgentNotReadyReasonKeys flags a missing chat model only without a workspace default', () => {
|
||||
// No KnowledgeQA model in the workspace: nothing to fall back to.
|
||||
assert.deepEqual(getAgentNotReadyReasonKeys(
|
||||
{},
|
||||
[],
|
||||
{ isAgentMode: false, isSharedAgent: false },
|
||||
), ['summary_model'])
|
||||
// Workspace default exists: the empty model_id resolves at run time.
|
||||
assert.deepEqual(getAgentNotReadyReasonKeys(
|
||||
{},
|
||||
[{ id: 'chat-1', type: 'KnowledgeQA' }],
|
||||
{ isAgentMode: false, isSharedAgent: false },
|
||||
), [])
|
||||
// Shared agents must declare an explicit model; cannot validate locally.
|
||||
assert.deepEqual(getAgentNotReadyReasonKeys(
|
||||
{},
|
||||
[{ id: 'chat-1', type: 'KnowledgeQA' }],
|
||||
{ isAgentMode: false, isSharedAgent: true },
|
||||
), ['summary_model'])
|
||||
})
|
||||
|
||||
test('getAgentNotReadyReasonKeys requires rerank only in agent mode with KB search', () => {
|
||||
assert.deepEqual(getAgentNotReadyReasonKeys(
|
||||
{ kb_selection_mode: 'all', allowed_tools: ['search_knowledge'] },
|
||||
{ model_id: 'chat-1', kb_selection_mode: 'all', allowed_tools: ['search_knowledge'] },
|
||||
[{ id: 'chat-1', type: 'KnowledgeQA' }, { id: 'rerank-1', type: 'Rerank' }],
|
||||
{ isAgentMode: true, isSharedAgent: false },
|
||||
), ['summary_model', 'rerank_model'])
|
||||
), ['rerank_model'])
|
||||
assert.deepEqual(getAgentNotReadyReasonKeys(
|
||||
{ kb_selection_mode: 'all', allowed_tools: ['knowledge_search'] },
|
||||
{ model_id: 'chat-1', kb_selection_mode: 'all', allowed_tools: ['knowledge_search'] },
|
||||
[{ id: 'chat-1', type: 'KnowledgeQA' }, { id: 'rerank-1', type: 'Rerank' }],
|
||||
{ isAgentMode: true, isSharedAgent: false },
|
||||
), ['summary_model', 'rerank_model'])
|
||||
), ['rerank_model'])
|
||||
})
|
||||
|
||||
test('built-in agents fall back to the workspace rerank without a reason', () => {
|
||||
// Mirrors session_agent_qa.go: empty rerank on a builtin resolves from the
|
||||
// workspace (or searches without reranking) instead of blocking the run.
|
||||
assert.deepEqual(getAgentNotReadyReasonKeys(
|
||||
{ model_id: 'chat-1', kb_selection_mode: 'all', allowed_tools: ['search_knowledge'] },
|
||||
[{ id: 'chat-1', type: 'KnowledgeQA' }, { id: 'rerank-1', type: 'Rerank' }],
|
||||
{ isAgentMode: true, isSharedAgent: false, isBuiltin: true },
|
||||
), [])
|
||||
// Even with no rerank model at all: builtin searches without reranking.
|
||||
assert.deepEqual(getAgentNotReadyReasonKeys(
|
||||
{ model_id: 'chat-1', kb_selection_mode: 'all', allowed_tools: ['search_knowledge'] },
|
||||
[{ id: 'chat-1', type: 'KnowledgeQA' }],
|
||||
{ isAgentMode: true, isSharedAgent: false, isBuiltin: true },
|
||||
), [])
|
||||
})
|
||||
|
||||
test('custom agents without a rerank model stay flagged', () => {
|
||||
assert.deepEqual(getAgentNotReadyReasonKeys(
|
||||
{ model_id: 'chat-1', kb_selection_mode: 'all', allowed_tools: ['search_knowledge'] },
|
||||
[{ id: 'chat-1', type: 'KnowledgeQA' }, { id: 'rerank-1', type: 'Rerank' }],
|
||||
{ isAgentMode: true, isSharedAgent: false, isBuiltin: false },
|
||||
), ['rerank_model'])
|
||||
})
|
||||
|
||||
test('getAgentNotReadyReasonKeys does not treat current shared context as shared without sourceTenantId', () => {
|
||||
|
||||
@@ -1,28 +1,47 @@
|
||||
import type { CustomAgentConfig } from '@/api/agent'
|
||||
import type { ModelConfig } from '@/api/model'
|
||||
import { allowedToolsInclude } from './legacy-tool-names'
|
||||
import { selectInitialModelId } from './modelDefaults'
|
||||
|
||||
export type AgentNotReadyReasonKey = 'summary_model' | 'rerank_model' | 'allowed_tools'
|
||||
|
||||
/**
|
||||
* An agent is chat-ready only when it explicitly references a usable chat
|
||||
* model. Merely having some built-in/default model in the tenant must not hide
|
||||
* incomplete agent configuration.
|
||||
* An agent is chat-ready when it references a usable chat model, or when it
|
||||
* may fall back to the workspace default: an empty model_id is resolved at run
|
||||
* time from the agent's knowledge base or the workspace's default KnowledgeQA
|
||||
* model (backend UsesWorkspaceModelFallback + selectChatModelID), so a local
|
||||
* agent without an explicit model is ready as long as the workspace has a
|
||||
* usable default. Only a model_id that points at a missing/non-KnowledgeQA
|
||||
* model counts as incomplete configuration.
|
||||
*
|
||||
* For shared agents the model belongs to the source tenant, so the caller can
|
||||
* require a non-empty ID but must leave existence validation to the backend.
|
||||
*/
|
||||
export function agentHasConfiguredChatModel(
|
||||
config: Pick<CustomAgentConfig, 'model_id'> | undefined,
|
||||
models: Pick<ModelConfig, 'id' | 'type'>[],
|
||||
models: Pick<ModelConfig, 'id' | 'type' | 'status'>[],
|
||||
sourceModelIsRemote = false,
|
||||
): boolean {
|
||||
const modelID = config?.model_id?.trim()
|
||||
if (!modelID) return false
|
||||
if (!modelID) {
|
||||
if (sourceModelIsRemote) return false
|
||||
return hasWorkspaceDefaultChatModel(models)
|
||||
}
|
||||
if (sourceModelIsRemote) return true
|
||||
return models.some(model => model.type === 'KnowledgeQA' && model.id === modelID)
|
||||
}
|
||||
|
||||
/**
|
||||
* Workspace default chat model: the declared KnowledgeQA default, else the
|
||||
* first active KnowledgeQA model — same rule as the backend's
|
||||
* PickDefaultModelID and the agent editor's auto pre-fill.
|
||||
*/
|
||||
export function hasWorkspaceDefaultChatModel(
|
||||
models: Pick<ModelConfig, 'id' | 'type' | 'status'>[],
|
||||
): boolean {
|
||||
return selectInitialModelId(models, 'KnowledgeQA') != null
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep this aligned with backend agentRequiresRerankModel.
|
||||
*
|
||||
@@ -50,8 +69,8 @@ export function getAgentNotReadyReasonKeys(
|
||||
CustomAgentConfig,
|
||||
'model_id' | 'rerank_model_id' | 'kb_selection_mode' | 'allowed_tools' | 'agent_mode'
|
||||
> | undefined,
|
||||
models: Pick<ModelConfig, 'id' | 'type'>[],
|
||||
options: { isAgentMode: boolean; isSharedAgent: boolean },
|
||||
models: Pick<ModelConfig, 'id' | 'type' | 'status'>[],
|
||||
options: { isAgentMode: boolean; isSharedAgent: boolean; isBuiltin?: boolean },
|
||||
): AgentNotReadyReasonKey[] {
|
||||
const reasons: AgentNotReadyReasonKey[] = []
|
||||
|
||||
@@ -61,12 +80,20 @@ export function getAgentNotReadyReasonKeys(
|
||||
|
||||
if (options.isAgentMode && agentRequiresRerankModel(config)) {
|
||||
const rerankModelID = config?.rerank_model_id?.trim()
|
||||
const rerankExists = !!rerankModelID && (
|
||||
options.isSharedAgent
|
||||
|| models.some(model => model.type === 'Rerank' && model.id === rerankModelID)
|
||||
)
|
||||
if (!rerankExists) {
|
||||
reasons.push('rerank_model')
|
||||
if (!rerankModelID) {
|
||||
// Built-in agents are seeded without a rerank model; the run falls back
|
||||
// to the workspace rerank (or searches without reranking) instead of
|
||||
// blocking, mirroring session_agent_qa.go's UsesWorkspaceModelFallback
|
||||
// branch. Custom agents must declare their own rerank model.
|
||||
if (!options.isBuiltin || options.isSharedAgent) {
|
||||
reasons.push('rerank_model')
|
||||
}
|
||||
} else {
|
||||
const rerankExists = options.isSharedAgent
|
||||
|| models.some(model => model.type === 'Rerank' && model.id === rerankModelID)
|
||||
if (!rerankExists) {
|
||||
reasons.push('rerank_model')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -367,9 +367,9 @@ const roleDict = ref<TrainingRoleDef[]>([])
|
||||
// 本人职称角色(权限门控口径与培训页一致:人事/经理/空间管理员可维护)
|
||||
const rawRoles = ref<string[]>([])
|
||||
const myRoles = computed(() => expandRoles(rawRoles.value, roleDict.value))
|
||||
const canManage = computed(
|
||||
() => authStore.hasRole('admin') || myRoles.value.some((r) => r === 'hr' || r === 'exec'),
|
||||
)
|
||||
// 000163 权限收口:组织架构页仅平台超级管理员可查看/维护
|
||||
// (路由 requiresSystemAdmin 守卫为主,此处为页面内兜底)。
|
||||
const canManage = computed(() => authStore.isSystemAdmin)
|
||||
|
||||
const rolesVisible = ref(false)
|
||||
const activeEmployee = ref<OrgEmployee | null>(null)
|
||||
|
||||
@@ -130,9 +130,9 @@ const canManageTabs = computed(() =>
|
||||
isAdmin.value ||
|
||||
myRoles.value.some((r) => ['hr', 'supervisor', 'exec', 'lecturer', 'super_admin'].includes(r)))
|
||||
|
||||
// 配置中心门槛(000158):人事/空间管理员之外,经理职称角色同权查看与维护。
|
||||
const canManageConfig = computed(() =>
|
||||
isAdmin.value || myRoles.value.some((r) => r === 'exec'))
|
||||
// 配置中心门槛(000163 权限收口):仅平台超级管理员可查看与维护
|
||||
// (菜单入口/路由守卫同步收口,此处为页面内兜底)。
|
||||
const canManageConfig = computed(() => authStore.isSystemAdmin)
|
||||
|
||||
// 页头角色标签:展示实际分配的角色(非权限展开),文案取自配置中心字典
|
||||
const myRoleLabel = computed(() =>
|
||||
|
||||
Reference in new issue
Block a user