Files
bot-rates/README.md

81 lines
3.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 台銀即期賣出匯率換算工具
一個跨平台的小工具,抓取台灣銀行官方 USD / JPY / EUR 即期賣出匯率,並提供即時台幣換算功能。
## 特色
- **即時匯率**:從台銀官網 CSV`rate.bot.com.tw/xrt/flcsv/0/day`)抓取,免 API key
- **雙向換算**:每個幣別獨立輸入框,輸入外幣金額立即換算出台幣
- **一鍵複製**:按「複製」即把整數(如 `3163`,四捨五入到個位)寫入剪貼簿,可直接貼到 Excel
- **零依賴**:單一執行檔,使用者不需要安裝 Python、Rust 或任何 runtime
- **跨平台**Windows 與 macOS 共用同一份 Rust 原始碼
## 檔案結構
```
02/
├── bot_rates.exe # Windows 執行檔5.4 MB
├── bot_rates.zip # Windows 執行檔的 zip 壓縮2.7 MB方便傳送
├── BotRates.app/ # macOS 應用程式 bundle
│ └── Contents/
│ ├── Info.plist
│ └── MacOS/BotRates # macOS 執行檔5.2 MB
├── bot_rates_rs/ # Rust 原始碼
│ ├── Cargo.toml
│ ├── .cargo/config.toml # 交叉編譯 linker 設定
│ └── src/main.rs
├── bot_rates.py # 早期 Python CLI 版(僅列印匯率)
├── bot_rates_gui.py # 早期 Python tkinter GUI 版(已被 Rust 版取代)
├── build.bat # Python → exe 打包腳本(已不需要)
├── README.md
├── QUICKSTART.md
└── SUMMARY.md
```
## 使用方式
### 一般使用者
**Windows**:解壓 `bot_rates.zip`,雙擊 `bot_rates.exe` 即可執行。
**macOS**:雙擊 `BotRates.app`。首次開啟若跳出「無法驗證開發者」提示,請在「系統設定 → 隱私權與安全性」按「仍要打開」,或執行 `xattr -cr BotRates.app`
啟動後:
1. 每一列左側顯示幣別和即期賣出匯率
2. 中間輸入外幣金額(預設 100
3. 右側自動顯示台幣換算結果
4. 按「複製」按鈕即可把換算結果貼到其他軟體
5. 左下角顯示最後更新時間,右下角「重新整理」可重新抓匯率
### 開發者(重新編譯)
需要 Rust 工具鏈與 mingw-w64僅 Windows 交叉編譯需要):
```bash
# macOS 版
cd bot_rates_rs
RUST_MIN_STACK=16777216 cargo build --release
# 輸出target/release/bot_rates
# Windows 版(從 macOS 交叉編譯)
brew install mingw-w64
rustup target add x86_64-pc-windows-gnu
RUST_MIN_STACK=16777216 cargo build --release --target x86_64-pc-windows-gnu
# 輸出target/x86_64-pc-windows-gnu/release/bot_rates.exe
```
> `RUST_MIN_STACK=16777216` 是為了避免 LLVM 在優化階段堆疊溢位(`eframe` 依賴龐大optimize pipeline 會大量遞迴)。
## 技術棧
| 用途 | 函式庫 |
|------|--------|
| GUI framework | `eframe` / `egui` 0.27immediate mode無系統依賴 |
| HTTPS 請求 | `ureq` + `rustls`(純 Rust TLS不需要 OpenSSL 或 SChannel |
| 中文字型 | 執行期載入系統字型Windows 的 `msjh.ttc`、macOS 的 `PingFang.ttc` |
## 資料來源
- 台灣銀行牌告匯率 CSV<https://rate.bot.com.tw/xrt/flcsv/0/day>
- 欄位索引:`即期賣出` 位於第 14 欄index 13