跳到主内容

前端源代码

Casdoor 前端包含管理控制台和登录页面,位于 Casdoor 仓库的 web 目录中。它是一个使用 TypeScript 编写的 React 应用,由 Vite 构建,并使用 Tailwind CSS 和 shadcn/ui 进行样式设计。本页介绍源代码的布局。

运行和构建前端​

在 web 目录中运行以下命令。

Command描述
yarn installInstalls the dependencies. Use Yarn 1.x
yarn startStarts the development server on port 7001. It expects the backend on port 8000
yarn buildBuilds the static files into web/build, which the backend serves

有关完整的设置,请参阅 Run in development mode。

web 目录中的文件​

File or directory描述
publicStatic files that are copied to the build as they are
srcSource code of the application
index.htmlHTML entry point
vite.config.tsVite configuration
tailwind.config.js, postcss.config.jsTailwind CSS configuration
components.jsonshadcn/ui configuration
tsconfig.jsonTypeScript configuration
cypress, cypress.config.jsEnd-to-end tests
package.json, yarn.lockDependencies

src 目录中的文件​

File or directoryDescription
main.tsxEntry point that mounts the application
App.tsxRoutes of the admin console and the sign-in pages
Conf.tsCompile-time settings, such as the default theme and the custom footer. See Compile-time frontend settings
pagesOne file per page. *ListPage.tsx is the list of an object type, and *EditPage.tsx is its edit page. pages/auth contains the sign-in, sign-up, and related pages
componentsShared components, grouped by area, for example application, provider, and user. components/ui contains the shadcn/ui components
backendOne file per object type with the calls to the Casdoor API, for example ApplicationBackend.ts
authHelpers of the sign-in flow, such as provider URLs, the password obfuscator, and WebAuthn
hooksReact hooks, for example for the signed-in account, the language, and the theme
libHelper functions. lib/setting.tsx contains the general helpers
本地Translations, one data.json per language
i18n.tsSetup of the translation library
index.cssGlobal styles

另请参阅​