monaca分块 ref懒加载(部分) - #4072
Open
hjhke wants to merge 9 commits into
Open
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
PR CI 汇总状态:全部通过
由 pull_request test workflow 自动生成 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Monaco-based YakitEditor by splitting large in-file logic into smaller modules/hooks and moving shared helpers (menus, decorations, formatting, plugin search, binary fold) into dedicated files. It also adjusts Monaco completion code to import getAllRows from a UI-decoupled types module and removes unused imports.
Changes:
- Split
YakitEditor.tsxresponsibilities into hooks/modules (binary fold, plugin search, Yak format/static analyze, decorations generation, menu helpers). - Move
getAllRowstoCustomizeCodeTypes.tsfor lighter-weight reuse from Monaco spec utilities. - Minor cleanup: remove unused imports and adjust some performance-sensitive paths (e.g., highlight fingerprinting, versionId checks).
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| app/renderer/src/main/src/utils/monacoSpec/yakEditor.ts | Removes unused import from Monaco spec utilities. |
| app/renderer/src/main/src/utils/monacoSpec/yakCompletionSchema.ts | Updates getAllRows import source for snippet completion. |
| app/renderer/src/main/src/utils/monacoSpec/fuzzHTTPMonacoSpec.ts | Updates getAllRows import source for HTTP header suggestions. |
| app/renderer/src/main/src/components/yakitUI/YakitEditor/YakitEditor.tsx | Major refactor: delegates to new helpers/hooks; improves cleanup for some disposables; adds perf optimizations. |
| app/renderer/src/main/src/components/yakitUI/YakitEditor/menus/menuHelpers.tsx | New shared menu helpers (dedupe/sort/keybinding rendering). |
| app/renderer/src/main/src/components/yakitUI/YakitEditor/hooks/useYakFormat.ts | New hook for Yak format + static analysis integration. |
| app/renderer/src/main/src/components/yakitUI/YakitEditor/hooks/usePluginSearch.ts | New hook encapsulating plugin menu fetching logic. |
| app/renderer/src/main/src/components/yakitUI/YakitEditor/hooks/useBinaryFold.ts | New hook encapsulating binary fuzztag fold/unfold state and translation. |
| app/renderer/src/main/src/components/yakitUI/YakitEditor/fizzMenu/editerMenuFun.tsx | New module extracting click/selection floating menu behavior. |
| app/renderer/src/main/src/components/yakitUI/YakitEditor/decorations/generateDecorations.ts | New module extracting decoration generation logic. |
| app/renderer/src/main/src/components/yakitUI/YakitEditor/constants/index.ts | New constants/types module extracted from YakitEditor.tsx. |
| app/renderer/src/main/src/components/configNetwork/CustomizeCodeTypes.ts | Adds getAllRows utility to decouple Monaco usage from UI component file. |
| app/renderer/src/main/src/components/configNetwork/CustomizeCode.tsx | Removes local getAllRows implementation; imports from types module instead. |
Suppressed comments (1)
app/renderer/src/main/src/components/yakitUI/YakitEditor/menus/menuHelpers.tsx:65
- Divider detection is checking
data['type'](the whole array) instead of the currentitem, so the divider branch will never run and divider items won’t be handled as intended.
/** 屏蔽菜单分割线选项 */
if (typeof (data as any as EditorMenuItemDividerProps)['type'] !== 'undefined') {
const info: EditorMenuItemDividerProps = { type: 'divider' }
menus.push(info)
Comment on lines
+55
to
+56
| t: TFunction, | ||
| keyBindingRef: React.MutableRefObject<KeyboardToFuncProps>, |
Comment on lines
+3
to
+7
| import { queryYakScriptList } from '@/pages/yakitStore/network' | ||
| import { YakScript } from '@/pages/invoker/schema' | ||
| import { failed } from '@/utils/notification' | ||
| import emiter from '@/utils/eventBus/eventBus' | ||
| import { useStore } from '@/store/editorState' |
| searchCodecCustomHTTPMutatePlugin() | ||
| searchCodecCustomContextMenuPlugin() | ||
| } | ||
| }, [inViewport]) |
| yakStaticAnalyze: { | ||
| run: (editor: YakitIMonacoEditor, model: YakitITextModel) => void | ||
| } | ||
| AnalyzeSessionIDRef: React.MutableRefObject<string> |
Comment on lines
+18
to
+20
| binaryFoldEntriesRef: React.MutableRefObject<Map<string, BinaryFuzztagEntry>> | ||
| binaryFoldRangesRef: React.MutableRefObject<{ id: string; range: monaco.Range; ordinal: number }[]> | ||
| binaryModifiedOrdinalsRef: React.MutableRefObject<Set<number>> |
Comment on lines
+30
to
+32
| binaryFoldEntriesRef: React.MutableRefObject<Map<string, BinaryFuzztagEntry>> | ||
| binaryFoldRangesRef: React.MutableRefObject<{ id: string; range: monaco.Range; ordinal: number }[]> | ||
| binaryModifiedOrdinalsRef: React.MutableRefObject<Set<number>> |
Comment on lines
1197
to
+1201
| useEffect(() => { | ||
| if (editor && isShowSelectRangeMenu) { | ||
| editerMenuFun(editor) | ||
| editerMenuFun({ | ||
| editor, | ||
| selectNode, |
Comment on lines
+45
to
+48
| export const getAllRows = <T extends Record<string, any[]>>(data: T): RowOf<T>[] => { | ||
| const keys = Object.keys(data) as (keyof T)[] | ||
| const length = Math.max(...keys.map((k) => data[k].length)) | ||
|
|
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.
第二个合并方式