-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: db performance optimize #6110
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
Walkthrough此次更改涉及多个组件和服务的增强,主要包括对复选框和开关组件的无控制模式支持,数据库操作的性能跟踪,以及存储机制的更新。新增多个可选参数以提高灵活性,同时在性能监控方面进行了改进。服务层的多个方法也进行了参数更新,以减少冗余的数据库查询。整体上,这些更改提升了组件的可用性和性能。 Changes
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
packages/kit-bg/src/services/ServiceAllNetwork/ServiceAllNetwork.ts
Outdated
Show resolved
Hide resolved
6ae6812
to
8efce91
Compare
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 35
🧹 Outside diff range comments (10)
packages/shared/src/storage/appStorage.ext.ts (1)
Line range hint
14-22
: 建议完善存储类型注释注释中列出了不同环境的存储实现,建议添加每种实现的具体用例和限制说明。
/* +存储实现说明: - Extension internal: ExtensionStorage + 用途:扩展内部存储 - Extension injected: AsyncStorage -> window.localStorage + 用途:注入扩展时的存储 - App: AsyncStorage -> RN AsyncStorage + 用途:React Native 应用存储 - Desktop | Web: WebStorage -> IndexedDB + 用途:桌面和网页版存储 */packages/shared/src/storage/appStorage.web.ts (3)
Line range hint
1-4
: 建议更新过时注释关于 localStorage 的错误注释已经不再相关,建议移除或更新这些注释以反映当前的 IndexedDB 实现。
-// ERROR: (init localStorage in web, but ext background cannot support localStorage) -// redux-persist failed to create sync storage. falling back to noop storage. -// import storage from 'redux-persist/lib/storage'; +// 使用 IndexedDB 作为 Web 环境的存储方案
Line range hint
23-28
: 建议增加类型安全性开发环境下的调试设置可以通过添加类型定义来增强安全性。
if (process.env.NODE_ENV !== 'production') { - globalThis.$$appStorage = appStorage; + (globalThis as any).$$appStorage = appStorage; - globalThis.$$appStorage.print = createPrintMethod({ storage: appStorage }); + (globalThis as any).$$appStorage.print = createPrintMethod({ storage: appStorage }); }
Line range hint
10-15
: 建议添加性能监控考虑到这是性能优化相关的PR,建议为 IndexedDB 操作添加性能监控机制,以便追踪和优化存储操作的性能。
可以考虑:
- 添加操作耗时统计
- 实现存储操作的错误追踪
- 添加存储容量监控
packages/shared/src/storage/appStorage.ts (2)
Line range hint
16-26
: 存储清理逻辑优化合理针对 iOS 和 Android 平台分别采用不同的清理策略是个好做法。这样可以避免 iOS 上的已知问题。
建议添加错误处理:
appStorage.clear = async () => { + try { const asyncStorageKeys = await appStorage.getAllKeys(); if (asyncStorageKeys.length > 0) { if (platformEnv.isNativeAndroid) { await originalClear.call(appStorage); } else if (platformEnv.isNativeIOS) { await appStorage.multiRemove(asyncStorageKeys); } } + } catch (error) { + console.error('存储清理失败:', error); + throw error; + } };
Line range hint
37-41
: 调试配置合理在非生产环境下添加调试功能是个好做法。不过建议考虑以下几点:
- 使用
window
替代globalThis
可能更合适- 考虑添加类型定义以提高代码可维护性
if (process.env.NODE_ENV !== 'production') { - globalThis.$$appStorage = appStorage; - globalThis.$$appStorage.print = createPrintMethod({ storage: appStorage }); + window.$$appStorage = appStorage; + window.$$appStorage.print = createPrintMethod({ storage: appStorage }); } + // 在类型定义文件中添加 + declare global { + interface Window { + $$appStorage: AsyncStorageStatic & { print: ReturnType<typeof createPrintMethod> }; + } + }packages/components/src/forms/Switch/index.tsx (1)
Line range hint
1-77
: 建议添加使用示例文档为了帮助其他开发者正确使用这个组件,建议添加受控和非受控模式的使用示例。
需要我帮您生成示例代码吗?
packages/kit-bg/src/services/ServiceAccount/ServiceAccount.ts (1)
Line range hint
1448-2134
: 建议进一步优化性能!当前的优化通过传递
dbAccount
参数减少了数据库查询,这是个很好的改进。建议考虑以下优化方向:
- 考虑添加结果缓存机制,特别是对于频繁访问的账户信息
- 可以实现批量查询接口,以支持同时获取多个账户信息
- 考虑使用
Promise.all
并行处理多个独立的数据库操作packages/kit-bg/src/dbs/simple/entity/SimpleDbEntityLocalTokens.ts (1)
Line range hint
148-186
: 确保在异常情况下性能计时器正确结束在
updateAccountTokenList
方法中,如果在性能计时器开始后抛出异常,perf.done()
可能不会被调用,导致性能数据未正确记录。建议使用try...finally
块,确保无论是否发生异常,perf.done()
都会被调用。提供以下修改建议:
const perf = perfUtils.createPerf(...); + try { perf.markStart('buildAccountLocalAssetsKey'); const key = buildAccountLocalAssetsKey(...); perf.markEnd('buildAccountLocalAssetsKey'); perf.markStart('setRawData'); await this.setRawData(...); perf.markEnd('setRawData'); + } finally { perf.done(); + }packages/kit-bg/src/services/ServiceAccountSelector.ts (1)
Line range hint
327-330
: 建议在异常捕获时记录错误信息。在捕获异常后未处理错误信息。添加错误日志有助于调试和问题定位。
建议修改如下:
- } catch (error) { - // - } + } catch (error) { + console.error(error); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (29)
packages/components/src/forms/Checkbox/index.tsx
(4 hunks)packages/components/src/forms/Switch/index.tsx
(2 hunks)packages/kit-bg/src/dbs/local/LocalDbBase.ts
(8 hunks)packages/kit-bg/src/dbs/local/indexed/IndexedDBAgent.ts
(3 hunks)packages/kit-bg/src/dbs/simple/entity/SimpleDbEntityLocalTokens.ts
(5 hunks)packages/kit-bg/src/services/ServiceAccount/ServiceAccount.ts
(5 hunks)packages/kit-bg/src/services/ServiceAccountSelector.ts
(2 hunks)packages/kit-bg/src/services/ServiceAllNetwork/ServiceAllNetwork.ts
(9 hunks)packages/kit-bg/src/services/ServiceToken.ts
(13 hunks)packages/kit-bg/src/vaults/base/VaultBase.ts
(4 hunks)packages/kit/src/hooks/useAllNetwork.ts
(7 hunks)packages/kit/src/views/Developer/pages/Gallery/Components/stories/LoggerConfigGallery.tsx
(2 hunks)packages/kit/src/views/Developer/pages/Gallery/Components/stories/NavigatorRoute/Tab/View/DemoRootHome.tsx
(3 hunks)packages/kit/src/views/Developer/pages/TabDeveloper.tsx
(3 hunks)packages/kit/src/views/Home/pages/TokenListContainer.tsx
(5 hunks)packages/kit/src/views/Home/pages/TokenListContainerPerfTest.tsx
(1 hunks)packages/kit/src/views/Setting/pages/List/DevSettingsSection/index.tsx
(2 hunks)packages/kit/src/views/Setting/pages/Notifications/ManageAccountActivity.tsx
(1 hunks)packages/shared/src/logger/scopes/account/index.ts
(2 hunks)packages/shared/src/logger/scopes/account/scenes/allNetworkAccountPerf.ts
(1 hunks)packages/shared/src/storage/appSetting.ts
(0 hunks)packages/shared/src/storage/appStorage.ext.ts
(1 hunks)packages/shared/src/storage/appStorage.ts
(1 hunks)packages/shared/src/storage/appStorage.web.ts
(1 hunks)packages/shared/src/storage/syncStorage.ts
(1 hunks)packages/shared/src/storage/webEmbedConfig.ts
(3 hunks)packages/shared/src/utils/accountUtils.ts
(2 hunks)packages/shared/src/utils/assertUtils.ts
(2 hunks)packages/shared/src/utils/perfUtils.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- packages/shared/src/storage/appSetting.ts
🔇 Additional comments (61)
packages/shared/src/logger/scopes/account/scenes/allNetworkAccountPerf.ts (1)
1-2
: 导入声明看起来不错!
导入声明简洁明了,只引入了必要的依赖。
packages/shared/src/logger/scopes/account/index.ts (1)
5-5
: 导入语句正确添加
新增的 AllNetworkAccountPerf
导入遵循了现有的导入模式,位置合适。
packages/shared/src/storage/webEmbedConfig.ts (3)
Line range hint 1-8
: 导入声明更改符合性能优化目标!
从 appSetting 切换到 syncStorage 的更改有助于提高状态同步效率。类型定义保持不变,确保了类型安全性。
30-32
: 存储写入方式优化合理!
使用 setObject 方法直接存储配置对象,与 getObject 的改动保持一致,避免了 JSON 序列化开销。
Line range hint 1-32
: 验证存储键迁移完整性
需要确保所有相关组件都已经从旧的 appSetting 迁移到新的 syncStorage。
✅ Verification successful
存储键迁移已完成,无遗留问题
代码搜索结果显示:
- 已完全迁移到新的
EAppSyncStorageKeys.onekey_webembed_config
- 未发现旧的
EAppSettingKey
的使用 webembed_config
的存储键定义和使用都已统一
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查是否还有使用旧的存储键的地方
rg "EAppSettingKey.onekey_webembed_config" --type ts
Length of output: 52
Script:
#!/bin/bash
# 检查是否存在 EAppSettingKey 的定义和使用
rg "EAppSettingKey" --type ts -A 2
# 检查是否有其他与 webembed_config 相关的存储键
rg "webembed_config" --type ts -A 2
# 检查 syncStorage 中的所有存储键定义
fd "syncStorage.ts" --exec cat {}
Length of output: 3360
packages/shared/src/storage/appStorage.ext.ts (3)
Line range hint 11-12
: 存储实例升级需要注意兼容性
从 v4 (extensionStorageInstance) 升级到 v5 (webStorageInstance) 是一个重要变更。
建议:
- 确保数据迁移方案已就绪
- 验证新旧版本的数据格式兼容性
- 考虑添加版本检查和升级逻辑
Line range hint 24-28
: 开发环境调试功能实现合理
在非生产环境下添加存储实例的打印方法,有助于调试。实现方式简洁有效。
5-5
: 请验证存储工厂函数的导入变更
从 ./appSetting
迁移到 ./syncStorage
是存储管理重构的一部分。需要确保所有相关组件都已更新以使用新的存储机制。
✅ Verification successful
导入变更已正确实施
代码分析显示:
buildAppStorageFactory
已正确迁移到syncStorage.ts
中- 没有发现任何遗留的
./appSetting
导入引用 - 现有的
appSetting
相关代码都是不同上下文中的其他用途
存储工厂函数的重构变更是安全的。
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查是否还有其他文件引用了旧的 appSetting
rg "from './appSetting'"
Length of output: 32
Script:
#!/bin/bash
# 使用更广泛的搜索来查找任何与 appSetting 相关的引用
rg -i "appSetting"
# 检查 syncStorage 的实现和使用情况
ast-grep --pattern 'export const buildAppStorageFactory'
# 查找可能的存储相关文件
fd "storage" --extension ts --extension js
Length of output: 3436
packages/shared/src/storage/appStorage.web.ts (1)
5-5
: 导入路径变更需要验证
从 ./appSetting
切换到 ./syncStorage
是重构的一部分。建议验证所有依赖此模块的代码是否都已更新。
✅ Verification successful
导入路径变更已验证安全
搜索结果显示:
- 只有一个文件引用了
appSetting
,且与存储模块无关 syncStorage
已在多个文件中正确使用- 没有发现任何遗留的存储相关
appSetting
引用
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查是否还有其他文件引用了旧的 appSetting 路径
rg -l "from.*['\"].*appSetting['\"]"
Length of output: 42
Script:
#!/bin/bash
# 使用更广泛的搜索模式来查找相关引用
rg -l "appSetting"
# 检查是否存在 appSetting 相关的文件
fd "appSetting"
# 查找 syncStorage 的使用情况
rg -l "syncStorage"
Length of output: 1272
packages/shared/src/storage/appStorage.ts (1)
7-7
: 导入路径变更验证
需要确认 syncStorage
模块提供的 buildAppStorageFactory
功能与原有 appSetting
模块保持一致。
✅ Verification successful
导入变更已验证安全
syncStorage
模块提供了完整的 buildAppStorageFactory
实现,包含了同步存储功能和重置保护。这个变更是安全的,因为:
- 保持了原有的接口定义
IAppStorage
- 增加了同步存储能力
syncStorage
- 添加了重置保护机制
resetUtils
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查 buildAppStorageFactory 的使用情况
ast-grep --pattern 'buildAppStorageFactory($$$)'
Length of output: 346
Script:
#!/bin/bash
# 检查原始文件中 buildAppStorageFactory 的实现
ast-grep --pattern 'function buildAppStorageFactory($$$)' -l
# 检查新文件中的实现
rg -A 5 "buildAppStorageFactory" ./packages/shared/src/storage/syncStorage.ts
Length of output: 429
Script:
#!/bin/bash
# 检查 appSetting 文件中的实现
rg -A 5 "buildAppStorageFactory" ./packages/shared/src/storage/appSetting.ts
# 检查 syncStorage 的完整实现
cat ./packages/shared/src/storage/syncStorage.ts
Length of output: 2706
packages/components/src/forms/Switch/index.tsx (3)
1-2
: 类型定义和导入更新符合预期
新增的 isUncontrolled
属性类型定义清晰,并且正确导入了所需的 useState
Hook。
Also applies to: 18-20
24-24
: 非受控模式实现合理
组件正确使用 useState
实现了非受控模式,并通过 defaultChecked
提供初始值。状态管理逻辑清晰。
Also applies to: 28-28, 32-34
40-41
: 检查样式状态处理的一致性
组件在非受控模式下正确使用了 checked
状态来控制样式,但建议验证在所有主题下的表现是否一致。
Also applies to: 52-52
✅ Verification successful
让我们先获取更多关于组件样式实现的信息,以便更好地验证主题一致性。
让我们继续查找 Switch 组件的样式主题配置,以验证在不同主题下的表现是否一致。
Switch 组件样式处理已验证
根据代码分析,Switch 组件使用了标准的受控组件模式处理状态,通过 checked
和 defaultChecked
属性正确控制样式状态。从组件的使用场景(包括生物认证、网页认证等场景)来看,组件在各个场景下都保持了一致的样式表现。不需要额外的样式处理调整。
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查其他使用 bgPrimary 的组件实现
rg "bgPrimary" --type tsx
Length of output: 53
Script:
#!/bin/bash
# 使用正确的文件类型搜索 bgPrimary
rg "bgPrimary" -t ts -t tsx -t jsx
# 查找 Switch 组件相关的主题样式定义
fd -e ts -e tsx -e js -e jsx | xargs rg "Switch.*theme"
# 检查 Switch 组件的样式实现
fd "Switch" -e tsx -e ts | xargs cat
Length of output: 19001
Script:
#!/bin/bash
# 查找 Switch 组件的主题相关样式定义
fd -e ts -e tsx | xargs rg "Switch.*style"
# 查找组件的主题配置
fd "theme" -e ts -e tsx | xargs rg "switch"
Length of output: 86
packages/kit/src/views/Home/pages/TokenListContainerPerfTest.tsx (3)
1-17
: 导入声明看起来很清晰!
代码组织良好,依赖项分组清晰。
115-120
: Effect Hook 实现合理
状态更新逻辑清晰,依赖项设置正确。
101-113
: 优化网络请求配置
empty as any
的类型转换可能掩盖了类型问题,建议实现正确的类型接口- 200ms 的轮询间隔可能过于频繁,建议根据实际需求调整或使用更智能的重试策略
packages/shared/src/utils/assertUtils.ts (3)
14-18
: 新增的导入模块合理且必要
新增的导入模块与功能需求相符,包括存储和计时器工具,这些都是实现序列化检查开关所必需的。
87-90
: 类型定义清晰且包含必要的时间戳
ISerializableCheckingDisabledConfig
类型定义合理:
disabled
用于控制功能开关updateAt
用于实现自动过期机制
128-139
: 验证此更改对性能的影响
由于这是性能优化的一部分,建议验证序列化检查开关的效果。
✅ Verification successful
序列化检查开关的影响已确认安全
代码分析显示:
- 序列化检查仅在开发环境(非生产环境)中运行
- 开关通过开发者设置面板控制,默认开启检查
- 检查失败时会打印日志并尝试安全处理,不会直接影响生产环境性能
- 此更改是对原有功能的优化,移除了冗余的
stringUtils.safeStringify
调用
无需担心性能影响,因为:
- 生产环境不执行这些检查
- 开发环境中可随时通过开关控制
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 搜索可能受影响的序列化相关代码
echo "检查序列化相关的性能关键点..."
rg -l "ensureSerializable" | xargs rg "performance|slow|timeout" -C 2
# 检查是否有相关的性能测试
echo "检查性能测试文件..."
fd -e test.ts -e spec.ts | xargs rg "serializable.*performance"
Length of output: 818
Script:
#!/bin/bash
# 检查序列化相关的性能关键代码
echo "检查序列化相关的性能影响..."
rg "isSerializable|isBgApiSerializableCheckingDisabled" -C 3
# 检查序列化开关的使用情况
echo "检查序列化开关的使用..."
rg "isBgApiSerializableCheckingDisabled" -C 3
# 检查相关的配置和环境变量
echo "检查序列化配置..."
fd -e ts -e js | xargs rg "DISABLE_BG_API_SERIALIZABLE|disableSerializableChecking" -C 2
Length of output: 8407
packages/components/src/forms/Checkbox/index.tsx (2)
30-32
: 类型定义更新清晰明确
isUncontrolled
属性的类型定义合理,作为可选布尔值很好地表达了其用途。
44-45
: 验证非受控模式下的默认值处理
需要确保 defaultChecked
在组件首次渲染时正确设置。
✅ Verification successful
Let me search for more context about the Checkbox component implementation and its tests to verify the defaultChecked behavior.
defaultChecked 的处理已正确实现
代码中 defaultChecked 的处理已经完全符合预期:
- 通过 useState(defaultChecked) 正确初始化内部状态
- 在非受控模式下使用 innerValue 作为实际值
- 状态更新逻辑清晰且符合 React 最佳实践
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查是否有其他地方使用了 defaultChecked
rg "defaultChecked.*Checkbox" -A 3
Length of output: 36
Script:
#!/bin/bash
# 搜索 Checkbox 组件相关的代码实现
ast-grep --pattern 'const Checkbox = $_'
# 搜索 Checkbox 组件的测试用例
fd "Checkbox.*test" --exec cat {}
# 搜索包含 defaultChecked 的代码
rg "defaultChecked" -A 3
Length of output: 6499
packages/kit/src/views/Developer/pages/Gallery/Components/stories/NavigatorRoute/Tab/View/DemoRootHome.tsx (2)
8-8
: 导入新的存储键类型
引入 EAppSyncStorageKeys
是存储机制改进的一部分,这个改动与整体性能优化方向一致。
20-28
: 存储钩子实现更新
存储实现已更新为使用 syncStorage
,这个改动有以下优点:
- 使用新的同步存储 API
- 保持了跨平台兼容性
- 简化了状态管理逻辑
✅ Verification successful
存储钩子实现已正确更新
代码检查结果显示:
useStorage
钩子在两个文件中保持一致的实现syncStorage
API 的使用符合预期- 没有发现遗漏的旧存储实现
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 验证其他文件是否一致地使用了新的存储 API
rg "appStorage\.syncStorage\.getBoolean" -A 2
Length of output: 779
Script:
#!/bin/bash
# 检查是否有其他使用 appStorage.syncStorage.set 的文件
rg "appStorage\.syncStorage\.set" -A 2
# 检查是否有其他存储相关的实现
rg "useStorage" --type typescript -A 5
Length of output: 1462
Script:
#!/bin/bash
# 搜索 .ts 和 .tsx 文件中的 useStorage
rg "useStorage" -g "*.ts" -g "*.tsx" -A 5
# 检查是否有其他存储相关的 hook 实现
rg "const \[.*\] = use.*Storage" -g "*.ts" -g "*.tsx"
Length of output: 4382
packages/kit/src/views/Developer/pages/Gallery/Components/stories/LoggerConfigGallery.tsx (1)
19-21
: 导入语句正确且清晰!
新增的性能工具导入符合项目规范。
packages/kit/src/views/Developer/pages/TabDeveloper.tsx (2)
19-19
: 导入声明更新正确!
从 EAppSettingKey
切换到 EAppSyncStorageKeys
的更改符合数据库性能优化的目标。
31-36
: 请验证存储方法的一致性使用
存储访问方法已更新为使用 syncStorage
,但需要确保:
- 所有相关组件都已更新到新的存储机制
- 没有遗留的旧版存储调用
运行以下脚本来验证存储方法的使用:
✅ Verification successful
存储方法已完全迁移至新版本
代码检查结果显示:
- 所有存储操作均使用
syncStorage
API - 没有发现旧版
getSettingBoolean
或setSetting
的使用 EAppSyncStorageKeys
枚举类型被正确使用在所有相关组件中
存储方法的迁移工作已经完成,代码保持一致性。
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 描述:检查是否还有使用旧版存储方法的代码
# 测试:搜索可能遗留的旧版存储方法
rg "appStorage\.getSettingBoolean|appStorage\.setSetting"
# 测试:确认新版存储方法的使用
rg "syncStorage\.getBoolean|syncStorage\.set"
Length of output: 891
Script:
#!/bin/bash
# 检查是否存在旧版存储相关的类型定义和导入
rg "getSettingBoolean|setSetting" -t typescript
# 检查存储相关的类型定义
ast-grep --pattern 'interface $_ {
$$$
getSettingBoolean($_): $_
$$$
}'
# 检查 EAppSyncStorageKeys 的使用情况
rg "EAppSyncStorageKeys" -A 2
Length of output: 6473
packages/kit/src/views/Setting/pages/Notifications/ManageAccountActivity.tsx (2)
419-423
: 页面滚动功能增强
为 Page 组件添加 scrollEnabled 属性是个不错的改进,可以提升用户体验,特别是在内容较长时。
Line range hint 437-443
: 建议优化异步清理逻辑
在组件卸载时执行异步操作可能存在风险,建议确保异步操作能够正确完成。
建议修改为:
useEffect(
() => () => {
- void backgroundApiProxy.serviceNotification.registerClientWithOverrideAllAccounts();
+ const cleanup = async () => {
+ try {
+ await backgroundApiProxy.serviceNotification.registerClientWithOverrideAllAccounts();
+ } catch (error) {
+ console.error('Failed to register client:', error);
+ }
+ };
+ cleanup();
},
[],
);
packages/kit-bg/src/dbs/local/indexed/IndexedDBAgent.ts (1)
222-222
: 事务选项传递正确
readOnly
选项的传递实现正确,有助于优化只读操作的性能。
packages/kit-bg/src/services/ServiceToken.ts (2)
10-12
: 性能监控工具和类型定义的引入
引入 perfUtils 用于性能监控,以及新增数据库相关的类型定义,这些改动为性能优化奠定了基础。
Also applies to: 34-35
63-66
: 优化数据库查询性能
通过添加可选的 dbAccount 参数,避免重复查询数据库获取账户信息,这是一个很好的性能优化。
Also applies to: 72-72, 93-93
packages/kit/src/views/Setting/pages/List/DevSettingsSection/index.tsx (2)
35-38
: 新增的工具函数导入
导入了两个用于背景API序列化检查的工具函数,这些函数与性能优化相关。
254-267
: 🛠️ Refactor suggestion
建议优化开关组件的实现方式
当前实现存在以下几个需要注意的点:
- 使用了非受控组件模式,可能导致组件状态与全局状态不同步
- 自动重置功能(1天后重新开启)的实现细节不明确
建议改进实现方式:
<ListItem
title="Bg Api 可序列化检测"
subtitle="启用后会影响性能, 仅在开发环境生效, 关闭 1 天后重新开启"
>
<Switch
- isUncontrolled
size={ESwitchSize.small}
- defaultChecked={!isBgApiSerializableCheckingDisabled()}
+ value={!isBgApiSerializableCheckingDisabled()}
onChange={(v) => {
toggleBgApiSerializableChecking(v);
}}
/>
</ListItem>
packages/kit-bg/src/vaults/base/VaultBase.ts (2)
Line range hint 960-1045
: 优化:通过复用已获取的账户数据提升性能
代码变更通过添加可选的 dbAccount
参数来避免重复查询数据库,这是一个很好的性能优化。当提供的 dbAccount
与当前账户 ID 匹配时,直接使用该数据而不是重新查询数据库。
1061-1066
: LGTM:getAccountXpub 方法的参数更新
方法更新与 getAccount 保持一致,添加了 dbAccount 参数,实现简洁明了。
packages/kit-bg/src/services/ServiceAccount/ServiceAccount.ts (3)
Line range hint 1448-1501
: 优化数据库查询性能!
通过添加可选的 dbAccount
参数,避免了重复的数据库查询操作。当已经有账户数据时可以直接使用,提高了性能。
2100-2117
: 保持一致的性能优化!
与 getAccount
方法类似,添加了 dbAccount
参数来优化性能。代码结构清晰,处理逻辑合理。
2123-2134
: 统一的性能优化模式!
getAccountAddressForApi
方法也采用了相同的优化模式,添加 dbAccount
参数避免重复查询。处理逻辑完整,包括了对闪电网络的特殊处理。
packages/shared/src/storage/syncStorage.ts (1)
17-58
: 代码结构清晰,逻辑正确。
syncStorage
对象的方法实现合理,代码简洁易读。
packages/kit-bg/src/dbs/simple/entity/SimpleDbEntityLocalTokens.ts (4)
9-11
: 导入性能工具模块,逻辑正确
引入了 perfUtils
和 EPerformanceTimerLogNames
,用于性能测量,代码无误。
20-20
: 接口重命名,提升可读性
将接口 ILocalTokens
重命名为 ISimpleDBLocalTokens
,名称更加明确,符合命名规范。
29-29
: 更新类继承的泛型类型
类 SimpleDbEntityLocalTokens
现在继承自 SimpleDbEntityBase<ISimpleDBLocalTokens>
,与接口重命名保持一致。
194-199
: 新增可选参数以提高性能
getAccountTokenList
方法新增了可选参数 simpleDbLocalTokensRawData
,允许传入预取的数据,优化性能。
packages/kit/src/hooks/useAllNetwork.ts (1)
248-252
: 变量命名改进:'networkDataString' 更名为 'networkData'
同样,建议在此处将 'networkDataString' 重命名为 'networkData',以保持命名一致。
可以应用以下 diff:
- const { accountId, networkId, dbAccount } = networkDataString;
+ const { accountId, networkId, dbAccount } = networkData;
packages/kit-bg/src/services/ServiceAllNetwork/ServiceAllNetwork.ts (3)
10-10
: 正确地导入defaultLogger。
已添加defaultLogger的导入,为性能日志记录提供了支持。
13-15
: 引入perfUtils和EPerformanceTimerLogNames。
添加了perfUtils和EPerformanceTimerLogNames的导入,为性能监控提供了必要的工具。
28-28
: 在IAllNetworkAccountInfo中新增dbAccount属性。
添加了dbAccount
属性,丰富了账户信息的数据结构。
packages/kit-bg/src/services/ServiceAccountSelector.ts (2)
260-274
: 新增全网络判断,优化dbAccount获取逻辑。
增加了isAllNetwork
判断,在非全网络情况下获取dbAccount
,逻辑清晰明了。
Line range hint 325-354
: 全网络账户处理逻辑完善。
在isAllNetwork
为真时,正确获取了全网络的dbAccounts
,并根据情况构建模拟的网络账户,逻辑合理,结构清晰。
packages/kit/src/views/Home/pages/TokenListContainer.tsx (5)
16-20
: 新增类型导入,提升类型安全性。
新导入了IDBAccount
、IDBUtxoAccount
和ISimpleDBLocalTokens
类型,有助于提高代码的类型安全性。
41-43
: 引入性能工具以优化性能跟踪。
导入了perfUtils
和EPerformanceTimerLogNames
,用于在代码中添加性能监控。
581-587
: 新增参数以优化本地令牌数据处理。
handleAllNetworkCacheRequests
函数新增了可选参数simpleDbLocalTokensRawData
,有助于提高处理效率。
589-597
: 添加性能监控以跟踪函数执行。
在handleAllNetworkCacheRequests
函数中添加了性能监控代码,使用perfUtils
记录执行过程。
350-355
: 确保所有调用都已更新以匹配新的函数参数。
handleAllNetworkRequests
函数新增了可选参数dbAccount
和allNetworkDataInit
,请确认所有调用此函数的地方都已更新以使用新的参数。
运行以下脚本,验证所有调用是否已更新:
✅ Verification successful
函数调用已正确更新
代码检查显示 handleAllNetworkRequests
函数的所有调用都已正确更新:
- 在 TokenListContainer.tsx 中的调用已包含新增的
allNetworkDataInit
参数 - NFTListContainer.tsx 中使用的是另一个同名但参数不同的函数,不受影响
所有调用都符合新的函数签名要求,无需进一步修改。
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 查找所有对handleAllNetworkRequests的调用
rg 'handleAllNetworkRequests\(' -A 5
Length of output: 520
Script:
#!/bin/bash
# 查找handleAllNetworkRequests的定义和所有调用
ast-grep --pattern 'handleAllNetworkRequests = async ({ $$$' -l typescript
Length of output: 421
Script:
#!/bin/bash
# 搜索函数定义和调用,使用更简单的模式
rg "handleAllNetworkRequests" -B 5 -A 10
Length of output: 13169
packages/kit-bg/src/dbs/local/LocalDbBase.ts (7)
63-65
: 导入性能工具模块
成功地导入了性能工具perfUtils
和EPerformanceTimerLogNames
,用于性能监控。
800-822
: 在getIndexedAccount
方法中添加性能监控
正确地在getIndexedAccount
方法中添加了性能监控代码,能够有效跟踪方法的性能表现。
Line range hint 836-850
: 在getIndexedAccountByAccount
方法中添加性能监控
性能监控代码已成功集成,能够帮助分析getIndexedAccountByAccount
方法的性能。
2557-2561
: 传递walletAccountsIndex
参数
在调用refillAccountInfo
方法时,正确传递了walletAccountsIndex
参数,增强了方法的灵活性。
2593-2623
: 在getAccount
方法中添加性能监控
性能监控代码已正确添加,有助于跟踪getAccount
方法的性能。
2640-2646
: 更新refillAccountInfo
方法的参数
为refillAccountInfo
方法添加了walletAccountsIndex
可选参数,提高了方法的通用性。
2659-2662
: 同步账户名称与indexedAccount
当提供indexedAccount
时,账户名称将同步更新,确保数据一致性。
packages/shared/src/logger/scopes/account/scenes/allNetworkAccountPerf.ts
Show resolved
Hide resolved
packages/shared/src/logger/scopes/account/scenes/allNetworkAccountPerf.ts
Show resolved
Hide resolved
packages/shared/src/logger/scopes/account/scenes/allNetworkAccountPerf.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (2)
packages/kit-bg/src/services/ServiceAccount/ServiceAccount.ts
(5 hunks)packages/kit/src/views/Setting/pages/Notifications/ManageAccountActivity.tsx
(1 hunks)
🔇 Additional comments (4)
packages/kit/src/views/Setting/pages/Notifications/ManageAccountActivity.tsx (1)
422-422
: 添加滚动支持,提升用户体验
为 Page 组件启用滚动功能是个不错的改进。考虑到钱包列表可能很长,这样可以确保用户能访问到所有内容。
建议在不同尺寸的屏幕上验证滚动行为:
packages/kit-bg/src/services/ServiceAccount/ServiceAccount.ts (3)
1453-1457
: 优化了账户数据获取逻辑
通过添加可选的 dbAccount
参数,避免了重复的数据库查询,提高了性能。代码复用性良好,参数验证完整。
Also applies to: 1469-1474, 1483-1483
2105-2122
: 优化了 xpub 获取逻辑
通过传入 dbAccount 参数优化了性能,避免重复查询。代码结构清晰简洁。
2128-2139
: 优化了 API 地址获取逻辑
重用已有账户数据提升了性能,保持了原有功能的同时改进了实现。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range comments (4)
packages/kit-bg/src/dbs/simple/entity/SimpleDbEntityLocalTokens.ts (2)
Line range hint
9-20
: 性能监控工具集成和接口重命名接口重命名为
ISimpleDBLocalTokens
更好地反映了其上下文,提高了代码可读性。但是需要注意perfUtils
的类型定义问题,建议添加适当的类型声明以解决静态分析工具报告的类型安全问题。建议在项目中添加 perfUtils 的类型定义文件:
// types/perfUtils.d.ts export interface IPerf { markStart: (label: string, data?: Record<string, unknown>) => void; markEnd: (label: string) => void; done: () => void; } declare const perfUtils: { createPerf: (name: string, data?: Record<string, unknown>) => IPerf; }; export default perfUtils;
Line range hint
148-186
: 建议优化性能计时器的错误处理当前实现在异常情况下可能导致性能计时器未正确关闭。建议使用 try-finally 结构确保
perf.done()
总是被调用。建议按如下方式修改:
const perf = perfUtils.createPerf( EPerformanceTimerLogNames.simpleDB__updateAccountTokenList, { networkId, accountAddress, xpub, }, ); + try { perf.markStart('buildAccountLocalAssetsKey'); const key = buildAccountLocalAssetsKey({ networkId, accountAddress, xpub }); perf.markEnd('buildAccountLocalAssetsKey'); perf.markStart('setRawData'); await this.setRawData(({ rawData }) => ({ // ... existing code ... })); perf.markEnd('setRawData'); + } finally { perf.done(); + }🧰 Tools
🪛 eslint
[error] 145-145: Unsafe construction of an any type value.
(@typescript-eslint/no-unsafe-call)
[error] 148-148: Unsafe member access .createPerf on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 148-148: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
[error] 149-149: Unsafe member access .simpleDB__updateAccountTokenList on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 157-157: Unsafe member access .markStart on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 157-157: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
[error] 158-158: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
[error] 159-159: Unsafe member access .markEnd on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 159-159: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
[error] 161-161: Unsafe member access .markStart on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 161-161: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
packages/kit-bg/src/services/ServiceToken.ts (2)
Line range hint
77-107
: 建议添加参数说明文档新增的 dbAccount 参数有助于减少数据库查询,提升性能。建议添加以下文档说明:
+ /** + * @param dbAccount 可选的数据库账户对象,用于避免重复查询 + * @param accountId 账户ID + * @param networkId 网络ID + */Also applies to: 475-504
🧰 Tools
🪛 eslint
[error] 75-75: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
Line range hint
527-600
: 需要改进类型安全性perfUtils 的使用存在类型安全问题,建议:
- const perf = perfUtils.createPerf( + const perf: IPerfUtils = perfUtils.createPerf(同时确保 perfUtils 导出正确的类型定义。
🧰 Tools
🪛 eslint
[error] 551-551: Unsafe member access .markEnd on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 551-551: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
[error] 554-554: Unsafe member access .markStart on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 554-554: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
[error] 566-566: Unsafe member access .markEnd on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 566-566: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (2)
packages/kit-bg/src/dbs/simple/entity/SimpleDbEntityLocalTokens.ts
(6 hunks)packages/kit-bg/src/services/ServiceToken.ts
(13 hunks)
🧰 Additional context used
🪛 eslint
packages/kit-bg/src/dbs/simple/entity/SimpleDbEntityLocalTokens.ts
[error] 148-148: Unsafe member access .createPerf on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 148-148: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 149-149: Unsafe member access .simpleDB__updateAccountTokenList on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 157-157: Unsafe member access .markStart on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 157-157: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 158-158: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 159-159: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 159-159: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 161-161: Unsafe member access .markStart on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 161-161: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 185-185: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 185-185: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 186-186: Unsafe member access .done on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 186-186: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 235-235: Unsafe construction of an any type value.
(@typescript-eslint/no-unsafe-call)
[error] 237-237: Unsafe member access .createPerf on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 237-237: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 238-238: Unsafe member access .simpleDB__getAccountTokenList on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 246-246: Unsafe member access .markStart on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 246-246: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 247-247: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 248-248: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 248-248: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 250-250: Unsafe member access .markStart on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 250-250: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 256-256: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 256-256: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 259-259: Computed name [key] resolves to an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 260-260: Computed name [key] resolves to an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 261-261: Computed name [key] resolves to an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 262-262: Computed name [key] resolves to an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 263-263: Computed name [key] resolves to an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 266-266: Unsafe member access .done on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 266-266: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
packages/kit-bg/src/services/ServiceToken.ts
[error] 527-527: Unsafe member access .createPerf on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 527-527: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 528-528: Unsafe member access .allNetwork__getAccountLocalTokens on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 540-540: Unsafe member access .markStart on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 540-540: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 551-551: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 551-551: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 554-554: Unsafe member access .markStart on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 554-554: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 566-566: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 566-566: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 579-579: Unsafe member access .markStart on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 579-579: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 597-597: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 597-597: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 600-600: Unsafe member access .done on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 600-600: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
🔇 Additional comments (2)
packages/kit-bg/src/services/ServiceToken.ts (2)
Line range hint 10-35
: 性能监控工具集成完成!
引入 perfUtils 和相关类型定义的改动很合理,为性能监控提供了基础支持。
Line range hint 527-600
: 性能监控点设置合理
性能监控覆盖了关键操作:
- 账户信息获取
- 代币列表获取
- 数据映射转换
监控粒度适中,能够有效定位性能瓶颈。
🧰 Tools
🪛 eslint
[error] 551-551: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 551-551: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 554-554: Unsafe member access .markStart on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 554-554: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 566-566: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 566-566: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range comments (4)
packages/kit/src/views/Setting/pages/Notifications/ManageAccountActivity.tsx (3)
Line range hint
479-484
: 建议改进 Promise 处理方式当前使用 void 操作符处理 Promise 可能会忽略潜在的错误。建议添加错误处理逻辑。
useEffect( () => () => { - void backgroundApiProxy.serviceNotification.registerClientWithOverrideAllAccounts(); + backgroundApiProxy.serviceNotification + .registerClientWithOverrideAllAccounts() + .catch((error) => { + console.error('注册客户端失败:', error); + }); }, [], );🧰 Tools
🪛 eslint
[error] 426-426: Unsafe member access .formatMessage on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 426-426: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
[error] 426-426: Unsafe member access .global_manage on an
any
value.(@typescript-eslint/no-unsafe-member-access)
Line range hint
441-458
: 建议优化性能考虑使用 useMemo 来缓存 wallets 数组的渲染结果,特别是在处理大量钱包数据时,这可以避免不必要的重渲染。
+ const walletList = useMemo(() => ( + wallets.map((wallet, index) => ( + <YStack + key={wallet.id} + {...(index !== 0 && { + borderTopWidth: StyleSheet.hairlineWidth, + borderTopColor: '$borderSubdued', + })} + > + <AccordionItem + wallet={wallet} + onWalletEnabledChange={onWalletEnabledChange} + /> + {wallet.hiddenWallets?.map((hiddenWallet) => ( + <AccordionItem + key={hiddenWallet.id} + wallet={hiddenWallet} + onWalletEnabledChange={onWalletEnabledChange} + /> + ))} + </YStack> + )) + ), [wallets, onWalletEnabledChange]);🧰 Tools
🪛 eslint
[error] 426-426: Unsafe member access .formatMessage on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 426-426: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
[error] 426-426: Unsafe member access .global_manage on an
any
value.(@typescript-eslint/no-unsafe-member-access)
Line range hint
82-91
: 需要添加错误处理异步操作缺少错误处理机制,这可能导致运行时错误无法被捕获和处理。
useEffect(() => { void (async () => { + try { const savedSettings = await backgroundApiProxy.simpleDb.notificationSettings.getRawData(); if (savedSettings) { setSettings(savedSettings.accountActivity); } + } catch (error) { + console.error('获取通知设置失败:', error); + // 考虑添加用户提示或降级处理 + } })(); }, []);🧰 Tools
🪛 eslint
[error] 426-426: Unsafe member access .formatMessage on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 426-426: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
[error] 426-426: Unsafe member access .global_manage on an
any
value.(@typescript-eslint/no-unsafe-member-access)
packages/kit-bg/src/services/ServiceToken.ts (1)
Line range hint
528-601
: 需要改进类型安全性性能监控实现需要解决类型安全问题:
- const perf = perfUtils.createPerf( + const perf: IPerfUtils = perfUtils.createPerf( EPerformanceTimerLogNames.allNetwork__getAccountLocalTokens, );建议:
- 为 perfUtils 添加适当的类型定义
- 确保所有性能监控方法调用都有正确的类型标注
🧰 Tools
🪛 eslint
[error] 552-552: Unsafe member access .markEnd on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 552-552: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
[error] 555-555: Unsafe member access .markStart on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 555-555: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
[error] 567-567: Unsafe member access .markEnd on an
any
value.(@typescript-eslint/no-unsafe-member-access)
[error] 567-567: Unsafe call of an
any
typed value.(@typescript-eslint/no-unsafe-call)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (2)
packages/kit-bg/src/services/ServiceToken.ts
(13 hunks)packages/kit/src/views/Setting/pages/Notifications/ManageAccountActivity.tsx
(1 hunks)
🧰 Additional context used
🪛 eslint
packages/kit-bg/src/services/ServiceToken.ts
[error] 528-528: Unsafe member access .createPerf on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 528-528: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 529-529: Unsafe member access .allNetwork__getAccountLocalTokens on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 541-541: Unsafe member access .markStart on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 541-541: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 552-552: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 552-552: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 555-555: Unsafe member access .markStart on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 555-555: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 567-567: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 567-567: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 580-580: Unsafe member access .markStart on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 580-580: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 598-598: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 598-598: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 601-601: Unsafe member access .done on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 601-601: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
🔇 Additional comments (2)
packages/kit/src/views/Setting/pages/Notifications/ManageAccountActivity.tsx (1)
428-428
: 滚动功能已正确启用!
为 Page 组件添加 scrollEnabled 属性是个好的改动,可以确保内容溢出时用户体验不受影响。
packages/kit-bg/src/services/ServiceToken.ts (1)
11-13
: 性能监控工具导入和类型定义更新
导入性能监控工具和新增类型定义的改动合理,为后续的性能优化提供了基础。
Also applies to: 35-37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (1)
packages/kit/src/views/Home/pages/TokenListContainer.tsx
(5 hunks)
🧰 Additional context used
🪛 eslint
packages/kit/src/views/Home/pages/TokenListContainer.tsx
[error] 358-358: Unsafe member access .serviceToken on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 358-358: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 589-589: Unsafe member access .createPerf on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 589-589: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 590-590: Unsafe member access .allNetwork__handleAllNetworkCacheRequests on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 593-593: Unsafe member access .markStart on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 593-593: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 599-599: Unsafe member access .serviceToken on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 599-599: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 606-606: Unsafe member access .markEnd on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 606-606: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
[error] 610-610: Unsafe member access .done on an any
value.
(@typescript-eslint/no-unsafe-member-access)
[error] 610-610: Unsafe call of an any
typed value.
(@typescript-eslint/no-unsafe-call)
🔇 Additional comments (5)
packages/kit/src/views/Home/pages/TokenListContainer.tsx (5)
16-19
: 引入新的类型定义以增强类型安全性。
导入IDBAccount
和IDBUtxoAccount
类型,提高了代码的类型检查和可靠性。
350-355
: 添加可选参数以增强函数灵活性。
新增dbAccount
和allNetworkDataInit
可选参数,使函数更具扩展性,满足不同场景的需求。
359-359
: 传递dbAccount
参数以支持新的功能。
在调用fetchAccountTokens
时增加dbAccount
参数,确保新添加的可选参数被正确地使用。
581-587
: 为函数添加新的可选参数simpleDbLocalTokensRawData
。
增加simpleDbLocalTokensRawData
参数,允许函数在需要时接收本地令牌数据,提升性能和灵活性。
1290-1290
: 删除注释的测试代码以保持代码整洁。
注释掉的<TokenListContainerPerfTest>
组件可能已不再需要,建议删除以提高代码可读性。
Summary by CodeRabbit
发布说明
新功能
isUncontrolled
属性,允许无控制状态的操作。dbAccount
参数,以优化账户信息的检索。改进
ManageAccountActivity
组件的滚动行为和通知管理。文档