feat:页面按钮隐藏 - #209
Conversation
|
|
|
head_sha: 变更摘要此 PR 主要引入了一个全局配置项 主要改动
|
|
head_sha: 代码审查Now I have all findings covered. Let me provide the closing summary. 审查总结本次 PR"feat:页面按钮隐藏"涉及 19 个文件的变更,核心目的是通过新增
整体风险评估:中等。核心问题(P2 Finding 1)导致按钮隐藏功能在当前实现下完全无法通过后端配置触发—— 逐文件审查结果
⛔ 需要修改 |
|
head_sha:
|
| } | ||
|
|
||
| public setConfigs(configs: IAgentConfigs) { | ||
| configs.studio_btn_show = true; |
There was a problem hiding this comment.
head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895
🟡 Medium Priority
setConfigs 方法第 77 行无条件执行 configs.studio_btn_show = true,强制覆盖后端传入的任何值(包括 false)。这意味着整个 PR 的"页面按钮隐藏"功能无法通过后端配置触发:即使后端下发 studio_btn_show: false,setConfigs 也会将其改写为 true,所有按钮始终可见。
证据链:
修复方向:改为仅在未设置时默认 true,保留后端下发的值:configs.studio_btn_show = configs.studio_btn_show ?? true;
建议:将无条件赋值改为仅在 undefined 时提供默认值:configs.studio_btn_show = configs.studio_btn_show ?? true;
| this.kbQuantityLimit = this.configServ.getConfigs()?.agent_knowledge_bound_limit ?? this.kbQuantityLimit; | ||
| } | ||
|
|
||
| this.studioBtnShow = this.configServ.getConfigs()?.studio_btn_show; |
There was a problem hiding this comment.
head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895
🟡 Medium Priority
knowledge-base-selector.component.ts 第 182 行声明 studioBtnShow = true 作为类字段默认值,但在 ngOnInit 第 223 行直接覆盖为 this.configServ.getConfigs()?.studio_btn_show。
受影响行为:当 studio_btn_show 为 undefined 时,studioBtnShow 变为 undefined(falsy),导致 HTML 模板中两处 *ngIf="... && studioBtnShow" 条件判断失败:
- 第 30 行:创建知识库按钮被隐藏
- 第 79 行:空数据页面的创建知识库按钮被隐藏
失败模式:与 flow-detail-header 相同——如果 setConfigs 硬编码被修复且后端未下发该字段,"创建知识库"入口会意外消失。
建议:使用空值合并运算符 ?? true 兜底:this.studioBtnShow = this.configServ.getConfigs()?.studio_btn_show ?? true;
| this.studioBtnShow = this.configServ.getConfigs()?.studio_btn_show; | |
| this.studioBtnShow = this.configServ.getConfigs()?.studio_btn_show ?? true; |
| private appFlowServe: AppFlowService, | ||
| private commonService: CommonService | ||
| ) { | ||
| this.studioBtnShow = this.configServ.getConfigs()?.studio_btn_show; |
There was a problem hiding this comment.
head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895
🟡 Medium Priority
studioBtnShow 在 constructor 中(第 72 行)通过 this.configServ.getConfigs()?.studio_btn_show 一次性读取,之后再也不会更新。由于 initConfigs() 是异步网络请求(在 app.component.ts 中通过 subscribe 回调调用),FlowDetailHeaderComponent 构造时 configs 很可能尚未加载,此时 getConfigs() 返回空对象 {},studio_btn_show 为 undefined。
证据链:
- 当
setConfigs后续被调用时,studioBtnShow不会更新,因为没有订阅configs$
影响:返回按钮(onClickBack())是页面导航的关键元素,被隐藏后用户无法返回上一页。
建议:改为订阅 configServ.data$ 以响应配置变更,或在 ngOnInit 中读取配置(此时配置通常已加载完成),并提供默认值兜底:this.studioBtnShow = this.configServ.getConfigs()?.studio_btn_show ?? true;
| tips: '', | ||
| show: this.configServ.getConfigs()?.studio_btn_show, | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895
🟡 Medium Priority
configHeaderTabs 数组在第 579-593 行作为类字段静态初始化。其中 releaseManage tab 的 show 属性在初始化时读取 this.configServ.getConfigs()?.studio_btn_show,此时 configs 尚未加载(BehaviorSubject 初始值为 {}),因此 show 为 undefined。
证据链:
- 第 579-593 行:
configHeaderTabs在类字段声明时立即求值 - 当
setConfigs后续被调用时,configHeaderTabs[1].show仍是初始化时的undefined,不会更新
影响:即使修复了 Finding 1(setConfigs 正确传递 false),releaseManage tab 也永远不会被隐藏,因为其 show 已固化为 undefined。
建议:将 configHeaderTabs 的初始化移到 ngOnInit 中(此时 configs 通常已加载),或改为 getter 以动态读取最新配置值。例如在 ngOnInit 中设置 this.configHeaderTabs[1].show = this.configServ.getConfigs()?.studio_btn_show ?? true;。
| } | ||
| </nz-tabs> | ||
| `, | ||
| styles: [ |
There was a problem hiding this comment.
head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895
🟠 High Priority
selectedIndex getter(第 48-51 行)在未过滤的 tabs 数组上计算激活 tab 的索引,但模板已改为使用 @if (tab.show !== false) 过滤不可见的 tab。当某个 show: false 的 tab 位于激活 tab 之前时,nzSelectedIndex 会指向错误的渲染 tab。
证据链:
flow.component.ts:591 新增了 show: this.configServ.getConfigs()?.studio_btn_show,当该值为 false 时(修复 Finding 1 后),对应的 releaseManage tab 会被隐藏,若它恰好在激活 tab 之前,将触发此 bug。
建议:selectedIndex 应在过滤后的可见 tab 列表上计算,而非完整 tabs 数组。同时 onSelectedIndexChange 也应在可见 tab 列表中查找。
| styles: [ | |
| get selectedIndex(): number { | |
| const visibleTabs = this.tabs.filter(tab => tab.show !== false); | |
| const index = visibleTabs.findIndex(tab => tab.active); | |
| return index >= 0 ? index : 0; | |
| } |
Paired: GitHub #209 ↔ GitCode !1783
What type of PR is this?
/kind
Self-checklist:(请自检,在[ ]内打上x,我们将检视你的完成情况,否则会导致pr无法合入)
Linked Closing Issues: