PR zh/zh_tw readme update for relex 0.5.2 (#3415)
This commit is contained in:
parent
7a12fe2c5e
commit
6c1af838cf
@ -15,11 +15,26 @@
|
||||

|
||||
[](https://reflex.dev/docs/getting-started/introduction)
|
||||
[](https://discord.gg/T5WSbC2YtQ)
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md)
|
||||
|
||||
[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md)
|
||||
|
||||
---
|
||||
|
||||
# Reflex
|
||||
|
||||
Reflex 是一個可以用純 Python 構建全端網頁應用程式的函式庫。
|
||||
|
||||
主要特色:
|
||||
|
||||
* **純 Python** - 您可以用 Python 撰寫應用程式的前端和後端,無需學習 Javascript。
|
||||
* **完全靈活性** - Reflex 易於上手,但也可以擴展到複雜的應用程式。
|
||||
* **立即部署** - 構建後,只需使用[單一指令](https://reflex.dev/docs/hosting/deploy-quick-start/)即可部署您的應用程式,或在您自己的伺服器上託管。
|
||||
請參閱我們的[架構頁面](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture)了解 Reflex 如何在底層運作。
|
||||
|
||||
## ⚙️ 安裝
|
||||
|
||||
開啟一個終端機並且執行 (需要 Python 3.8+):
|
||||
@ -70,7 +85,8 @@ reflex run
|
||||
import reflex as rx
|
||||
import openai
|
||||
|
||||
openai.api_key = "YOUR_API_KEY"
|
||||
openai_client = openai.OpenAI()
|
||||
|
||||
|
||||
class State(rx.State):
|
||||
"""應用程式狀態"""
|
||||
@ -86,33 +102,33 @@ class State(rx.State):
|
||||
|
||||
self.processing, self.complete = True, False
|
||||
yield
|
||||
response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024")
|
||||
self.image_url = response["data"][0]["url"]
|
||||
response = openai_client.images.generate(
|
||||
prompt=self.prompt, n=1, size="1024x1024"
|
||||
)
|
||||
self.image_url = response.data[0].url
|
||||
self.processing, self.complete = False, True
|
||||
|
||||
|
||||
def index():
|
||||
return rx.center(
|
||||
rx.vstack(
|
||||
rx.heading("DALL·E"),
|
||||
rx.input(placeholder="Enter a prompt", on_blur=State.set_prompt),
|
||||
rx.heading("DALL-E", font_size="1.5em"),
|
||||
rx.input(
|
||||
placeholder="Enter a prompt..",
|
||||
on_blur=State.set_prompt,
|
||||
width="25em",
|
||||
),
|
||||
rx.button(
|
||||
"Generate Image",
|
||||
"Generate Image",
|
||||
on_click=State.get_image,
|
||||
is_loading=State.processing,
|
||||
width="100%",
|
||||
width="25em",
|
||||
loading=State.processing
|
||||
),
|
||||
rx.cond(
|
||||
State.complete,
|
||||
rx.image(
|
||||
src=State.image_url,
|
||||
height="25em",
|
||||
width="25em",
|
||||
)
|
||||
rx.image(src=State.image_url, width="20em"),
|
||||
),
|
||||
padding="2em",
|
||||
shadow="lg",
|
||||
border_radius="lg",
|
||||
align="center",
|
||||
),
|
||||
width="100%",
|
||||
height="100vh",
|
||||
@ -120,10 +136,22 @@ def index():
|
||||
|
||||
# 把狀態跟頁面添加到應用程式。
|
||||
app = rx.App()
|
||||
app.add_page(index, title="reflex:DALL·E")
|
||||
app.add_page(index, title="Reflex:DALL-E")
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 讓我們來拆解一下。
|
||||
|
||||
<div align="center">
|
||||
<img src="docs/images/dalle_colored_code_example.png" alt="Explaining the differences between backend and frontend parts of the DALL-E app." width="900" />
|
||||
</div>
|
||||
|
||||
|
||||
### **Reflex 使用者介面**
|
||||
|
||||
讓我們從使用介面開始。
|
||||
@ -150,8 +178,9 @@ class State(rx.State):
|
||||
"""應用程式狀態"""
|
||||
prompt = ""
|
||||
image_url = ""
|
||||
image_processing = False
|
||||
image_made = False
|
||||
processing = False
|
||||
complete = False
|
||||
|
||||
```
|
||||
|
||||
應用程式狀態定義了應用程式中所有可以更改的變數及變更他們的函式 (稱為 vars)。
|
||||
@ -168,8 +197,10 @@ def get_image(self):
|
||||
|
||||
self.processing, self.complete = True, False
|
||||
yield
|
||||
response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024")
|
||||
self.image_url = response["data"][0]["url"]
|
||||
response = openai_client.images.generate(
|
||||
prompt=self.prompt, n=1, size="1024x1024"
|
||||
)
|
||||
self.image_url = response.data[0].url
|
||||
self.processing, self.complete = False, True
|
||||
```
|
||||
|
||||
@ -199,34 +230,35 @@ app.add_page(index, title="DALL-E")
|
||||
|
||||
<div align="center">
|
||||
|
||||
📑 [Docs](https://reflex.dev/docs/getting-started/introduction) | 🗞️ [Blog](https://reflex.dev/blog) | 📱 [Component Library](https://reflex.dev/docs/library) | 🖼️ [Gallery](https://reflex.dev/docs/gallery) | 🛸 [Deployment](https://reflex.dev/docs/hosting/deploy)
|
||||
📑 [Docs](https://reflex.dev/docs/getting-started/introduction) | 🗞️ [Blog](https://reflex.dev/blog) | 📱 [Component Library](https://reflex.dev/docs/library) | 🖼️ [Gallery](https://reflex.dev/docs/gallery) | 🛸 [Deployment](https://reflex.dev/docs/hosting/deploy-quick-start)
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
## ✅ Reflex 狀態
|
||||
## ✅ 產品狀態
|
||||
|
||||
Reflex 於 2022 年 12 月推出,當時名為 Pynecone。
|
||||
Reflex 在 2022 年 12 月以 Pynecone 的名字推出。
|
||||
|
||||
截至 2023 年 7 月,我們處於 **Public Beta** 階段。
|
||||
|
||||
- :white_check_mark: **Public Alpha**: 任何人都可以安裝與使用 Reflex,或許包含問題, 但我們正在積極的解決他們。
|
||||
- :large_orange_diamond: **Public Beta**: 對於不涉及商業目的使用情境來說足夠穩定。
|
||||
- **Public Hosting Beta**: _Optionally_, 部屬跟託管你的 Reflex!
|
||||
- **Public**: 這版本的 Reflex 是可用於軟體產品的。
|
||||
截至 2024 年 2 月,我們的託管服務已進入 alpha 階段!在此期間,任何人都可以免費部署他們的應用程式。請參閱我們的[產品地圖](https://github.com/reflex-dev/reflex/issues/2727)了解未來的計劃。
|
||||
|
||||
Reflex 每周都有新功能和釋出新版本! 確保你按下 :star: 和 :eyes: watch 這個 repository 來確保知道最新資訊。
|
||||
|
||||
## 貢獻
|
||||
|
||||
我們歡迎任何大小的貢獻,以下是幾個好的方法來加入 Reflex 社群。
|
||||
我們歡迎任何大小的貢獻,以下是一些加入 Reflex 社群的好方法。
|
||||
|
||||
- **加入我們的 Discord**: 我們的 [Discord](https://discord.gg/T5WSbC2YtQ) 是幫助你加入 Reflex 專案和討論或貢獻最棒的地方。
|
||||
- **GitHub Discussions**: 一個來討論你想要添加的功能或是需要澄清的事情的好地方。
|
||||
- **GitHub Issues**: 報告錯誤的絕佳地方,另外你可以試著解決一些 issue 和送出 PR。
|
||||
- **加入我們的 Discord**: 我們的 [Discord](https://discord.gg/T5WSbC2YtQ) 是獲取 Reflex 專案幫助和討論如何貢獻的最佳地方。
|
||||
- **GitHub Discussions**: 這是一個討論您想新增的功能或對於一些困惑/需要澄清事項的好方法。
|
||||
- **GitHub Issues**: 在 [Issues](https://github.com/reflex-dev/reflex/issues) 頁面報告錯誤是一個絕佳的方式。此外,您也可以嘗試解決現有 Issue 並提交 PR。
|
||||
|
||||
我們正在積極尋找貢獻者,無關你的技能水平或經驗。
|
||||
我們積極尋找貢獻者,不論您的技能水平或經驗如何。要貢獻,請查看 [CONTIBUTING.md](https://github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md)
|
||||
|
||||
|
||||
## 感謝所有貢獻者:
|
||||
<a href="https://github.com/reflex-dev/reflex/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=reflex-dev/reflex" />
|
||||
</a>
|
||||
|
||||
## 授權
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user