You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.1KB

2 yıl önce
2 yıl önce
2 yıl önce
2 yıl önce
2 yıl önce
2 yıl önce
2 yıl önce
2 yıl önce
2 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # Dify Frontend
  2. This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
  3. ## Getting Started
  4. ### Run by source code
  5. To start the web frontend service, you will need [Node.js v18.x (LTS)](https://nodejs.org/en) and [NPM version 8.x.x](https://www.npmjs.com/) or [Yarn](https://yarnpkg.com/).
  6. First, install the dependencies:
  7. ```bash
  8. npm install
  9. # or
  10. yarn install --frozen-lockfile
  11. ```
  12. Then, configure the environment variables. Create a file named `.env.local` in the current directory and copy the contents from `.env.example`. Modify the values of these environment variables according to your requirements:
  13. ```bash
  14. cp .env.example .env.local
  15. ```
  16. ```
  17. # For production release, change this to PRODUCTION
  18. NEXT_PUBLIC_DEPLOY_ENV=DEVELOPMENT
  19. # The deployment edition, SELF_HOSTED
  20. NEXT_PUBLIC_EDITION=SELF_HOSTED
  21. # The base URL of console application, refers to the Console base URL of WEB service if console domain is
  22. # different from api or web app domain.
  23. # example: http://cloud.dify.ai/console/api
  24. NEXT_PUBLIC_API_PREFIX=http://localhost:5001/console/api
  25. # The URL for Web APP, refers to the Web App base URL of WEB service if web app domain is different from
  26. # console or api domain.
  27. # example: http://udify.app/api
  28. NEXT_PUBLIC_PUBLIC_API_PREFIX=http://localhost:5001/api
  29. # SENTRY
  30. NEXT_PUBLIC_SENTRY_DSN=
  31. ```
  32. Finally, run the development server:
  33. ```bash
  34. npm run dev
  35. # or
  36. yarn dev
  37. ```
  38. Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
  39. You can start editing the file under folder `app`. The page auto-updates as you edit the file.
  40. ## Deploy
  41. ### Deploy on server
  42. First, build the app for production:
  43. ```bash
  44. npm run build
  45. ```
  46. Then, start the server:
  47. ```bash
  48. npm run start
  49. ```
  50. If you want to customize the host and port:
  51. ```bash
  52. npm run start --port=3001 --host=0.0.0.0
  53. ```
  54. ## Storybook
  55. This project uses [Storybook](https://storybook.js.org/) for UI component development.
  56. To start the storybook server, run:
  57. ```bash
  58. yarn storybook
  59. ```
  60. Open [http://localhost:6006](http://localhost:6006) with your browser to see the result.
  61. ## Lint Code
  62. If your IDE is VSCode, rename `web/.vscode/settings.example.json` to `web/.vscode/settings.json` for lint code setting.
  63. ## Test
  64. We start to use [Jest](https://jestjs.io/) and [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/) for Unit Testing.
  65. You can create a test file with a suffix of `.spec` beside the file that to be tested. For example, if you want to test a file named `util.ts`. The test file name should be `util.spec.ts`.
  66. Run test:
  67. ```bash
  68. npm run test
  69. ```
  70. If you are not familiar with writing tests, here is some code to refer to:
  71. * [classnames.spec.ts](./utils/classnames.spec.ts)
  72. * [index.spec.tsx](./app/components/base/button/index.spec.tsx)
  73. ## Documentation
  74. Visit <https://docs.dify.ai/getting-started/readme> to view the full documentation.
  75. ## Community
  76. The Dify community can be found on [Discord community](https://discord.gg/5AEfbxcd9k), where you can ask questions, voice ideas, and share your projects.