69 lines
2.4 KiB
Markdown
69 lines
2.4 KiB
Markdown
# @ti-pote/frontend
|
|
|
|
Desktop companion app for Ti-Pote. **Vite + React + TypeScript + Tailwind**,
|
|
wrappable as a native desktop app with **Tauri v2**.
|
|
|
|
## Features
|
|
|
|
- Auth: register / login / auto refresh-token rotation
|
|
- Session persistence (Tauri Store plugin on desktop, localStorage in browser)
|
|
- Dashboard: list of associated robots (`GET /api/devices`)
|
|
- Robot pairing: 6-digit code screen wired to `POST /api/pairing/confirm`
|
|
|
|
## Quick start (web dev)
|
|
|
|
```bash
|
|
cd apps/frontend
|
|
cp .env.example .env # point VITE_API_URL to your backend
|
|
pnpm install
|
|
pnpm dev # http://localhost:1420
|
|
```
|
|
|
|
## Desktop build (Tauri v2)
|
|
|
|
Prerequisites: Rust toolchain (`rustup`) and the
|
|
[Tauri prerequisites](https://v2.tauri.app/start/prerequisites/) for your OS.
|
|
|
|
```bash
|
|
# First time only: generate the bundle icons from any source PNG
|
|
pnpm tauri icon path/to/logo.png
|
|
|
|
# Dev (hot reload + native window)
|
|
pnpm tauri dev
|
|
|
|
# Production bundle (.dmg / .app on macOS, .msi on Windows, .deb/.AppImage on Linux)
|
|
pnpm tauri build
|
|
```
|
|
|
|
## Project layout
|
|
|
|
```
|
|
apps/frontend/
|
|
├── src/
|
|
│ ├── components/ Button / Input / Card / ProtectedRoute
|
|
│ ├── context/ AuthContext (React)
|
|
│ ├── lib/
|
|
│ │ ├── api.ts fetch wrapper + typed endpoints + auto-refresh
|
|
│ │ └── storage.ts Tauri Store ↔ localStorage fallback
|
|
│ ├── pages/ Login / Register / Dashboard / PairRobot
|
|
│ ├── styles/ Tailwind entry
|
|
│ ├── App.tsx Router
|
|
│ └── main.tsx Entry point
|
|
└── src-tauri/ Tauri v2 Rust wrapper
|
|
├── Cargo.toml
|
|
├── tauri.conf.json
|
|
├── capabilities/
|
|
└── src/{main.rs,lib.rs}
|
|
```
|
|
|
|
## Backend API used
|
|
|
|
| Flow | Endpoint | Notes |
|
|
| -------- | ---------------------------- | ---------------------------------- |
|
|
| Register | `POST /api/auth/register` | Creates user + home |
|
|
| Login | `POST /api/auth/login` | |
|
|
| Refresh | `POST /api/auth/refresh` | Called transparently on 401 |
|
|
| Me | `GET /api/auth/me` | |
|
|
| Devices | `GET /api/devices` | Dashboard |
|
|
| Pair | `POST /api/pairing/confirm` | `{ code }` — 6-digit from robot UI |
|