@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,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-browser-storage
|
|
3
|
+
description: 用于选择、实现或审查 localStorage、sessionStorage、IndexedDB、cookie、客户端持久化、离线数据、安全存储或清理策略等浏览器存储方案;中文触发词包括 浏览器存储、客户端持久化。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 浏览器存储
|
|
7
|
+
|
|
8
|
+
## 用途
|
|
9
|
+
|
|
10
|
+
根据数据大小、安全要求和生命周期选择合适的客户端存储方案。
|
|
11
|
+
|
|
12
|
+
## 流程
|
|
13
|
+
|
|
14
|
+
1. 先判断数据敏感度、体积、生命周期、是否需要跨 Tab、是否需要随请求发送。
|
|
15
|
+
2. 小量非敏感偏好用 localStorage;Tab 级临时数据用 sessionStorage;大量结构化数据或离线缓存用 IndexedDB;认证态优先 httpOnly cookie。
|
|
16
|
+
3. 封装统一 key 前缀、JSON parse/stringify、异常处理、过期清理和 quota 兜底。
|
|
17
|
+
4. 敏感数据按安全规则处理,不把明文 token、密码、信用卡信息放进可被 JS 读取的存储。
|
|
18
|
+
5. 审查隐私模式、存储配额、清理策略和跨浏览器兼容性。
|
|
19
|
+
|
|
20
|
+
## 详细参考
|
|
21
|
+
|
|
22
|
+
涉及存储选型表、localStorage/sessionStorage 封装、IndexedDB 示例、Cookie 辅助方法和敏感数据规则时,加载 [references/storage-patterns.md](references/storage-patterns.md)。
|
|
23
|
+
|
|
24
|
+
## 约束
|
|
25
|
+
|
|
26
|
+
- localStorage/sessionStorage 是同步 API,大数据读写会阻塞主线程。
|
|
27
|
+
- 除 httpOnly cookie 外,客户端存储都可被 XSS 读取。
|
|
28
|
+
- Cookie 每次请求自动携带,不适合大数据。
|
|
29
|
+
- IndexedDB 配额和隐私模式行为有浏览器差异。
|
|
30
|
+
- URL 中不要传 token 或敏感数据。
|
|
31
|
+
|
|
32
|
+
## 预期输出
|
|
33
|
+
|
|
34
|
+
产出统一的 storage/cookie/db 封装,key 有命名空间,数据有过期或清理策略,敏感数据只进入合适的安全边界。
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# 浏览器存储模式
|
|
2
|
+
|
|
3
|
+
## 选型表
|
|
4
|
+
|
|
5
|
+
| 存储 | 容量 | API | 是否发送服务端 | 适用场景 | 安全性 |
|
|
6
|
+
| --- | --- | --- | --- | --- | --- |
|
|
7
|
+
| LocalStorage | ~5MB | 同步 | 否 | 用户偏好、非敏感持久数据 | XSS 可读取 |
|
|
8
|
+
| SessionStorage | ~5MB | 同步 | 否 | Tab 级临时数据 | XSS 可读取 |
|
|
9
|
+
| IndexedDB | 大 | 异步 | 否 | 大数据、文件、离线缓存 | XSS 可读取 |
|
|
10
|
+
| Cookie | ~4KB | 同步 | 是 | 认证 Session/httpOnly token | httpOnly 可防 JS 读取 |
|
|
11
|
+
|
|
12
|
+
## localStorage 封装
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
const STORAGE_PREFIX = "app:";
|
|
16
|
+
|
|
17
|
+
export const storage = {
|
|
18
|
+
get<T>(key: string): T | null {
|
|
19
|
+
try {
|
|
20
|
+
const raw = localStorage.getItem(STORAGE_PREFIX + key);
|
|
21
|
+
return raw ? JSON.parse(raw) : null;
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
set<T>(key: string, value: T): void {
|
|
27
|
+
localStorage.setItem(STORAGE_PREFIX + key, JSON.stringify(value));
|
|
28
|
+
},
|
|
29
|
+
remove(key: string): void {
|
|
30
|
+
localStorage.removeItem(STORAGE_PREFIX + key);
|
|
31
|
+
},
|
|
32
|
+
clear(): void {
|
|
33
|
+
Object.keys(localStorage)
|
|
34
|
+
.filter((key) => key.startsWith(STORAGE_PREFIX))
|
|
35
|
+
.forEach((key) => localStorage.removeItem(key));
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## IndexedDB
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { openDB } from "idb";
|
|
44
|
+
|
|
45
|
+
export const db = openDB("app-offline-db", 1, {
|
|
46
|
+
upgrade(database) {
|
|
47
|
+
if (!database.objectStoreNames.contains("requests")) {
|
|
48
|
+
database.createObjectStore("requests", { keyPath: "id" });
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Cookie
|
|
55
|
+
|
|
56
|
+
- httpOnly 只能由服务端设置。
|
|
57
|
+
- 认证 Cookie 使用 `Secure`、`SameSite=Lax/Strict`。
|
|
58
|
+
- 需要跨站点嵌入时才考虑 `SameSite=None; Secure`。
|
|
59
|
+
|
|
60
|
+
## 敏感数据规则
|
|
61
|
+
|
|
62
|
+
- 认证 token、刷新 token、Session ID:优先 httpOnly cookie。
|
|
63
|
+
- 用户偏好:localStorage。
|
|
64
|
+
- 表单草稿:sessionStorage 或 IndexedDB,避免敏感字段。
|
|
65
|
+
- 离线数据:IndexedDB,但不要缓存隐私或高价值敏感数据。
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-canvas-threejs
|
|
3
|
+
description: 用于构建或审查 Canvas 2D、Three.js/WebGL、React Three Fiber、GLSL shader、ShaderToy 到 WebGL 适配、2D/3D 可视化、游戏渲染、动画循环、GPU 资源清理或渲染性能。不要用于标准 DOM UI、已有图表库覆盖的图表或非图形类性能工作;中文触发词包括 Canvas、Three.js、WebGL、GLSL、Shader、3D、数据可视化、游戏。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Canvas 与 Three.js
|
|
7
|
+
|
|
8
|
+
## 用途
|
|
9
|
+
|
|
10
|
+
在浏览器中实现高性能 2D/3D 图形渲染。
|
|
11
|
+
|
|
12
|
+
## 流程
|
|
13
|
+
|
|
14
|
+
1. 先选渲染层:标准 UI 用 DOM;简单 2D 图形/签名/粒子用 Canvas 2D;3D 模型、空间交互和复杂粒子用 Three.js/WebGL;React 项目中的声明式 3D 用 React Three Fiber。
|
|
15
|
+
2. 为渲染容器定义稳定尺寸、DPI 适配和 resize 行为;Canvas 不会自动随 CSS 清晰缩放。
|
|
16
|
+
3. 动画循环使用 `requestAnimationFrame`,不可见或无变化时暂停,卸载时取消。
|
|
17
|
+
4. Three.js 必须释放 geometry/material/texture/renderer,并移除事件监听和 observer。
|
|
18
|
+
5. Shader/WebGL 任务先识别是 SDF、ray marching、noise、particle、post-processing、multipass 还是调试问题,再决定是否需要原生 WebGL2、Three.js ShaderMaterial 或 R3F。
|
|
19
|
+
6. WebGL2 适配时检查 GLSL 版本、入口函数、varying/in-out、texture API、uniform 使用和函数声明顺序,避免白屏只留控制台错误。
|
|
20
|
+
7. 对不可访问的图形内容提供 `aria-label`、替代文本或 DOM 版摘要;交互式图形要有键盘兜底。
|
|
21
|
+
|
|
22
|
+
## 核心模式
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
26
|
+
canvas.width = width * dpr;
|
|
27
|
+
canvas.height = height * dpr;
|
|
28
|
+
canvas.style.width = `${width}px`;
|
|
29
|
+
canvas.style.height = `${height}px`;
|
|
30
|
+
ctx.scale(dpr, dpr);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
let animationId = 0;
|
|
35
|
+
function animate() {
|
|
36
|
+
animationId = requestAnimationFrame(animate);
|
|
37
|
+
renderer.render(scene, camera);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return () => {
|
|
41
|
+
cancelAnimationFrame(animationId);
|
|
42
|
+
geometry.dispose();
|
|
43
|
+
material.dispose();
|
|
44
|
+
renderer.dispose();
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 详细参考
|
|
49
|
+
|
|
50
|
+
涉及 Canvas 2D 绘图、动画循环、Three.js 场景搭建、React Three Fiber、InstancedMesh 和性能清理时,加载 [references/rendering-patterns.md](references/rendering-patterns.md)。
|
|
51
|
+
|
|
52
|
+
涉及着色器路由、WebGL2 适配、GLSL 调试、多 pass 预算和视觉验证时,加载 [references/shader-webgl-patterns.md](references/shader-webgl-patterns.md)。
|
|
53
|
+
|
|
54
|
+
## 约束
|
|
55
|
+
|
|
56
|
+
- Canvas/WebGL 内容对屏幕阅读器不可见,必须提供替代语义。
|
|
57
|
+
- WebGL 消耗 GPU,低端设备需限制像素比、面数和纹理大小。
|
|
58
|
+
- Three.js 资源不会自动释放,遗漏 `dispose()` 会造成 GPU 内存泄漏。
|
|
59
|
+
- Canvas 响应式必须同步 CSS 尺寸、绘图尺寸和相机/viewport。
|
|
60
|
+
- 复杂布局/路径规划可联用后台线程 workflow,但渲染本身仍在主线程/渲染线程协调。
|
|
61
|
+
- Shader 主循环、采样层数和多 pass 数量必须有预算;低端设备上要降低 DPR、步数、粒子数或禁用重后处理。
|
|
62
|
+
- 交付前必须确认 canvas 非空、尺寸正确、resize 后不拉伸、控制台无 shader compile/link 错误。
|
|
63
|
+
|
|
64
|
+
## 预期输出
|
|
65
|
+
|
|
66
|
+
2D/3D 场景清晰、响应式、可清理,关键设备上接近 60fps;用户能通过替代文本或键盘路径理解/操作核心内容。
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Canvas、Three.js 与 R3F 模式
|
|
2
|
+
|
|
3
|
+
## Canvas 2D
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
const canvas = document.getElementById("chart") as HTMLCanvasElement;
|
|
7
|
+
const ctx = canvas.getContext("2d");
|
|
8
|
+
if (!ctx) throw new Error("Canvas 2D is unavailable");
|
|
9
|
+
|
|
10
|
+
ctx.fillStyle = "#3b82f6";
|
|
11
|
+
ctx.fillRect(10, 10, 50, 50);
|
|
12
|
+
ctx.beginPath();
|
|
13
|
+
ctx.arc(100, 100, 30, 0, Math.PI * 2);
|
|
14
|
+
ctx.fill();
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 动画循环
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
let animationId = 0;
|
|
21
|
+
|
|
22
|
+
function animate() {
|
|
23
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
24
|
+
updateParticles();
|
|
25
|
+
drawParticles(ctx);
|
|
26
|
+
animationId = requestAnimationFrame(animate);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
animate();
|
|
30
|
+
return () => cancelAnimationFrame(animationId);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Three.js 基础场景
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
const scene = new THREE.Scene();
|
|
37
|
+
const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
|
|
38
|
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
|
39
|
+
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
|
40
|
+
|
|
41
|
+
const geometry = new THREE.BoxGeometry(1, 1, 1);
|
|
42
|
+
const material = new THREE.MeshStandardMaterial({ color: 0x00ff00 });
|
|
43
|
+
const cube = new THREE.Mesh(geometry, material);
|
|
44
|
+
scene.add(cube);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## React Three Fiber
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
<Canvas camera={{ position: [0, 0, 5], fov: 75 }} role="img" aria-label="3D 产品预览">
|
|
51
|
+
<ambientLight intensity={0.5} />
|
|
52
|
+
<directionalLight position={[5, 5, 5]} />
|
|
53
|
+
<mesh>
|
|
54
|
+
<boxGeometry />
|
|
55
|
+
<meshStandardMaterial color="hotpink" />
|
|
56
|
+
</mesh>
|
|
57
|
+
<OrbitControls />
|
|
58
|
+
</Canvas>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 性能与清理
|
|
62
|
+
|
|
63
|
+
- 纹理尽量压缩并限制尺寸,常规上限先按 2048px 评估。
|
|
64
|
+
- 重复几何体用 `InstancedMesh`。
|
|
65
|
+
- 不需要持续重绘时暂停 animation loop。
|
|
66
|
+
- 卸载时释放 geometry、material、texture、renderer、controls。
|
|
67
|
+
- ResizeObserver 更新相机 aspect 和 renderer size。
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Shader 与 WebGL 模式
|
|
2
|
+
|
|
3
|
+
## 技术选型参考
|
|
4
|
+
|
|
5
|
+
| 目标 | 推荐起点 | 注意事项 |
|
|
6
|
+
| ------------------ | ------------------ | ------------------------------ |
|
|
7
|
+
| 数学几何 3D 形态 | SDF + 光线步进 | 步数上限、法线质量、软阴影开销 |
|
|
8
|
+
| 有机运动效果 | 噪声 + 域扭曲 | 过度绘制、重复噪声调用 |
|
|
9
|
+
| 粒子效果 | 实例化或着色器粒子 | 移动端粒子数量上限、混合开销 |
|
|
10
|
+
| 泛光/故障/色彩调整 | 后处理通道 | 额外帧缓冲区显存 |
|
|
11
|
+
| 持续模拟 | 乒乓帧缓冲区 | 纹理格式支持 |
|
|
12
|
+
| 白屏调试 | 编译/链接日志 | 函数顺序、被优化掉的 uniform |
|
|
13
|
+
|
|
14
|
+
## WebGL2 适配清单
|
|
15
|
+
|
|
16
|
+
- 片元着色器以 `#version 300 es` 开头。
|
|
17
|
+
- 添加 `precision highp float;` 和 `out vec4 fragColor;`。
|
|
18
|
+
- 用 `in`/`out` 替代旧版 `varying`。
|
|
19
|
+
- 用 `texture()` 替代 `texture2D()`。
|
|
20
|
+
- 将 ShaderToy 风格的 `mainImage` 包装为标准 `main`。
|
|
21
|
+
- 使用 `gl_FragCoord.xy` 获取片元坐标。
|
|
22
|
+
- 辅助函数必须在被调用前声明。
|
|
23
|
+
- 预计算常量,不要在宏定义中放函数调用。
|
|
24
|
+
|
|
25
|
+
## 运行时骨架
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
const gl = canvas.getContext("webgl2");
|
|
29
|
+
if (!gl) throw new Error("WebGL2 is unavailable");
|
|
30
|
+
|
|
31
|
+
function compile(type: number, source: string) {
|
|
32
|
+
const shader = gl.createShader(type);
|
|
33
|
+
if (!shader) throw new Error("Cannot create shader");
|
|
34
|
+
gl.shaderSource(shader, source.trim());
|
|
35
|
+
gl.compileShader(shader);
|
|
36
|
+
|
|
37
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
38
|
+
throw new Error(gl.getShaderInfoLog(shader) ?? "Shader compile failed");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return shader;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 性能预算
|
|
46
|
+
|
|
47
|
+
- 光线步进步数:从 64 起步,仅在出现伪影且证明必要时再提升。
|
|
48
|
+
- 体积采样:桌面端每条射线 16-24 次,移动端酌情降低。
|
|
49
|
+
- FBM 倍频:从 4 开始;避免在光线循环内嵌套 FBM。
|
|
50
|
+
- DPR:桌面端上限 2,移动端重度场景上限 1.5。
|
|
51
|
+
- 纹理尺寸:使用压缩或缩放资源;不要假设 4K 纹理是安全的。
|
|
52
|
+
|
|
53
|
+
## 调试视图
|
|
54
|
+
|
|
55
|
+
- 法线:输出归一化后的法线,映射到 0-1 范围。
|
|
56
|
+
- 步数:输出当前步数除以最大步数。
|
|
57
|
+
- 距离/深度:以灰度输出命中距离。
|
|
58
|
+
- UV:映射后输出 `vec3(uv, 0.0)`。
|
|
59
|
+
- 材质 ID:将 ID 映射到少量固定调色板。
|
|
60
|
+
|
|
61
|
+
## 视觉验证
|
|
62
|
+
|
|
63
|
+
- 桌面端和移动端尺寸下 Canvas 不为空白。
|
|
64
|
+
- 缩放时更新绘制缓冲区、视口、相机纵横比和 uniform。
|
|
65
|
+
- 低功耗模式下仍能响应,或有静态降级方案。
|
|
66
|
+
- 控制台无着色器编译/链接错误。
|
|
67
|
+
- 卸载或场景隐藏时停止动画。
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-code-review
|
|
3
|
+
description: 用于用户要求通用前端代码评审、PR 评审、合并就绪评估、架构可维护性、类型安全、渲染/状态风险、样式一致性、可测性缺口或横向评审总结时。深度安全、无障碍、E2E 或性能问题应委托对应专项 skill;中文触发词包括 代码审查、代码评审、review。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 前端代码评审
|
|
7
|
+
|
|
8
|
+
## 用途
|
|
9
|
+
|
|
10
|
+
从架构、类型安全、可访问性、样式一致性、性能和可测试性等 8 个维度审查前端代码质量,输出分级评审报告。
|
|
11
|
+
|
|
12
|
+
## 流程
|
|
13
|
+
|
|
14
|
+
1. 先读项目事实:package scripts、框架、目录约定、最近 diff、现有测试和相关规则。
|
|
15
|
+
2. 按风险找问题,而不是按个人偏好挑风格;每个发现都要能指向具体文件、行号和用户影响。
|
|
16
|
+
3. 用五轴收敛结论:正确性、可维护性、类型/接口、用户体验、验证覆盖。
|
|
17
|
+
4. 对安全、无障碍、E2E、性能等深水区只做初筛;需要专项调查时明确分流。
|
|
18
|
+
5. 多维评审时先按职责拆分,再合并同类发现;同一文件同一根因只保留一条主发现,避免重复噪声。
|
|
19
|
+
6. 报告先列阻塞问题,再列建议项;没有证据的问题不要写成确定结论。
|
|
20
|
+
|
|
21
|
+
## 多维评审编排
|
|
22
|
+
|
|
23
|
+
当改动跨越多个质量维度时,按“主评审 + 专项分流”组织,而不是让所有维度重复检查同一处代码。
|
|
24
|
+
|
|
25
|
+
| 维度 | 触发条件 | 分流边界 |
|
|
26
|
+
| ------------------- | ---------------------------------------------------- | ------------------------------------ |
|
|
27
|
+
| TypeScript 工程与类型契约 | DTO、泛型、公共类型、类型守卫、`any`、断言、tsconfig | 深入类型建模和 TS 配置交给 TypeScript 流程 |
|
|
28
|
+
| 状态管理 | 状态归属、全局 store、URL 状态、派生状态、跨页面同步 | 状态选型与迁移交给状态管理专项流程 |
|
|
29
|
+
| 安全 | 用户输入、HTML 渲染、token、上传、第三方脚本 | 漏洞级分析交给安全专项流程 |
|
|
30
|
+
| 无障碍 | 弹窗、菜单、表单、键盘操作、焦点管理 | WCAG 细查交给无障碍专项流程 |
|
|
31
|
+
| 性能 | 大列表、重依赖、重复请求、长任务、包体积 | 性能证据与预算交给性能专项流程 |
|
|
32
|
+
| E2E | 关键用户路径、登录态、支付、跨页面流程 | 浏览器用例与 trace 交给 E2E 专项流程 |
|
|
33
|
+
|
|
34
|
+
发现合并规则:
|
|
35
|
+
|
|
36
|
+
- 同一根因出现在多个维度时,只保留最高严重级别,并在 `Dimension` 中列出相关维度。
|
|
37
|
+
- 同一文件多处重复模式,合并为一条模式级发现,列出代表性位置。
|
|
38
|
+
- 置信度不足的问题放入 Open Questions,不升级为阻塞项。
|
|
39
|
+
- 自动化可稳定捕获的格式问题交给 lint/format,不作为人工评审主发现。
|
|
40
|
+
|
|
41
|
+
## 评审维度
|
|
42
|
+
|
|
43
|
+
1. 架构
|
|
44
|
+
|
|
45
|
+
- 组件边界是否清晰
|
|
46
|
+
- 展示逻辑与业务逻辑是否分离
|
|
47
|
+
- 是否有可复用抽象
|
|
48
|
+
- 是否存在上帝组件
|
|
49
|
+
|
|
50
|
+
2. 类型安全
|
|
51
|
+
|
|
52
|
+
- 是否存在不必要的 `any`
|
|
53
|
+
- props 类型是否明确
|
|
54
|
+
- hooks/composables 返回值是否稳定
|
|
55
|
+
- 在可行情况下 API 契约是否有类型约束
|
|
56
|
+
|
|
57
|
+
3. 渲染与状态
|
|
58
|
+
|
|
59
|
+
- 是否存在不必要的重复渲染
|
|
60
|
+
- key 的使用是否稳定
|
|
61
|
+
- 可推导状态是否被重复存储
|
|
62
|
+
- 本地状态是否耦合过深
|
|
63
|
+
- 全局 store 是否只保存真正跨边界共享的客户端状态
|
|
64
|
+
- URL 状态、服务端状态、表单状态和浏览器持久化是否边界清晰
|
|
65
|
+
|
|
66
|
+
4. 样式
|
|
67
|
+
|
|
68
|
+
- 已有 Token 时是否还在使用 magic number
|
|
69
|
+
- 类名是否与仓库约定一致
|
|
70
|
+
- 响应式处理是否明确
|
|
71
|
+
- 是否无必要地混用了多套样式体系
|
|
72
|
+
|
|
73
|
+
5. 可访问性
|
|
74
|
+
|
|
75
|
+
- 语义结构是否合理
|
|
76
|
+
- 是否在需要时正确使用 label 和 aria
|
|
77
|
+
- 是否支持键盘操作
|
|
78
|
+
- 浮层和菜单的焦点管理是否正确
|
|
79
|
+
|
|
80
|
+
6. 可维护性
|
|
81
|
+
|
|
82
|
+
- 组件/页面文件规模是否合理(宜约 **300 行**内;逾 **500 行**或复杂度过高须拆分,见共享 React / Vue 规则中的「组件文件规模」)
|
|
83
|
+
- 命名质量是否良好
|
|
84
|
+
- 是否有应该提取的重复逻辑
|
|
85
|
+
- 是否存在死代码、过期注释或临时性 hack
|
|
86
|
+
- 业务状态、类型、标识是否用裸数字/裸字符串(应对齐 `templates/shared/rules/fec-typescript.md`「禁止 Magic Number / Magic String」)
|
|
87
|
+
|
|
88
|
+
7. 测试
|
|
89
|
+
|
|
90
|
+
- 是否缺少关键测试覆盖
|
|
91
|
+
- 是否存在脆弱的选择器或不稳定的测试模式
|
|
92
|
+
|
|
93
|
+
8. 安全
|
|
94
|
+
|
|
95
|
+
- 无明显 XSS 风险(dangerouslySetInnerHTML / v-html 必须审查)
|
|
96
|
+
- 无敏感信息硬编码
|
|
97
|
+
- 无未校验的用户输入直接渲染
|
|
98
|
+
|
|
99
|
+
9. 性能与体验证据
|
|
100
|
+
|
|
101
|
+
- 是否引入首屏重依赖、重复请求、大列表渲染或长任务
|
|
102
|
+
- loading、empty、error、disabled、focus 等状态是否完整
|
|
103
|
+
- 响应式布局是否有可验证断点和文本溢出保护
|
|
104
|
+
|
|
105
|
+
10. 必检项(阻塞合并)
|
|
106
|
+
|
|
107
|
+
- [ ] TypeScript 类型完整,无 `any`
|
|
108
|
+
- [ ] 外部输入、DTO、公共类型边界无无守卫断言
|
|
109
|
+
- [ ] 无 XSS 风险
|
|
110
|
+
- [ ] 无敏感信息硬编码
|
|
111
|
+
- [ ] 核心逻辑有单元测试
|
|
112
|
+
|
|
113
|
+
11. 质量项(建议修改)
|
|
114
|
+
|
|
115
|
+
- [ ] 组件文件规模符合约定(约 300 行内为佳;逾 500 行或高复杂度已拆子组件 / Hooks / Composables / utils)
|
|
116
|
+
- [ ] 无重复代码(DRY 原则)
|
|
117
|
+
- [ ] 无未使用的 import
|
|
118
|
+
|
|
119
|
+
12. 规范项(风格建议)
|
|
120
|
+
|
|
121
|
+
- [ ] 命名语义清晰
|
|
122
|
+
- [ ] 注释覆盖复杂逻辑
|
|
123
|
+
|
|
124
|
+
## 详细参考
|
|
125
|
+
|
|
126
|
+
撰写代码评审报告时,加载 [references/report-template.md](references/report-template.md)。发现必须具体且可操作;不要写"优化性能"等空泛建议而不指出具体代码模式。
|
|
127
|
+
|
|
128
|
+
## 约束
|
|
129
|
+
|
|
130
|
+
- 不把个人风格偏好写成阻塞问题;阻塞项必须有明确用户影响、运行时风险、安全风险或维护成本证据。
|
|
131
|
+
- 不在缺少 diff、文件位置或复现线索时给确定结论。
|
|
132
|
+
- 深度安全、无障碍、E2E 和性能问题只做初筛;需要证据链时分流到专项 skill。
|
|
133
|
+
- 同一根因不要重复报多条;合并为一条代表性发现并列出影响范围。
|
|
134
|
+
- 自动化工具稳定覆盖的格式问题交给 lint/format,不作为人工评审主发现。
|
|
135
|
+
|
|
136
|
+
## 预期输出
|
|
137
|
+
|
|
138
|
+
- 分级评审报告(CRITICAL / HIGH / MEDIUM / LOW)
|
|
139
|
+
- 每个问题关联具体文件和行号,附修复建议
|
|
140
|
+
- 阻塞项(CRITICAL)修复前不建议合并
|
|
141
|
+
- 评审报告保存为 `reports/code-review-YYYY-MM-DD-HHmmss.md`
|
|
142
|
+
- 多维评审要合并重复发现,并说明已分流到哪些专项能力
|
|
143
|
+
- 对不确定项标注需要的验证命令或补充上下文,不把猜测写成事实
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# 代码审查报告模板
|
|
2
|
+
|
|
3
|
+
```markdown
|
|
4
|
+
# 代码审查报告
|
|
5
|
+
|
|
6
|
+
> 生成时间: YYYY-MM-DD HH:mm
|
|
7
|
+
> 评审工具: frontend-craft
|
|
8
|
+
|
|
9
|
+
## CRITICAL / 必须修改 (N项)
|
|
10
|
+
- **[文件:行号]** 问题描述 -> 建议修改
|
|
11
|
+
|
|
12
|
+
## HIGH / 建议优化 (N项)
|
|
13
|
+
- ...
|
|
14
|
+
|
|
15
|
+
## MEDIUM / 可选优化项 (N项)
|
|
16
|
+
- ...
|
|
17
|
+
|
|
18
|
+
## LOW / 观察项 (N项)
|
|
19
|
+
- ...
|
|
20
|
+
|
|
21
|
+
## 做得好的地方
|
|
22
|
+
- ...
|
|
23
|
+
|
|
24
|
+
## 风险等级:低 / 中 / 高
|
|
25
|
+
|
|
26
|
+
**总体评价**: 可合并 / 待修改后合并 / 需要重构
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
评审完成后,将报告保存到 `reports/code-review-YYYY-MM-DD-HHmmss.md`,并告知用户报告路径。
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-component-testing
|
|
3
|
+
description: 用于编写或审查靠近 UI 代码的前端单元、组件或轻量集成测试,包括 React Testing Library、Vue Test Utils、hooks/composables、props/emits、回调、可访问查询、user-event 交互、mock、loading/error/empty 状态和回归覆盖。若是测试分层规划、真实浏览器旅程或现有验证失败,优先选择对应测试或验证工作流;中文触发词包括 组件测试、组件单测、单元测试、轻量集成测试。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 组件测试
|
|
7
|
+
|
|
8
|
+
## 用途
|
|
9
|
+
|
|
10
|
+
用贴近代码和用户行为的测试验证纯逻辑、组件契约与轻量模块协作,减少重构和 UI 交互回归。
|
|
11
|
+
|
|
12
|
+
## 流程
|
|
13
|
+
|
|
14
|
+
### 1. 先确定测试层级
|
|
15
|
+
|
|
16
|
+
- 单元测试:纯函数、hooks/composables、utils、状态逻辑、schema。
|
|
17
|
+
- 组件测试:props/emits、回调、用户交互、loading/error/empty、mock 边界。
|
|
18
|
+
- 轻量集成测试:表单 + API mock + Router/Store/Provider 上下文。
|
|
19
|
+
|
|
20
|
+
跨页面真实浏览器流程分流到 E2E workflow;测试层选择不清楚时先做测试分层规划。
|
|
21
|
+
|
|
22
|
+
### 2. 优先按用户可感知行为测试
|
|
23
|
+
|
|
24
|
+
每个测试保持 Arrange / Act / Assert 清晰分段:准备数据和渲染、执行用户动作、断言用户可见结果或公开契约。
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { render, screen } from "@testing-library/react";
|
|
28
|
+
import userEvent from "@testing-library/user-event";
|
|
29
|
+
import { SearchBox } from "./SearchBox";
|
|
30
|
+
|
|
31
|
+
test("submits the entered keyword", async () => {
|
|
32
|
+
const user = userEvent.setup();
|
|
33
|
+
const onSearch = vi.fn();
|
|
34
|
+
|
|
35
|
+
render(<SearchBox onSearch={onSearch} />);
|
|
36
|
+
|
|
37
|
+
await user.type(screen.getByRole("searchbox", { name: /keyword/i }), "orders");
|
|
38
|
+
await user.click(screen.getByRole("button", { name: /search/i }));
|
|
39
|
+
|
|
40
|
+
expect(onSearch).toHaveBeenCalledWith("orders");
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 3. Vue 组件使用可访问查询或明确文本断言
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { mount } from "@vue/test-utils";
|
|
48
|
+
import UserMenu from "./UserMenu.vue";
|
|
49
|
+
|
|
50
|
+
test("emits logout when the logout item is clicked", async () => {
|
|
51
|
+
const wrapper = mount(UserMenu, {
|
|
52
|
+
props: { userName: "Ada" },
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
await wrapper.get('[data-testid="logout-button"]').trigger("click");
|
|
56
|
+
|
|
57
|
+
expect(wrapper.emitted("logout")).toHaveLength(1);
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
优先使用角色、标签和可见文本;仅在没有稳定语义时使用 `data-testid`。
|
|
62
|
+
|
|
63
|
+
### 4. 控制 mock 边界
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
vi.mock("../api/users", () => ({
|
|
67
|
+
fetchUsers: vi.fn(async () => [{ id: "1", name: "Ada" }]),
|
|
68
|
+
}));
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- mock 网络、时间、路由和浏览器 API。
|
|
72
|
+
- 不 mock 被测组件的内部函数。
|
|
73
|
+
- 对设计系统基础组件只做轻量 mock,保留可访问行为。
|
|
74
|
+
- mock 数据应表达业务场景,不使用只有测试作者能理解的随意字符串。
|
|
75
|
+
- 共享 fixture 应保持可读,复杂对象用 builder 补默认值;每个测试只覆盖与场景相关的字段。
|
|
76
|
+
- mock 网络时优先模拟用户可见结果和错误形状,不复制后端实现细节。
|
|
77
|
+
|
|
78
|
+
### 5. 覆盖关键状态
|
|
79
|
+
|
|
80
|
+
每个复杂组件至少覆盖:
|
|
81
|
+
|
|
82
|
+
- 默认渲染。
|
|
83
|
+
- 用户交互和回调。
|
|
84
|
+
- loading / empty / error。
|
|
85
|
+
- 权限或禁用态。
|
|
86
|
+
- 键盘交互和焦点行为(适用时)。
|
|
87
|
+
|
|
88
|
+
### 6. 保持测试可维护
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
function setup() {
|
|
92
|
+
const user = userEvent.setup();
|
|
93
|
+
const onSubmit = vi.fn();
|
|
94
|
+
render(<ProfileForm onSubmit={onSubmit} />);
|
|
95
|
+
return { user, onSubmit };
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
将重复渲染逻辑放入 `setup`,但不要隐藏测试的核心操作和断言。
|
|
100
|
+
|
|
101
|
+
### 7. 回归测试先证明问题
|
|
102
|
+
|
|
103
|
+
- Bug 修复先写能复现失败的最小测试。
|
|
104
|
+
- 失败原因应指向用户行为或公开契约,而不是导入错误、测试环境或等待方式。
|
|
105
|
+
- 修复后保留回归测试,避免把验证只留在手工步骤里。
|
|
106
|
+
|
|
107
|
+
## 约束
|
|
108
|
+
|
|
109
|
+
- 避免测试实现细节,例如内部 state 名称、私有函数调用、DOM 层级快照。
|
|
110
|
+
- 不把 snapshot 作为交互组件的主要断言;它只能辅助检查稳定静态输出。
|
|
111
|
+
- 异步断言使用 `findBy*` 或 `waitFor`,不要用固定延迟。
|
|
112
|
+
- 测试名称应描述用户场景,而不是函数名。
|
|
113
|
+
- 组件测试不能替代 E2E;路由、真实浏览器兼容和跨页流程仍需 E2E。
|
|
114
|
+
- 不在测试里复制组件实现逻辑;否则测试会和错误实现一起通过。
|
|
115
|
+
- 不在测试间共享可变 fixture、全局 store 或 fake timer 状态;每个用例独立 setup 和 cleanup。
|
|
116
|
+
|
|
117
|
+
## 预期输出
|
|
118
|
+
|
|
119
|
+
产出与组件同目录或项目约定目录下的测试文件,覆盖核心交互、状态和回归场景。验证时运行项目现有 test 命令,确认失败信息能定位到用户行为或组件契约。
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fec-data-fetching
|
|
3
|
+
description: 用于实现或审查前端服务端状态流程:类型化查询、请求缓存、失效、mutation、乐观更新、无限查询、预取、SSR hydration 或 API 层整合。不要用于本地 UI 状态或 Service Worker 缓存;中文触发词包括 数据获取、缓存、乐观更新。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Server State 数据获取
|
|
7
|
+
|
|
8
|
+
## 用途
|
|
9
|
+
|
|
10
|
+
为前端 server state 建立清晰的数据获取、缓存、失效和提交边界,避免请求状态散落在页面组件中。
|
|
11
|
+
|
|
12
|
+
## 流程
|
|
13
|
+
|
|
14
|
+
1. 判断状态来源:来自服务端且需要缓存、去重、刷新、分页或 mutation 时使用请求缓存方案;纯本地 UI 状态用组件 state 或 store。
|
|
15
|
+
2. 先沿用项目已有数据获取库;新增依赖时 React/Vue/Solid/Svelte 可考虑 TanStack Query,也可沿用 SWR、Nuxt/Nitro 数据获取或项目封装。
|
|
16
|
+
3. 设计稳定 cache key/query key:结构包含实体、动作和所有影响结果的参数。
|
|
17
|
+
4. API 函数保持纯请求函数,数据 hook/composable 负责缓存、select、loading/error/empty 状态。
|
|
18
|
+
5. mutation 成功后 invalidation;需要即时反馈时使用 optimistic update 并在失败时回滚。
|
|
19
|
+
|
|
20
|
+
## React 快速开始
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
24
|
+
|
|
25
|
+
export function UserList({ keyword }: { keyword: string }) {
|
|
26
|
+
const query = useQuery({
|
|
27
|
+
queryKey: ["users", "list", { keyword }],
|
|
28
|
+
queryFn: () => getUserList({ keyword, page: 1, pageSize: 20 }),
|
|
29
|
+
select: (response) => response.list,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (query.isLoading) return <Skeleton />;
|
|
33
|
+
if (query.isError) return <ErrorFallback onRetry={() => query.refetch()} />;
|
|
34
|
+
if (!query.data?.length) return <EmptyState />;
|
|
35
|
+
|
|
36
|
+
return query.data.map((user) => <UserRow key={user.id} user={user} />);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function useCreateUser() {
|
|
40
|
+
const queryClient = useQueryClient();
|
|
41
|
+
return useMutation({
|
|
42
|
+
mutationFn: createUser,
|
|
43
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["users"] }),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 详细参考
|
|
49
|
+
|
|
50
|
+
涉及是否需要查询库、QueryClient 默认配置、Vue adapter、乐观更新、无限滚动查询、预取、SSR 水合和 API 层整合时,加载 [references/query-patterns.md](references/query-patterns.md)。
|
|
51
|
+
|
|
52
|
+
## 约束
|
|
53
|
+
|
|
54
|
+
- 相同数据必须复用相同 cache key/query key;参数缺失会造成缓存串读。
|
|
55
|
+
- `staleTime` 过长会显示旧数据,过短会造成频繁请求。
|
|
56
|
+
- 请求缓存库不管理本地 UI 状态;不要把 modal、输入框值放进 query cache。
|
|
57
|
+
- 乐观更新必须保存快照并在失败时回滚。
|
|
58
|
+
- SSR/SSG 场景必须使用框架支持的预取、水合或服务端数据边界。
|
|
59
|
+
|
|
60
|
+
## 预期输出
|
|
61
|
+
|
|
62
|
+
数据获取层具备 loading/error/empty/data 状态,重复请求自动去重,mutation 后缓存正确失效或回滚,API 层与 UI 层边界清晰。
|