@bovinphang/frontend-craft 2.7.0 → 2.9.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 +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +378 -305
- package/CHANGELOG.zh-CN.md +377 -304
- package/CONTRIBUTING.md +371 -361
- package/CONTRIBUTING.zh-CN.md +371 -361
- package/README.md +545 -493
- package/README.openclaw.md +359 -264
- package/README.openclaw.zh-CN.md +359 -264
- package/README.zh-CN.md +545 -493
- package/agents/fec-architect.md +70 -70
- package/agents/fec-code-reviewer.md +103 -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 +17 -14
- package/agents/fec-refactoring-expert.md +81 -0
- package/agents/fec-security-reviewer.md +82 -67
- package/agents/fec-test-planner.md +27 -27
- package/agents/fec-typescript-reviewer.md +103 -87
- package/agents/fec-ui-checker.md +64 -64
- 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-refactor-plan.md +17 -0
- package/commands/fec-refactor.md +18 -0
- package/commands/fec-review.md +71 -41
- package/commands/fec-scaffold.md +41 -41
- package/commands/fec-smell.md +17 -0
- package/commands/fec-tdd.md +17 -13
- package/dist/bin/frontend-craft.js +190 -36
- package/dist/hooks/fec-run-tests.js +5 -1
- package/dist/hooks/fec-session-start.js +1 -1
- package/docs/example-prompts.md +157 -137
- package/docs/ja-JP/README.md +534 -493
- package/docs/ko-KR/README.md +534 -493
- package/docs/project-structure.md +151 -123
- package/docs/refactoring/README.md +50 -0
- package/docs/refactoring/catalog.md +105 -0
- package/docs/refactoring/smell-refactoring-matrix.md +41 -0
- package/docs/review-and-diagram-workflows.md +39 -0
- package/docs/runtimes/antigravity.md +18 -10
- package/docs/runtimes/augment.md +18 -10
- package/docs/runtimes/claude.md +191 -177
- package/docs/runtimes/claude.zh-CN.md +189 -175
- package/docs/runtimes/cline.md +18 -10
- package/docs/runtimes/codebuddy.md +18 -10
- package/docs/runtimes/codex.md +18 -10
- package/docs/runtimes/compatibility.md +27 -0
- package/docs/runtimes/copilot.md +18 -10
- package/docs/runtimes/cursor.md +18 -10
- package/docs/runtimes/gemini.md +18 -10
- package/docs/runtimes/kilo.md +18 -10
- package/docs/runtimes/openclaw.md +18 -10
- package/docs/runtimes/opencode.md +18 -10
- package/docs/runtimes/qoder.md +18 -19
- package/docs/runtimes/trae.md +18 -10
- package/docs/runtimes/windsurf.md +18 -10
- package/docs/superpowers/plans/2026-09-26-content-integrity.md +145 -0
- package/docs/superpowers/plans/2026-09-26-diagram-quality.md +170 -0
- package/docs/superpowers/specs/2026-09-26-diagram-quality-design.md +77 -0
- package/docs/superpowers/specs/2026-09-26-project-optimization-design.md +95 -0
- package/docs/zh-CN/example-prompts.md +157 -137
- package/docs/zh-CN/project-structure.md +148 -123
- package/docs/zh-CN/review-and-diagram-workflows.md +39 -0
- package/docs/zh-TW/README.md +534 -493
- package/localized/zh-CN/agents/fec-architect.md +125 -0
- package/localized/zh-CN/agents/fec-code-reviewer.md +171 -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 +35 -0
- package/localized/zh-CN/agents/fec-refactoring-expert.md +53 -0
- package/localized/zh-CN/agents/fec-security-reviewer.md +132 -0
- package/localized/zh-CN/agents/fec-test-planner.md +50 -0
- package/localized/zh-CN/agents/fec-typescript-reviewer.md +158 -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-refactor-plan.md +15 -0
- package/localized/zh-CN/commands/fec-refactor.md +14 -0
- package/localized/zh-CN/commands/fec-review.md +97 -0
- package/localized/zh-CN/commands/fec-scaffold.md +205 -0
- package/localized/zh-CN/commands/fec-smell.md +13 -0
- package/localized/zh-CN/commands/fec-tdd.md +25 -0
- package/localized/zh-CN/skills/TEMPLATE.md +155 -0
- package/localized/zh-CN/skills/eval_queries.json +1257 -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 +162 -0
- package/localized/zh-CN/skills/fec-code-review/references/report-template.md +39 -0
- package/localized/zh-CN/skills/fec-code-smells/SKILL.md +33 -0
- package/localized/zh-CN/skills/fec-code-smells/references/detection-guide.md +25 -0
- package/localized/zh-CN/skills/fec-code-smells/references/smell-catalog.md +817 -0
- package/localized/zh-CN/skills/fec-code-smells/references/smell-to-refactoring-map.md +265 -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 +110 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/README.md +14 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/architecture.json +121 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/invalid-explicit.json +41 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/sequence.json +53 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/sequence.mmd +21 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/workflow.json +98 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/workflow.mmd +7 -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 +81 -0
- package/localized/zh-CN/skills/fec-image-generation/references/html-technical-diagrams.md +243 -0
- package/localized/zh-CN/skills/fec-image-generation/references/png-qa-autofix.md +37 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/diagram-browser.mjs +90 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/diagram-layout.mjs +176 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/export-diagram.mjs +332 -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/mermaid-render.mjs +64 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/png-qa.mjs +462 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1537 -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 +54 -0
- package/localized/zh-CN/skills/fec-refactor-clean/references/report-template.md +42 -0
- package/localized/zh-CN/skills/fec-refactoring/SKILL.md +83 -0
- package/localized/zh-CN/skills/fec-refactoring/references/principles.md +43 -0
- package/localized/zh-CN/skills/fec-refactoring/references/refactoring-vs-feature-change.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring/references/when-to-refactor.md +17 -0
- package/localized/zh-CN/skills/fec-refactoring/references/workflow.md +59 -0
- package/localized/zh-CN/skills/fec-refactoring-api/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-api/references/api-refactorings.md +496 -0
- package/localized/zh-CN/skills/fec-refactoring-catalog/SKILL.md +21 -0
- package/localized/zh-CN/skills/fec-refactoring-catalog/references/catalog-index.md +99 -0
- package/localized/zh-CN/skills/fec-refactoring-catalog/references/composition-guide.md +49 -0
- package/localized/zh-CN/skills/fec-refactoring-catalog/references/selection-guide.md +41 -0
- package/localized/zh-CN/skills/fec-refactoring-control/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-control/references/conditional-refactorings.md +299 -0
- package/localized/zh-CN/skills/fec-refactoring-data/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-data/references/data-refactorings.md +248 -0
- package/localized/zh-CN/skills/fec-refactoring-encapsulation/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-encapsulation/references/encapsulation-refactorings.md +452 -0
- package/localized/zh-CN/skills/fec-refactoring-functions/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-functions/references/function-refactorings.md +567 -0
- package/localized/zh-CN/skills/fec-refactoring-inheritance/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-inheritance/references/inheritance-refactorings.md +550 -0
- package/localized/zh-CN/skills/fec-refactoring-move-features/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-move-features/references/moving-refactorings.md +453 -0
- package/localized/zh-CN/skills/fec-refactoring-validation/SKILL.md +52 -0
- package/localized/zh-CN/skills/fec-refactoring-validation/references/behavior-preservation.md +15 -0
- package/localized/zh-CN/skills/fec-refactoring-validation/references/refactoring-test-checklist.md +25 -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 +54 -0
- package/localized/zh-CN/skills/fec-security-review/references/report-template.md +37 -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 +55 -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 +2004 -0
- package/localized/zh-CN/skills/relations.json +1023 -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 +55 -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 +2 -3
- package/package.json +28 -17
- package/skills/TEMPLATE.md +74 -74
- package/skills/eval_queries.json +922 -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 +113 -94
- package/skills/fec-code-review/references/report-template.md +23 -13
- package/skills/fec-code-smells/SKILL.md +33 -0
- package/skills/fec-code-smells/references/detection-guide.md +25 -0
- package/skills/fec-code-smells/references/smell-catalog.md +861 -0
- package/skills/fec-code-smells/references/smell-to-refactoring-map.md +265 -0
- 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 +84 -29
- package/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
- package/skills/fec-image-generation/assets/quality-examples/README.md +14 -0
- package/skills/fec-image-generation/assets/quality-examples/architecture.json +121 -0
- package/skills/fec-image-generation/assets/quality-examples/invalid-explicit.json +41 -0
- package/skills/fec-image-generation/assets/quality-examples/sequence.json +53 -0
- package/skills/fec-image-generation/assets/quality-examples/sequence.mmd +21 -0
- package/skills/fec-image-generation/assets/quality-examples/workflow.json +98 -0
- package/skills/fec-image-generation/assets/quality-examples/workflow.mmd +7 -0
- package/skills/fec-image-generation/references/diagram-workflows.md +41 -3
- package/skills/fec-image-generation/references/html-technical-diagrams.md +243 -0
- package/skills/fec-image-generation/references/png-qa-autofix.md +9 -2
- package/skills/fec-image-generation/scripts/diagram-browser.mjs +90 -0
- package/skills/fec-image-generation/scripts/diagram-layout.mjs +176 -0
- package/skills/fec-image-generation/scripts/export-diagram.mjs +332 -0
- package/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
- package/skills/fec-image-generation/scripts/mermaid-render.mjs +64 -0
- package/skills/fec-image-generation/scripts/png-qa.mjs +35 -4
- package/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1537 -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 +33 -30
- package/skills/fec-refactor-clean/references/report-template.md +23 -23
- package/skills/fec-refactoring/SKILL.md +83 -0
- package/skills/fec-refactoring/references/principles.md +60 -0
- package/skills/fec-refactoring/references/refactoring-vs-feature-change.md +27 -0
- package/skills/fec-refactoring/references/when-to-refactor.md +31 -0
- package/skills/fec-refactoring/references/workflow.md +90 -0
- package/skills/fec-refactoring-api/SKILL.md +25 -0
- package/skills/fec-refactoring-api/references/api-refactorings.md +496 -0
- package/skills/fec-refactoring-catalog/SKILL.md +28 -0
- package/skills/fec-refactoring-catalog/references/catalog-index.md +99 -0
- package/skills/fec-refactoring-catalog/references/composition-guide.md +49 -0
- package/skills/fec-refactoring-catalog/references/selection-guide.md +47 -0
- package/skills/fec-refactoring-control/SKILL.md +25 -0
- package/skills/fec-refactoring-control/references/conditional-refactorings.md +299 -0
- package/skills/fec-refactoring-data/SKILL.md +25 -0
- package/skills/fec-refactoring-data/references/data-refactorings.md +248 -0
- package/skills/fec-refactoring-encapsulation/SKILL.md +25 -0
- package/skills/fec-refactoring-encapsulation/references/encapsulation-refactorings.md +452 -0
- package/skills/fec-refactoring-functions/SKILL.md +25 -0
- package/skills/fec-refactoring-functions/references/function-refactorings.md +567 -0
- package/skills/fec-refactoring-inheritance/SKILL.md +25 -0
- package/skills/fec-refactoring-inheritance/references/inheritance-refactorings.md +550 -0
- package/skills/fec-refactoring-move-features/SKILL.md +25 -0
- package/skills/fec-refactoring-move-features/references/moving-refactorings.md +453 -0
- package/skills/fec-refactoring-validation/SKILL.md +59 -0
- package/skills/fec-refactoring-validation/references/behavior-preservation.md +53 -0
- package/skills/fec-refactoring-validation/references/refactoring-test-checklist.md +42 -0
- 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 +36 -20
- package/skills/fec-security-review/references/report-template.md +22 -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 +32 -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 +485 -116
- package/skills/relations.json +268 -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 +41 -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/docs/superpowers/plans/2026-05-29-fec-debug.md +0 -491
- package/docs/superpowers/specs/2026-05-29-fec-debug-design.md +0 -340
- package/skills/fec-drawio-studio/data/shape-index.json.gz +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# 框架专项性能诊断模式
|
|
2
|
+
|
|
3
|
+
本参考用于已经进入性能优化流程后的专项定位。先建立目标、基线和候选门禁,再按框架读取对应分类;不要从这些清单直接跳到结论。
|
|
4
|
+
|
|
5
|
+
## React / Client React
|
|
6
|
+
|
|
7
|
+
- **Waterfall**:独立请求、权限检查、feature flag 或子组件数据是否被串行等待。用 Network waterfall、React Profiler 或用户路径日志确认依赖关系。
|
|
8
|
+
- **Bundle**:首屏是否同步引入图表、编辑器、地图、3D、全量图标、重型日期库或 barrel export。用构建产物、source map 或 bundle analyzer 定位 chunk。
|
|
9
|
+
- **Rerender**:Context 是否过宽,selector 是否过粗,默认对象/数组 props 是否每次新建,昂贵派生是否在热路径重复执行。用 React Profiler 或可复现交互证明。
|
|
10
|
+
- **Effect**:是否用 effect 保存可直接推导的数据,是否把交互逻辑放进 effect,是否缺少取消、清理或稳定依赖。用渲染次数、请求次数或内存/订阅证据确认。
|
|
11
|
+
- **Lazy boundary**:Suspense、动态 import、错误 fallback、loading/empty/error 状态是否成对出现,懒加载是否破坏焦点或首屏布局稳定性。
|
|
12
|
+
|
|
13
|
+
## Vue 3 / Nuxt Client
|
|
14
|
+
|
|
15
|
+
- **Reactive payload size**:大型对象、表格数据或第三方实例是否被深层响应式代理。用组件更新、内存快照或长任务证据判断是否需要浅响应式或不可变边界。
|
|
16
|
+
- **Computed/watch**:本该 computed 的派生值是否用大范围 watcher 手动同步,watch 是否监听过宽对象,异步 watch 是否缺少取消和竞态处理。
|
|
17
|
+
- **Template hot path**:`v-for` 中是否混用 `v-if`、内联重计算、缺少稳定 `:key`,或在大列表中渲染非视区节点。
|
|
18
|
+
- **Async component boundary**:重型组件是否使用异步组件或路由级动态导入,加载状态是否稳定,错误态是否可恢复。
|
|
19
|
+
- **Store fan-out**:Pinia store 是否把高频 UI 临时状态扩散到大范围订阅者,或把服务端缓存复制到全局 store。
|
|
20
|
+
|
|
21
|
+
## Next.js
|
|
22
|
+
|
|
23
|
+
- **Dynamic route drift**:cookies、headers、searchParams 或未缓存 fetch 是否让静态路由变动态。用构建输出、响应头或路由行为确认。
|
|
24
|
+
- **RSC serialization**:Server Component 是否向 Client Component 传递过大 props、重复数据或不可序列化结构。
|
|
25
|
+
- **Fetch/cache policy**:`force-cache`、`no-store`、`revalidate`、tag/path revalidation 是否与数据私有性和更新频率匹配。
|
|
26
|
+
- **Client boundary leakage**:根布局或高层客户端边界是否同步带入重型浏览器库、Provider 或不必要状态。
|
|
27
|
+
- **Middleware cost**:middleware 是否承载重型查询、日志批处理或可放到 route handler 的业务逻辑。
|
|
28
|
+
|
|
29
|
+
## Nuxt 3
|
|
30
|
+
|
|
31
|
+
- **Rendering mode mismatch**:页面是否应为 SSR、SSG、ISR/route rules 或 SPA,实际行为是否和部署目标一致。
|
|
32
|
+
- **Data duplication**:`useFetch` / `useAsyncData` 是否重复请求,key 是否稳定,客户端 hydration 是否重复拉取同一数据。
|
|
33
|
+
- **Route middleware cost**:路由中间件是否做重型异步工作、重复鉴权请求或不可缓存的全局阻塞逻辑。
|
|
34
|
+
- **Client-only islands**:只在浏览器运行的图表、编辑器、地图或 WebGL 是否被隔离到 client-only 或异步边界。
|
|
35
|
+
|
|
36
|
+
## 输出要求
|
|
37
|
+
|
|
38
|
+
每个框架专项建议都要写清楚:证据来源、受影响路由/组件/chunk/请求、建议改法、验证命令和可能影响的 loading、error、empty、offline、reduced-motion 或移动端状态。
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# 性能分析报告模板
|
|
2
|
+
|
|
3
|
+
```markdown
|
|
4
|
+
# 前端性能分析报告
|
|
5
|
+
|
|
6
|
+
> 生成时间: YYYY-MM-DD HH:mm
|
|
7
|
+
> 目标页面/流程: ...
|
|
8
|
+
> 环境: 设备、浏览器、网络、分支或版本
|
|
9
|
+
|
|
10
|
+
## 性能目标
|
|
11
|
+
|
|
12
|
+
- 关注指标: LCP / CLS / INP / TBT / bundle size / memory / FPS
|
|
13
|
+
- 项目预算或目标阈值
|
|
14
|
+
- 用户主路径和 P95 场景
|
|
15
|
+
|
|
16
|
+
## 基线数据
|
|
17
|
+
|
|
18
|
+
| 指标 | 当前值 | 采集方式 | 备注 |
|
|
19
|
+
| --- | --- | --- | --- |
|
|
20
|
+
| LCP | ... | Lighthouse / RUM / trace | ... |
|
|
21
|
+
|
|
22
|
+
## 瓶颈定位
|
|
23
|
+
|
|
24
|
+
- 加载层、渲染层、数据层、主线程或资源层问题
|
|
25
|
+
- 关联文件、路由、chunk、组件或请求
|
|
26
|
+
- 支持该判断的 trace、bundle、日志或截图证据
|
|
27
|
+
|
|
28
|
+
## 候选门禁
|
|
29
|
+
|
|
30
|
+
| 候选问题 | 指标支撑 | 定位范围 | 前端可验证性 | 结论 |
|
|
31
|
+
| --- | --- | --- | --- | --- |
|
|
32
|
+
| ... | RUM / trace / bundle / network | route / component / chunk / request | 是 / 否 / 需协作 | investigate / defer / reject |
|
|
33
|
+
|
|
34
|
+
## 优先级
|
|
35
|
+
|
|
36
|
+
| 优先级 | 问题 | 用户影响 | 风险 |
|
|
37
|
+
| --- | --- | --- | --- |
|
|
38
|
+
| P0 / P1 / P2 | ... | ... | ... |
|
|
39
|
+
|
|
40
|
+
## 优化方案
|
|
41
|
+
|
|
42
|
+
- 具体改法
|
|
43
|
+
- 替代方案
|
|
44
|
+
- 可维护性、可访问性和产品行为影响
|
|
45
|
+
|
|
46
|
+
## 验证对比
|
|
47
|
+
|
|
48
|
+
| 指标 | 优化前 | 优化后 | 采集方式 |
|
|
49
|
+
| --- | --- | --- | --- |
|
|
50
|
+
| ... | ... | ... | ... |
|
|
51
|
+
|
|
52
|
+
## 剩余风险
|
|
53
|
+
|
|
54
|
+
- 未覆盖设备、网络或浏览器
|
|
55
|
+
- 需要后端、设计、产品或基础设施协作的部分
|
|
56
|
+
- 建议监控或后续任务
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
分析完成后,将报告保存到 `reports/performance-review-YYYY-MM-DD-HHmmss.md`,并告知用户报告路径。
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-pwa-implementation
|
|
3
|
+
description: 用于添加或审查 Progressive Web App 能力,如可安装性、manifest 元数据、Service Worker 注册、Workbox 缓存、离线兜底、应用更新提示、maskable icons 或 iOS PWA 兼容性。不要用于普通 API 缓存或不可安装的性能调优;中文触发词包括 PWA、离线、Service Worker。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PWA 实现
|
|
7
|
+
|
|
8
|
+
## 用途
|
|
9
|
+
|
|
10
|
+
让 Web 应用具备可安装、离线兜底和可控更新能力。
|
|
11
|
+
|
|
12
|
+
## 流程
|
|
13
|
+
|
|
14
|
+
1. 确认 PWA 是否值得做:面向移动端/桌面安装、弱网离线、重复访问场景时优先;纯内部后台、强实时流媒体或只需要普通缓存时不要强行 PWA。
|
|
15
|
+
2. 先补齐 manifest、图标、主题色和 HTML 引用;图标至少覆盖 192/512,Android 需 maskable,iOS 需 apple touch icon。
|
|
16
|
+
3. 注册 Service Worker,并设计更新提示;不要静默 `skipWaiting()` 后强刷用户页面。
|
|
17
|
+
4. 用 Workbox 或框架插件管理 precache/runtime cache;登录、支付、权限变更等敏感请求必须走网络。
|
|
18
|
+
5. 提供 offline fallback 页面和安装提示 UI,并验证首次加载、离线访问、更新激活、卸载重装。
|
|
19
|
+
|
|
20
|
+
## 详细参考
|
|
21
|
+
|
|
22
|
+
- 需要 manifest 字段、HTML 引用、图标要求、截图和 iOS 注意事项时,加载 [references/manifest-and-icons.md](references/manifest-and-icons.md)。
|
|
23
|
+
- 需要 Service Worker 注册、Workbox 策略、Vite 集成、离线兜底和更新流程时,加载 [references/service-worker-workbox.md](references/service-worker-workbox.md)。
|
|
24
|
+
|
|
25
|
+
## 约束
|
|
26
|
+
|
|
27
|
+
- Service Worker 仅在 HTTPS 下工作(localhost 除外)。
|
|
28
|
+
- 缓存策略必须区分页面、静态资源、API 与敏感操作;不要把登录、支付、权限接口缓存起来。
|
|
29
|
+
- Service Worker 更新有生命周期延迟;用户可见刷新提示优先于强制刷新。
|
|
30
|
+
- iOS PWA 能力弱于 Android,安装、推送和生命周期都要单独验证。
|
|
31
|
+
- 缓存有配额和逐出机制,必须设置 max entries / max age。
|
|
32
|
+
|
|
33
|
+
## 预期输出
|
|
34
|
+
|
|
35
|
+
产出可安装的 Web 应用、离线 fallback、可见更新提示和明确缓存策略。验证 Lighthouse PWA、DevTools Application 面板、离线模式、更新发布和移动端安装流程。
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Manifest、图标与安装入口
|
|
2
|
+
|
|
3
|
+
## Manifest 示例
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"name": "我的应用",
|
|
8
|
+
"short_name": "应用",
|
|
9
|
+
"start_url": "/",
|
|
10
|
+
"display": "standalone",
|
|
11
|
+
"background_color": "#ffffff",
|
|
12
|
+
"theme_color": "#0052cc",
|
|
13
|
+
"description": "应用描述",
|
|
14
|
+
"icons": [
|
|
15
|
+
{
|
|
16
|
+
"src": "/icon-192.png",
|
|
17
|
+
"sizes": "192x192",
|
|
18
|
+
"type": "image/png",
|
|
19
|
+
"purpose": "any maskable"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"src": "/icon-512.png",
|
|
23
|
+
"sizes": "512x512",
|
|
24
|
+
"type": "image/png",
|
|
25
|
+
"purpose": "any maskable"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"screenshots": [
|
|
29
|
+
{
|
|
30
|
+
"src": "/screenshot-desktop.png",
|
|
31
|
+
"sizes": "1280x720",
|
|
32
|
+
"type": "image/png",
|
|
33
|
+
"form_factor": "wide"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## HTML 引用
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<link rel="manifest" href="/manifest.json" />
|
|
43
|
+
<meta name="theme-color" content="#0052cc" />
|
|
44
|
+
<link rel="apple-touch-icon" href="/icon-192.png" />
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 检查要点
|
|
48
|
+
|
|
49
|
+
- `display: "standalone"` 才有接近原生应用的启动体验。
|
|
50
|
+
- `purpose: "any maskable"` 避免 Android 自适应图标被裁剪。
|
|
51
|
+
- `start_url` 应指向登录后或游客可安全进入的入口。
|
|
52
|
+
- `screenshots` 会影响安装对话框质量。
|
|
53
|
+
- iOS 仍依赖 `apple-touch-icon`,安装提示也通常需要用户手动完成。
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Service Worker、Workbox 与更新流
|
|
2
|
+
|
|
3
|
+
## 注册 Service Worker
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
export function registerServiceWorker() {
|
|
7
|
+
if (!("serviceWorker" in navigator)) return;
|
|
8
|
+
|
|
9
|
+
window.addEventListener("load", async () => {
|
|
10
|
+
const registration = await navigator.serviceWorker.register("/sw.js", {
|
|
11
|
+
scope: "/",
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
registration.addEventListener("updatefound", () => {
|
|
15
|
+
const nextWorker = registration.installing;
|
|
16
|
+
nextWorker?.addEventListener("statechange", () => {
|
|
17
|
+
if (nextWorker.state === "installed" && navigator.serviceWorker.controller) {
|
|
18
|
+
showUpdatePrompt();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 缓存策略
|
|
27
|
+
|
|
28
|
+
| 策略 | 适用 | 注意 |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| `CacheFirst` | 带 hash 的图片、字体、CSS/JS | 必须设置过期策略 |
|
|
31
|
+
| `NetworkFirst` | 页面导航、低风险 GET API | 网络失败才降级缓存 |
|
|
32
|
+
| `StaleWhileRevalidate` | 字体、头像、低风险静态数据 | 用户会先看到旧数据 |
|
|
33
|
+
| `NetworkOnly` | 登录、支付、权限、写操作 | 不进入 SW 缓存 |
|
|
34
|
+
|
|
35
|
+
## Vite 集成
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { VitePWA } from "vite-plugin-pwa";
|
|
39
|
+
import { defineConfig } from "vite";
|
|
40
|
+
|
|
41
|
+
export default defineConfig({
|
|
42
|
+
plugins: [
|
|
43
|
+
VitePWA({
|
|
44
|
+
registerType: "prompt",
|
|
45
|
+
injectRegister: "auto",
|
|
46
|
+
workbox: {
|
|
47
|
+
globPatterns: ["**/*.{js,css,html,ico,png,svg,woff2}"],
|
|
48
|
+
runtimeCaching: [
|
|
49
|
+
{
|
|
50
|
+
urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp)$/,
|
|
51
|
+
handler: "CacheFirst",
|
|
52
|
+
options: {
|
|
53
|
+
cacheName: "images",
|
|
54
|
+
expiration: { maxEntries: 100, maxAgeSeconds: 30 * 24 * 60 * 60 },
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
],
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 离线与更新
|
|
65
|
+
|
|
66
|
+
- 为未缓存页面准备 `/offline.html`,不要让用户只看到浏览器错误页。
|
|
67
|
+
- 更新提示应说明“新版本已可用”,由用户确认刷新。
|
|
68
|
+
- 调试时使用 DevTools Application 面板,必要时清理旧 Service Worker 和 Cache Storage。
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-react-project-standard
|
|
3
|
+
description: 用于设计或审查 React + TypeScript 项目结构、feature/module 边界、组件架构、hooks 组织、路由组合、状态/API/错误/样式默认约定或仓库级 React 规范。表单、数据获取、测试、无障碍、虚拟列表、动画或安全深挖优先使用更窄的 skill;中文触发词包括 React 项目规范、React 组件架构。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# React 项目规范
|
|
7
|
+
|
|
8
|
+
适用于 React + TypeScript 仓库中的中大型模块建设、页面重构和工程结构设计。
|
|
9
|
+
|
|
10
|
+
## 用途
|
|
11
|
+
|
|
12
|
+
为 React + TypeScript 项目提供工程结构、模块边界和默认实现约定,确保架构清晰、代码可维护。
|
|
13
|
+
|
|
14
|
+
## 流程
|
|
15
|
+
|
|
16
|
+
本 skill 主要解决 React 工程任务“如何设计和落地”的问题,不重复声明基础编码底线。处理 React 工程化任务时,按以下顺序执行:
|
|
17
|
+
|
|
18
|
+
1. 识别仓库已有约定
|
|
19
|
+
- 目录组织方式
|
|
20
|
+
- 样式体系
|
|
21
|
+
- 状态管理方案
|
|
22
|
+
- 请求封装方式
|
|
23
|
+
- 测试框架
|
|
24
|
+
- UI 组件库 / 设计系统
|
|
25
|
+
|
|
26
|
+
2. 判断目标属于哪一层
|
|
27
|
+
- 路由页面
|
|
28
|
+
- 页面私有组件
|
|
29
|
+
- feature 业务模块
|
|
30
|
+
- 全局通用组件
|
|
31
|
+
- hooks / services / stores / utils
|
|
32
|
+
|
|
33
|
+
3. 设计边界后再落代码
|
|
34
|
+
- 哪些逻辑属于页面编排
|
|
35
|
+
- 哪些逻辑属于 feature
|
|
36
|
+
- 哪些逻辑应下沉为通用能力
|
|
37
|
+
- 哪些状态应本地管理,哪些应交给 store / query / URL
|
|
38
|
+
- 状态归属复杂时使用状态管理流程先做状态清单
|
|
39
|
+
- DTO、公共 props、泛型组件或 `tsconfig` 边界复杂时,先使用 TypeScript 项目规范流程收敛跨框架类型契约
|
|
40
|
+
|
|
41
|
+
4. 输出时补齐关键质量项
|
|
42
|
+
- loading / error / empty / data 状态
|
|
43
|
+
- 错误处理与重试
|
|
44
|
+
- 类型约束
|
|
45
|
+
- 关键测试入口
|
|
46
|
+
- 必要的专项 skill 分流
|
|
47
|
+
- 依赖是否已存在于 `package.json`,缺失时先给安装命令再使用
|
|
48
|
+
- 重型 UI 能力(动效、图表、3D、编辑器、地图)是否隔离为 leaf component 并按需加载
|
|
49
|
+
- 图片、视频、字体等资源是否本地化、可缓存,并避免占位 URL 进入交付
|
|
50
|
+
- 页面级 Error Boundary、模块级 fallback、API 错误映射和用户可恢复动作是否一致
|
|
51
|
+
- Tailwind token/variant 或响应式布局需求是否应分流到对应专项 skill
|
|
52
|
+
- 对明显架构性能风险做轻量筛查,如重型依赖边界、过宽 Context、高频派生值和懒加载 fallback;需要指标证据时进入性能优化 workflow
|
|
53
|
+
|
|
54
|
+
## 详细参考
|
|
55
|
+
|
|
56
|
+
按需要加载更细的参考文件:
|
|
57
|
+
|
|
58
|
+
- 项目目录、组件分层、组件边界和组件目录建议:加载 [references/react-project-structure.md](references/react-project-structure.md)。
|
|
59
|
+
- 组件模式、Hooks、路由、状态归属、API 层、错误处理和 Suspense/懒加载:加载 [references/react-runtime-patterns.md](references/react-runtime-patterns.md)。
|
|
60
|
+
- 样式、注释、TypeScript、测试、反模式和输出检查清单:加载 [references/react-quality-patterns.md](references/react-quality-patterns.md)。
|
|
61
|
+
- React 项目规范层面的轻量性能约定:加载 [references/react-performance-patterns.md](references/react-performance-patterns.md)。
|
|
62
|
+
|
|
63
|
+
## 约束
|
|
64
|
+
|
|
65
|
+
- 默认遵守仓库现有全局规则和 React rule
|
|
66
|
+
- 若仓库已有明确目录结构、样式体系、状态管理或请求封装,优先沿用仓库约定
|
|
67
|
+
- 组件文件规模宜约 **300 行**内;逾 **500 行**或复杂度过高须拆分子组件、Hooks、utils、类型
|
|
68
|
+
- 禁止新增类组件(Error Boundary 用 `react-error-boundary` 等库)
|
|
69
|
+
- 禁止绕过模块出口,从 feature 深层路径导入
|
|
70
|
+
- 不要用 `useEffect + setState` 模拟本可直接计算的派生值
|
|
71
|
+
- 避免 prop drilling 过深却不考虑组合或局部封装
|
|
72
|
+
- 不在通用页面组件里同步引入 GSAP、Three.js、Lottie、富文本编辑器或地图 SDK;需要时用动态导入、路由级分包或叶子组件隔离。
|
|
73
|
+
- 不在 React 组件中散落裸 `fetch`、API URL、token refresh 或上传流程;跨边界请求应收敛到 API 集成层。
|
|
74
|
+
- 不用 Error Boundary 处理普通 API 失败;请求错误应优先落到 loading/error/empty/data 状态和可恢复操作。
|
|
75
|
+
- 不把 React 性能建议写成无证据的全局 memo 化;先定位请求瀑布、bundle 边界、重复渲染或 effect 误用。
|
|
76
|
+
|
|
77
|
+
## 预期输出
|
|
78
|
+
|
|
79
|
+
- 组件边界清晰,pages/features/components 分层明确
|
|
80
|
+
- Props 类型完整且明确;复杂公共类型或外部数据收窄已分流到 TypeScript 项目规范流程
|
|
81
|
+
- 可复用逻辑已提取为 hooks,loading/error/empty/data 状态齐全
|
|
82
|
+
- API 层具备类型约束和统一错误处理,状态管理符合就近原则
|
|
83
|
+
- URL 状态、服务端状态、表单状态和全局客户端状态边界明确
|
|
84
|
+
- 关键行为有测试覆盖,关键模块已用 `react-error-boundary` 包裹
|
|
85
|
+
- 超长列表已评估虚拟化,弹窗/复合组件具备键盘与焦点支持
|
|
86
|
+
- 先尊重仓库现状,再给推荐结构
|
|
87
|
+
- 给出必要的文件划分建议
|
|
88
|
+
- 必要时说明为什么这样分层
|
|
89
|
+
- 对新增模块,优先输出最小可落地结构,而不是一次性过度设计
|
|
90
|
+
- 对重构任务,优先保证可迁移性和风险可控
|
|
91
|
+
- 对性能相关 React 变更,说明触发的风险类别、证据来源和验证命令
|
package/localized/zh-CN/skills/fec-react-project-standard/references/react-performance-patterns.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# React 性能模式
|
|
2
|
+
|
|
3
|
+
本文件保留轻量级 React 项目规范性能指导。当任务需要指标、trace、profile、包体分析、网络证据或正式性能报告时,使用前端性能工作流。
|
|
4
|
+
|
|
5
|
+
### 性能(与「性能优化」一节配合)
|
|
6
|
+
|
|
7
|
+
- **useMemo**:昂贵派生、大列表排序/过滤;注意不可变数据,例如 `useMemo(() => [...list].sort(...), [list])`,避免直接 `sort` 可变原数组。
|
|
8
|
+
- **useCallback**:传给 **`React.memo`** 子组件或作为其他 Hook 依赖的回调,在确有稳定引用需求时使用。
|
|
9
|
+
- **React.memo**:纯展示、props 浅比较可接受的组件;不要全局套 memo。
|
|
10
|
+
- **虚拟列表**:超长列表用 **TanStack Virtual**、**react-window** 等,只渲染视区内节点(路由级与组件级懒加载仍见「Suspense 与懒加载」)。
|
|
11
|
+
|
|
12
|
+
## 性能优化
|
|
13
|
+
|
|
14
|
+
在以下场景考虑性能优化:
|
|
15
|
+
|
|
16
|
+
- 大列表 / 大表格
|
|
17
|
+
- 高频重渲染组件
|
|
18
|
+
- 大量 props 传递的复杂树
|
|
19
|
+
- 重型第三方组件
|
|
20
|
+
- 高频变化 context
|
|
21
|
+
|
|
22
|
+
### 推荐手段
|
|
23
|
+
|
|
24
|
+
- 合理使用 `React.memo`
|
|
25
|
+
- 只在必要时使用 `useMemo` / `useCallback`
|
|
26
|
+
- 列表使用稳定 `key`
|
|
27
|
+
- 大列表使用虚拟滚动
|
|
28
|
+
- 路由级做 code splitting
|
|
29
|
+
- 避免将高频变化值放进顶层 context
|
|
30
|
+
- 避免在 render 中无意义创建大量新对象 / 新函数 / 新数组
|
|
31
|
+
- 重型图表、编辑器、地图、3D 和媒体处理能力放到叶子组件或路由级懒加载边界
|
|
32
|
+
- 懒加载组件必须配套 loading、error、empty 或降级 UI,避免只优化包体却破坏用户状态
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
package/localized/zh-CN/skills/fec-react-project-standard/references/react-project-structure.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# React 项目结构与组件边界
|
|
2
|
+
|
|
3
|
+
## 项目结构(推荐参考)
|
|
4
|
+
|
|
5
|
+
以下为中大型 React 项目的业界最佳实践结构,按项目实际情况裁剪:
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
src/
|
|
9
|
+
├── app/ # 应用入口与全局配置
|
|
10
|
+
│ ├── App.tsx # 根组件(Provider 组合)
|
|
11
|
+
│ ├── routes.tsx # 路由配置
|
|
12
|
+
│ └── providers.tsx # 全局 Provider 组装
|
|
13
|
+
│
|
|
14
|
+
├── pages/ # 页面组件(与路由一一对应)
|
|
15
|
+
│ ├── Dashboard/
|
|
16
|
+
│ │ ├── DashboardPage.tsx
|
|
17
|
+
│ │ ├── components/ # 页面私有组件
|
|
18
|
+
│ │ └── hooks/ # 页面私有 hooks
|
|
19
|
+
│ ├── UserList/
|
|
20
|
+
│ └── Settings/
|
|
21
|
+
│
|
|
22
|
+
├── layouts/ # 布局组件
|
|
23
|
+
│ ├── MainLayout.tsx # 主布局(侧边栏 + 顶栏 + 内容区)
|
|
24
|
+
│ ├── AuthLayout.tsx # 登录/注册页布局
|
|
25
|
+
│ └── BlankLayout.tsx # 空白布局(错误页等)
|
|
26
|
+
│
|
|
27
|
+
├── features/ # 功能模块(按业务领域划分)
|
|
28
|
+
│ ├── auth/
|
|
29
|
+
│ │ ├── components/ # 模块组件
|
|
30
|
+
│ │ ├── hooks/ # 模块 hooks
|
|
31
|
+
│ │ ├── api.ts # 模块 API 调用
|
|
32
|
+
│ │ ├── types.ts # 模块类型定义
|
|
33
|
+
│ │ ├── constants.ts # 模块常量
|
|
34
|
+
│ │ └── index.ts # 模块公开导出
|
|
35
|
+
│ └── order/
|
|
36
|
+
│
|
|
37
|
+
├── components/ # 全局共享 UI 组件
|
|
38
|
+
│ ├── Button/
|
|
39
|
+
│ │ ├── Button.tsx
|
|
40
|
+
│ │ ├── Button.styles.css
|
|
41
|
+
│ │ └── __tests__/
|
|
42
|
+
│ ├── Modal/
|
|
43
|
+
│ ├── Form/
|
|
44
|
+
│ └── ErrorBoundary/ # 对 react-error-boundary 等的薄封装(函数组件)
|
|
45
|
+
│
|
|
46
|
+
├── hooks/ # 全局共享 hooks
|
|
47
|
+
│ ├── useAuth.ts
|
|
48
|
+
│ ├── useDebounce.ts
|
|
49
|
+
│ └── useMediaQuery.ts
|
|
50
|
+
│
|
|
51
|
+
├── services/ # API 基础层
|
|
52
|
+
│ ├── request.ts # Axios/fetch 实例与拦截器
|
|
53
|
+
│ └── endpoints/ # API 端点定义(如按领域拆分)
|
|
54
|
+
│
|
|
55
|
+
├── stores/ # 全局状态管理
|
|
56
|
+
│ ├── authStore.ts
|
|
57
|
+
│ └── uiStore.ts
|
|
58
|
+
│
|
|
59
|
+
├── locales/ # 国际化语言包
|
|
60
|
+
│ ├── zh-CN.json # 中文
|
|
61
|
+
│ ├── en-US.json # 英文
|
|
62
|
+
│ └── index.ts # i18n 实例初始化(i18next / react-intl)
|
|
63
|
+
│
|
|
64
|
+
├── assets/ # 静态资源
|
|
65
|
+
│ ├── images/ # 图片(PNG、JPG、WebP)
|
|
66
|
+
│ ├── icons/ # SVG 图标
|
|
67
|
+
│ └── fonts/ # 自定义字体
|
|
68
|
+
│
|
|
69
|
+
├── config/ # 应用配置
|
|
70
|
+
│ ├── env.ts # 环境变量类型化封装
|
|
71
|
+
│ └── features.ts # Feature Flags 管理
|
|
72
|
+
│
|
|
73
|
+
├── types/ # 全局共享类型
|
|
74
|
+
│ ├── api.ts # API 响应/请求通用类型
|
|
75
|
+
│ ├── models.ts # 业务实体类型
|
|
76
|
+
│ └── global.d.ts # 全局类型扩展(图片模块声明等)
|
|
77
|
+
│
|
|
78
|
+
├── utils/ # 纯工具函数
|
|
79
|
+
│ ├── format.ts # 日期、数字、货币格式化
|
|
80
|
+
│ ├── validators.ts # 表单校验规则
|
|
81
|
+
│ └── storage.ts # LocalStorage / SessionStorage 封装
|
|
82
|
+
│
|
|
83
|
+
├── styles/ # 全局样式与主题
|
|
84
|
+
│ ├── global.css # 全局基础样式(reset / normalize)
|
|
85
|
+
│ ├── variables.css # CSS 变量(颜色、间距、字号)
|
|
86
|
+
│ ├── breakpoints.ts # 响应式断点常量
|
|
87
|
+
│ └── themes/ # 主题定义
|
|
88
|
+
│ ├── light.css # 亮色主题变量
|
|
89
|
+
│ ├── dark.css # 暗色主题变量
|
|
90
|
+
│ └── index.ts # 主题切换逻辑
|
|
91
|
+
│
|
|
92
|
+
└── constants/ # 全局常量
|
|
93
|
+
├── routes.ts # 路由路径常量
|
|
94
|
+
└── config.ts # 业务常量(分页大小、超时时间等)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 关键原则
|
|
98
|
+
|
|
99
|
+
- `pages/` 做路由映射和页面编排,不承载大块可复用业务逻辑
|
|
100
|
+
- `layouts/` 负责页面骨架和布局容器,由路由配置引用
|
|
101
|
+
- `features/` 按业务领域划分,模块内尽量自包含
|
|
102
|
+
- `components/` 仅放跨页面、跨模块复用的通用组件
|
|
103
|
+
- `hooks/` 仅放全局通用 hooks;业务 hooks 优先放回对应 feature 或 page
|
|
104
|
+
- `locales/` 存放语言包 JSON 文件,组件中使用 `t('key')` 而非硬编码文案
|
|
105
|
+
- `assets/` 存放静态资源,图标优先使用 SVG,图片优先使用 WebP/AVIF
|
|
106
|
+
- `services/` 负责请求基础设施,不堆叠业务细节
|
|
107
|
+
- `config/` 统一封装环境变量和特性开关,禁止组件中直接读取 `import.meta.env`
|
|
108
|
+
- `styles/` 和主题变量统一管理,避免颜色和尺寸散落在业务代码中
|
|
109
|
+
- 每个模块通过 `index.ts` 管控对外公开 API,避免深层路径导入
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 组件与模块分层
|
|
114
|
+
|
|
115
|
+
推荐分层:
|
|
116
|
+
|
|
117
|
+
```text
|
|
118
|
+
页面组件 (Pages) → 路由映射、布局组合、页面编排
|
|
119
|
+
└── 容器/编排层 → 数据获取、状态组织、事件编排
|
|
120
|
+
└── 业务组件 → 领域逻辑展示
|
|
121
|
+
└── 通用组件 → 无业务耦合、可跨模块复用
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 什么时候放到 `pages/`
|
|
125
|
+
|
|
126
|
+
适合放:
|
|
127
|
+
|
|
128
|
+
- 路由入口组件
|
|
129
|
+
- 页面级布局组合
|
|
130
|
+
- 页面私有的轻量编排逻辑
|
|
131
|
+
|
|
132
|
+
不适合放:
|
|
133
|
+
|
|
134
|
+
- 大量领域逻辑
|
|
135
|
+
- 可复用于多个页面的复杂业务块
|
|
136
|
+
- 与某个业务域强绑定的 API / hooks / types
|
|
137
|
+
|
|
138
|
+
### 什么时候放到 `features/`
|
|
139
|
+
|
|
140
|
+
适合放:
|
|
141
|
+
|
|
142
|
+
- 某个业务域的组件、hooks、api、types
|
|
143
|
+
- 可被多个页面共享但带业务语义的逻辑
|
|
144
|
+
- 一个完整业务单元的自包含实现
|
|
145
|
+
|
|
146
|
+
### 什么时候放到 `components/`
|
|
147
|
+
|
|
148
|
+
适合放:
|
|
149
|
+
|
|
150
|
+
- 按钮、弹窗、表单项、表格壳子、空态、错误态等通用 UI
|
|
151
|
+
- 与具体业务无关、可跨模块复用的组件
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 组件设计规范
|
|
156
|
+
|
|
157
|
+
- 使用**函数组件**、Hooks 与 TypeScript;**不要**新增类组件(Error Boundary 用 `react-error-boundary` 等库,见下文)
|
|
158
|
+
- **单文件规模**与拆分原则见 `templates/shared/rules/fec-react.md`「**组件文件规模**」(约 300 行内为佳,逾 500 行或复杂度过高拆子组件、Hooks、utils、类型)
|
|
159
|
+
- 保持组件职责单一、可组合
|
|
160
|
+
- 将可复用逻辑提取到 hooks
|
|
161
|
+
- 在合适场景优先使用受控组件 API
|
|
162
|
+
- props 定义清晰且类型明确
|
|
163
|
+
- 优先复用现有设计系统组件
|
|
164
|
+
- 保持可访问性与键盘交互
|
|
165
|
+
- 避免过深的 JSX 嵌套和重复分支
|
|
166
|
+
- 对可推导的值不要额外存 state
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
## 组件目录建议
|
|
172
|
+
|
|
173
|
+
当组件复杂度较低时,可只保留一个文件。
|
|
174
|
+
当组件包含样式、子组件、hooks、测试时,推荐使用如下结构:
|
|
175
|
+
|
|
176
|
+
```text
|
|
177
|
+
ComponentName/
|
|
178
|
+
├── ComponentName.tsx
|
|
179
|
+
├── ComponentName.types.ts
|
|
180
|
+
├── ComponentName.styles.css
|
|
181
|
+
├── hooks/
|
|
182
|
+
│ └── useComponentLogic.ts
|
|
183
|
+
├── components/
|
|
184
|
+
│ └── SubComponent.tsx
|
|
185
|
+
└── __tests__/
|
|
186
|
+
└── ComponentName.spec.tsx
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
说明:
|
|
190
|
+
|
|
191
|
+
- 类型复杂时再拆 `ComponentName.types.ts`
|
|
192
|
+
- 存在局部逻辑复用时再拆 `hooks/`
|
|
193
|
+
- 子组件仅在当前组件内部使用时,放到当前目录 `components/`
|
|
194
|
+
- 测试是否就近放置,应遵循仓库现有约定
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|