@bovinphang/frontend-craft 2.7.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +34 -0
- package/CHANGELOG.zh-CN.md +34 -0
- package/README.md +1 -1
- package/README.openclaw.md +99 -43
- package/README.openclaw.zh-CN.md +99 -43
- package/README.zh-CN.md +1 -1
- package/agents/fec-architect.md +70 -70
- package/agents/fec-code-reviewer.md +82 -82
- package/agents/fec-debugger.md +20 -20
- package/agents/fec-design-token-mapper.md +36 -36
- package/agents/fec-doc-updater.md +13 -13
- package/agents/fec-e2e-runner.md +45 -45
- package/agents/fec-figma-implementer.md +59 -59
- package/agents/fec-performance-optimizer.md +128 -128
- package/agents/fec-refactor-cleaner.md +14 -14
- package/agents/fec-security-reviewer.md +66 -67
- package/agents/fec-test-planner.md +27 -27
- package/agents/fec-typescript-reviewer.md +87 -87
- package/agents/fec-ui-checker.md +74 -74
- package/commands/fec-debug.md +19 -19
- package/commands/fec-doc-sync.md +11 -11
- package/commands/fec-init.md +37 -38
- package/commands/fec-plan.md +58 -58
- package/commands/fec-refactor-clean.md +11 -11
- package/commands/fec-review.md +41 -41
- package/commands/fec-scaffold.md +41 -41
- package/commands/fec-tdd.md +13 -13
- package/dist/bin/frontend-craft.js +29 -27
- package/docs/example-prompts.md +3 -0
- package/docs/ja-JP/README.md +1 -1
- package/docs/ko-KR/README.md +1 -1
- package/docs/project-structure.md +13 -5
- package/docs/zh-CN/example-prompts.md +3 -0
- package/docs/zh-CN/project-structure.md +6 -1
- package/docs/zh-TW/README.md +1 -1
- package/localized/zh-CN/agents/fec-architect.md +125 -0
- package/localized/zh-CN/agents/fec-code-reviewer.md +152 -0
- package/localized/zh-CN/agents/fec-debugger.md +44 -0
- package/localized/zh-CN/agents/fec-design-token-mapper.md +75 -0
- package/localized/zh-CN/agents/fec-doc-updater.md +30 -0
- package/localized/zh-CN/agents/fec-e2e-runner.md +107 -0
- package/localized/zh-CN/agents/fec-figma-implementer.md +104 -0
- package/localized/zh-CN/agents/fec-performance-optimizer.md +293 -0
- package/localized/zh-CN/agents/fec-refactor-cleaner.md +32 -0
- package/localized/zh-CN/agents/fec-security-reviewer.md +116 -0
- package/localized/zh-CN/agents/fec-test-planner.md +50 -0
- package/localized/zh-CN/agents/fec-typescript-reviewer.md +142 -0
- package/localized/zh-CN/agents/fec-ui-checker.md +120 -0
- package/localized/zh-CN/commands/fec-debug.md +30 -0
- package/localized/zh-CN/commands/fec-doc-sync.md +19 -0
- package/localized/zh-CN/commands/fec-init.md +70 -0
- package/localized/zh-CN/commands/fec-plan.md +94 -0
- package/localized/zh-CN/commands/fec-refactor-clean.md +19 -0
- package/localized/zh-CN/commands/fec-review.md +66 -0
- package/localized/zh-CN/commands/fec-scaffold.md +205 -0
- package/localized/zh-CN/commands/fec-tdd.md +21 -0
- package/localized/zh-CN/skills/TEMPLATE.md +155 -0
- package/localized/zh-CN/skills/eval_queries.json +1013 -0
- package/localized/zh-CN/skills/fec-accessibility-check/SKILL.md +39 -0
- package/localized/zh-CN/skills/fec-accessibility-check/references/report-template.md +23 -0
- package/localized/zh-CN/skills/fec-accessibility-check/references/screen-reader-testing.md +33 -0
- package/localized/zh-CN/skills/fec-alchemy/SKILL.md +74 -0
- package/localized/zh-CN/skills/fec-alchemy/assets/absorption-plan-template.md +47 -0
- package/localized/zh-CN/skills/fec-alchemy/assets/intake-template.md +55 -0
- package/localized/zh-CN/skills/fec-alchemy/assets/review-checklist.md +31 -0
- package/localized/zh-CN/skills/fec-alchemy/references/methodology.md +94 -0
- package/localized/zh-CN/skills/fec-alchemy/references/originality-and-licensing.md +57 -0
- package/localized/zh-CN/skills/fec-api-integration/SKILL.md +78 -0
- package/localized/zh-CN/skills/fec-api-integration/references/integration-patterns.md +80 -0
- package/localized/zh-CN/skills/fec-backend-requirements-handoff/SKILL.md +45 -0
- package/localized/zh-CN/skills/fec-browser-storage/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-browser-storage/references/storage-patterns.md +65 -0
- package/localized/zh-CN/skills/fec-canvas-threejs/SKILL.md +66 -0
- package/localized/zh-CN/skills/fec-canvas-threejs/references/rendering-patterns.md +67 -0
- package/localized/zh-CN/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +67 -0
- package/localized/zh-CN/skills/fec-code-review/SKILL.md +143 -0
- package/localized/zh-CN/skills/fec-code-review/references/report-template.md +29 -0
- package/localized/zh-CN/skills/fec-component-testing/SKILL.md +119 -0
- package/localized/zh-CN/skills/fec-data-fetching/SKILL.md +62 -0
- package/localized/zh-CN/skills/fec-data-fetching/references/query-patterns.md +103 -0
- package/localized/zh-CN/skills/fec-debug-framework/SKILL.md +157 -0
- package/localized/zh-CN/skills/fec-debug-framework/references/report-template.md +58 -0
- package/localized/zh-CN/skills/fec-dependency-upgrade/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +56 -0
- package/localized/zh-CN/skills/fec-doc-sync/SKILL.md +39 -0
- package/localized/zh-CN/skills/fec-drawio-studio/SKILL.md +73 -0
- package/localized/zh-CN/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
- package/localized/zh-CN/skills/fec-drawio-studio/data/brand-icons.json +878 -0
- package/localized/zh-CN/skills/fec-drawio-studio/data/shape-index.json +83570 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/data-residency.md +27 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/diagram-patterns.md +60 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/layout-and-export.md +72 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/troubleshooting.md +29 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/xml-and-mermaid.md +58 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/brand-symbols.mjs +99 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-lint.mjs +205 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-url.mjs +102 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/layout-graph.mjs +107 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/png-embed-fix.mjs +26 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-go-packages.mjs +36 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-js-modules.mjs +52 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-classes.mjs +30 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-modules.mjs +55 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/shape-query.mjs +121 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/studio-core.mjs +139 -0
- package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/corporate.json +49 -0
- package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/default.json +49 -0
- package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/handdrawn.json +49 -0
- package/localized/zh-CN/skills/fec-drawio-studio/styles/schema.json +112 -0
- package/localized/zh-CN/skills/fec-e2e-testing/SKILL.md +42 -0
- package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-ci-reporting.md +62 -0
- package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-special-scenarios.md +52 -0
- package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-visual-regression.md +60 -0
- package/localized/zh-CN/skills/fec-e2e-testing/references/playwright-patterns.md +95 -0
- package/localized/zh-CN/skills/fec-form-handling/SKILL.md +76 -0
- package/localized/zh-CN/skills/fec-form-handling/references/advanced-form-patterns.md +101 -0
- package/localized/zh-CN/skills/fec-image-generation/SKILL.md +80 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
- package/localized/zh-CN/skills/fec-image-generation/references/artifact-routing.md +80 -0
- package/localized/zh-CN/skills/fec-image-generation/references/diagram-workflows.md +74 -0
- package/localized/zh-CN/skills/fec-image-generation/references/html-technical-diagrams.md +236 -0
- package/localized/zh-CN/skills/fec-image-generation/references/png-qa-autofix.md +30 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/export-diagram.mjs +364 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/png-qa.mjs +431 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1397 -0
- package/localized/zh-CN/skills/fec-implement-from-design/SKILL.md +129 -0
- package/localized/zh-CN/skills/fec-implement-from-design/references/design-plan-template.md +36 -0
- package/localized/zh-CN/skills/fec-legacy-to-modern-migration/SKILL.md +46 -0
- package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +110 -0
- package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +41 -0
- package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +48 -0
- package/localized/zh-CN/skills/fec-legacy-web-standard/SKILL.md +35 -0
- package/localized/zh-CN/skills/fec-legacy-web-standard/references/legacy-patterns.md +85 -0
- package/localized/zh-CN/skills/fec-list-virtualization/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-list-virtualization/references/virtualization-patterns.md +80 -0
- package/localized/zh-CN/skills/fec-monorepo-project-standard/SKILL.md +142 -0
- package/localized/zh-CN/skills/fec-motion-interaction/SKILL.md +73 -0
- package/localized/zh-CN/skills/fec-motion-interaction/references/motion-patterns.md +112 -0
- package/localized/zh-CN/skills/fec-nextjs-project-standard/SKILL.md +123 -0
- package/localized/zh-CN/skills/fec-nuxt-project-standard/SKILL.md +122 -0
- package/localized/zh-CN/skills/fec-performance-optimization/SKILL.md +80 -0
- package/localized/zh-CN/skills/fec-performance-optimization/references/framework-performance-patterns.md +38 -0
- package/localized/zh-CN/skills/fec-performance-optimization/references/report-template.md +59 -0
- package/localized/zh-CN/skills/fec-pwa-implementation/SKILL.md +35 -0
- package/localized/zh-CN/skills/fec-pwa-implementation/references/manifest-and-icons.md +53 -0
- package/localized/zh-CN/skills/fec-pwa-implementation/references/service-worker-workbox.md +68 -0
- package/localized/zh-CN/skills/fec-react-project-standard/SKILL.md +91 -0
- package/localized/zh-CN/skills/fec-react-project-standard/references/react-performance-patterns.md +35 -0
- package/localized/zh-CN/skills/fec-react-project-standard/references/react-project-structure.md +197 -0
- package/localized/zh-CN/skills/fec-react-project-standard/references/react-quality-patterns.md +131 -0
- package/localized/zh-CN/skills/fec-react-project-standard/references/react-runtime-patterns.md +293 -0
- package/localized/zh-CN/skills/fec-refactor-clean/SKILL.md +51 -0
- package/localized/zh-CN/skills/fec-refactor-clean/references/report-template.md +42 -0
- package/localized/zh-CN/skills/fec-responsive-layout/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-responsive-layout/references/responsive-layout-patterns.md +70 -0
- package/localized/zh-CN/skills/fec-route-protection/SKILL.md +135 -0
- package/localized/zh-CN/skills/fec-security-review/SKILL.md +38 -0
- package/localized/zh-CN/skills/fec-security-review/references/report-template.md +27 -0
- package/localized/zh-CN/skills/fec-security-review/references/security-checklist.md +64 -0
- package/localized/zh-CN/skills/fec-source-driven-development/SKILL.md +87 -0
- package/localized/zh-CN/skills/fec-state-management/SKILL.md +140 -0
- package/localized/zh-CN/skills/fec-state-management/references/state-patterns.md +109 -0
- package/localized/zh-CN/skills/fec-storybook-component-doc/SKILL.md +37 -0
- package/localized/zh-CN/skills/fec-storybook-component-doc/references/story-patterns.md +118 -0
- package/localized/zh-CN/skills/fec-svg-animation/SKILL.md +148 -0
- package/localized/zh-CN/skills/fec-tailwind-design-system/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +59 -0
- package/localized/zh-CN/skills/fec-tdd-workflow/SKILL.md +52 -0
- package/localized/zh-CN/skills/fec-testing-strategy/SKILL.md +45 -0
- package/localized/zh-CN/skills/fec-typescript-project-standard/SKILL.md +54 -0
- package/localized/zh-CN/skills/fec-typescript-project-standard/references/type-safety-patterns.md +102 -0
- package/localized/zh-CN/skills/fec-typescript-project-standard/references/type-safety.md +148 -0
- package/localized/zh-CN/skills/fec-ui-design/SKILL.md +108 -0
- package/localized/zh-CN/skills/fec-ui-design/data/product-rules.json +231 -0
- package/localized/zh-CN/skills/fec-ui-design/data/stack-ui-rules.json +146 -0
- package/localized/zh-CN/skills/fec-ui-design/data/style-archetypes.json +373 -0
- package/localized/zh-CN/skills/fec-ui-design/data/ux-quality-rules.json +203 -0
- package/localized/zh-CN/skills/fec-ui-design/references/design-intelligence.md +97 -0
- package/localized/zh-CN/skills/fec-ui-design/references/master-page-overrides.md +30 -0
- package/localized/zh-CN/skills/fec-ui-design/references/pre-delivery-checklist.md +39 -0
- package/localized/zh-CN/skills/fec-ui-design/scripts/design-system.mjs +648 -0
- package/localized/zh-CN/skills/fec-validation-fix/SKILL.md +51 -0
- package/localized/zh-CN/skills/fec-validation-fix/references/report-template.md +43 -0
- package/localized/zh-CN/skills/fec-vite-project-standard/SKILL.md +83 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/SKILL.md +58 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +162 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +13 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-project-structure.md +176 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +216 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/SKILL.md +61 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/data/starter-themes.json +59 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/references/chapter-craft.md +37 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/references/content-plan.md +38 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/references/recording-and-audio.md +33 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/references/theme-system.md +36 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/scripts/create-video-presentation.mjs +430 -0
- package/localized/zh-CN/skills/fec-web-workers/SKILL.md +35 -0
- package/localized/zh-CN/skills/fec-web-workers/references/advanced-workers.md +54 -0
- package/localized/zh-CN/skills/fec-web-workers/references/basic-worker.md +67 -0
- package/localized/zh-CN/skills/metadata.json +1646 -0
- package/localized/zh-CN/skills/relations.json +755 -0
- package/localized/zh-CN/templates/claude/CLAUDE.md +106 -0
- package/localized/zh-CN/templates/claude/settings.json +62 -0
- package/localized/zh-CN/templates/codex/AGENTS.md +105 -0
- package/localized/zh-CN/templates/codex/config.toml +32 -0
- package/localized/zh-CN/templates/openclaw/AGENTS.md +101 -0
- package/localized/zh-CN/templates/openclaw/OPENCLAW-CONFIG.md +12 -0
- package/localized/zh-CN/templates/shared/rules/fec-agent-workflow.md +54 -0
- package/localized/zh-CN/templates/shared/rules/fec-api-layer.md +99 -0
- package/localized/zh-CN/templates/shared/rules/fec-ci-cd.md +40 -0
- package/localized/zh-CN/templates/shared/rules/fec-code-comments.md +33 -0
- package/localized/zh-CN/templates/shared/rules/fec-design-system.md +72 -0
- package/localized/zh-CN/templates/shared/rules/fec-error-handling.md +56 -0
- package/localized/zh-CN/templates/shared/rules/fec-git-conventions.md +73 -0
- package/localized/zh-CN/templates/shared/rules/fec-i18n.md +64 -0
- package/localized/zh-CN/templates/shared/rules/fec-naming-conventions.md +120 -0
- package/localized/zh-CN/templates/shared/rules/fec-performance.md +101 -0
- package/localized/zh-CN/templates/shared/rules/fec-react.md +82 -0
- package/localized/zh-CN/templates/shared/rules/fec-refactoring.md +47 -0
- package/localized/zh-CN/templates/shared/rules/fec-rendering-patterns.md +40 -0
- package/localized/zh-CN/templates/shared/rules/fec-responsive-design.md +50 -0
- package/localized/zh-CN/templates/shared/rules/fec-source-driven-development.md +31 -0
- package/localized/zh-CN/templates/shared/rules/fec-state-management.md +60 -0
- package/localized/zh-CN/templates/shared/rules/fec-testing.md +98 -0
- package/localized/zh-CN/templates/shared/rules/fec-typescript.md +112 -0
- package/localized/zh-CN/templates/shared/rules/fec-vue.md +64 -0
- package/localized/zh-CN/templates/shared/rules/fec-working-modes.md +50 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -2
- package/skills/TEMPLATE.md +74 -74
- package/skills/eval_queries.json +678 -678
- package/skills/fec-accessibility-check/SKILL.md +21 -21
- package/skills/fec-accessibility-check/references/report-template.md +12 -12
- package/skills/fec-accessibility-check/references/screen-reader-testing.md +24 -24
- package/skills/fec-alchemy/SKILL.md +50 -50
- package/skills/fec-alchemy/assets/absorption-plan-template.md +32 -32
- package/skills/fec-alchemy/assets/intake-template.md +55 -55
- package/skills/fec-alchemy/assets/review-checklist.md +23 -23
- package/skills/fec-alchemy/references/methodology.md +66 -66
- package/skills/fec-alchemy/references/originality-and-licensing.md +42 -42
- package/skills/fec-api-integration/SKILL.md +61 -61
- package/skills/fec-api-integration/references/integration-patterns.md +30 -30
- package/skills/fec-backend-requirements-handoff/SKILL.md +25 -25
- package/skills/fec-browser-storage/SKILL.md +16 -16
- package/skills/fec-browser-storage/references/storage-patterns.md +16 -16
- package/skills/fec-canvas-threejs/SKILL.md +21 -21
- package/skills/fec-canvas-threejs/references/rendering-patterns.md +10 -10
- package/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +37 -37
- package/skills/fec-code-review/SKILL.md +94 -94
- package/skills/fec-code-review/references/report-template.md +13 -13
- package/skills/fec-component-testing/SKILL.md +39 -39
- package/skills/fec-data-fetching/SKILL.md +16 -16
- package/skills/fec-data-fetching/references/query-patterns.md +27 -27
- package/skills/fec-debug-framework/SKILL.md +95 -95
- package/skills/fec-debug-framework/references/report-template.md +34 -34
- package/skills/fec-dependency-upgrade/SKILL.md +17 -17
- package/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +31 -31
- package/skills/fec-doc-sync/SKILL.md +23 -23
- package/skills/fec-drawio-studio/SKILL.md +42 -38
- package/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +1 -1
- package/skills/fec-drawio-studio/data/shape-index.json +83570 -0
- package/skills/fec-drawio-studio/references/diagram-patterns.md +19 -0
- package/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
- package/skills/fec-drawio-studio/references/layout-and-export.md +18 -3
- package/skills/fec-drawio-studio/references/xml-and-mermaid.md +5 -1
- package/skills/fec-drawio-studio/scripts/diagram-lint.mjs +62 -0
- package/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
- package/skills/fec-drawio-studio/scripts/shape-query.mjs +55 -15
- package/skills/fec-e2e-testing/SKILL.md +24 -24
- package/skills/fec-e2e-testing/references/e2e-ci-reporting.md +20 -20
- package/skills/fec-e2e-testing/references/e2e-special-scenarios.md +10 -10
- package/skills/fec-e2e-testing/references/e2e-visual-regression.md +17 -17
- package/skills/fec-e2e-testing/references/playwright-patterns.md +6 -6
- package/skills/fec-form-handling/SKILL.md +21 -21
- package/skills/fec-form-handling/references/advanced-form-patterns.md +41 -41
- package/skills/fec-image-generation/SKILL.md +54 -29
- package/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
- package/skills/fec-image-generation/references/diagram-workflows.md +33 -2
- package/skills/fec-image-generation/references/html-technical-diagrams.md +236 -0
- package/skills/fec-image-generation/scripts/export-diagram.mjs +364 -0
- package/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
- package/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1397 -0
- package/skills/fec-implement-from-design/SKILL.md +81 -81
- package/skills/fec-implement-from-design/references/design-plan-template.md +16 -16
- package/skills/fec-legacy-to-modern-migration/SKILL.md +29 -29
- package/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +81 -81
- package/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +37 -37
- package/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +31 -31
- package/skills/fec-legacy-web-standard/SKILL.md +17 -17
- package/skills/fec-legacy-web-standard/references/legacy-patterns.md +16 -16
- package/skills/fec-list-virtualization/SKILL.md +16 -16
- package/skills/fec-list-virtualization/references/virtualization-patterns.md +31 -31
- package/skills/fec-monorepo-project-standard/SKILL.md +52 -52
- package/skills/fec-motion-interaction/SKILL.md +51 -51
- package/skills/fec-motion-interaction/references/motion-patterns.md +11 -11
- package/skills/fec-nextjs-project-standard/SKILL.md +64 -64
- package/skills/fec-nuxt-project-standard/SKILL.md +57 -57
- package/skills/fec-performance-optimization/SKILL.md +54 -54
- package/skills/fec-performance-optimization/references/framework-performance-patterns.md +23 -23
- package/skills/fec-performance-optimization/references/report-template.md +31 -31
- package/skills/fec-pwa-implementation/SKILL.md +17 -17
- package/skills/fec-pwa-implementation/references/manifest-and-icons.md +12 -12
- package/skills/fec-pwa-implementation/references/service-worker-workbox.md +13 -13
- package/skills/fec-react-project-standard/SKILL.md +72 -72
- package/skills/fec-react-project-standard/references/react-performance-patterns.md +28 -28
- package/skills/fec-react-project-standard/references/react-project-structure.md +112 -112
- package/skills/fec-react-project-standard/references/react-quality-patterns.md +72 -72
- package/skills/fec-react-project-standard/references/react-runtime-patterns.md +94 -94
- package/skills/fec-refactor-clean/SKILL.md +30 -30
- package/skills/fec-refactor-clean/references/report-template.md +23 -23
- package/skills/fec-responsive-layout/SKILL.md +17 -17
- package/skills/fec-responsive-layout/references/responsive-layout-patterns.md +37 -37
- package/skills/fec-route-protection/SKILL.md +26 -26
- package/skills/fec-security-review/SKILL.md +20 -20
- package/skills/fec-security-review/references/report-template.md +12 -12
- package/skills/fec-security-review/references/security-checklist.md +27 -27
- package/skills/fec-source-driven-development/SKILL.md +59 -59
- package/skills/fec-state-management/SKILL.md +34 -34
- package/skills/fec-state-management/references/state-patterns.md +19 -19
- package/skills/fec-storybook-component-doc/SKILL.md +19 -19
- package/skills/fec-storybook-component-doc/references/story-patterns.md +12 -12
- package/skills/fec-svg-animation/SKILL.md +32 -32
- package/skills/fec-tailwind-design-system/SKILL.md +17 -17
- package/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +36 -36
- package/skills/fec-tdd-workflow/SKILL.md +28 -28
- package/skills/fec-testing-strategy/SKILL.md +29 -29
- package/skills/fec-typescript-project-standard/SKILL.md +38 -38
- package/skills/fec-typescript-project-standard/references/type-safety-patterns.md +20 -20
- package/skills/fec-typescript-project-standard/references/type-safety.md +18 -18
- package/skills/fec-ui-design/SKILL.md +90 -90
- package/skills/fec-ui-design/references/design-intelligence.md +61 -61
- package/skills/fec-ui-design/references/master-page-overrides.md +15 -15
- package/skills/fec-ui-design/references/pre-delivery-checklist.md +38 -38
- package/skills/fec-validation-fix/SKILL.md +26 -26
- package/skills/fec-validation-fix/references/report-template.md +25 -25
- package/skills/fec-vite-project-standard/SKILL.md +39 -39
- package/skills/fec-vue3-project-standard/SKILL.md +38 -38
- package/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +36 -36
- package/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +8 -8
- package/skills/fec-vue3-project-standard/references/vue3-project-structure.md +112 -112
- package/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +74 -74
- package/skills/fec-web-video-presentation/SKILL.md +33 -33
- package/skills/fec-web-workers/SKILL.md +16 -16
- package/skills/fec-web-workers/references/advanced-workers.md +13 -13
- package/skills/fec-web-workers/references/basic-worker.md +8 -8
- package/skills/metadata.json +121 -115
- package/skills/relations.json +4 -0
- package/templates/claude/CLAUDE.md +60 -60
- package/templates/codex/AGENTS.md +76 -76
- package/templates/codex/config.toml +4 -4
- package/templates/openclaw/AGENTS.md +68 -68
- package/templates/openclaw/OPENCLAW-CONFIG.md +8 -8
- package/templates/shared/rules/fec-agent-workflow.md +40 -40
- package/templates/shared/rules/fec-api-layer.md +52 -52
- package/templates/shared/rules/fec-ci-cd.md +29 -29
- package/templates/shared/rules/fec-code-comments.md +22 -22
- package/templates/shared/rules/fec-design-system.md +53 -53
- package/templates/shared/rules/fec-error-handling.md +40 -40
- package/templates/shared/rules/fec-git-conventions.md +42 -42
- package/templates/shared/rules/fec-i18n.md +48 -48
- package/templates/shared/rules/fec-naming-conventions.md +91 -91
- package/templates/shared/rules/fec-performance.md +78 -78
- package/templates/shared/rules/fec-react.md +58 -58
- package/templates/shared/rules/fec-refactoring.md +34 -34
- package/templates/shared/rules/fec-rendering-patterns.md +36 -36
- package/templates/shared/rules/fec-responsive-design.md +37 -37
- package/templates/shared/rules/fec-source-driven-development.md +22 -22
- package/templates/shared/rules/fec-state-management.md +56 -56
- package/templates/shared/rules/fec-testing.md +64 -64
- package/templates/shared/rules/fec-typescript.md +75 -75
- package/templates/shared/rules/fec-vue.md +42 -42
- package/templates/shared/rules/fec-working-modes.md +34 -34
- package/skills/fec-drawio-studio/data/shape-index.json.gz +0 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-implement-from-design
|
|
3
|
+
description: 用于根据 Figma、Sketch、MasterGo、Pixso、墨刀、摹客、截图、设计选区、设计 Token 或设计转代码任务实现生产级前端组件/页面;中文触发词包括 设计稿、按设计实现。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 按设计稿实现
|
|
7
|
+
|
|
8
|
+
## 用途
|
|
9
|
+
|
|
10
|
+
基于设计工具(Figma、Sketch、MasterGo、Pixso、墨刀、摹客)的设计上下文,高保真实现页面或组件,强调组件复用、设计 Token 映射、可访问性和面向生产的前端实现。
|
|
11
|
+
|
|
12
|
+
## 支持的设计工具
|
|
13
|
+
|
|
14
|
+
| 工具 | MCP 集成 | 获取设计数据方式 |
|
|
15
|
+
| -------- | ------------------------- | ----------------------------------------- |
|
|
16
|
+
| Figma | `figma` / `figma-desktop` | API 获取设计结构、变量定义 |
|
|
17
|
+
| Sketch | `sketch` | MCP 获取设计选区截图 |
|
|
18
|
+
| MasterGo | `mastergo` | API 获取 DSL 结构数据 |
|
|
19
|
+
| Pixso | `pixso` | 本地 MCP 获取帧数据和代码 |
|
|
20
|
+
| 墨刀 | `modao` | MCP 获取原型数据、生成设计描述 |
|
|
21
|
+
| 摹客 | 无 MCP | 通过用户提供的截图、标注或导出的 CSS 获取 |
|
|
22
|
+
|
|
23
|
+
## 目标
|
|
24
|
+
|
|
25
|
+
- 尽量高还原地实现设计稿
|
|
26
|
+
- 在创建新组件前优先复用现有项目组件
|
|
27
|
+
- 尽可能把设计变量映射到现有 Token
|
|
28
|
+
- 保持实现结果可维护、类型明确、可测试且具备可访问性
|
|
29
|
+
- 避免引入重复的基础组件或并行设计系统
|
|
30
|
+
|
|
31
|
+
## 流程
|
|
32
|
+
|
|
33
|
+
### 1. 识别设计来源
|
|
34
|
+
|
|
35
|
+
按优先级选择设计数据获取方式:
|
|
36
|
+
|
|
37
|
+
- `figma` — Figma API 集成
|
|
38
|
+
- `figma-desktop` — Figma 桌面端集成
|
|
39
|
+
- `mastergo` — MasterGo DSL 数据
|
|
40
|
+
- `pixso` — Pixso 本地 MCP
|
|
41
|
+
- `modao` — 墨刀原型数据
|
|
42
|
+
- `sketch` — Sketch 选区截图
|
|
43
|
+
- 如以上 MCP 均不可用,请求用户提供设计截图或标注(适用于摹客等无 MCP 工具)
|
|
44
|
+
- 如果没有权威设计稿,但任务明确要求视觉型网站、品牌页、作品集或高审美重设计,可把用户提供或本地生成的分区级参考图作为临时视觉事实来源;这种来源必须先分析后实现,并在计划中标明不是权威设计系统。
|
|
45
|
+
|
|
46
|
+
### 2. 读取设计上下文
|
|
47
|
+
|
|
48
|
+
通过 MCP 或用户提供的设计数据读取设计上下文:
|
|
49
|
+
|
|
50
|
+
- 检查布局结构
|
|
51
|
+
- 检查间距、字体、颜色、变量、状态、图标和组件层级
|
|
52
|
+
- 如果 MCP 提供了资源文件或 SVG / 图片源,直接使用
|
|
53
|
+
- 如果 MCP 已提供真实资源,不要自行造占位资源
|
|
54
|
+
- 如果用户提供截图而非 MCP 数据,从截图中推断布局、颜色、字体等视觉信息
|
|
55
|
+
- 如果使用图像/截图参考,先提取区块结构、视觉层级、主色和功能色、字体气质、间距节奏、媒体位置、交互状态暗示和响应式风险,再写代码。
|
|
56
|
+
- 对多区块页面优先使用清晰的分区级参考图或局部细节图;不要从压缩长图里猜测按钮、字号、间距和组件状态。
|
|
57
|
+
- 视觉参考中的不可读文字、假截图、不可检查素材或冲突状态不能直接照搬;需要转译成项目真实内容、真实状态或明确占位说明。
|
|
58
|
+
|
|
59
|
+
### 3. 搜索可复用组件
|
|
60
|
+
|
|
61
|
+
在创建新组件前先搜索代码库中的可复用组件,重点检查:
|
|
62
|
+
|
|
63
|
+
- 按钮(Button)
|
|
64
|
+
- 输入框 / 选择器 / 复选框 / 单选框 / 开关(Input / Select / Checkbox / Radio / Switch)
|
|
65
|
+
- 模态框 / 抽屉 / 对话框(Modal / Drawer / Dialog)
|
|
66
|
+
- 表格 / 列表 / 卡片(Table / List / Card)
|
|
67
|
+
- 标签页 / 面包屑 / 分页(Tabs / Breadcrumb / Pagination)
|
|
68
|
+
- 页面容器 / 区块容器 / 空状态 / Loading 状态
|
|
69
|
+
|
|
70
|
+
### 4. 产出实现计划
|
|
71
|
+
|
|
72
|
+
在改文件前先产出一份简短实现计划,计划必须包含:
|
|
73
|
+
|
|
74
|
+
- 需要改动的文件列表
|
|
75
|
+
- 组件拆分方案
|
|
76
|
+
- 状态 / 数据流
|
|
77
|
+
- 响应式行为
|
|
78
|
+
- 复用还是新建的决策
|
|
79
|
+
- 设计缺口或歧义点
|
|
80
|
+
- 图像/截图来源的可靠性,以及哪些视觉细节会被项目 token、组件约定或可访问性要求覆盖
|
|
81
|
+
|
|
82
|
+
### 5. 按框架实现
|
|
83
|
+
|
|
84
|
+
按仓库当前使用的前端框架进行实现:
|
|
85
|
+
|
|
86
|
+
- 严格遵循仓库现有约定
|
|
87
|
+
- 优先使用明确类型的 props 和 interfaces/types
|
|
88
|
+
- 保持组件小而可组合
|
|
89
|
+
- 将重复逻辑提取为 hooks / composables / utilities
|
|
90
|
+
|
|
91
|
+
### 6. 设计 Token 映射
|
|
92
|
+
|
|
93
|
+
- 优先使用现有 design token、CSS 变量、主题变量或工具类
|
|
94
|
+
- 除非确实没有对应 Token,否则不要硬编码颜色、圆角和间距
|
|
95
|
+
- 如果设计使用了新 Token,要明确指出,不要悄悄到处硬编码
|
|
96
|
+
|
|
97
|
+
### 7. 可访问性保障
|
|
98
|
+
|
|
99
|
+
- 优先使用语义化 HTML
|
|
100
|
+
- 确保交互控件具有可访问名称
|
|
101
|
+
- 保留可见的焦点样式
|
|
102
|
+
- 检查对话框、菜单、标签页、表单控件的键盘可操作性
|
|
103
|
+
|
|
104
|
+
### 8. 编码后验证
|
|
105
|
+
|
|
106
|
+
- 如有 lint,执行 lint
|
|
107
|
+
- 如有测试,执行测试
|
|
108
|
+
- 如果缺少测试,说明建议补充的最小测试范围
|
|
109
|
+
|
|
110
|
+
## 详细参考
|
|
111
|
+
|
|
112
|
+
撰写实现计划报告时,加载 [references/design-plan-template.md](references/design-plan-template.md)。
|
|
113
|
+
|
|
114
|
+
## 约束
|
|
115
|
+
|
|
116
|
+
- 如果已有设计上下文(MCP 或截图),不要靠猜来实现 UI
|
|
117
|
+
- 如果项目已有 UI 体系,不要再引入一套新的 UI Kit
|
|
118
|
+
- 除非有合理理由,不要用硬编码替代已 Token 化的样式
|
|
119
|
+
- 不要忽略 hover、active、disabled、loading、empty、error 等状态
|
|
120
|
+
- 摹客等无 MCP 工具场景下,主动向用户索要关键截图和标注信息,不要凭空编造视觉数据
|
|
121
|
+
- 不把生成图像当作可直接复制的代码规范;它只提供视觉证据,最终实现必须服从当前项目组件、token、可访问性和性能边界
|
|
122
|
+
- 不用一张不可读整页图替代分区分析;关键区块、CTA、表单、导航和状态必须可检查
|
|
123
|
+
|
|
124
|
+
## 预期输出
|
|
125
|
+
|
|
126
|
+
- 设计实现计划报告保存为 `reports/design-plan-YYYY-MM-DD-HHmmss.md`,包含实现概要、组件拆分方案、状态/数据流、变更文件清单
|
|
127
|
+
- 代码实现高保真还原设计稿,组件复用率最大化
|
|
128
|
+
- 设计变量映射到现有 Token,无硬编码颜色/间距/圆角
|
|
129
|
+
- 交互元素具备可访问名称和键盘支持,焦点样式可见
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# 设计实现计划模板
|
|
2
|
+
|
|
3
|
+
```markdown
|
|
4
|
+
# 设计实现计划
|
|
5
|
+
|
|
6
|
+
> 生成时间: YYYY-MM-DD HH:mm
|
|
7
|
+
> 评审工具: frontend-craft
|
|
8
|
+
> 设计工具: Figma / Sketch / MasterGo / Pixso / 墨刀 / 摹客
|
|
9
|
+
|
|
10
|
+
## 实现概要
|
|
11
|
+
- 设计稿来源: ...
|
|
12
|
+
- 目标页面/组件: ...
|
|
13
|
+
|
|
14
|
+
## 复用的组件
|
|
15
|
+
- ...
|
|
16
|
+
|
|
17
|
+
## 新建的组件
|
|
18
|
+
- ...
|
|
19
|
+
|
|
20
|
+
## 组件拆分方案
|
|
21
|
+
- ...
|
|
22
|
+
|
|
23
|
+
## 状态/数据流
|
|
24
|
+
- ...
|
|
25
|
+
|
|
26
|
+
## 与设计稿的偏差
|
|
27
|
+
- ...
|
|
28
|
+
|
|
29
|
+
## 缺失的资源 / Token / 交互细节
|
|
30
|
+
- ...
|
|
31
|
+
|
|
32
|
+
## 变更文件清单
|
|
33
|
+
- ...
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
实现计划确定后,将报告保存到 `reports/design-plan-YYYY-MM-DD-HHmmss.md`,并告知用户报告路径。
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-legacy-to-modern-migration
|
|
3
|
+
description: 用于规划或实施从 JavaScript、jQuery、HTML/CSS、服务端渲染模板、MPA 遗留前端代码或旧框架代码迁移到现代前端技术栈,同时保持行为一致。不要用于仍留在旧技术栈内的日常遗留 bug 修复;中文触发词包括 遗留项目、技术栈升级、jQuery 迁移。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 传统前端到现代框架迁移
|
|
7
|
+
|
|
8
|
+
适用于将 JavaScript + jQuery + HTML/CSS 多页面应用(MPA)、服务端模板渲染项目或旧框架代码,渐进迁移到 React、Vue、Next.js、Nuxt、TypeScript,或保留 MPA 形态但现代化模块、构建、类型和测试的场景。
|
|
9
|
+
|
|
10
|
+
## 用途
|
|
11
|
+
|
|
12
|
+
指导传统前端项目渐进迁移到目标现代栈,提供迁移策略、概念映射、分阶段步骤和实施约束,确保功能等价和风险可控。
|
|
13
|
+
|
|
14
|
+
## 流程
|
|
15
|
+
|
|
16
|
+
1. 先识别目标栈、迁移边界和是否保留 MPA/服务端模板形态。
|
|
17
|
+
2. 加载 [references/migration-strategy-and-mapping.md](references/migration-strategy-and-mapping.md),选择渐进式或一次性重写策略,并明确遗留模式到目标栈的映射。
|
|
18
|
+
3. 加载 [references/migration-execution-checklist.md](references/migration-execution-checklist.md),完成存量盘点、依赖分析、优先级排序和分阶段迁移计划。
|
|
19
|
+
4. 撰写迁移分析或迁移计划报告时,加载 [references/migration-report-template.md](references/migration-report-template.md)。
|
|
20
|
+
5. 按准备、基础层、模块/页面迁移、收尾的顺序推进,每次迁移一个可验证单元。
|
|
21
|
+
6. 每个迁移单元验证功能等价、视觉一致、类型安全、可访问性、i18n、资源和样式边界。
|
|
22
|
+
|
|
23
|
+
## 约束
|
|
24
|
+
|
|
25
|
+
- 迁移前必须先输出迁移分析报告,明确策略、优先级和风险。
|
|
26
|
+
- 不要在一次迁移中同时改架构、改 UI、改接口。
|
|
27
|
+
- 优先保证功能等价,再考虑优化和现代化。
|
|
28
|
+
- 迁移过程中保持旧系统可运行,避免大爆炸式上线。
|
|
29
|
+
- 遇到 jQuery 插件无现成替代时,可暂时用 iframe 或微前端方式嵌入,待后续替换。
|
|
30
|
+
- 目标栈先识别 React/Vue/Next/Nuxt、现代 MPA 或局部现代化目标,不默认强制改成 SPA。
|
|
31
|
+
- 图片使用原项目资源;图标体系优先沿用原项目或目标项目规范;内联 SVG 例外需有可访问性、组件化或维护理由。
|
|
32
|
+
- 样式参考原项目效果但不照搬 CSS,优先使用目标项目样式体系;内联样式例外需局部、可解释。
|
|
33
|
+
- 目标是视觉与交互一致、代码更简洁易维护,业务功能不得缺失。
|
|
34
|
+
- 涉及页面、组件、路由、表单、弹窗、导航或关键用户流程的迁移,必须建立重构前后的行为清单,并使用 Playwright 或同等真实浏览器验证方式对关键路径做对比验证。
|
|
35
|
+
- 对视觉敏感页面,应补充截图对比或人工截图验收;动态内容、动画、字体和环境差异需明确屏蔽、稳定化或说明。
|
|
36
|
+
- 对纯逻辑、类型、构建或无 UI 的迁移,不强制 Playwright,应选择更贴近风险的验证层:type-check、unit test、component test、build 或 lint。
|
|
37
|
+
- 验证目标不是像素级完全一致,而是确认业务功能无缺失、关键交互等价、主要视觉布局无非预期偏差,并且代码比旧实现更清晰、可维护。
|
|
38
|
+
|
|
39
|
+
## 预期输出
|
|
40
|
+
|
|
41
|
+
- 迁移分析报告保存为 `reports/migration-plan-YYYY-MM-DD-HHmmss.md`,包含策略选择、存量盘点、依赖关系、分阶段步骤、风险与回滚方案。
|
|
42
|
+
- 迁移后的业务功能与原项目完全等价,无功能缺失。
|
|
43
|
+
- 视觉与交互与原项目一致,用户无感知差异。
|
|
44
|
+
- 类型定义完整,无 `any` 滥用,API 调用统一且类型安全。
|
|
45
|
+
- 图片使用原项目资源,样式进入目标项目样式体系,图标和内联样式例外有明确理由。
|
|
46
|
+
- 新代码文案已 i18n,关键路径有测试覆盖。
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# 迁移执行与检查清单
|
|
2
|
+
|
|
3
|
+
## 迁移前分析
|
|
4
|
+
|
|
5
|
+
在动手迁移前,必须完成以下分析并输出**迁移分析报告**:
|
|
6
|
+
|
|
7
|
+
1. **存量盘点**
|
|
8
|
+
- 页面数量、功能模块数量
|
|
9
|
+
- 依赖的 jQuery 插件及替代方案(如 DataTables → TanStack Table)
|
|
10
|
+
- 现有 API 调用方式、是否有统一封装
|
|
11
|
+
- 是否有服务端模板(JSP/Thymeleaf/EJS 等)需要保留、局部替换或改为纯前端渲染
|
|
12
|
+
- 目标栈是 React/Vue/Next/Nuxt、现代 MPA,还是只做局部 TypeScript/构建/测试现代化
|
|
13
|
+
|
|
14
|
+
2. **依赖关系**
|
|
15
|
+
- 页面间共享的 JS/CSS 模块
|
|
16
|
+
- 跨页面复用的业务逻辑
|
|
17
|
+
- 与后端的接口契约(是否需调整)
|
|
18
|
+
|
|
19
|
+
3. **迁移优先级**
|
|
20
|
+
- 按业务价值、复杂度、耦合度排序
|
|
21
|
+
- 优先迁移独立模块、低耦合页面
|
|
22
|
+
- 识别可复用的工具函数、常量、类型定义
|
|
23
|
+
|
|
24
|
+
## 分阶段迁移流程
|
|
25
|
+
|
|
26
|
+
### 阶段 0:准备
|
|
27
|
+
|
|
28
|
+
- 搭建或识别目标项目骨架:React/Vue/Next/Nuxt、现代 MPA,或现有项目内的渐进式 TypeScript/构建入口
|
|
29
|
+
- 配置 ESLint、Prettier、测试框架
|
|
30
|
+
- 建立 `services/request.ts` 统一请求层,与现有 API 兼容
|
|
31
|
+
- 将遗留项目中的 `utils`、`constants` 逐步迁移并补充类型
|
|
32
|
+
|
|
33
|
+
### 阶段 1:基础层
|
|
34
|
+
|
|
35
|
+
- 迁移并类型化 API 调用(`$.ajax` → `axios`/`fetch`)
|
|
36
|
+
- 迁移工具函数(日期、格式化、校验等)
|
|
37
|
+
- 迁移常量、枚举、类型定义
|
|
38
|
+
- 建立目标导航/页面入口骨架;未迁移页面可继续走旧路由、重定向、iframe 或微前端嵌入
|
|
39
|
+
|
|
40
|
+
### 阶段 2:按模块/页面迁移
|
|
41
|
+
|
|
42
|
+
- 每次迁移一个完整功能或页面
|
|
43
|
+
- 从简单到复杂:静态页 → 列表页 → 表单页 → 复杂交互页
|
|
44
|
+
- 迁移时提取可复用组件,遵循目标 React 或 Vue 项目的目录结构
|
|
45
|
+
- 每完成一个模块,补充单元测试和 E2E 关键路径
|
|
46
|
+
|
|
47
|
+
### 阶段 3:收尾
|
|
48
|
+
|
|
49
|
+
- 按迁移策略移除或冻结旧代码入口;若保留 MPA,则收敛旧入口并完成现代化边界
|
|
50
|
+
- 配置 404、错误边界、全局错误处理
|
|
51
|
+
- 性能优化(懒加载、代码分割、缓存策略)
|
|
52
|
+
- 文档更新、部署流程调整
|
|
53
|
+
|
|
54
|
+
## 重构实施要求
|
|
55
|
+
|
|
56
|
+
迁移时需遵循以下实施约束,确保视觉与交互一致、代码更简洁易维护。
|
|
57
|
+
|
|
58
|
+
### 图片与图标
|
|
59
|
+
|
|
60
|
+
- 直接使用原项目的图片资源路径,不重新托管或替换
|
|
61
|
+
- 可使用 SVG 图片(`<img src="*.svg" />` 或 CSS `background-image`);图标组件或可访问交互确需内联 SVG 时,应遵循目标项目图标规范并说明理由。
|
|
62
|
+
- 若原项目使用了 iconfont 或 IcoMoon 图标,重构时优先继续使用,保持图标体系一致;替换为其他图标方案前需评估视觉一致性、包体和维护成本。
|
|
63
|
+
- 图标优先使用原项目已有的图标文件(iconfont / IcoMoon / 已有 SVG),必要时可引入 SVG 文件作为独立资源
|
|
64
|
+
|
|
65
|
+
### 国际化(i18n)
|
|
66
|
+
|
|
67
|
+
- 新栈代码(React / Vue 等)中的用户可见文案须走项目 i18n,不在新代码里硬编码中/英文案
|
|
68
|
+
- 遗留 HTML/JS 中**不要新增**用户可见硬编码文案,除非纯静态且仓库尚无可用 i18n 接入点;改动文案前先查 locales 是否已有条目,并同步主要语言文件
|
|
69
|
+
- key 按页面/模块/语义组织,复用既有 key;仅当旧 key 为对外契约时才做映射过渡,详见项目规则中的 **国际化 (i18n)**(`templates/shared/rules/fec-i18n.md` 内「遗留代码与迁移场景」)
|
|
70
|
+
|
|
71
|
+
### 样式
|
|
72
|
+
|
|
73
|
+
- 布局样式对齐原项目视觉效果,但**只参考原项目效果,不照搬其 CSS**
|
|
74
|
+
- 优先使用 **flex 弹性布局**,避免 `float`、复杂 `position`、冗余嵌套
|
|
75
|
+
- 避免不合理写法:如 `!important` 滥用、过深选择器、重复定义
|
|
76
|
+
- 组件中优先避免内联样式(`style={{ ... }}` / `style="..."`);确需使用运行时动态值、第三方组件 API 或 CSS 变量桥接时,应保持局部、可解释,并优先放入目标项目样式体系。
|
|
77
|
+
|
|
78
|
+
### 目标
|
|
79
|
+
|
|
80
|
+
- **视觉和交互**:与原项目一致,用户无感知差异
|
|
81
|
+
- **代码质量**:更简洁、易维护,符合目标框架规范
|
|
82
|
+
- **业务功能**:与原项目保持一致,**不得缺失功能**;迁移前后行为等价
|
|
83
|
+
|
|
84
|
+
### 验证分层
|
|
85
|
+
|
|
86
|
+
- 涉及页面、组件、路由、表单、弹窗、导航或关键用户流程的迁移,先建立重构前后的行为清单,再使用 Playwright 或同等真实浏览器验证方式对关键路径做对比验证。
|
|
87
|
+
- 对视觉敏感页面,补充截图对比或人工截图验收;动态内容、动画、字体和环境差异需明确屏蔽、稳定化或说明。
|
|
88
|
+
- 对纯逻辑、类型、构建或无 UI 的迁移,不强制 Playwright,应选择更贴近风险的验证层:type-check、unit test、component test、build 或 lint。
|
|
89
|
+
- 验证目标不是像素级完全一致,而是确认业务功能无缺失、关键交互等价、主要视觉布局无非预期偏差,并且代码比旧实现更清晰、可维护。
|
|
90
|
+
|
|
91
|
+
## 迁移检查清单
|
|
92
|
+
|
|
93
|
+
每个迁移单元完成后,确认:
|
|
94
|
+
|
|
95
|
+
- [ ] 已建立重构前后的行为清单,覆盖公共 API、路由、表单、权限、错误状态、缓存、埋点和关键交互
|
|
96
|
+
- [ ] 业务逻辑与旧实现一致,无功能遗漏,功能完整等价
|
|
97
|
+
- [ ] 涉及 UI、交互或关键流程的迁移已使用 Playwright 或同等真实浏览器验证方式完成关键路径对比
|
|
98
|
+
- [ ] 视觉敏感页面已完成截图对比或人工截图验收,并说明动态内容、动画、字体和环境差异处理方式
|
|
99
|
+
- [ ] 纯逻辑、类型、构建或无 UI 迁移已选择更贴近风险的验证层,不强制套用 Playwright
|
|
100
|
+
- [ ] 类型定义完整,无 `any` 滥用
|
|
101
|
+
- [ ] API 调用使用统一 request 层,错误处理完整
|
|
102
|
+
- [ ] 表单校验、loading、空状态、错误状态已实现
|
|
103
|
+
- [ ] 可访问性:表单有 label、交互可键盘操作
|
|
104
|
+
- [ ] 无 XSS 风险(用户输入已转义或使用安全 API)
|
|
105
|
+
- [ ] 关键路径有测试覆盖
|
|
106
|
+
- [ ] 符合目标栈的项目规范(React / Vue / Next / Nuxt / MPA 现代化等)
|
|
107
|
+
- [ ] 图片使用原项目资源;图标体系优先沿用原项目或目标项目规范,例外已说明
|
|
108
|
+
- [ ] 样式参考原项目效果但不照搬 CSS,优先使用目标项目样式体系,内联样式例外已说明
|
|
109
|
+
- [ ] 视觉与交互与原项目一致,代码更简洁易维护
|
|
110
|
+
- [ ] 新代码路径文案已 i18n;遗留层未扩大硬编码;locales 检索与多语言同步已完成(参见 i18n 规则迁移补充清单)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 迁移分析报告模板
|
|
2
|
+
|
|
3
|
+
```markdown
|
|
4
|
+
# 迁移分析报告
|
|
5
|
+
|
|
6
|
+
> 生成时间: YYYY-MM-DD HH:mm
|
|
7
|
+
> 评审工具: frontend-craft
|
|
8
|
+
|
|
9
|
+
## 策略选择
|
|
10
|
+
- 渐进式 / 一次性重写:
|
|
11
|
+
- 理由:
|
|
12
|
+
|
|
13
|
+
## 存量盘点
|
|
14
|
+
- 页面数量:
|
|
15
|
+
- 功能模块:
|
|
16
|
+
- jQuery 插件:
|
|
17
|
+
- 服务端模板:
|
|
18
|
+
- API 调用方式:
|
|
19
|
+
|
|
20
|
+
## 依赖关系
|
|
21
|
+
- 共享 JS/CSS:
|
|
22
|
+
- 跨页面逻辑:
|
|
23
|
+
- 后端接口契约:
|
|
24
|
+
|
|
25
|
+
## 迁移优先级
|
|
26
|
+
- 第一批:
|
|
27
|
+
- 第二批:
|
|
28
|
+
- 暂缓:
|
|
29
|
+
|
|
30
|
+
## 分阶段步骤
|
|
31
|
+
- 阶段 0:
|
|
32
|
+
- 阶段 1:
|
|
33
|
+
- 阶段 2:
|
|
34
|
+
- 阶段 3:
|
|
35
|
+
|
|
36
|
+
## 风险与回滚
|
|
37
|
+
- 风险:
|
|
38
|
+
- 回滚方案:
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
迁移分析或计划完成后,将报告保存到 `reports/migration-plan-YYYY-MM-DD-HHmmss.md`,并告知用户报告路径。
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# 迁移策略与概念映射
|
|
2
|
+
|
|
3
|
+
## 迁移策略选择
|
|
4
|
+
|
|
5
|
+
| 策略 | 适用情况 | 优点 | 风险 |
|
|
6
|
+
| --------------------------- | ------------------------------------ | ---------------------------- | ---------------------------- |
|
|
7
|
+
| **渐进式(Strangler Fig)** | 大型项目、需持续交付、团队熟悉度不足 | 风险可控、可分批上线、可回滚 | 新旧并存期长、需维护两套代码 |
|
|
8
|
+
| **一次性重写** | 中小型项目、业务稳定、有充足时间窗口 | 目标架构清晰、无历史包袱 | 周期长、上线压力大、回滚困难 |
|
|
9
|
+
|
|
10
|
+
**推荐**:优先考虑渐进式,除非项目规模小且业务简单。
|
|
11
|
+
|
|
12
|
+
## 概念映射
|
|
13
|
+
|
|
14
|
+
### jQuery → React
|
|
15
|
+
|
|
16
|
+
| 遗留模式 | React 对应 |
|
|
17
|
+
| ------------------------------------------ | -------------------------------------- |
|
|
18
|
+
| `$(selector).html(content)` | 声明式 JSX + state 驱动渲染 |
|
|
19
|
+
| `$(document).on('click', '.btn', handler)` | `onClick` + 事件委托由 React 处理 |
|
|
20
|
+
| `$.ajax()` / `$.get()` | 项目请求层、`fetch` / `axios`,可按需接 TanStack Query 或 SWR |
|
|
21
|
+
| 全局变量 / 命名空间存储状态 | 局部 state、Context 或项目既有 store,可按需使用 Zustand/Redux |
|
|
22
|
+
| `$(el).show()` / `$(el).hide()` | 条件渲染 `{visible && <Component />}` |
|
|
23
|
+
| 手动 DOM 操作 `append` / `remove` | 数据驱动,通过 setState 触发重渲染 |
|
|
24
|
+
| 模板字符串拼接 HTML | JSX 组件 + props |
|
|
25
|
+
| 多页面 + 服务端路由 | React Router 客户端路由 |
|
|
26
|
+
|
|
27
|
+
### jQuery → Vue 3
|
|
28
|
+
|
|
29
|
+
| 遗留模式 | Vue 3 对应 |
|
|
30
|
+
| ------------------------------------------ | -------------------------------------------------- |
|
|
31
|
+
| `$(selector).html(content)` | 模板 + `ref` / `reactive` 驱动渲染 |
|
|
32
|
+
| `$(document).on('click', '.btn', handler)` | `@click` + 事件修饰符 |
|
|
33
|
+
| `$.ajax()` / `$.get()` | 项目请求层、`fetch` / `axios`,可按需接 VueUse、Nuxt `useFetch` 或 TanStack Query Vue adapter |
|
|
34
|
+
| 全局变量 / 命名空间存储状态 | `ref` / `reactive` / Pinia |
|
|
35
|
+
| `$(el).show()` / `$(el).hide()` | `v-show` / `v-if` |
|
|
36
|
+
| 手动 DOM 操作 | 数据驱动,通过响应式更新视图 |
|
|
37
|
+
| 模板字符串拼接 HTML | 单文件组件 `<template>` + props |
|
|
38
|
+
| 多页面 + 服务端路由 | Vue Router 客户端路由 |
|
|
39
|
+
|
|
40
|
+
### 通用映射
|
|
41
|
+
|
|
42
|
+
| 遗留概念 | 现代对应 |
|
|
43
|
+
| --------------------------------- | ------------------------------------------ |
|
|
44
|
+
| 页面级 JS 入口(每页一个 script) | 路由/页面入口 + 懒加载模块,或保留 MPA 入口并现代化打包 |
|
|
45
|
+
| 公共 JS 模块(utils、ajax 封装) | `services/`、`utils/`、类型化 API 层 |
|
|
46
|
+
| 内联样式 / 页面级 CSS | 目标项目样式体系,如 CSS Modules、Tailwind、全局样式分层或组件库样式 |
|
|
47
|
+
| 服务端模板变量 | 通过 API 获取、SSR/loader 注入,或保留服务端模板边界并类型化数据 |
|
|
48
|
+
| 表单提交 + 整页刷新 | 表单库 + 客户端校验 + API 调用 |
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-legacy-web-standard
|
|
3
|
+
description: 用于维护或安全修改既有非框架前端代码:原生 JavaScript、jQuery、HTML/CSS、MPA 页面、服务端渲染模板、遗留插件或需要长期保持当前技术栈的代码。若是规划迁移到 React/Vue/TypeScript,请使用迁移 skill;中文触发词包括 传统前端、原生 JS、jQuery。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 传统前端项目规范(JS + jQuery + HTML)
|
|
7
|
+
|
|
8
|
+
## 用途
|
|
9
|
+
|
|
10
|
+
在不重写技术栈的前提下安全维护 vanilla JS、jQuery、HTML/CSS 和服务端模板项目。
|
|
11
|
+
|
|
12
|
+
## 流程
|
|
13
|
+
|
|
14
|
+
1. 先确认本次改动是维护旧栈还是迁移;迁移到 React/Vue/TypeScript 时切换到现代化迁移 workflow。
|
|
15
|
+
2. 沿用现有架构和代码风格,优先修复问题,不在一次改动中引入多项现代化。
|
|
16
|
+
3. JavaScript 用 IIFE/命名空间减少全局污染,事件绑定优先委托到合理容器。
|
|
17
|
+
4. DOM 更新缓存选择器、批量操作、转义用户输入;Ajax 必须处理 loading、error、空状态和防重复提交。
|
|
18
|
+
5. HTML/CSS 保持语义、label、alt、BEM/既有命名和低选择器深度。
|
|
19
|
+
6. 安全重点检查 `.html()`、`innerHTML`、URL 参数渲染、CSRF token 和文件上传。
|
|
20
|
+
|
|
21
|
+
## 详细参考
|
|
22
|
+
|
|
23
|
+
涉及 jQuery 命名空间、事件绑定、Ajax、XSS 转义、文件组织和维护清单示例时,加载 [references/legacy-patterns.md](references/legacy-patterns.md)。
|
|
24
|
+
|
|
25
|
+
## 约束
|
|
26
|
+
|
|
27
|
+
- 在现有架构内改进,不要引入与项目格格不入的现代框架。
|
|
28
|
+
- 渐进增强优于推倒重来。
|
|
29
|
+
- 禁止用 `innerHTML` / `.html()` 直接插入用户输入。
|
|
30
|
+
- 避免全局变量污染。
|
|
31
|
+
- 每次聚焦一个维护点,避免顺手重构整个模块。
|
|
32
|
+
|
|
33
|
+
## 预期输出
|
|
34
|
+
|
|
35
|
+
改动与旧项目风格一致,无全局变量泄漏,事件和 DOM 操作可维护,Ajax 状态完整,用户输入已转义,渐进改进不破坏现有功能。
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# 传统前端维护模式
|
|
2
|
+
|
|
3
|
+
## 命名空间
|
|
4
|
+
|
|
5
|
+
```javascript
|
|
6
|
+
var App = App || {};
|
|
7
|
+
App.UserModule = (function ($) {
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
function init() {
|
|
11
|
+
bindEvents();
|
|
12
|
+
loadData();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function bindEvents() {
|
|
16
|
+
$(document).on("click", ".js-submit-btn", handleSubmit);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return { init: init };
|
|
20
|
+
})(jQuery);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 事件与 DOM
|
|
24
|
+
|
|
25
|
+
- 事件触发元素用 `.js-*` class,与样式 class 分离。
|
|
26
|
+
- 缓存频繁使用的选择器。
|
|
27
|
+
- 批量 DOM 操作用 `DocumentFragment` 或一次性插入。
|
|
28
|
+
- 页面卸载或模块销毁时解绑事件或调用插件 destroy。
|
|
29
|
+
|
|
30
|
+
## Ajax
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
function fetchUserList(params) {
|
|
34
|
+
return $.ajax({
|
|
35
|
+
url: "/api/v1/users",
|
|
36
|
+
method: "GET",
|
|
37
|
+
data: params,
|
|
38
|
+
dataType: "json",
|
|
39
|
+
})
|
|
40
|
+
.done(function (res) {
|
|
41
|
+
if (res.code === 0) renderList(res.data);
|
|
42
|
+
else showError(res.message);
|
|
43
|
+
})
|
|
44
|
+
.fail(function () {
|
|
45
|
+
showError("网络错误,请稍后重试");
|
|
46
|
+
})
|
|
47
|
+
.always(function () {
|
|
48
|
+
hideLoading();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## XSS 转义
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
$(".username").text(userData.name);
|
|
57
|
+
|
|
58
|
+
function escapeHtml(str) {
|
|
59
|
+
var div = document.createElement("div");
|
|
60
|
+
div.appendChild(document.createTextNode(str));
|
|
61
|
+
return div.innerHTML;
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 文件组织
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
project/
|
|
69
|
+
├── css/
|
|
70
|
+
│ ├── common.css
|
|
71
|
+
│ └── pages/user-list.css
|
|
72
|
+
├── js/
|
|
73
|
+
│ ├── lib/jquery.min.js
|
|
74
|
+
│ ├── common/utils.js
|
|
75
|
+
│ └── pages/user-list.js
|
|
76
|
+
└── pages/
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 检查清单
|
|
80
|
+
|
|
81
|
+
- 没有全局变量泄漏。
|
|
82
|
+
- 事件绑定在合理容器上。
|
|
83
|
+
- Ajax 处理 loading/error/empty。
|
|
84
|
+
- 用户输入已转义。
|
|
85
|
+
- 未扩大第三方库或框架依赖。
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-list-virtualization
|
|
3
|
+
description: 用于优化或审查大列表、虚拟滚动、windowing、react-window、TanStack Virtual、可变高度行、动态测量、无限滚动、网格虚拟化或滚动性能;中文触发词包括 虚拟列表、大列表优化、滚动性能。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 列表虚拟化优化
|
|
7
|
+
|
|
8
|
+
## 用途
|
|
9
|
+
|
|
10
|
+
通过窗口化只渲染可视区域,解决大列表 DOM 过多和滚动卡顿。
|
|
11
|
+
|
|
12
|
+
## 流程
|
|
13
|
+
|
|
14
|
+
1. 先确认列表规模和瓶颈:500+ 项、滚动掉帧、DOM 节点过多或内存飙升才引入虚拟化。
|
|
15
|
+
2. 先遵循项目现有框架、依赖和设计系统约束,再按场景选库:React 可考虑 `react-window` 或 TanStack Virtual;Vue/Solid/Svelte、动态测量、网格或跨框架场景优先考虑 TanStack Virtual;遗留 `react-virtualized` 只维护不新增。
|
|
16
|
+
3. 明确 item size、overscan、容器高度、key、滚动容器和 resize 行为。
|
|
17
|
+
4. 无限滚动时分离数据分页和 DOM 虚拟化;数据获取可联用数据获取 workflow。
|
|
18
|
+
5. 验证 DOM 节点数、滚动 FPS、键盘/屏幕阅读器体验和 Ctrl+F/SEO 限制。
|
|
19
|
+
|
|
20
|
+
## 详细参考
|
|
21
|
+
|
|
22
|
+
涉及是否需要虚拟化、库选型、固定高度、可变/动态高度、无限滚动、网格虚拟化和性能注意事项时,加载 [references/virtualization-patterns.md](references/virtualization-patterns.md)。
|
|
23
|
+
|
|
24
|
+
## 约束
|
|
25
|
+
|
|
26
|
+
- SEO 关键内容不要只存在于虚拟项中。
|
|
27
|
+
- 浏览器原生 Ctrl+F 无法搜索未挂载项目。
|
|
28
|
+
- Row 根元素必须透传虚拟库提供的 style/measure ref。
|
|
29
|
+
- overscan 过大会浪费内存,过小会白屏。
|
|
30
|
+
- 动态高度测量要处理 ResizeObserver 和布局抖动。
|
|
31
|
+
|
|
32
|
+
## 预期输出
|
|
33
|
+
|
|
34
|
+
10000+ 项列表滚动接近 60fps,DOM 节点数稳定在可视区域及缓冲区范围,内存从 O(n) 降至 O(visible)。
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# 虚拟列表模式
|
|
2
|
+
|
|
3
|
+
## 先判断是否需要虚拟化
|
|
4
|
+
|
|
5
|
+
- 只有列表规模、渲染成本或滚动性能已经形成瓶颈时才引入虚拟化;小列表、轻量静态列表和分页后可控的列表不需要。
|
|
6
|
+
- SEO 关键内容、依赖浏览器原生 Ctrl+F 的全文内容、需要一次性打印/导出的内容,不要只存在于虚拟项中。
|
|
7
|
+
- 虚拟化只减少 DOM 渲染成本,不替代数据分页、接口缓存、图片懒加载或复杂行组件的渲染优化。
|
|
8
|
+
|
|
9
|
+
## 选型参考
|
|
10
|
+
|
|
11
|
+
先沿用项目已有虚拟列表库和框架约定;新增依赖时再按场景选择。
|
|
12
|
+
|
|
13
|
+
| 场景 | 候选方案 | 注意点 |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| React 固定高度列表 | `react-window` 或 TanStack Virtual | `react-window` 轻量稳定;TanStack Virtual 更适合统一复杂场景。 |
|
|
16
|
+
| React 可变高度列表 | `react-window` 的 `VariableSizeList` 或 TanStack Virtual | 高度可计算时两者都可用;内容真实高度会变化时需要测量和重置。 |
|
|
17
|
+
| 动态测量、聊天流、展开行 | TanStack Virtual | 配合 `measureElement` / ResizeObserver,处理布局抖动和滚动锚点。 |
|
|
18
|
+
| Vue / Solid / Svelte / 跨框架 | TanStack Virtual 或项目既有生态库 | 不要为非 React 项目引入 React-only 虚拟列表库。 |
|
|
19
|
+
| 二维网格、表格、列虚拟化 | TanStack Virtual row/column 双轴方案或现有表格库虚拟化能力 | 固定列、粘性表头和键盘导航需要单独验证。 |
|
|
20
|
+
| 遗留 `react-virtualized` 项目 | 维护现有实现 | 不建议新功能继续扩散;大改时评估迁移成本。 |
|
|
21
|
+
|
|
22
|
+
## 通用实现原则
|
|
23
|
+
|
|
24
|
+
- 容器高度必须稳定,滚动容器必须明确,item key 必须来自稳定业务标识。
|
|
25
|
+
- 行根元素必须透传虚拟库提供的 `style`、定位属性和测量 ref。
|
|
26
|
+
- `overscan` 按设备和行渲染成本调节:过小会白屏,过大会接近全量渲染。
|
|
27
|
+
- 动态高度需要估算高度、真实测量、resize 更新和滚动锚点策略。
|
|
28
|
+
- 无限滚动要分离“数据分页”和“DOM 虚拟化”;不要在 render 阶段无条件触发请求。
|
|
29
|
+
- 验证键盘导航、屏幕阅读器语义、焦点保持、滚动恢复、空态/加载态和错误态。
|
|
30
|
+
|
|
31
|
+
## React 固定高度示例
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { FixedSizeList as List } from "react-window";
|
|
35
|
+
|
|
36
|
+
const Row = ({ index, style, data }: { index: number; style: React.CSSProperties; data: User[] }) => (
|
|
37
|
+
<div style={style}>{data[index].name}</div>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export const UserList = ({ users }: { users: User[] }) => (
|
|
41
|
+
<List height={500} itemCount={users.length} itemSize={48} width="100%" itemData={users}>
|
|
42
|
+
{Row}
|
|
43
|
+
</List>
|
|
44
|
+
);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## React 可变高度示例
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { VariableSizeList as List } from "react-window";
|
|
51
|
+
|
|
52
|
+
const getItemSize = (index: number) => (items[index].hasSummary ? 120 : 60);
|
|
53
|
+
|
|
54
|
+
<List height={600} itemCount={items.length} itemSize={getItemSize} width="100%">
|
|
55
|
+
{CardRow}
|
|
56
|
+
</List>;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## TanStack Virtual 动态高度示例
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
const virtualizer = useVirtualizer({
|
|
63
|
+
count: messages.length,
|
|
64
|
+
getScrollElement: () => parentRef.current,
|
|
65
|
+
estimateSize: () => 60,
|
|
66
|
+
overscan: 5,
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
动态内容需要测量元素并处理 ResizeObserver;Vue/Solid/Svelte 项目使用 TanStack Virtual 对应框架 adapter,核心选项保持一致。
|
|
71
|
+
|
|
72
|
+
## 无限滚动
|
|
73
|
+
|
|
74
|
+
- `count` 包含 loader 占位项。
|
|
75
|
+
- 最后一个虚拟项进入视口时调用 `fetchNextPage()`。
|
|
76
|
+
- 不要在 render 中无条件触发请求,使用 effect 或明确状态保护。
|
|
77
|
+
|
|
78
|
+
## 网格虚拟化
|
|
79
|
+
|
|
80
|
+
二维网格使用 `FixedSizeGrid` 或 TanStack Virtual 的 row/column 双轴方案,确保单元格 style 透传。
|