Some checks failed
App Prod-Parity E2E Dispatch / dispatch (push) Failing after 10s
CD Storybook UI / build (push) Failing after 3m25s
CD Storybook UI / dispatch (push) Has been skipped
CD deploy main / website-changed-files (push) Successful in 18m8s
CI Agent Skills / changed-files-check (push) Successful in 18m9s
CI Create App E2E minimal / changed-files-check (push) Successful in 24s
CI Create App / changed-files-check (push) Successful in 26s
CI Docs / changed-files-check (push) Successful in 26s
CI Emails / changed-files-check (push) Successful in 28s
CI Example App Hello World / changed-files-check (push) Successful in 23s
CI Front / changed-files-check (push) Has been skipped
CI Example App Postcard / changed-files-check (push) Successful in 27s
CI UI / changed-files-check (push) Has been skipped
CI Utils Test / changed-files-check (push) Successful in 45s
CI Twenty Apps / discover (push) Successful in 1m3s
CD deploy main / deploy-main (push) Failing after 3s
CI Agent Skills / agent-skills-validate (push) Has been skipped
CI Create App / create-app-test (lint) (push) Has been skipped
CI Emails / emails-test (push) Has been skipped
CI Front / front-task (lingui:compile) (push) Has been skipped
CI Front / front-task (lint) (push) Has been skipped
CI Example App Postcard / example-app-postcard (push) Has been skipped
CI UI / ui-task (lint) (push) Has been skipped
CI UI / ui-task (pack-size) (push) Has been skipped
CI UI / ui-task (size) (push) Has been skipped
CI UI / ui-task (test) (push) Has been skipped
CI UI / ui-task (typecheck) (push) Has been skipped
CI Utils Test / utils-test (push) Has been skipped
CI Twenty Apps / ${{ matrix.app.name }} (push) Has been skipped
CI Emails / ci-emails-status-check (push) Successful in 2s
CI Example App Hello World / ci-example-app-hello-world-status-check (push) Successful in 2s
CI Example App Postcard / ci-example-app-postcard-status-check (push) Successful in 3s
CI UI / ui-sb-test (push) Has been skipped
CI Utils Test / ci-utils-test-status-check (push) Successful in 2s
CI Twenty Apps / ci-twenty-apps-status-check (push) Successful in 2s
CI UI / ci-ui-status-check (push) Successful in 2s
CI Desktop / desktop (push) Failing after 1m8s
Push docs to Crowdin / Push documentation to Crowdin (push) Failing after 55s
Push translations to Crowdin / Extract and upload translations (push) Failing after 5s
Push website translations to Crowdin / Extract and upload website translations (push) Failing after 5s
CI Create App / create-app-test (test) (push) Has been skipped
CI Create App / create-app-test (typecheck) (push) Has been skipped
CI Docs / docs-lint (push) Has been skipped
CI Example App Hello World / example-app-hello-world (push) Has been skipped
CI Front / front-task (lingui:extract) (push) Has been skipped
CI Front / front-task (test) (push) Has been skipped
CI Front / front-task (typecheck) (push) Has been skipped
CI UI / ui-sb-build (push) Failing after 1m32s
CI Twenty Apps / ${{ matrix.app.name }} (${{ matrix.server-source }}) (push) Has been skipped
CI Agent Skills / agent-skills-publish (push) Has been skipped
CI Create App / ci-create-app-status-check (push) Successful in 2s
CI Agent Skills / agent-skills-remote-source (push) Has been skipped
CI Create App E2E minimal / create-app-e2e-minimal (push) Has been cancelled
CI E2E Main / e2e-test (push) Has been cancelled
CI Front / front-sb-build (push) Has been cancelled
CI Front / front-build (push) Has been cancelled
CI Create App E2E minimal / ci-create-app-e2e-minimal-status-check (push) Has been cancelled
CI E2E Main / ci-e2e-main-status-check (push) Has been cancelled
CI E2E Main / notify-main-ci-failure (push) Has been cancelled
CI E2E Main / qa-scout-comment (push) Has been cancelled
CI Front / front-sb-test (push) Has been cancelled
CI Front / front-sb-screenshots (push) Has been cancelled
CI Front / ci-front-status-check (push) Has been cancelled
DPA Sub-Processor Sync / sync-subprocessors (push) Failing after 3s
AI Catalog Sync / sync-catalog (push) Failing after 2s
111 lines
6.0 KiB
Plaintext
111 lines
6.0 KiB
Plaintext
---
|
||
title: Архитектура папок
|
||
icon: folder-tree
|
||
info: Подробное рассмотрение нашей архитектуры папок
|
||
---
|
||
|
||
В этом руководстве вы изучите детали структуры каталога проекта и то, как она способствует организации и сопровождаемости Twenty.
|
||
|
||
Следуя этому соглашению об архитектуре папок, легче находить файлы, связанные с конкретными функциями, и обеспечивать масштабируемость и поддерживаемость приложения.
|
||
|
||
```
|
||
front
|
||
└───modules
|
||
│ └───module1
|
||
│ │ └───submodule1
|
||
│ └───module2
|
||
│ └───ui
|
||
│ │ └───display
|
||
│ │ └───inputs
|
||
│ │ │ └───buttons
|
||
│ │ └───...
|
||
└───pages
|
||
└───...
|
||
```
|
||
|
||
## Страницы
|
||
|
||
Включает компоненты высокого уровня, определенные маршрутами приложения. Они импортируют более низкоуровневые компоненты из папки модулей (подробности ниже).
|
||
|
||
## Модули
|
||
|
||
Каждый модуль представляет собой функционал или группу функций, содержащий свои специфические компоненты, состояния и операционную логику.
|
||
Все они должны следовать структуре ниже. Вы можете вложить модули в модули (называются подмодулями), и те же правила будут применяться.
|
||
|
||
```
|
||
module1
|
||
└───components
|
||
│ └───component1
|
||
│ └───component2
|
||
└───constants
|
||
└───contexts
|
||
└───graphql
|
||
│ └───fragments
|
||
│ └───queries
|
||
│ └───mutations
|
||
└───hooks
|
||
│ └───internal
|
||
└───states
|
||
│ └───selectors
|
||
└───types
|
||
└───utils
|
||
```
|
||
|
||
### Контексты
|
||
|
||
Контекст — это способ передачи данных через дерево компонентов без необходимости передавать props вручную на каждом уровне.
|
||
|
||
См. [React Context](https://react.dev/reference/react#context-hooks) для более подробной информации.
|
||
|
||
### GraphQL
|
||
|
||
Включает фрагменты, запросы и мутации.
|
||
|
||
См. [GraphQL](https://graphql.org/learn/) для более подробной информации.
|
||
|
||
* Фрагменты
|
||
|
||
Фрагмент — это переиспользуемая часть запроса, которую можно использовать в разных местах. Используя фрагменты, легче избежать дублирования кода.
|
||
|
||
См. [GraphQL Fragments](https://graphql.org/learn/queries/#fragments) для более подробной информации.
|
||
|
||
* Запросы
|
||
|
||
См. [GraphQL Queries](https://graphql.org/learn/queries/) для более подробной информации.
|
||
|
||
* Мутации
|
||
|
||
См. [GraphQL Mutations](https://graphql.org/learn/queries/#mutations) для более подробной информации.
|
||
|
||
### Хуки
|
||
|
||
См. [Hooks](https://react.dev/learn/reusing-logic-with-custom-hooks) для более подробной информации.
|
||
|
||
### Состояния
|
||
|
||
Содержит логику управления состоянием. [Jotai](https://jotai.org) этим управляет.
|
||
|
||
* Селекторы: Производные атомы (с использованием `createAtomSelector`) вычисляют значения из других атомов и автоматически мемоизируются.
|
||
|
||
Встроенное управление состоянием в React все еще управляет состоянием внутри компонента.
|
||
|
||
### Утилиты
|
||
|
||
Должны содержать только переиспользуемые чистые функции. В противном случае создайте пользовательские хуки в папке `hooks`.
|
||
|
||
## Пользовательский интерфейс
|
||
|
||
Содержит все переиспользуемые компоненты пользовательского интерфейса, используемые в приложении.
|
||
|
||
Эта папка может содержать подкаталоги, такие как `data`, `display`, `feedback` и `input` для конкретных типов компонентов. Каждый компонент должен быть автономным и переиспользуемым, чтобы вы могли использовать его в разных частях приложения.
|
||
|
||
Разделяя компоненты пользовательского интерфейса от других компонентов в папке `modules`, легче поддерживать согласованность дизайна и вносить изменения в пользовательский интерфейс, не затрагивая другие части (бизнес-логику) кодовой базы.
|
||
|
||
## Интерфейс и зависимости
|
||
|
||
Вы можете импортировать код других модулей из любого модуля, кроме папки `ui`. Это позволит упростить тестирование его кода.
|
||
|
||
### Внутренний
|
||
|
||
Каждая часть (хуки, состояния, ...) модуля может иметь внутреннюю папку, содержащую части, которые используются только внутри модуля.
|