@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
package/localized/zh-CN/skills/fec-react-project-standard/references/react-quality-patterns.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# React 质量模式
|
|
2
|
+
|
|
3
|
+
## 样式接入
|
|
4
|
+
|
|
5
|
+
本 skill 不强制具体样式方案,默认遵循仓库现状。
|
|
6
|
+
|
|
7
|
+
适配时注意:
|
|
8
|
+
|
|
9
|
+
- Tailwind 项目继续使用 Tailwind
|
|
10
|
+
- CSS Modules 项目保持命名与文件组织一致
|
|
11
|
+
- styled-components 项目继续沿用其模式
|
|
12
|
+
- 主题、颜色、字号、间距等优先复用仓库 token / CSS 变量
|
|
13
|
+
- 避免在组件内硬编码大量视觉常量
|
|
14
|
+
- 禁止内联样式(除动态值外)
|
|
15
|
+
- 响应式处理需与项目断点约定一致
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 注释规范
|
|
20
|
+
|
|
21
|
+
- **优先使用中文**:解释「为什么这样做」、业务约束、边界情况、非显而易见的权衡时,优先用中文撰写注释,便于团队与业务方阅读。
|
|
22
|
+
- **与代码语言一致时的例外**:对接第三方协议字段名、HTTP 头、规范中的英文术语时,注释里可保留英文专有名词,必要时中英文并列说明。
|
|
23
|
+
- **少而精**:能通过清晰命名与类型表达清楚的逻辑不写废话注释;复杂分支、临时兼容、性能取舍必须写清意图。
|
|
24
|
+
- **公开 API**:模块或 hooks 的对外契约可用 JSDoc(`@param` / `@returns` / `@example`),说明用中文即可,除非仓库统一要求英文。
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## TypeScript 规范
|
|
29
|
+
|
|
30
|
+
通用 TypeScript 工程规则由 `fec-typescript-project-standard` 负责,包括 `tsconfig`、strictness、DTO / view model 边界、`unknown` 收窄、public API 类型、声明产物和类型测试。
|
|
31
|
+
|
|
32
|
+
React 规范只补充组件、Props、事件和 TSX 泛型写法;复杂类型建模或跨框架类型契约先分流到 `fec-typescript-project-standard`。
|
|
33
|
+
|
|
34
|
+
### React 项目补充约定
|
|
35
|
+
|
|
36
|
+
- Props interface 命名: `ComponentNameProps`
|
|
37
|
+
- 事件处理函数: `handle` 前缀(如 `handleClick`)
|
|
38
|
+
- 回调 Props: `on` 前缀(如 `onChange`、`onSubmit`)
|
|
39
|
+
- 组件优先写显式 props 与返回值类型(`JSX.Element` / `React.ReactElement`),避免依赖 `React.FC` 的隐式 `children` 等行为差异
|
|
40
|
+
- 泛型组件使用 `<T>` 约束,保持调用处类型推导;回调与事件类型优先使用 DOM / React 自带类型(如 `React.ChangeEvent<HTMLInputElement>`)
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
interface TableProps<T extends Record<string, unknown>> {
|
|
44
|
+
data: T[];
|
|
45
|
+
columns: ColumnDef<T>[];
|
|
46
|
+
onRowClick?: (row: T) => void;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 测试规范
|
|
53
|
+
|
|
54
|
+
### 应优先覆盖的内容
|
|
55
|
+
|
|
56
|
+
- 核心交互行为(点击、输入、提交)
|
|
57
|
+
- 条件渲染(loading / error / empty / data)
|
|
58
|
+
- 关键 hooks 的返回值和副作用
|
|
59
|
+
- API 调用 mock 与模块级集成测试
|
|
60
|
+
|
|
61
|
+
### 推荐风格
|
|
62
|
+
|
|
63
|
+
- 测试用户行为,而不是实现细节
|
|
64
|
+
- 优先使用 `screen.getByRole`、`getByLabelText`
|
|
65
|
+
- 避免围绕内部 state 写脆弱测试
|
|
66
|
+
- 只测关键行为,不机械追求覆盖率数字
|
|
67
|
+
|
|
68
|
+
### 示例
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
describe("UserForm", () => {
|
|
72
|
+
it("should submit with valid data", async () => {
|
|
73
|
+
const onSubmit = vi.fn();
|
|
74
|
+
render(<UserForm onSubmit={onSubmit} />);
|
|
75
|
+
|
|
76
|
+
await userEvent.type(screen.getByLabelText("用户名"), "test");
|
|
77
|
+
await userEvent.click(screen.getByRole("button", { name: "提交" }));
|
|
78
|
+
|
|
79
|
+
expect(onSubmit).toHaveBeenCalledWith({ username: "test" });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("should show error on invalid input", async () => {
|
|
83
|
+
render(<UserForm onSubmit={vi.fn()} />);
|
|
84
|
+
await userEvent.click(screen.getByRole("button", { name: "提交" }));
|
|
85
|
+
expect(screen.getByText("用户名不能为空")).toBeInTheDocument();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## 常见反模式
|
|
94
|
+
|
|
95
|
+
避免:
|
|
96
|
+
|
|
97
|
+
- prop drilling 过深却不考虑组合或局部封装
|
|
98
|
+
- 对局部问题过度使用 context
|
|
99
|
+
- 把数据请求、视图渲染、命令式 DOM 操作全塞进一个文件
|
|
100
|
+
- 在 useEffect 中做可以在事件处理函数中完成的事
|
|
101
|
+
- 用 `useEffect + setState` 模拟本可直接计算的派生值
|
|
102
|
+
- 将所有状态都推进全局 store
|
|
103
|
+
- 在 `components/` 中放业务耦合组件
|
|
104
|
+
- 直接绕过模块出口,从 feature 深层路径导入
|
|
105
|
+
- 没有明显收益却提前做复杂优化
|
|
106
|
+
- **新增类组件**或手写类式 Error Boundary(应函数组件 + `react-error-boundary` 等)
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 输出检查清单
|
|
111
|
+
|
|
112
|
+
输出 React 代码或方案时,至少检查:
|
|
113
|
+
|
|
114
|
+
- [ ] 是否先对齐了仓库现有约定
|
|
115
|
+
- [ ] 页面 / feature / 通用组件边界是否清晰
|
|
116
|
+
- [ ] 目录结构是否与模块复杂度匹配
|
|
117
|
+
- [ ] Props 类型完整且明确
|
|
118
|
+
- [ ] 解释性注释是否优先使用中文且点到要害
|
|
119
|
+
- [ ] 可复用逻辑是否已提取为 hooks
|
|
120
|
+
- [ ] loading / error / empty / data 状态是否齐全
|
|
121
|
+
- [ ] API 层是否具备类型约束和统一错误处理
|
|
122
|
+
- [ ] 复杂 DTO、外部数据收窄、公共类型或 `tsconfig` 问题是否已分流到 `fec-typescript-project-standard`
|
|
123
|
+
- [ ] 状态管理是否符合就近原则
|
|
124
|
+
- [ ] 路由级或重型模块是否考虑懒加载
|
|
125
|
+
- [ ] 样式方案是否与仓库保持一致
|
|
126
|
+
- [ ] 关键行为是否有测试覆盖
|
|
127
|
+
- [ ] 关键模块已用 **`react-error-boundary`**(等)包裹,且未手写类组件式 Boundary
|
|
128
|
+
- [ ] 超长列表是否评估虚拟化;弹窗/复合组件是否具备键盘与焦点约定
|
|
129
|
+
- [ ] 是否引入了不必要的新依赖或新范式
|
|
130
|
+
|
|
131
|
+
---
|
package/localized/zh-CN/skills/fec-react-project-standard/references/react-runtime-patterns.md
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# React 运行时模式
|
|
2
|
+
|
|
3
|
+
## 常用 UI 与状态模式
|
|
4
|
+
|
|
5
|
+
以下模式可与本 skill 其他章节(Hooks、状态管理、性能优化、错误处理)对照使用;**按业务复杂度与团队熟悉度选用**,避免为模式而模式。思路参考业界常见的 React 前端模式实践(如组件组合、复合组件、性能与无障碍等)。
|
|
6
|
+
|
|
7
|
+
### 组合优于继承
|
|
8
|
+
|
|
9
|
+
- 用**小颗粒子组件** + `children` / 显式 props 拼装界面,而不是在 React 中搭建类继承层次。
|
|
10
|
+
- 示例:`Card` + `CardHeader` + `CardBody`,由使用方组合,而不是一个巨型 `Card` 用大量布尔 props 分支。
|
|
11
|
+
|
|
12
|
+
### 复合组件(Compound Components)
|
|
13
|
+
|
|
14
|
+
- 根组件通过 **Context** 向子组件提供内部状态(如当前 Tab、打开/关闭)。
|
|
15
|
+
- 子组件在 `useContext` 为空时**抛错或断言**,明确「必须在 Provider 树内使用」。
|
|
16
|
+
- API 表面保持可读:`<Tabs><TabList><Tab /></TabList></Tabs>`。
|
|
17
|
+
|
|
18
|
+
### Render Props / 函数子
|
|
19
|
+
|
|
20
|
+
- 适用:封装**数据获取与三态**(loading / error / data),把**渲染决策**交给父级。
|
|
21
|
+
- 与 **自定义 Hook** 二选一即可:多数场景 `useXxx()` + 普通组件更直观;仅在需要强约束「同层渲染逻辑」时保留 Render Props。
|
|
22
|
+
|
|
23
|
+
### Context + useReducer
|
|
24
|
+
|
|
25
|
+
- 适合**中等复杂度、多子树共享**的客户端状态,且更新可归约为明确 `action`。
|
|
26
|
+
- 避免把高频变化的大对象塞进顶层 Context;服务端数据仍优先 **React Query / SWR**。
|
|
27
|
+
- 大型全局业务状态继续用仓库已选的 **Zustand / Redux Toolkit / Jotai**。
|
|
28
|
+
|
|
29
|
+
### 表单
|
|
30
|
+
|
|
31
|
+
- 受控字段 + 校验错误对象是一类可行实现;中大型表单优先 **React Hook Form**(或 Formik)+ **Zod**,复杂表单值、DTO 和校验类型契约分流到 `fec-typescript-project-standard`。
|
|
32
|
+
- 避免单组件内巨型 `useState` 表单对象与重复校验逻辑,可拆字段子组件或抽 `useFormSchema`。
|
|
33
|
+
|
|
34
|
+
### Error Boundary
|
|
35
|
+
|
|
36
|
+
- **不要**在业务代码中手写 React **类组件**形式的 Error Boundary;统一使用 **`react-error-boundary`**(或团队认可的同类库)在**模块边界**兜底渲染失败(与本章「错误处理」、`error-handling.md` 一致)。
|
|
37
|
+
- 用 `FallbackComponent` 与 `resetErrorBoundary` 提供「重试」;**日志上报**放在库的 **`onError`**(等回调)中,生产代码避免长期依赖 `console.log`(见 TypeScript 规则)。
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### 动画与过渡
|
|
41
|
+
|
|
42
|
+
- 列表进出场可用 **Framer Motion** 的 `AnimatePresence` + `key`,或 CSS `transition`;注意减少布局抖动与 `prefers-reduced-motion`(与无障碍策略一致时)。
|
|
43
|
+
|
|
44
|
+
### 无障碍与焦点
|
|
45
|
+
|
|
46
|
+
- 自定义下拉、标签页等:**`role` / `aria-*`**、**方向键 / Enter / Escape** 行为与焦点环可见。
|
|
47
|
+
- 弹窗:打开时将焦点移入对话框,关闭时**恢复**触发元素焦点;可用 **`focus-trap-react`** 或类似方案,与 `fec-accessibility-check` skill 互补。
|
|
48
|
+
|
|
49
|
+
### Next.js 与服务端组件
|
|
50
|
+
|
|
51
|
+
- **App Router、Server Components、服务端数据获取与缓存**见 **`fec-nextjs-project-standard`**;客户端交互模式仍以本章与 Hooks 规范为准。
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Hooks 设计模式
|
|
57
|
+
|
|
58
|
+
### 适合抽为自定义 Hook 的场景
|
|
59
|
+
|
|
60
|
+
- 数据获取与三态管理
|
|
61
|
+
- 表单状态逻辑
|
|
62
|
+
- 分页、筛选、排序编排
|
|
63
|
+
- 事件监听与副作用清理
|
|
64
|
+
- 可在多个组件复用的交互逻辑
|
|
65
|
+
|
|
66
|
+
### 推荐原则
|
|
67
|
+
|
|
68
|
+
- 统一使用 `use` 前缀命名
|
|
69
|
+
- 返回对象而非数组,方便按需解构,增强可读性和扩展性
|
|
70
|
+
- 状态和行为封装在一起
|
|
71
|
+
- Hook 内部处理 `loading / error / data`
|
|
72
|
+
- 对外暴露清晰的最小接口,不泄漏无关内部细节
|
|
73
|
+
|
|
74
|
+
### 示例
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
function useUserList(params: QueryParams) {
|
|
78
|
+
const [data, setData] = useState<User[]>([]);
|
|
79
|
+
const [loading, setLoading] = useState(false);
|
|
80
|
+
const [error, setError] = useState<Error | null>(null);
|
|
81
|
+
|
|
82
|
+
const fetch = useCallback(async () => {
|
|
83
|
+
setLoading(true);
|
|
84
|
+
setError(null);
|
|
85
|
+
try {
|
|
86
|
+
const res = await getUserList(params);
|
|
87
|
+
setData(res.list);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
setError(e as Error);
|
|
90
|
+
} finally {
|
|
91
|
+
setLoading(false);
|
|
92
|
+
}
|
|
93
|
+
}, [params]);
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
fetch();
|
|
97
|
+
}, [fetch]);
|
|
98
|
+
|
|
99
|
+
return { data, loading, error, refetch: fetch };
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Hook 使用原则
|
|
104
|
+
|
|
105
|
+
- `useEffect` 必须有正确依赖和清理逻辑
|
|
106
|
+
- `useMemo` / `useCallback` 不要滥用,只有在稳定引用确实重要时再加
|
|
107
|
+
- 不在条件分支或循环中调用 hooks
|
|
108
|
+
- 已引入 React Query / SWR 时,数据请求优先走这些库,而不是自己重复造一套缓存层
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 路由组织
|
|
113
|
+
|
|
114
|
+
### 推荐方式
|
|
115
|
+
|
|
116
|
+
- 路由配置集中管理
|
|
117
|
+
- 路径常量化
|
|
118
|
+
- 页面组件按需懒加载
|
|
119
|
+
- 权限控制放在 guard 层,而不是散落在页面组件内
|
|
120
|
+
- 分页、筛选、排序等 URL 驱动状态优先与地址栏同步
|
|
121
|
+
|
|
122
|
+
### 示例
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
const routes: RouteObject[] = [
|
|
126
|
+
{
|
|
127
|
+
path: "/",
|
|
128
|
+
element: <MainLayout />,
|
|
129
|
+
children: [
|
|
130
|
+
{ index: true, element: <DashboardPage /> },
|
|
131
|
+
{ path: "users", element: <UserListPage /> },
|
|
132
|
+
{ path: "users/:id", element: <UserDetailPage /> },
|
|
133
|
+
{ path: "settings", element: <SettingsPage /> },
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
{ path: "/login", element: <LoginPage /> },
|
|
137
|
+
{ path: "*", element: <NotFoundPage /> },
|
|
138
|
+
];
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
const UserListPage = lazy(() => import("@/pages/UserList/UserListPage"));
|
|
143
|
+
|
|
144
|
+
function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
|
145
|
+
const { isAuthenticated } = useAuth();
|
|
146
|
+
if (!isAuthenticated) return <Navigate to="/login" replace />;
|
|
147
|
+
return <>{children}</>;
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 状态管理选型
|
|
154
|
+
|
|
155
|
+
| 状态类型 | 推荐方案 |
|
|
156
|
+
| ------------------ | ------------------------------------------------- |
|
|
157
|
+
| 组件内临时 UI 状态 | `useState` / `useReducer` |
|
|
158
|
+
| 跨组件共享业务状态 | Zustand / Redux Toolkit / Jotai(按仓库实际选择) |
|
|
159
|
+
| 服务端数据缓存 | React Query / SWR |
|
|
160
|
+
| URL 驱动状态 | 路由参数 / `useSearchParams` |
|
|
161
|
+
| 表单状态 | React Hook Form / Formik |
|
|
162
|
+
|
|
163
|
+
### 核心原则
|
|
164
|
+
|
|
165
|
+
- 就近管理:状态尽量放在最近的公共祖先
|
|
166
|
+
- 单一数据源:同一份数据不要维护多份
|
|
167
|
+
- 派生优于同步:可计算值优先在渲染期计算
|
|
168
|
+
- 服务端数据优先交给请求库管理,不手动塞进全局 store
|
|
169
|
+
- 不要因为“以后可能会用到”就把局部状态提前升级为全局状态
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## API 层规范
|
|
174
|
+
|
|
175
|
+
### 设计原则
|
|
176
|
+
|
|
177
|
+
- 请求基础设施集中在 `services/`
|
|
178
|
+
- 业务 API 按 feature 拆分,而不是全部堆在一个文件
|
|
179
|
+
- 请求参数和响应结果都应有明确类型
|
|
180
|
+
- 认证、错误格式化、通用拦截放在请求层统一处理
|
|
181
|
+
- 页面和组件不要直接散落拼接请求细节
|
|
182
|
+
|
|
183
|
+
### 示例
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
// services/request.ts
|
|
187
|
+
const request = axios.create({
|
|
188
|
+
baseURL: import.meta.env.VITE_API_BASE_URL,
|
|
189
|
+
timeout: 10000,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
request.interceptors.response.use(
|
|
193
|
+
(res) => res.data,
|
|
194
|
+
(error) => {
|
|
195
|
+
if (error.response?.status === 401) {
|
|
196
|
+
redirectToLogin();
|
|
197
|
+
}
|
|
198
|
+
return Promise.reject(normalizeError(error));
|
|
199
|
+
},
|
|
200
|
+
);
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
// features/user/api.ts
|
|
205
|
+
export function getUserList(
|
|
206
|
+
params: UserQueryParams,
|
|
207
|
+
): Promise<PageResult<User>> {
|
|
208
|
+
return request.get("/users", { params });
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function updateUser(id: string, data: UpdateUserDTO): Promise<User> {
|
|
212
|
+
return request.put(`/users/${id}`, data);
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 错误处理
|
|
219
|
+
|
|
220
|
+
### 必须覆盖的状态
|
|
221
|
+
|
|
222
|
+
- Loading
|
|
223
|
+
- Error
|
|
224
|
+
- Empty
|
|
225
|
+
- Data
|
|
226
|
+
|
|
227
|
+
### 推荐做法
|
|
228
|
+
|
|
229
|
+
- 关键功能模块使用 Error Boundary 包裹,避免局部异常导致全页白屏
|
|
230
|
+
- 异步请求失败时必须给用户可见反馈
|
|
231
|
+
- 重要操作提供重试能力
|
|
232
|
+
- 不要吞错,不写空 `catch`
|
|
233
|
+
|
|
234
|
+
### 示例(`react-error-boundary`,函数式 Fallback)
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
238
|
+
|
|
239
|
+
function ModuleErrorFallback({
|
|
240
|
+
resetErrorBoundary,
|
|
241
|
+
}: {
|
|
242
|
+
resetErrorBoundary: () => void;
|
|
243
|
+
}) {
|
|
244
|
+
return (
|
|
245
|
+
<div>
|
|
246
|
+
模块加载失败
|
|
247
|
+
<button type="button" onClick={resetErrorBoundary}>
|
|
248
|
+
重试
|
|
249
|
+
</button>
|
|
250
|
+
</div>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function UserDashboardSection() {
|
|
255
|
+
return (
|
|
256
|
+
<ErrorBoundary FallbackComponent={ModuleErrorFallback}>
|
|
257
|
+
<UserDashboard />
|
|
258
|
+
</ErrorBoundary>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Suspense 与懒加载
|
|
266
|
+
|
|
267
|
+
适用场景:
|
|
268
|
+
|
|
269
|
+
- 路由级页面
|
|
270
|
+
- 图表、富文本编辑器、地图、重型表格等大体积组件
|
|
271
|
+
- 初始化成本较高的模块
|
|
272
|
+
|
|
273
|
+
示例:
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
const HeavyChart = lazy(() => import("./components/HeavyChart"));
|
|
277
|
+
|
|
278
|
+
function Dashboard() {
|
|
279
|
+
return (
|
|
280
|
+
<Suspense fallback={<ChartSkeleton />}>
|
|
281
|
+
<HeavyChart data={chartData} />
|
|
282
|
+
</Suspense>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
建议:
|
|
288
|
+
|
|
289
|
+
- 路由级优先 `lazy + Suspense`
|
|
290
|
+
- `fallback` 优先使用 Skeleton 或更贴近内容的占位态,而不是纯 spinner
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-refactor-clean
|
|
3
|
+
description: 用于安全移除前端死代码、未使用导出、陈旧组件、废弃路由、未使用依赖,或由 knip、depcheck、ts-prune、TypeScript、ESLint、人工审查发现的清理目标。不要用于会改变行为的功能重写;中文触发词包括 死代码、清理未使用、refactor clean、依赖清理、删除无用代码。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 重构清理
|
|
7
|
+
|
|
8
|
+
## 用途
|
|
9
|
+
|
|
10
|
+
在验证保护下识别并清理无用前端代码,减少技术债,同时避免误删动态引用、路由入口、配置文件和运行时约定。
|
|
11
|
+
|
|
12
|
+
## 流程
|
|
13
|
+
|
|
14
|
+
1. 先建立基线:运行或确认当前 lint、type-check、test、build 的状态。
|
|
15
|
+
2. 收集候选项:
|
|
16
|
+
- 优先使用仓库已有工具,如 knip、depcheck、ts-prune、eslint、TypeScript。
|
|
17
|
+
- 没有工具时,用 `rg` 检查引用、导出、路由、注册点和文档入口。
|
|
18
|
+
3. 按风险分类:
|
|
19
|
+
- SAFE:测试夹具、未引用工具函数、明确未导出的私有组件。
|
|
20
|
+
- CAUTION:共享组件、feature 入口、样式文件、Storybook stories。
|
|
21
|
+
- DANGER:路由、配置、package scripts、运行时模板、动态 import、插件元数据。
|
|
22
|
+
- UPGRADE:过期依赖、重复依赖、未使用依赖和安全告警先进入依赖升级或依赖清理评估,不与死代码删除混做。
|
|
23
|
+
4. 只自动处理 SAFE 项;CAUTION 和 DANGER 需输出建议和证据,不直接删除。
|
|
24
|
+
5. 每批清理后运行受影响验证命令。
|
|
25
|
+
6. 若验证失败,停止扩大清理范围,先定位该批次。
|
|
26
|
+
7. 清理结束后做行为等价复核:公开 API、路由、命令、模板、metadata、文档示例和报告输出仍可被引用。
|
|
27
|
+
8. 对技术债排序:优先清理有验证保护、影响开发效率或阻塞升级的项目;低证据的大范围重写只输出建议。
|
|
28
|
+
|
|
29
|
+
## 前端专项检查
|
|
30
|
+
|
|
31
|
+
- 检查 JSX/模板字符串、路由配置、barrel export、Storybook、测试、文档示例和动态组件注册。
|
|
32
|
+
- 样式文件需检查 className、CSS Modules、Tailwind safelist、全局选择器和主题变量。
|
|
33
|
+
- 依赖清理需检查构建插件、运行时模板、CLI scripts、monorepo 子包和 peer dependency。
|
|
34
|
+
|
|
35
|
+
## 约束
|
|
36
|
+
|
|
37
|
+
- 不改变用户可见行为。
|
|
38
|
+
- 不删除无法证明无引用的公开 API、路由、模板或配置。
|
|
39
|
+
- 不用“一次大删除”替代可验证的小批次清理。
|
|
40
|
+
- 不把格式化、重命名或架构重写混入死代码清理。
|
|
41
|
+
- 不用“看起来没人用”作为证据;必须有搜索、工具输出、类型错误消失或测试保护。
|
|
42
|
+
- 不把依赖大版本升级伪装成清理;升级风险、release notes 和 lockfile 变更应分流到依赖升级工作流。
|
|
43
|
+
|
|
44
|
+
## 详细参考
|
|
45
|
+
|
|
46
|
+
撰写清理报告时,加载 [references/report-template.md](references/report-template.md)。
|
|
47
|
+
|
|
48
|
+
## 预期输出
|
|
49
|
+
|
|
50
|
+
- 清理报告保存为 `reports/refactor-clean-YYYY-MM-DD-HHmmss.md`。
|
|
51
|
+
- 代码清理后相关验证命令通过,或明确说明阻塞原因。
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# 重构清理报告模板
|
|
2
|
+
|
|
3
|
+
```markdown
|
|
4
|
+
# 重构清理报告
|
|
5
|
+
|
|
6
|
+
> 生成时间: YYYY-MM-DD HH:mm
|
|
7
|
+
> 清理范围: 文件 / 模块 / 依赖 / 路由 / 样式
|
|
8
|
+
|
|
9
|
+
## 基线验证
|
|
10
|
+
|
|
11
|
+
| 命令 | 清理前状态 | 清理后状态 | 备注 |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| `npm run lint` | 失败 / 通过 / 未运行 | 失败 / 通过 / 未运行 | ... |
|
|
14
|
+
|
|
15
|
+
## 候选项与证据
|
|
16
|
+
|
|
17
|
+
| 候选项 | 证据 | 风险分类 |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| `path/to/file.ts` | 工具输出 / rg 搜索 / 类型检查 | SAFE / CAUTION / DANGER / UPGRADE |
|
|
20
|
+
|
|
21
|
+
## 已清理项
|
|
22
|
+
|
|
23
|
+
- 删除或修改的文件、导出、样式、依赖或配置
|
|
24
|
+
- 每项清理对应的证据
|
|
25
|
+
|
|
26
|
+
## 跳过原因
|
|
27
|
+
|
|
28
|
+
- CAUTION / DANGER 项为什么没有自动处理
|
|
29
|
+
- 需要人工确认、运行时验证或专项流程的内容
|
|
30
|
+
|
|
31
|
+
## 验证命令
|
|
32
|
+
|
|
33
|
+
- 执行的 lint、type-check、test、build 或手工验证
|
|
34
|
+
- 关键输出摘要
|
|
35
|
+
|
|
36
|
+
## 剩余风险
|
|
37
|
+
|
|
38
|
+
- 动态引用、运行时模板、插件元数据或外部入口风险
|
|
39
|
+
- 建议后续清理或依赖升级项
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
清理完成后,将报告保存到 `reports/refactor-clean-YYYY-MM-DD-HHmmss.md`,并告知用户报告路径。
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-responsive-layout
|
|
3
|
+
description: 用于设计、实现或审查响应式前端布局、移动优先断点、容器查询、流式网格、数据密集表格、触摸目标、安全区域、横竖屏变化、视口溢出或跨设备 UI 行为;中文触发词包括 响应式布局、移动端适配、断点、容器查询、横竖屏、触摸目标。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 响应式布局
|
|
7
|
+
|
|
8
|
+
适用于需要让页面、工具界面、表格、仪表盘或组件在多设备上稳定工作的前端任务。需要布局模式和检查清单时加载 [references/responsive-layout-patterns.md](references/responsive-layout-patterns.md)。
|
|
9
|
+
|
|
10
|
+
## 用途
|
|
11
|
+
|
|
12
|
+
用内容优先、移动优先和容器感知的方式设计响应式布局,避免只靠固定断点修补溢出。
|
|
13
|
+
|
|
14
|
+
## 流程
|
|
15
|
+
|
|
16
|
+
1. 明确信息优先级:小屏先保留核心任务、关键操作和反馈;次要信息折叠、延后或移入详情层。
|
|
17
|
+
2. 选择布局策略:简单页面用 mobile-first 断点;嵌套组件、卡片网格和侧栏优先考虑 container query。
|
|
18
|
+
3. 设计流式尺寸:用 `minmax()`、`clamp()`、`aspect-ratio`、`max-width`、`min-width: 0` 和稳定网格轨道控制伸缩。
|
|
19
|
+
4. 处理数据密集界面:表格、列表、看板和编辑器需要明确横向滚动、列优先级、冻结列或移动端摘要视图。
|
|
20
|
+
5. 保证触摸与键盘:触摸目标、焦点路径、hover 替代、虚拟键盘、安全区域和横竖屏切换都要复核。
|
|
21
|
+
6. 关联性能与资源:移动端减少首屏大图、重型图表、同步动画和不必要列渲染。
|
|
22
|
+
7. 验证断点之间:检查 375px、768px、1024px、1440px,以及断点中间值是否溢出、遮挡或跳变。
|
|
23
|
+
|
|
24
|
+
## 约束
|
|
25
|
+
|
|
26
|
+
- 不把桌面版缩小当作移动端设计。
|
|
27
|
+
- 不让关键功能只依赖 hover 或宽屏侧栏。
|
|
28
|
+
- 不用固定高度掩盖内容变化;需要固定格式时用稳定约束和可滚动区域。
|
|
29
|
+
- 不用 viewport 字体缩放替代真实排版层级。
|
|
30
|
+
- 不让移动端横向溢出成为默认解决方案;只有数据表、画布或编辑器等明确场景可以局部横滚。
|
|
31
|
+
|
|
32
|
+
## 预期输出
|
|
33
|
+
|
|
34
|
+
输出响应式信息优先级、断点或容器策略、关键组件布局模式、触摸/键盘要求、数据密集区域处理方案和验证结果。完成后页面在常见视口和输入方式下不溢出、不遮挡、可操作。
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# 响应式布局模式
|
|
2
|
+
|
|
3
|
+
## 策略选择
|
|
4
|
+
|
|
5
|
+
| 场景 | 策略 |
|
|
6
|
+
| ---- | ---- |
|
|
7
|
+
| 页面级结构 | 移动优先断点 |
|
|
8
|
+
| 会被放进未知父容器的复用组件 | 容器查询 |
|
|
9
|
+
| 卡片网格 | `repeat(auto-fit, minmax())`,并设置合理最小宽度 |
|
|
10
|
+
| 数据表格 | 列优先级、横向滚动或移动端摘要行 |
|
|
11
|
+
| 编辑器 / 画布 / dashboard | 稳定外壳 + 可滚动工作区 |
|
|
12
|
+
|
|
13
|
+
## CSS 模式
|
|
14
|
+
|
|
15
|
+
```css
|
|
16
|
+
.card-grid {
|
|
17
|
+
display: grid;
|
|
18
|
+
grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr));
|
|
19
|
+
gap: 1rem;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.panel {
|
|
23
|
+
min-width: 0;
|
|
24
|
+
container-type: inline-size;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@container (min-width: 42rem) {
|
|
28
|
+
.panel-body {
|
|
29
|
+
display: grid;
|
|
30
|
+
grid-template-columns: 16rem minmax(0, 1fr);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
当 grid/flex 子项包含长文本、表格、代码、图表或媒体时,给子项设置 `min-width: 0`。
|
|
36
|
+
|
|
37
|
+
## 数据密集型界面
|
|
38
|
+
|
|
39
|
+
- 编码前先确定移动端列优先级。
|
|
40
|
+
- 主标识、状态和主要操作保持可见。
|
|
41
|
+
- 低优先级元数据移入详情行、抽屉或可展开面板。
|
|
42
|
+
- 小屏仍要保留排序、筛选、分页和选择能力。
|
|
43
|
+
- 虚拟滚动只解决 DOM 数量问题,不能解决信息层级问题。
|
|
44
|
+
- 表格可以局部横向滚动,但页面整体不应出现无意水平溢出。
|
|
45
|
+
|
|
46
|
+
## 响应式媒体
|
|
47
|
+
|
|
48
|
+
- 图片和视频要有稳定尺寸、`aspect-ratio` 或容器约束,避免加载后推挤布局。
|
|
49
|
+
- 需要多尺寸资源时使用 `srcset`、`sizes` 或 `<picture>`,不要让移动端下载桌面大图。
|
|
50
|
+
- 非首屏图片默认懒加载;首屏主体图按框架能力设置明确优先级。
|
|
51
|
+
- 媒体裁切必须保留主体信息;不要为了填满卡片裁掉产品、人物、图表关键区域。
|
|
52
|
+
|
|
53
|
+
## 触控与视口检查
|
|
54
|
+
|
|
55
|
+
- 空间允许时,交互目标至少 44x44px。
|
|
56
|
+
- 移动端输入框字号避免低于 16px。
|
|
57
|
+
- 固定底部栏和操作条必须考虑 `env(safe-area-inset-bottom)`。
|
|
58
|
+
- 对话框和抽屉需要适配虚拟键盘导致的视口变化。
|
|
59
|
+
- 只在 hover 时出现的内容必须提供点击、焦点或常驻可见替代方案。
|
|
60
|
+
- iOS/Android 横竖屏切换后,主操作、焦点位置和滚动容器仍应可达。
|
|
61
|
+
- 需要局部滚动的区域应明确最大高度和滚动边界,避免页面和内部容器互相抢滚动。
|
|
62
|
+
|
|
63
|
+
## 验证清单
|
|
64
|
+
|
|
65
|
+
- 320-375px:页面级没有横向溢出。
|
|
66
|
+
- 768px:布局切换后阅读顺序仍然合理。
|
|
67
|
+
- 1024-1440px:内容宽度有约束,扫描路径清晰。
|
|
68
|
+
- 长标签、翻译文本、数字以及 empty/error/loading 状态不会撑坏固定格式控件。
|
|
69
|
+
- 横竖屏切换不会困住焦点或隐藏主操作。
|
|
70
|
+
- 虚拟键盘弹出时,输入框、提交按钮和错误提示不被遮挡。
|