feat: 添加fetchAnnotationData函数以获取注释数据#347
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
概览此 PR 在多个应用入口文件中添加了数据权限注解数据的初始化逻辑。新增 变更
序列图sequenceDiagram
participant App as 应用启动
participant FetchFunc as fetchAnnotationData()
participant Config as platform.config.json
participant API as API 服务
participant Window as window.annotationAllData
App->>FetchFunc: 模块初始化调用
FetchFunc->>Config: 读取 enableDataPermission<br/>和 sysPrefixPath
alt 权限禁用或数据已存在
FetchFunc->>FetchFunc: 提前返回
else 需要获取数据
FetchFunc->>API: 并行请求 entityAll 和 logicAll
API-->>FetchFunc: 返回 JSON 响应
FetchFunc->>FetchFunc: 解析并归一化数据<br/>(response.Data 处理)
FetchFunc->>Window: 存储结果到<br/>window.annotationAllData
end
FetchFunc-->>App: 初始化完成
Note over App,Window: 应用继续启动流程
预估代码审查工作量🎯 3 (Moderate) | ⏱️ ~20 分钟 可能关联的 PR
诗歌
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/vue2/src/data-permission.js (1)
14-17: 缺少 HTTP 响应状态检查。当服务器返回 4xx/5xx 错误时,
response.json()仍会尝试解析响应体,可能将错误信息错误地存入window.annotationAllData。♻️ 建议添加响应状态检查
const [entityAll, logicAll] = await Promise.all([ - fetch(urlEntity).then((response) => response.json()), - fetch(urlLogic).then((response) => response.json()), + fetch(urlEntity).then((response) => { + if (!response.ok) throw new Error(`HTTP ${response.status}`); + return response.json(); + }), + fetch(urlLogic).then((response) => { + if (!response.ok) throw new Error(`HTTP ${response.status}`); + return response.json(); + }), ]);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/vue2/src/data-permission.js` around lines 14 - 17, The current Promise.all that sets const [entityAll, logicAll] = await Promise.all([ fetch(urlEntity).then((response) => response.json()), fetch(urlLogic).then((response) => response.json()), ]) lacks HTTP status checks; update the fetch handlers for fetch(urlEntity) and fetch(urlLogic) to verify response.ok (or check response.status) and throw or return a handled error when not ok before calling response.json(), so that invalid 4xx/5xx responses are not parsed into entityAll/logicAll (and thus not written into window.annotationAllData); ensure the thrown error is caught where the Promise.all is awaited or let the caller handle it.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/vue2/src/data-permission.js`:
- Around line 10-11: The constructed URLs urlEntity and urlLogic use
sysPrefixPath which can be undefined; ensure sysPrefixPath defaults to an empty
string before building those URLs (e.g., set sysPrefixPath to
(platformConfig?.sysPrefixPath) ?? '' or equivalent) so urlEntity and urlLogic
become correct when platformConfig.sysPrefixPath is missing; update the code
around the sysPrefixPath variable assignment (used to build urlEntity and
urlLogic) to apply this default.
---
Nitpick comments:
In `@packages/vue2/src/data-permission.js`:
- Around line 14-17: The current Promise.all that sets const [entityAll,
logicAll] = await Promise.all([ fetch(urlEntity).then((response) =>
response.json()), fetch(urlLogic).then((response) => response.json()), ]) lacks
HTTP status checks; update the fetch handlers for fetch(urlEntity) and
fetch(urlLogic) to verify response.ok (or check response.status) and throw or
return a handled error when not ok before calling response.json(), so that
invalid 4xx/5xx responses are not parsed into entityAll/logicAll (and thus not
written into window.annotationAllData); ensure the thrown error is caught where
the Promise.all is awaited or let the caller handle it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 19e5029e-b1b2-4dfe-bad7-2ced482300f6
📒 Files selected for processing (5)
packages/vue2/source/icestark/main.jspackages/vue2/source/qiankun/main.jspackages/vue2/source/wujie/main.jspackages/vue2/src/data-permission.jspackages/vue2/src/main.js
Co-authored-by: 御风 <18012261618@126.com>
Summary by CodeRabbit
发布说明