Files
bot-rates/QUICKSTART.md

92 lines
2.3 KiB
Markdown
Raw 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.
# 快速上手
## 給終端使用者(只想用,不想裝東西)
### Windows
1. 拿到 `bot_rates.zip`
2. 對 zip 按右鍵 → 「解壓縮全部」
3. 雙擊 `bot_rates.exe`
完成。不用裝 Python不用裝任何 runtime單一檔案執行。
### macOS
1. 拿到 `BotRates.app`(整個資料夾)
2. 雙擊打開
若跳出「無法驗證開發者」:
```bash
xattr -cr /path/to/BotRates.app
```
或在「系統設定 → 隱私權與安全性」按「仍要打開」。
## 怎麼用
| 欄位 | 說明 |
|------|------|
| 左側 | 幣別、代碼、即期賣出匯率(例如 `美元 USD 31.6200` |
| 中間 | 輸入外幣金額(預設 100可自由修改 |
| 右側 | 台幣換算結果,四捨五入到個位(例如 `NT$ 3,163` |
| 複製 | 按下複製純整數(`3163`)到剪貼簿,可直接貼 Excel |
| 重新整理 | 右下角按鈕,重新抓最新匯率 |
---
## 給開發者(想改程式或重新編譯)
### 先決條件(一次性)
```bash
# Rust 本體(已有可略)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# 交叉編譯到 Windows 用的 linker
brew install mingw-w64
rustup target add x86_64-pc-windows-gnu
```
### 編譯
```bash
cd bot_rates_rs
# macOS 版
RUST_MIN_STACK=16777216 cargo build --release
# Windows 版(在 macOS 交叉編譯)
RUST_MIN_STACK=16777216 cargo build --release --target x86_64-pc-windows-gnu
```
### 部署
```bash
# mac 版複製進 .app bundle
cp target/release/bot_rates ../BotRates.app/Contents/MacOS/BotRates
xattr -cr ../BotRates.app
# Windows 版複製到專案根目錄並壓 zip
cp target/x86_64-pc-windows-gnu/release/bot_rates.exe ../bot_rates.exe
cd .. && zip -9 bot_rates.zip bot_rates.exe
```
### 常見修改點
| 想改什麼 | 改哪裡(`src/main.rs` |
|----------|------------------------|
| 新增幣別 | `TARGETS` 常數,加一行 `(代碼, 中文名)` |
| 換成即期買入 | `fetch_rates` 裡把 `cols[13]``cols[3]` |
| 視窗大小 | `main` 裡的 `with_inner_size` |
| 預設輸入金額 | `App::new` 裡的 `"100".to_string()` |
| 配色 | `update` 開頭的 `bg` / `card` / `rate_color` 等常數 |
### 欄位對照(台銀 CSV
| index | 欄位 |
|-------|------|
| 0 | 幣別 |
| 3 | 本行即期買入 |
| 13 | 本行即期賣出 ← 目前使用 |