Skip to content
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

feat: 组件二等分 #3965

Merged
merged 4 commits into from
Feb 21, 2023
Merged

Conversation

LonelySteve
Copy link
Contributor

@LonelySteve LonelySteve commented Feb 4, 2023

和 vscode 的「扩展二等分」功能类似,可帮助开发人员定位是哪个组件导致的问题。

idea 来自:#3829

目前支持两种方式唤起二等分操作:

  • 通过 launchBar(搜索栏),输入「二等分」
  • 通过 componentApis API,在控制台中调用 bilibiliEvolved.componentApis.bisectComponent 方法

API 方式可指定需要固定启用或禁用状态的组件,以便进一步缩小范围。例如,下面的调用方式表示在始终启用「记忆倍速」和「扩展倍速」组件的情况下,对其他组件进行二等分:

const bisector = await bilibiliEvolved.componentApis.bisectComponent({keepEnabledComponents: ["extendVideoSpeed", "rememberVideoSpeed"]})
bisector.start()

演示效果

2.webm
default.webm

@LonelySteve LonelySteve marked this pull request as ready for review February 5, 2023 08:00
@FoundTheWOUT
Copy link
Contributor

大佬,组件二分可以确定两个组件之间的冲突吗,如果可以是怎么做到的(纯好奇
按我的理解应该是只能判断当前加载的组件和已经加载了的组件是否发生了冲突吧🤔

@LonelySteve
Copy link
Contributor Author

LonelySteve commented Feb 13, 2023

@FoundTheWOUT 如果你怀疑某个组件会和其他组件冲突,那就可以用组件二等分的功能去排查,通过 API 的方式可以指定始终保持开启或关闭的组件(这些组件虽然不参与二等分过程,但对于复现冲突起着决定性的作用)。

就以「记忆倍速」和「扩展倍速」这两个组件为例,如果你发现这两个组件工作不正常,但如果仅开启这两个组件又是正常的,那么就可以采用组件二等分排查冲突,将「记忆倍速」和「扩展倍速」设置为始终保持开启的组件:

const bisector = await bilibiliEvolved.componentApis.bisectComponent({keepEnabledComponents: ["extendVideoSpeed", "rememberVideoSpeed"]})
bisector.start()

下面这个图可以帮你理解一下二等分的工作过程:

二等分的工作示意图

其实我想给 bisectComponent API 加个 UI 来着,如果可以通过 UI 指定哪些组件保持开启,哪些组件保持关闭,那样会更直观方便,目前版本的组件二等分可能只有开发人员会关注和使用。

src/components/bisector/bisect.ts Outdated Show resolved Hide resolved
src/core/utils/index.ts Outdated Show resolved Hide resolved
src/components/bisector/index.ts Outdated Show resolved Hide resolved
src/components/bisector/DialogContent.vue Show resolved Hide resolved
@the1812 the1812 merged commit cb3e1fd into the1812:preview-features Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants