@bovinphang/frontend-craft 2.6.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 +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +72 -1
- package/CHANGELOG.zh-CN.md +71 -1
- package/README.md +10 -6
- package/README.openclaw.md +100 -42
- package/README.openclaw.zh-CN.md +100 -42
- package/README.zh-CN.md +10 -6
- 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 +88 -88
- 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 +84 -69
- package/docs/ja-JP/README.md +56 -52
- package/docs/ko-KR/README.md +45 -41
- package/docs/project-structure.md +19 -7
- package/docs/superpowers/plans/2026-05-29-fec-debug.md +491 -0
- package/docs/superpowers/specs/2026-05-29-fec-debug-design.md +340 -0
- package/docs/zh-CN/example-prompts.md +84 -69
- package/docs/zh-CN/project-structure.md +14 -5
- package/docs/zh-TW/README.md +33 -29
- 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/{skills/fec-typescript-type-safety → localized/zh-CN/skills/fec-typescript-project-standard}/references/type-safety-patterns.md +1 -1
- package/{skills/fec-typescript-type-safety/SKILL.md → localized/zh-CN/skills/fec-typescript-project-standard/references/type-safety.md} +5 -14
- 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 +4 -3
- package/skills/TEMPLATE.md +74 -74
- package/skills/eval_queries.json +717 -619
- 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 +45 -0
- 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 +73 -0
- package/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
- package/skills/fec-drawio-studio/data/brand-icons.json +878 -0
- package/skills/fec-drawio-studio/data/shape-index.json +83570 -0
- package/skills/fec-drawio-studio/references/data-residency.md +27 -0
- package/skills/fec-drawio-studio/references/diagram-patterns.md +60 -0
- package/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
- package/skills/fec-drawio-studio/references/layout-and-export.md +72 -0
- package/skills/fec-drawio-studio/references/troubleshooting.md +29 -0
- package/skills/fec-drawio-studio/references/xml-and-mermaid.md +58 -0
- package/skills/fec-drawio-studio/scripts/brand-symbols.mjs +99 -0
- package/skills/fec-drawio-studio/scripts/diagram-lint.mjs +205 -0
- package/skills/fec-drawio-studio/scripts/diagram-url.mjs +102 -0
- package/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
- package/skills/fec-drawio-studio/scripts/layout-graph.mjs +107 -0
- package/skills/fec-drawio-studio/scripts/png-embed-fix.mjs +26 -0
- package/skills/fec-drawio-studio/scripts/scan-go-packages.mjs +36 -0
- package/skills/fec-drawio-studio/scripts/scan-js-modules.mjs +52 -0
- package/skills/fec-drawio-studio/scripts/scan-python-classes.mjs +30 -0
- package/skills/fec-drawio-studio/scripts/scan-python-modules.mjs +55 -0
- package/skills/fec-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
- package/skills/fec-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
- package/skills/fec-drawio-studio/scripts/shape-query.mjs +121 -0
- package/skills/fec-drawio-studio/scripts/studio-core.mjs +139 -0
- package/skills/fec-drawio-studio/styles/built-in/corporate.json +49 -0
- package/skills/fec-drawio-studio/styles/built-in/default.json +49 -0
- package/skills/fec-drawio-studio/styles/built-in/handdrawn.json +49 -0
- package/skills/fec-drawio-studio/styles/schema.json +112 -0
- package/skills/fec-e2e-testing/SKILL.md +24 -22
- package/skills/fec-e2e-testing/references/e2e-ci-reporting.md +62 -0
- package/skills/fec-e2e-testing/references/e2e-special-scenarios.md +52 -0
- package/skills/fec-e2e-testing/references/e2e-visual-regression.md +60 -0
- 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 +81 -0
- package/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
- package/skills/fec-image-generation/references/artifact-routing.md +80 -0
- package/skills/fec-image-generation/references/diagram-workflows.md +74 -0
- package/skills/fec-image-generation/references/html-technical-diagrams.md +236 -0
- package/skills/fec-image-generation/references/png-qa-autofix.md +30 -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/png-qa.mjs +431 -0
- package/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1397 -0
- package/skills/fec-implement-from-design/SKILL.md +81 -74
- package/skills/fec-implement-from-design/references/design-plan-template.md +16 -16
- package/skills/fec-legacy-to-modern-migration/SKILL.md +29 -173
- package/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +110 -0
- 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 +48 -0
- 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 -44
- package/skills/fec-motion-interaction/references/motion-patterns.md +11 -11
- package/skills/fec-nextjs-project-standard/SKILL.md +64 -58
- package/skills/fec-nuxt-project-standard/SKILL.md +57 -57
- package/skills/fec-performance-optimization/SKILL.md +54 -50
- package/skills/fec-performance-optimization/references/framework-performance-patterns.md +38 -0
- package/skills/fec-performance-optimization/references/report-template.md +34 -28
- 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 -64
- package/skills/fec-react-project-standard/references/react-performance-patterns.md +35 -0
- package/skills/fec-react-project-standard/references/react-project-structure.md +197 -0
- package/skills/fec-react-project-standard/references/react-quality-patterns.md +131 -0
- package/skills/fec-react-project-standard/references/react-runtime-patterns.md +293 -0
- 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 +39 -28
- 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 +66 -40
- 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 -32
- 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 +54 -0
- package/skills/fec-typescript-project-standard/references/type-safety-patterns.md +102 -0
- package/skills/fec-typescript-project-standard/references/type-safety.md +148 -0
- package/skills/fec-ui-design/SKILL.md +90 -72
- package/skills/fec-ui-design/data/style-archetypes.json +40 -0
- package/skills/fec-ui-design/data/ux-quality-rules.json +35 -0
- package/skills/fec-ui-design/references/design-intelligence.md +81 -21
- package/skills/fec-ui-design/references/master-page-overrides.md +15 -15
- package/skills/fec-ui-design/references/pre-delivery-checklist.md +38 -32
- package/skills/fec-ui-design/scripts/design-system.mjs +119 -1
- 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 +39 -30
- package/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +163 -0
- package/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +13 -0
- package/skills/fec-vue3-project-standard/references/vue3-project-structure.md +177 -0
- package/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +216 -0
- package/skills/fec-web-video-presentation/SKILL.md +61 -0
- package/skills/fec-web-video-presentation/data/starter-themes.json +59 -0
- package/skills/fec-web-video-presentation/references/chapter-craft.md +37 -0
- package/skills/fec-web-video-presentation/references/content-plan.md +38 -0
- package/skills/fec-web-video-presentation/references/recording-and-audio.md +33 -0
- package/skills/fec-web-video-presentation/references/theme-system.md +36 -0
- package/skills/fec-web-video-presentation/scripts/create-video-presentation.mjs +430 -0
- 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 +402 -220
- package/skills/relations.json +120 -25
- 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 -117
- package/templates/shared/rules/fec-code-comments.md +22 -22
- package/templates/shared/rules/fec-design-system.md +65 -241
- package/templates/shared/rules/fec-error-handling.md +41 -185
- package/templates/shared/rules/fec-git-conventions.md +42 -42
- package/templates/shared/rules/fec-i18n.md +48 -96
- 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 -30
- package/templates/shared/rules/fec-rendering-patterns.md +40 -183
- package/templates/shared/rules/fec-responsive-design.md +37 -214
- package/templates/shared/rules/fec-source-driven-development.md +22 -22
- package/templates/shared/rules/fec-state-management.md +45 -148
- package/templates/shared/rules/fec-testing.md +64 -64
- package/templates/shared/rules/fec-typescript.md +98 -341
- package/templates/shared/rules/fec-vue.md +42 -42
- package/templates/shared/rules/fec-working-modes.md +34 -34
- package/skills/fec-e2e-testing/references/e2e-advanced.md +0 -176
- package/skills/fec-react-project-standard/references/react-project-details.md +0 -642
- package/skills/fec-vue3-project-standard/references/vue3-project-details.md +0 -547
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# 设计系统规则
|
|
2
|
+
|
|
3
|
+
凡是任务涉及 UI 实现、设计稿转代码、样式、设计 Token 或组件复用时,都应用本文件。本文只保留项目常驻设计约束;产品化设计方向、设计系统生成、页面级 override、UI QA 细节交给 `fec-ui-design`;Tailwind token、variant、dark mode 和 class 治理交给 `fec-tailwind-design-system`;响应式布局交给 `fec-responsive-layout`。
|
|
4
|
+
|
|
5
|
+
## 核心优先级
|
|
6
|
+
|
|
7
|
+
1. 复用已有组件。
|
|
8
|
+
2. 在已有组件上扩展。
|
|
9
|
+
3. 创建新的叶子组件。
|
|
10
|
+
4. 只有在理由充分、边界清晰且会被复用时,才创建新的共享基础组件。
|
|
11
|
+
|
|
12
|
+
## 产品化设计方向
|
|
13
|
+
|
|
14
|
+
- 工具型页面、SaaS 后台、CRM、运营台:优先安静、密集、可扫描,首屏直接呈现核心工作区。
|
|
15
|
+
- 品牌页、作品集、发布页:可以更有表现力,但 H1 应是品牌、产品、对象或品类,说明文案放在副标题。
|
|
16
|
+
- 可视化、游戏、创作工具:可以使用更强视觉资产和动效,但必须保持交互可控、状态清晰。
|
|
17
|
+
- 每个重要界面都应有贴合业务的视觉锚点,例如真实媒体、数据形态、行业材质、字体性格、空间组织或交互节奏。
|
|
18
|
+
- 大胆设计必须服务场景;高频工具重效率和稳定,展示型页面重主体识别和记忆点。
|
|
19
|
+
|
|
20
|
+
避免:
|
|
21
|
+
|
|
22
|
+
- 把日常高频工具做成营销落地页。
|
|
23
|
+
- 默认使用紫色渐变、装饰光斑、堆叠卡片、空泛 hero 或无语境默认字体。
|
|
24
|
+
- 页面区块大面积卡片化,尤其是卡片套卡片。
|
|
25
|
+
- 用可见说明文字解释常见控件本该表达的功能。
|
|
26
|
+
- 让整个界面只由一个色相的深浅变化组成。
|
|
27
|
+
|
|
28
|
+
## 设计稿转代码规则
|
|
29
|
+
|
|
30
|
+
- 有设计上下文时,先通过 MCP 或截图/标注读取事实来源,不靠猜测决定布局、间距、字体、颜色或状态。
|
|
31
|
+
- 设计稿中的颜色、间距、圆角、阴影和字体应映射到现有 token、CSS 变量、主题变量或组件 variant。
|
|
32
|
+
- 创建新组件前先检查现有组件库和业务组件,优先复用。
|
|
33
|
+
- 默认验证 mobile(375px)、tablet(768px)、desktop(1440px)。
|
|
34
|
+
- 像素还原要求以项目约定为准;没有约定时,核心结构、间距、字体、状态和交互优先于机械追求截图重合。
|
|
35
|
+
- 复杂设计任务实现前先给出简短实现计划,说明复用组件、新建组件、可能改动文件、响应式策略和 token 映射。
|
|
36
|
+
|
|
37
|
+
## 设计 Token 与样式
|
|
38
|
+
|
|
39
|
+
- 优先使用已有 design token、CSS 变量或主题变量;不要硬编码颜色、圆角、间距、阴影和字体取值。
|
|
40
|
+
- 缺少所需 token 时要明确指出,并集中补齐或记录,不在多个组件里散落字面量。
|
|
41
|
+
- Tailwind 项目中,token 应通过语义化 `theme.extend`、CSS 变量或组件 variant 承接;不要把 `blue-600`、`rounded-xl` 等具体值复制成事实标准。
|
|
42
|
+
- 组件 variant 应区分语义 tone、尺寸 size、密度 density 和状态 state;不要让一个字符串参数同时承载多种业务含义。
|
|
43
|
+
- 动态 Tailwind class 必须可被构建扫描识别;复杂映射使用显式对象、variant 工具或 safelist。
|
|
44
|
+
- 优先使用局部、受控的样式,不做大范围全局覆盖;与项目现有 CSS Modules、Tailwind、组件库或样式体系保持一致。
|
|
45
|
+
|
|
46
|
+
## 界面质感基线
|
|
47
|
+
|
|
48
|
+
- 嵌套圆角保持光学关系:外层圆角约等于内层圆角 + 间距。
|
|
49
|
+
- 图标按钮、箭头、播放三角等非对称图形按视觉中心微调。
|
|
50
|
+
- 小控件命中区域至少 40x40px,空间允许时优先 44x44px。
|
|
51
|
+
- 标题和短文本可用 `text-wrap: balance`,短中正文可用 `text-wrap: pretty`。
|
|
52
|
+
- 计数器、价格、时间、表格数字使用 `font-variant-numeric: tabular-nums`。
|
|
53
|
+
- 动效只声明实际变化属性,禁止 `transition: all` 和 `will-change: all`,并尊重 `prefers-reduced-motion`。
|
|
54
|
+
|
|
55
|
+
## 暗色模式
|
|
56
|
+
|
|
57
|
+
- 项目级暗色模式只选择一种主策略:CSS 变量、根节点 class、`data-theme` 或组件库主题。
|
|
58
|
+
- 支持手动切换主题时,要在首屏绘制前初始化用户偏好,避免主题闪烁;实现细节交给 Tailwind / design-system skill reference。
|
|
59
|
+
- 亮色与暗色都要复核 disabled、focus、selected、invalid、skeleton、chart、表单控件、第三方组件和阴影层级。
|
|
60
|
+
- 不只靠降低透明度表达 disabled,不只补背景色而忽略文本、边框、图表和焦点状态。
|
|
61
|
+
|
|
62
|
+
## 可访问性基线
|
|
63
|
+
|
|
64
|
+
- 优先使用语义化 HTML。
|
|
65
|
+
- 表单控件具备标签,纯图标按钮具备可访问名称。
|
|
66
|
+
- 菜单、标签页、对话框和自定义控件支持键盘操作。
|
|
67
|
+
- 焦点样式可见,标题层级正确,真实表格数据使用表格语义。
|
|
68
|
+
- 颜色对比度、触摸目标、reduced-motion 和错误提示不能被视觉 polish 破坏。
|
|
69
|
+
|
|
70
|
+
## UI 任务输出
|
|
71
|
+
|
|
72
|
+
实现完成后说明复用了什么、新建了什么、与设计稿或项目 token 的偏差、缺少哪些资源或交互细节。复杂 UI 还应说明状态覆盖、响应式验证和剩余设计风险。
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# 错误处理规范
|
|
2
|
+
|
|
3
|
+
本文件约定前端错误处理的常驻边界。React/Vue 组件边界细节交给对应框架 skill,API 错误映射和鉴权刷新交给 `fec-api-integration`,安全敏感错误交给 `fec-security-review`。
|
|
4
|
+
|
|
5
|
+
## 错误分层
|
|
6
|
+
|
|
7
|
+
| 层级 | 错误类型 | 默认处理 |
|
|
8
|
+
| ---- | -------- | -------- |
|
|
9
|
+
| 全局 | 未捕获异常、Promise rejection | 捕获、上报、全局降级 UI |
|
|
10
|
+
| 路由 / 页面 | 页面级渲染异常 | Error Boundary / 框架错误边界 + 页面级降级 |
|
|
11
|
+
| 模块 | 功能模块运行时异常 | 模块级边界 + 局部降级 |
|
|
12
|
+
| 组件 / 请求 | 数据请求失败、操作失败 | 用户可理解提示 + 可恢复动作 |
|
|
13
|
+
| 表单 | 校验失败 | 字段级错误提示和修正入口 |
|
|
14
|
+
|
|
15
|
+
## 全局与模块边界
|
|
16
|
+
|
|
17
|
+
- 应在应用入口注册未捕获异常和 Promise rejection 监听,并接入项目错误上报平台。
|
|
18
|
+
- React 使用项目统一的 Error Boundary 方案;业务组件保持函数式,不新增手写类组件边界。
|
|
19
|
+
- Vue 使用项目统一的 `app.config.errorHandler`、`onErrorCaptured` 或框架级错误边界。
|
|
20
|
+
- 独立功能模块应有局部降级能力,模块崩溃不应导致整个页面白屏。
|
|
21
|
+
- Error Boundary 处理渲染异常;普通 API 失败应落到 loading/error/empty/data 状态和可恢复操作。
|
|
22
|
+
|
|
23
|
+
## API 错误处理
|
|
24
|
+
|
|
25
|
+
- 请求层统一归一错误形状,组件不直接解析后端异常、token refresh 或重试策略。
|
|
26
|
+
- 每类错误都应对应明确下一步:重试、重新登录、修改输入、返回上级、刷新冲突数据、联系支持或稍后再试。
|
|
27
|
+
- `401`、`403`、`404`、`409`、`422`、`429`、`5xx` 和网络错误应有可区分的用户提示和日志语义。
|
|
28
|
+
- UI 可显示 request id / trace id 方便支持排查,但不得暴露内部堆栈、SQL、服务名、密钥或敏感字段。
|
|
29
|
+
|
|
30
|
+
## 用户体验
|
|
31
|
+
|
|
32
|
+
- 每个数据展示区域处理 Loading、Error、Empty、Success 四种状态。
|
|
33
|
+
- 全局级错误页提供返回首页、刷新或重试路径;模块级降级只影响该模块;操作级错误给出下一步。
|
|
34
|
+
- 重试策略要克制:用户手动重试优先,自动重试需有上限、退避和停止条件。
|
|
35
|
+
- 错误提示应保留用户已输入内容,避免因失败丢失表单或上下文。
|
|
36
|
+
|
|
37
|
+
## 错误上报
|
|
38
|
+
|
|
39
|
+
上报内容应包含错误堆栈、页面 URL、浏览器/设备信息、用户或会话标识、操作上下文、请求标识和版本信息。上报前清理 token、密码、个人敏感字段和大体积 payload。
|
|
40
|
+
|
|
41
|
+
## 反模式
|
|
42
|
+
|
|
43
|
+
- 空 `catch` 块吞掉错误。
|
|
44
|
+
- 所有错误统一用 `alert()` 或一个模糊 toast。
|
|
45
|
+
- 接口失败时 UI 无反馈,或把后端原始异常直接展示给用户。
|
|
46
|
+
- Error Boundary 没有重试或返回路径。
|
|
47
|
+
- 在组件中到处写重复 `try/catch`,而不是统一封装请求边界。
|
|
48
|
+
- 用 Error Boundary 承接普通 API 错误,导致用户无法理解或恢复。
|
|
49
|
+
|
|
50
|
+
## 检查清单
|
|
51
|
+
|
|
52
|
+
- [ ] 全局未捕获异常和 Promise rejection 已监听。
|
|
53
|
+
- [ ] 关键页面或模块有框架错误边界和局部降级 UI。
|
|
54
|
+
- [ ] API 请求有统一错误归一、分级处理和可恢复动作。
|
|
55
|
+
- [ ] 数据区域覆盖 Loading / Error / Empty / Success。
|
|
56
|
+
- [ ] 错误上报包含足够定位信息且不泄露敏感数据。
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Git 提交规范
|
|
2
|
+
|
|
3
|
+
凡是创建 commit、编写 commit message 或准备提交代码时,都应用本文件。
|
|
4
|
+
|
|
5
|
+
## Conventional Commits 格式
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
<type>(<scope>): <subject>
|
|
9
|
+
|
|
10
|
+
[body]
|
|
11
|
+
|
|
12
|
+
[footer]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### type 取值
|
|
16
|
+
|
|
17
|
+
| type | 用途 |
|
|
18
|
+
|------|------|
|
|
19
|
+
| `feat` | 新功能 |
|
|
20
|
+
| `fix` | 修复 bug |
|
|
21
|
+
| `refactor` | 重构(不改变行为) |
|
|
22
|
+
| `style` | 代码格式调整(不影响逻辑) |
|
|
23
|
+
| `docs` | 文档变更 |
|
|
24
|
+
| `test` | 测试相关 |
|
|
25
|
+
| `chore` | 构建、工具、依赖等杂项 |
|
|
26
|
+
| `perf` | 性能优化 |
|
|
27
|
+
| `ci` | CI/CD 配置变更 |
|
|
28
|
+
|
|
29
|
+
### scope
|
|
30
|
+
|
|
31
|
+
可选,标明影响范围,如模块名、组件名或功能域:
|
|
32
|
+
|
|
33
|
+
- `feat(auth): 新增手机号登录`
|
|
34
|
+
- `fix(table): 修复排序列未高亮`
|
|
35
|
+
- `refactor(api): 统一请求错误处理`
|
|
36
|
+
|
|
37
|
+
### subject 规范
|
|
38
|
+
|
|
39
|
+
- 使用祈使句("增加 xxx" 而非 "增加了 xxx")
|
|
40
|
+
- 不超过 72 个字符
|
|
41
|
+
- 不以句号结尾
|
|
42
|
+
- 如果影响范围较大,在 body 中详细说明
|
|
43
|
+
|
|
44
|
+
## 分支命名
|
|
45
|
+
|
|
46
|
+
- `feature/xxx` — 新功能
|
|
47
|
+
- `fix/xxx` — 修复
|
|
48
|
+
- `refactor/xxx` — 重构
|
|
49
|
+
- `hotfix/xxx` — 紧急修复
|
|
50
|
+
|
|
51
|
+
## 提交前检查
|
|
52
|
+
|
|
53
|
+
提交前必须通过:
|
|
54
|
+
|
|
55
|
+
1. lint
|
|
56
|
+
2. type-check
|
|
57
|
+
3. 与变更相关的测试
|
|
58
|
+
|
|
59
|
+
未经用户确认不要直接执行 `git commit`。
|
|
60
|
+
|
|
61
|
+
## 提交粒度
|
|
62
|
+
|
|
63
|
+
- 一个提交只包含一个清晰目的:功能、修复、测试、文档或清理。
|
|
64
|
+
- 大型计划应拆成可验证的小批次,每批都有说明和命令结果。
|
|
65
|
+
- 清理、格式化和行为变更不要混在同一提交中。
|
|
66
|
+
- 推送或发 PR 前先复查 diff,确认没有本地配置、密钥、临时报告或调试输出。
|
|
67
|
+
|
|
68
|
+
## 反模式
|
|
69
|
+
|
|
70
|
+
- 一个 commit 混合不相关的改动
|
|
71
|
+
- commit message 过于笼统(如 "update"、"fix bug"、"wip")
|
|
72
|
+
- 在 commit 中包含调试代码、console.log 或临时 hack
|
|
73
|
+
- 未说明验证命令或已知剩余风险就提交高风险改动
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# 国际化 (i18n) 规则
|
|
2
|
+
|
|
3
|
+
凡是涉及用户可见文案、提示信息、表单标签、错误消息或 UI 文本时,都应用本文件。请根据项目实际 i18n 方案修改 locales 路径、库与 key 前缀。
|
|
4
|
+
|
|
5
|
+
## 适用范围
|
|
6
|
+
|
|
7
|
+
- **现代栈(React / Vue / Next / Nuxt 等)**:新增或修改的用户可见文案必须走项目 i18n 方案。
|
|
8
|
+
- **遗留 HTML/JS、渐进迁移或新旧并存**:新代码路径仍须满足核心原则;遗留层遵守迁移约束,避免扩大硬编码和混乱 key。
|
|
9
|
+
|
|
10
|
+
下文用 `src/locales/` 指代项目实际文案资源目录,请按仓库约定替换。
|
|
11
|
+
|
|
12
|
+
## 核心原则
|
|
13
|
+
|
|
14
|
+
- 新应用代码中的用户可见文案须使用 i18n,禁止硬编码中文或英文字符串。
|
|
15
|
+
- i18n key 按模块组织,使用点分命名,例如 `order.list.empty`。
|
|
16
|
+
- 相同语义的文案复用同一个 key,避免重复定义。
|
|
17
|
+
- 变量、复数、日期、数字和货币使用 i18n 能力格式化,不用字符串拼接。
|
|
18
|
+
- 修改文案前先检索现有资源,优先复用准确 key。
|
|
19
|
+
|
|
20
|
+
## 文案与资源规范
|
|
21
|
+
|
|
22
|
+
- `common.*` 用于跨模块通用文案,例如确认、取消、提交、加载中。
|
|
23
|
+
- `module.component.*` 用于模块级文案。
|
|
24
|
+
- `validation.*` 用于表单校验提示。
|
|
25
|
+
- `error.*` 用于错误信息。
|
|
26
|
+
- 每种自然语言对应独立资源文件,禁止多种语言混写在同一文件或同一顶层多语言对象内。
|
|
27
|
+
- 文案文件须以 UTF-8 保存;团队有约定时优先 UTF-8 无 BOM,避免中文、日文等非 ASCII 文案乱码。
|
|
28
|
+
- 新增 key 时,同步更新当前功能应覆盖的主要语言文件;若某语言暂缺,必须显式记录缺口。
|
|
29
|
+
|
|
30
|
+
## 遗留代码与迁移场景
|
|
31
|
+
|
|
32
|
+
- 遗留 HTML 或 JS 中不新增用户可见硬编码,除非该段为纯静态展示且仓库尚无可接入 i18n 路径。
|
|
33
|
+
- React / Vue 等新代码路径新增提示、错误、按钮、表单标签时,必须走 i18n。
|
|
34
|
+
- 新增子应用或模块时,与现有语言文件结构、命名空间和懒加载策略一致。
|
|
35
|
+
- key 按页面、模块和语义组织,避免继续沿用历史缩写或无意义分段。
|
|
36
|
+
- 旧 key 若仅“能用但不准”,优先重命名 key 并重写译文,不长期保留并行兼容。
|
|
37
|
+
- 仅当旧 key 已成为对外契约(后端、埋点、外部文档、第三方集成等固定引用)时,才引入映射层或别名过渡。
|
|
38
|
+
|
|
39
|
+
## 实现约束
|
|
40
|
+
|
|
41
|
+
- Vue、React、Next、Nuxt 的具体调用方式以项目现有 i18n 库为准,例如 `vue-i18n`、`react-intl`、`react-i18next` 或框架内置方案。
|
|
42
|
+
- 组件中不要直接写用户可见硬编码;测试可通过 key 或最终文案断言,但应避免与翻译细节过度耦合。
|
|
43
|
+
- 懒加载语言包时,loading、fallback 和缺失 key 行为要可预期。
|
|
44
|
+
- 错误、表单和空状态文案要能表达用户下一步,不只翻译技术错误。
|
|
45
|
+
|
|
46
|
+
## 检查清单
|
|
47
|
+
|
|
48
|
+
- [ ] 所有新增用户可见文案使用 i18n key。
|
|
49
|
+
- [ ] 新增 key 已添加到所有应覆盖语言文件,且各语言分文件维护。
|
|
50
|
+
- [ ] 语言资源文件为 UTF-8,打开无乱码。
|
|
51
|
+
- [ ] key 命名符合模块、组件、用途约定,并复用已有语义。
|
|
52
|
+
- [ ] 插值、复数、日期、数字、货币使用 i18n 格式化。
|
|
53
|
+
- [ ] 迁移或混合栈中未扩大用户可见硬编码。
|
|
54
|
+
- [ ] 新代码未破坏现有命名空间、加载方式和子应用边界。
|
|
55
|
+
|
|
56
|
+
## 反模式
|
|
57
|
+
|
|
58
|
+
- 在模板或 JSX 中直接写用户可见中文或英文字符串。
|
|
59
|
+
- 使用字符串拼接代替 i18n 插值。
|
|
60
|
+
- 在 JS/TS 逻辑中硬编码 toast、错误或确认文案。
|
|
61
|
+
- 不同模块为相同含义创建不同 key。
|
|
62
|
+
- 多语言混写导致 diff、评审和按需加载困难。
|
|
63
|
+
- 用非 UTF-8 或错误编码保存文案文件。
|
|
64
|
+
- 为迁就历史缩写或劣质命名长期保留多套并行 key。
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# 命名规范
|
|
2
|
+
|
|
3
|
+
## 文件与目录命名
|
|
4
|
+
|
|
5
|
+
| 类型 | 命名风格 | 示例 |
|
|
6
|
+
|------|----------|------|
|
|
7
|
+
| 页面组件 | PascalCase + `Page` 后缀 | `UserDetailPage.tsx` / `UserDetailPage.vue` |
|
|
8
|
+
| 布局组件 | PascalCase + `Layout` 后缀 | `MainLayout.tsx` / `MainLayout.vue` |
|
|
9
|
+
| 通用组件 | PascalCase | `DataTable.tsx` / `AppButton.vue` |
|
|
10
|
+
| Hooks / Composables | camelCase + `use` 前缀 | `useAuth.ts`、`useDebounce.ts` |
|
|
11
|
+
| Store 文件 | camelCase + `Store` 后缀 | `authStore.ts`、`uiStore.ts` |
|
|
12
|
+
| API 文件 | camelCase | `api.ts` 或按领域命名 `userApi.ts` |
|
|
13
|
+
| 工具函数 | camelCase | `format.ts`、`validators.ts` |
|
|
14
|
+
| 类型文件 | camelCase | `types.ts`、`models.ts` |
|
|
15
|
+
| 常量文件 | camelCase | `constants.ts`、`config.ts` |
|
|
16
|
+
| 测试文件 | 与源文件同名 + `.spec` / `.test` | `Button.spec.tsx`、`useAuth.spec.ts` |
|
|
17
|
+
| 样式文件 | 组件名 + `.styles` + 扩展名 | `Button.styles.css`、`DataTable.styles.scss`;使用 styled-components 时为 `ComponentName.styles.ts` |
|
|
18
|
+
| 语言包 | 语言代码(BCP 47) | `zh-CN.json`、`en-US.json` |
|
|
19
|
+
| 目录名 | PascalCase(组件/页面)或 kebab-case(功能模块) | `UserDetail/`、`auth/`、`order/` |
|
|
20
|
+
|
|
21
|
+
## 组件命名
|
|
22
|
+
|
|
23
|
+
### React
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
// 文件名与组件名一致
|
|
27
|
+
// src/components/DataTable/DataTable.tsx
|
|
28
|
+
export function DataTable({ data, columns }: DataTableProps) { ... }
|
|
29
|
+
|
|
30
|
+
// 页面组件加 Page 后缀
|
|
31
|
+
// src/pages/UserDetail/UserDetailPage.tsx
|
|
32
|
+
export default function UserDetailPage() { ... }
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Vue
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<!-- 文件名与组件名一致 -->
|
|
39
|
+
<!-- src/components/AppButton/AppButton.vue -->
|
|
40
|
+
<script setup lang="ts">
|
|
41
|
+
// 无需 defineOptions,文件名即组件名
|
|
42
|
+
</script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- 多词组件名(避免与 HTML 原生标签冲突)
|
|
46
|
+
- Vue 全局组件推荐使用 `App` 前缀(`AppButton`、`AppModal`)
|
|
47
|
+
- 模板中使用 PascalCase 引用:`<AppButton>` 而非 `<app-button>`
|
|
48
|
+
|
|
49
|
+
## 变量与函数命名
|
|
50
|
+
|
|
51
|
+
| 类型 | 命名风格 | 示例 |
|
|
52
|
+
|------|----------|------|
|
|
53
|
+
| 普通变量 | camelCase | `userName`、`isLoading`、`pageSize` |
|
|
54
|
+
| 常量 | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT`、`DEFAULT_PAGE_SIZE` |
|
|
55
|
+
| 布尔值 | `is` / `has` / `should` / `can` 前缀 | `isVisible`、`hasPermission`、`canEdit` |
|
|
56
|
+
| 事件处理(组件内) | `handle` 前缀 | `handleClick`、`handleSubmit` |
|
|
57
|
+
| 回调 Props | `on` 前缀 | `onClick`、`onSubmit`、`onChange` |
|
|
58
|
+
| 数组 | 复数名词 | `users`、`orderItems`、`selectedIds` |
|
|
59
|
+
| Map / Record | `xxxMap` 或 `xxxByYyy` | `userMap`、`permissionsById` |
|
|
60
|
+
| Ref (Vue) | 不加 `Ref` 后缀 | `count`(不用 `countRef`) |
|
|
61
|
+
| 接口 | PascalCase,不加 `I` 前缀 | `UserProfile`(不用 `IUserProfile`) |
|
|
62
|
+
| Props 接口 | 组件名 + `Props` | `DataTableProps`、`UserFormProps` |
|
|
63
|
+
| Emits 接口 | 组件名 + `Emits` | `UserFormEmits` |
|
|
64
|
+
| 枚举 | PascalCase,成员用 PascalCase | `OrderStatus.Pending` |
|
|
65
|
+
| 泛型参数 | 单字母大写或语义化 | `T`、`TData`、`TItem` |
|
|
66
|
+
|
|
67
|
+
## CSS 类命名
|
|
68
|
+
|
|
69
|
+
- 与项目约定保持一致(BEM / CSS Modules / Tailwind / Atomic CSS)
|
|
70
|
+
- 如果使用 CSS Modules,类名用 camelCase:`.headerTitle`、`.cardBody`
|
|
71
|
+
- 如果使用 BEM,遵循 `block__element--modifier` 格式
|
|
72
|
+
- CSS 变量使用 kebab-case:`--color-primary`、`--spacing-md`
|
|
73
|
+
|
|
74
|
+
## 路由命名
|
|
75
|
+
|
|
76
|
+
| 类型 | 命名风格 | 示例 |
|
|
77
|
+
|------|----------|------|
|
|
78
|
+
| 路由路径 | kebab-case | `/user-detail`、`/order-list` |
|
|
79
|
+
| 路由名称 | PascalCase | `UserDetail`、`OrderList` |
|
|
80
|
+
| 路由参数 | camelCase | `:userId`、`:orderId` |
|
|
81
|
+
| 查询参数 | camelCase | `?pageSize=10&sortBy=name` |
|
|
82
|
+
| 路径常量 | UPPER_SNAKE_CASE | `ROUTE_USER_DETAIL = '/user-detail'` |
|
|
83
|
+
|
|
84
|
+
## API 命名
|
|
85
|
+
|
|
86
|
+
| 类型 | 命名风格 | 示例 |
|
|
87
|
+
|------|----------|------|
|
|
88
|
+
| GET 列表 | `getXxxList` | `getUserList(params)` |
|
|
89
|
+
| GET 单条 | `getXxxDetail` / `getXxxById` | `getUserDetail(id)` |
|
|
90
|
+
| POST 创建 | `createXxx` | `createOrder(data)` |
|
|
91
|
+
| PUT 更新 | `updateXxx` | `updateUser(id, data)` |
|
|
92
|
+
| DELETE 删除 | `deleteXxx` | `deleteOrder(id)` |
|
|
93
|
+
| DTO 类型 | 动词 + 名词 + `DTO` | `CreateOrderDTO`、`UpdateUserDTO` |
|
|
94
|
+
| 响应类型 | 名词 | `User`、`Order`、`PageResult<User>` |
|
|
95
|
+
|
|
96
|
+
## i18n Key 命名
|
|
97
|
+
|
|
98
|
+
- 使用点分命名空间:`module.section.label`
|
|
99
|
+
- 示例:`user.form.username`、`common.button.submit`、`error.network.timeout`
|
|
100
|
+
- 不使用中文 / 拼音作为 key
|
|
101
|
+
|
|
102
|
+
## 反模式
|
|
103
|
+
|
|
104
|
+
- 文件名和组件名不一致(`user-table.tsx` 导出 `DataGrid`)
|
|
105
|
+
- 同一项目混用多种命名风格(有的 kebab-case 有的 PascalCase)
|
|
106
|
+
- 使用缩写或不明确的名称(`btn`、`usr`、`tmp`、`handleA`)
|
|
107
|
+
- 布尔值没有语义前缀(`visible` → 应为 `isVisible`)
|
|
108
|
+
- 常量不用大写(`maxRetry` → 应为 `MAX_RETRY`)
|
|
109
|
+
- CSS 变量硬编码在组件中而非使用统一变量
|
|
110
|
+
|
|
111
|
+
## 检查清单
|
|
112
|
+
|
|
113
|
+
- [ ] 文件名与导出的组件/函数名一致
|
|
114
|
+
- [ ] 页面组件有 `Page` 后缀,布局组件有 `Layout` 后缀
|
|
115
|
+
- [ ] 布尔变量使用 `is` / `has` / `can` / `should` 前缀
|
|
116
|
+
- [ ] 事件处理用 `handle` 前缀,回调 Props 用 `on` 前缀
|
|
117
|
+
- [ ] 常量使用 UPPER_SNAKE_CASE
|
|
118
|
+
- [ ] 路由路径使用 kebab-case,路由名使用 PascalCase
|
|
119
|
+
- [ ] API 函数命名与 HTTP 方法语义一致
|
|
120
|
+
- [ ] i18n key 使用点分命名空间,无硬编码文案
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# 前端性能规则
|
|
2
|
+
|
|
3
|
+
凡是新增页面、组件、资源加载或数据请求时,都应用本文件。
|
|
4
|
+
|
|
5
|
+
## 核心原则
|
|
6
|
+
|
|
7
|
+
- 默认懒加载,按需加载
|
|
8
|
+
- 减少首屏关键资源
|
|
9
|
+
- 避免不必要的重渲染
|
|
10
|
+
- 关注 Core Web Vitals
|
|
11
|
+
- 前端构建必须同时验证开发体验和生产产物,不能只看 dev server 正常
|
|
12
|
+
- 在上下文或任务边界不清时,不启动大规模性能重构;先定位瓶颈再改代码
|
|
13
|
+
- 对长时间运行的命令保留可回看日志,必要时使用终端会话、CI artifact 或测试报告
|
|
14
|
+
- 每项性能建议都要绑定证据、影响范围、验证方式和回退风险
|
|
15
|
+
|
|
16
|
+
## 代码分割与懒加载
|
|
17
|
+
|
|
18
|
+
### 路由级分割
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
// React
|
|
22
|
+
const Dashboard = lazy(() => import('./pages/Dashboard'));
|
|
23
|
+
|
|
24
|
+
// Vue
|
|
25
|
+
const Dashboard = () => import('./pages/Dashboard.vue');
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 组件级分割
|
|
29
|
+
|
|
30
|
+
仅在以下场景使用组件级懒加载:
|
|
31
|
+
|
|
32
|
+
- 重型第三方库(图表、编辑器、地图)
|
|
33
|
+
- 条件渲染的大型模块(如设置面板、高级筛选)
|
|
34
|
+
- 不在首屏可视区域的内容
|
|
35
|
+
|
|
36
|
+
## 渲染性能
|
|
37
|
+
|
|
38
|
+
### React
|
|
39
|
+
|
|
40
|
+
- 合理使用 `React.memo` 避免不必要的重渲染
|
|
41
|
+
- `useMemo` / `useCallback` 仅在依赖稳定且子组件使用 memo 时才有意义
|
|
42
|
+
- 列表渲染必须使用稳定的 `key`
|
|
43
|
+
- 避免在渲染函数内创建新对象、数组或函数
|
|
44
|
+
|
|
45
|
+
### Vue
|
|
46
|
+
|
|
47
|
+
- 使用 `computed` 而非 `watch` + 手动赋值
|
|
48
|
+
- 大列表使用虚拟滚动
|
|
49
|
+
- 避免在 `v-for` 中使用 `v-if`
|
|
50
|
+
- 使用 `shallowRef` / `shallowReactive` 优化大型对象
|
|
51
|
+
|
|
52
|
+
## 资源优化
|
|
53
|
+
|
|
54
|
+
- 图片使用 WebP/AVIF 格式,提供适当尺寸
|
|
55
|
+
- 图标优先使用 SVG sprite 或 icon font,避免大量独立图片请求
|
|
56
|
+
- 字体按需加载,使用 `font-display: swap`
|
|
57
|
+
- 第三方依赖按需导入(如 `import { Button } from 'antd'` 而非 `import antd from 'antd'`)
|
|
58
|
+
|
|
59
|
+
## Vite 构建与开发性能
|
|
60
|
+
|
|
61
|
+
使用 Vite 时额外遵守:
|
|
62
|
+
|
|
63
|
+
- `vite build` 不做类型检查,CI 必须单独执行 `tsc --noEmit` 或接入 `vite-plugin-checker`
|
|
64
|
+
- 慢启动先用 `vite --profile` 定位插件、解析或预构建瓶颈
|
|
65
|
+
- 大项目可使用 `server.warmup.clientFiles` 预热核心入口
|
|
66
|
+
- CJS/UMD 依赖互操作问题优先通过 `optimizeDeps.include` 处理
|
|
67
|
+
- 手动分包优先使用稳定对象形式,不要把每个 `node_modules` 包拆成独立 chunk
|
|
68
|
+
- 组件库模式必须 externalize peer dependencies,并单独产出类型声明
|
|
69
|
+
- `vite preview` 只用于本地构建烟测,不是生产服务器
|
|
70
|
+
|
|
71
|
+
## 数据请求
|
|
72
|
+
|
|
73
|
+
- 避免瀑布式请求(串行依赖),尽可能并行
|
|
74
|
+
- 合理使用缓存策略(SWR / React Query / VueQuery)
|
|
75
|
+
- 分页加载或虚拟滚动处理大数据集
|
|
76
|
+
- 防抖/节流处理高频触发的请求(搜索、滚动)
|
|
77
|
+
|
|
78
|
+
## 检查清单
|
|
79
|
+
|
|
80
|
+
- [ ] 是否记录核心路由、设备、网络和当前指标
|
|
81
|
+
- [ ] 路由是否按需加载
|
|
82
|
+
- [ ] 重型组件是否懒加载
|
|
83
|
+
- [ ] 大列表是否使用虚拟滚动或分页
|
|
84
|
+
- [ ] 图片是否使用现代格式和合理尺寸
|
|
85
|
+
- [ ] 第三方库是否按需导入
|
|
86
|
+
- [ ] 是否存在不必要的重渲染
|
|
87
|
+
- [ ] Vite 项目是否单独执行 typecheck
|
|
88
|
+
- [ ] Vite 构建产物是否经过 `vite build` 和本地预览烟测
|
|
89
|
+
- [ ] 是否复查 loading、error、empty、disabled 和移动端状态没有被优化破坏
|
|
90
|
+
|
|
91
|
+
## 反模式
|
|
92
|
+
|
|
93
|
+
- 将所有路由打包在一个 chunk 中
|
|
94
|
+
- 在首屏加载整个图表库或编辑器
|
|
95
|
+
- 在组件内重复创建相同的 API 请求
|
|
96
|
+
- 大列表不做虚拟化直接渲染数千行 DOM
|
|
97
|
+
- 频繁操作(如输入、滚动)不做防抖/节流
|
|
98
|
+
- 认为 `vite build` 通过就代表 TypeScript 没有错误
|
|
99
|
+
- 设置 `envPrefix: ""` 或把服务端密钥注入客户端 bundle
|
|
100
|
+
- 未先复现卡顿、包体积或 Web Vitals 指标,就做大范围“性能优化”
|
|
101
|
+
- 为追求实验室分数删除状态反馈、降低可访问性或牺牲主路径可维护性
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# React 规则
|
|
2
|
+
|
|
3
|
+
当仓库或目标模块使用 React 时,应用本文件。
|
|
4
|
+
|
|
5
|
+
## 技术栈
|
|
6
|
+
|
|
7
|
+
<!-- 请根据项目实际情况修改 -->
|
|
8
|
+
|
|
9
|
+
- 框架: React + TypeScript
|
|
10
|
+
- 样式: Tailwind CSS + CSS Modules
|
|
11
|
+
- 状态管理: Zustand / Redux Toolkit / Jotai(按项目实际选择)
|
|
12
|
+
- UI 组件库: 按项目实际选择(如 Ant Design、Material UI 或内部 Design System)
|
|
13
|
+
- 版本与依赖:新建模块、补充 `package.json` 或更新本节前,优先采用彼此兼容的主流稳定版本(对齐官方文档、脚手架默认值或包管理器推荐),避免混用已停止维护或与仓库主线 major 不匹配的依赖。
|
|
14
|
+
|
|
15
|
+
## React 组件规范
|
|
16
|
+
|
|
17
|
+
- 使用**函数组件**、Hooks 与 TypeScript;**不要**新增类组件(含手写 Error Boundary,统一用 `react-error-boundary` 等库)
|
|
18
|
+
- 保持组件小而可组合
|
|
19
|
+
- 将可复用逻辑提取到 hooks
|
|
20
|
+
- props 保持明确且类型清晰
|
|
21
|
+
- 保持可访问性与键盘交互
|
|
22
|
+
- 优先使用可推导状态,避免重复维护 state
|
|
23
|
+
- 在创建新基础组件前,先复用现有设计系统
|
|
24
|
+
- 禁止使用 any,优先使用 unknown
|
|
25
|
+
- CSS 命名遵循 BEM(CSS Modules 场景)
|
|
26
|
+
|
|
27
|
+
## 模式与最佳实践(React)
|
|
28
|
+
|
|
29
|
+
- **组合**:用小组件 + `children`/props 拼装;避免宽布尔 props 与假「继承」。
|
|
30
|
+
- **复合组件**:根组件用 Context 向子组件暴露状态;子组件在缺少 Context 时明确报错。
|
|
31
|
+
- **Render Props**:仅在需要封装数据态并把渲染交给上层时考虑;多数场景优先自定义 Hook + 普通组件。
|
|
32
|
+
- **Context + useReducer**:中等复杂度的多子树客户端状态;勿把高频变化大对象放在顶层 Context;服务端数据用 React Query / SWR。
|
|
33
|
+
- **表单**:中大型表单优先 React Hook Form + Zod;避免单文件巨型受控 state。
|
|
34
|
+
- **Error Boundary**:关键模块用 **`react-error-boundary`**(或团队统一的同类库)在模块边界兜底;业务组件一律函数式,不手写类组件 Error Boundary。
|
|
35
|
+
- **性能**:`useMemo`/`useCallback`/`React.memo` 按需使用;长列表用虚拟列表(如 TanStack Virtual、react-window);昂贵计算注意不可变派生(勿原地 `sort` 原数组)。
|
|
36
|
+
- **动效**:Framer Motion 或 CSS transition;尊重 `prefers-reduced-motion`。
|
|
37
|
+
- **无障碍**:复合控件补齐 `role`/`aria-*` 与键盘操作;弹窗管理焦点落入与关闭后恢复。
|
|
38
|
+
- **Next.js**:App Router 与 Server Components 相关约定以项目 Next 规则为准。
|
|
39
|
+
|
|
40
|
+
## React 实现指导
|
|
41
|
+
|
|
42
|
+
创建新组件前:
|
|
43
|
+
|
|
44
|
+
1. 先搜索是否已存在等价组件
|
|
45
|
+
2. 判断逻辑是否应该放入自定义 hook
|
|
46
|
+
3. 与项目当前样式方案保持一致
|
|
47
|
+
|
|
48
|
+
编辑 React 组件时:
|
|
49
|
+
|
|
50
|
+
- 避免在同一个文件里混合数据请求、重业务逻辑和展示逻辑
|
|
51
|
+
- 避免设计过宽或语义不清的 props API
|
|
52
|
+
- 对局部问题避免滥用 context
|
|
53
|
+
- 保持条件渲染可读,必要时提取重复分支
|
|
54
|
+
|
|
55
|
+
## React 文件组织
|
|
56
|
+
|
|
57
|
+
优先遵循仓库已有约定。
|
|
58
|
+
常见输出可能包括:
|
|
59
|
+
|
|
60
|
+
- `Component.tsx`
|
|
61
|
+
- `Component.types.ts`
|
|
62
|
+
- `hooks/useComponentLogic.ts`
|
|
63
|
+
- `ComponentName.styles.css`(普通 CSS / CSS Modules;使用 styled-components 时为 `ComponentName.styles.ts`)
|
|
64
|
+
- 如果仓库采用就近测试,则补充测试文件,如:`__tests__/Component.spec.tsx`
|
|
65
|
+
|
|
66
|
+
## 组件文件规模
|
|
67
|
+
|
|
68
|
+
- 单个组件文件保持**职责单一**、语义清晰、易于维护。
|
|
69
|
+
- **行数参考**:优先将单文件控制在约 **300 行**以内;超过 **500 行**应视为**强烈拆分信号**。
|
|
70
|
+
- **未到 500 行也应拆分**的情形:同时存在**复杂状态交织**、**过多副作用**、**JSX 嵌套过深**、**密集条件分支**、数据获取与 UI 长期混在同一文件等,使单文件难以一眼把握时,应拆为**子组件**、**自定义 Hooks**、**工具函数**、**常量**与**类型定义**等独立单元(目录与命名仍遵循上文「React 文件组织」)。
|
|
71
|
+
|
|
72
|
+
## React 反模式
|
|
73
|
+
|
|
74
|
+
避免:
|
|
75
|
+
|
|
76
|
+
- 新建**类组件**或手写类式 Error Boundary(应使用函数组件 + `react-error-boundary` 等)
|
|
77
|
+
- 对可推导值使用多余 state
|
|
78
|
+
- 大段 JSX 不拆成子组件
|
|
79
|
+
- 单文件堆叠过多职责与行数,**逾 500 行或复杂度已高**仍拒不拆分(参见上文「组件文件规模」)
|
|
80
|
+
- 使用不稳定 key
|
|
81
|
+
- 在 props 和 hooks 中无理由使用 `any`
|
|
82
|
+
- 没有充分理由时引入第二套样式体系
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# 重构项目规则
|
|
2
|
+
|
|
3
|
+
当任务涉及从现有项目重构、迁移或重写前端代码时,应用本文件。
|
|
4
|
+
|
|
5
|
+
## 目标
|
|
6
|
+
|
|
7
|
+
- **视觉和交互**:与原项目一致,用户无感知差异
|
|
8
|
+
- **代码质量**:更简洁、易维护,符合目标框架规范
|
|
9
|
+
- **业务功能**:与原项目保持一致,**不得缺失功能**;重构前后行为等价
|
|
10
|
+
|
|
11
|
+
## 图片与图标
|
|
12
|
+
|
|
13
|
+
- 直接使用原项目的图片资源路径,不重新托管或替换
|
|
14
|
+
- 可使用 SVG 图片(`<img src="*.svg" />` 或 CSS `background-image`),**禁止使用内联 SVG**(`<svg>...</svg>` 直接写在组件中)
|
|
15
|
+
- **若原项目使用了 iconfont 或 IcoMoon 图标,重构时继续使用**,保持图标体系一致;不替换为其他图标方案
|
|
16
|
+
- 图标优先使用原项目已有的图标文件(iconfont / IcoMoon / 已有 SVG),必要时可引入 SVG 文件作为独立资源
|
|
17
|
+
|
|
18
|
+
## 样式
|
|
19
|
+
|
|
20
|
+
- 布局样式对齐原项目视觉效果,但**只参考原项目效果,不照搬其 CSS**
|
|
21
|
+
- 优先使用 **flex 弹性布局**,避免 `float`、复杂 `position`、冗余嵌套
|
|
22
|
+
- 避免不合理写法:`!important` 滥用、过深选择器、重复定义
|
|
23
|
+
- **组件中禁止使用内联样式**(`style={{ ... }}` / `style="..."`),样式统一放在 CSS Modules、Tailwind 类或样式文件中,便于维护
|
|
24
|
+
|
|
25
|
+
## 强约束
|
|
26
|
+
|
|
27
|
+
- 业务功能与原项目完整等价,不得缺失
|
|
28
|
+
- 图片使用原项目资源,无内联 SVG;若原项目用 iconfont/IcoMoon 则继续使用
|
|
29
|
+
- 样式参考原项目效果但不照搬 CSS,优先 flex 布局,无内联样式
|
|
30
|
+
- 对公共 API、路由、事件、埋点、权限、缓存和错误状态建立行为清单,重构前后逐项核对
|
|
31
|
+
- 涉及页面、组件、路由、表单、弹窗、导航或关键用户流程的迁移,必须使用 Playwright 或同等真实浏览器验证方式对关键路径做对比验证
|
|
32
|
+
- 对视觉敏感页面,应补充截图对比或人工截图验收;动态内容、动画、字体和环境差异需明确屏蔽、稳定化或说明
|
|
33
|
+
- 对纯逻辑、类型、构建或无 UI 的迁移,不强制 Playwright,应选择更贴近风险的验证层:type-check、unit test、component test、build 或 lint
|
|
34
|
+
- 验证目标不是像素级完全一致,而是确认业务功能无缺失、关键交互等价、主要视觉布局无非预期偏差,并且代码比旧实现更清晰、可维护
|
|
35
|
+
|
|
36
|
+
## 死代码清理
|
|
37
|
+
|
|
38
|
+
清理未使用代码、导出、样式或依赖时:
|
|
39
|
+
|
|
40
|
+
- 先建立验证基线,再做清理。
|
|
41
|
+
- 使用工具或搜索证据证明候选项无引用。
|
|
42
|
+
- 将候选项分为 SAFE、CAUTION、DANGER。
|
|
43
|
+
- 仅自动清理 SAFE 项;路由、配置、运行时模板、动态 import 和公开 API 默认视为高风险。
|
|
44
|
+
- 每批清理后运行受影响验证命令。
|
|
45
|
+
- 若验证失败,先回到最近一批候选项定位,不继续扩大清理范围。
|
|
46
|
+
|
|
47
|
+
不要把死代码清理与功能重写、视觉调整或依赖升级混在同一个改动里。
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# 渲染模式选型
|
|
2
|
+
|
|
3
|
+
当项目需要选择或评估 CSR / SSR / SSG / ISR / RSC 时,参考本文件。本文只保留跨框架决策约束;Next.js App Router 细节交给 `fec-nextjs-project-standard`,Nuxt 细节交给 `fec-nuxt-project-standard`,性能证据交给 `fec-performance-optimization`。
|
|
4
|
+
|
|
5
|
+
## 渲染模式概览
|
|
6
|
+
|
|
7
|
+
| 模式 | 生成时机 | 典型适用 |
|
|
8
|
+
| ---- | -------- | -------- |
|
|
9
|
+
| CSR | 浏览器运行时 | 登录后后台、内部工具、高交互 SPA |
|
|
10
|
+
| SSR | 请求时服务端 | SEO 关键且内容实时的公开页 |
|
|
11
|
+
| SSG | 构建时 | 文档、博客、营销页、变化慢的公开内容 |
|
|
12
|
+
| ISR | 构建时 + 按需再生成 | 页面数量多、内容更新频繁但允许延迟 |
|
|
13
|
+
| RSC | 服务端组件渲染 | Next.js App Router 中需要减少客户端 JS 的场景 |
|
|
14
|
+
|
|
15
|
+
## 选型原则
|
|
16
|
+
|
|
17
|
+
- SEO 必须且内容实时:优先 SSR,并明确缓存、超时和错误降级。
|
|
18
|
+
- SEO 必须且内容稳定:优先 SSG;页面数量巨大或更新频繁时考虑 ISR。
|
|
19
|
+
- 登录后后台、强交互工作区、内部工具:优先 CSR,公开登录/注册页可单独 SSG/SSR。
|
|
20
|
+
- 混合产品:公开页与私有页可以采用不同模式,不为统一架构牺牲体验或成本。
|
|
21
|
+
- 页面数量、更新频率、服务器成本、部署平台、缓存策略和团队运维能力必须一起评估。
|
|
22
|
+
- RSC 只在支持的框架和路由体系中使用;客户端交互、浏览器 API 和高频状态仍放在客户端叶子组件。
|
|
23
|
+
|
|
24
|
+
## 实施约束
|
|
25
|
+
|
|
26
|
+
- SSR / RSC 路径不得直接依赖 `window`、`document`、localStorage 或浏览器专属库。
|
|
27
|
+
- Hydration 前后的 HTML、时间、随机数、用户偏好和媒体查询结果要保持一致,避免水合不匹配。
|
|
28
|
+
- 服务端数据获取必须有超时、错误降级和缓存策略。
|
|
29
|
+
- SSG / ISR 需要明确未预渲染路径、revalidate / 失效策略和回滚方式。
|
|
30
|
+
- 客户端大型动效库、图表、编辑器、地图、WebGL/Canvas 等应按需加载,不进入根布局同步 bundle。
|
|
31
|
+
- 不在没有响应头、构建输出、trace、路由行为或线上指标证据时断言某路由“已缓存”或“必须动态”。
|
|
32
|
+
|
|
33
|
+
## 检查清单
|
|
34
|
+
|
|
35
|
+
- [ ] 明确公开页与私有页、SEO 需求和实时性需求。
|
|
36
|
+
- [ ] 明确每类页面使用 CSR / SSR / SSG / ISR / RSC 的理由。
|
|
37
|
+
- [ ] 评估页面数量、构建时间、服务器成本和缓存失效策略。
|
|
38
|
+
- [ ] 检查 SSR/RSC 代码没有浏览器 API 依赖和不可序列化 props。
|
|
39
|
+
- [ ] 确认 loading、error、not-found、离线和权限状态不会因渲染模式丢失。
|
|
40
|
+
- [ ] 用构建输出、响应头、trace 或路由行为验证最终模式。
|