观察器启停时机迁入 (fix #328) - #357
Merged
Merged
Conversation
增量补翻观察器的启停时机此前在内容脚本。迁入状态机:只在整页 翻译成功后启动恰好一次、还原时停止、失败与在飞还原不启动; 启停经注入钩子表达,沿用生命周期注册表幂等语义。 Co-Authored-By: zhexuancai-uts <261878103+zhexuancai-uts@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
增量补翻观察器的启停时机(翻译成功后启动、还原时停止、中止不启动)散落在内容脚本,未翻译状态下 SPA 可能自己冒出译文。
根因
启停时机决策没有迁入状态机。
修复
观察器启停迁入编排模块开关入口:整页翻译成功后启动恰好一次、还原时停止、失败与在飞还原不启动;启停经注入钩子(
onObserverStart/onObserverStop)表达,调用方接线到生命周期注册表,沿用其幂等启停语义。验证
pnpm typecheck通过;新增 6 个启停时机单测(未触发不启动、成功启动一次、失败不启动、在飞还原不启动、重复还原停止幂等、完整周期启停各一次),pnpm test641 个用例全部通过;pnpm build正常。Closes #328