Skip to content

monaca分块 ref懒加载(部分) - #4072

Open
hjhke wants to merge 9 commits into
masterfrom
hejiahui/fix/monaco-0729
Open

monaca分块 ref懒加载(部分)#4072
hjhke wants to merge 9 commits into
masterfrom
hejiahui/fix/monaco-0729

Conversation

@hjhke

@hjhke hjhke commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

第二个合并方式

@github-actions

Copy link
Copy Markdown
Contributor

PR CI 汇总

状态:全部通过

  • ✅ i18n(renderer src/main zh/zh-TW/en)
  • ✅ i18n(engine-link zh/zh-TW/en)
  • ✅ ESLint(renderer src/main)
  • ✅ TypeScript(renderer src/main)
  • ✅ ESLint(engine-link-startup)
  • ✅ TypeScript(engine-link-startup)
  • ✅ 图片/视频体积
  • ○ Vitest(main / renderer / engine-link;test 同目录·别名·相对路径)(skipped)
  • ✅ Prettier

由 pull_request test workflow 自动生成

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.tsx responsibilities into hooks/modules (binary fold, plugin search, Yak format/static analyze, decorations generation, menu helpers).
  • Move getAllRows to CustomizeCodeTypes.ts for 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 current item, 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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants