192 lines
4.3 KiB
Markdown
192 lines
4.3 KiB
Markdown
# ewa-mobile
|
|
|
|
Mobile/desktop EWA client built with Vue 3, Vite, Vant and Tauri 2.
|
|
|
|
The frontend uses generated TypeScript APIs from the Tauri backend. The backend exposes local and remote model resources through `che-tauri`, backed by `che-orm` and SQLite.
|
|
|
|
## Stack
|
|
|
|
- Vue 3 with `<script setup>`.
|
|
- TypeScript strict mode.
|
|
- Vite.
|
|
- Vue Router with hash history.
|
|
- Vant mobile UI components.
|
|
- Tauri 2 Rust backend.
|
|
- SQLite via `che-orm`.
|
|
- Remote REST access and sync via `che-tauri`/`reqwest`.
|
|
|
|
## Setup
|
|
|
|
Install frontend dependencies:
|
|
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
Run frontend dev server:
|
|
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
Run the Tauri app in development mode:
|
|
|
|
```bash
|
|
npm run tauri dev
|
|
```
|
|
|
|
Build frontend:
|
|
|
|
```bash
|
|
npm run build
|
|
```
|
|
|
|
Build Tauri app:
|
|
|
|
```bash
|
|
npm run tauri build
|
|
```
|
|
|
|
## Backend Commands
|
|
|
|
Run backend checks:
|
|
|
|
```bash
|
|
cd src-tauri
|
|
cargo fmt
|
|
cargo check
|
|
```
|
|
|
|
Apply migrations:
|
|
|
|
```bash
|
|
cd src-tauri
|
|
cargo run --bin manage -- migrate
|
|
```
|
|
|
|
Generate TypeScript API from Rust metadata:
|
|
|
|
```bash
|
|
cd src-tauri
|
|
cargo run --bin manage -- generate-ts --out ../src/generated
|
|
```
|
|
|
|
Create and apply migrations for one app:
|
|
|
|
```bash
|
|
cd src-tauri
|
|
cargo run --bin manage -- makemigrations <app>
|
|
cargo run --bin manage -- migrate <app>
|
|
```
|
|
|
|
## Project Structure
|
|
|
|
```text
|
|
src/
|
|
app/router/ Main Vue Router setup and auth guard
|
|
apps/auth/ Login feature
|
|
apps/tasks/ Task list/detail/create screens
|
|
apps/contracts/ Contract screens and PDF preview
|
|
apps/users/ Users screens
|
|
apps/personnel/ Personnel shared components
|
|
generated/ Generated TypeScript API and models
|
|
shared/auth/ Auth token state and restore logic
|
|
shared/composables/ Shared model API helpers
|
|
|
|
src-tauri/
|
|
src/lib.rs Tauri commands and API initialization
|
|
src/sync.rs Contract sync and file download logic
|
|
src/bin/manage.rs Management CLI entry point
|
|
src/apps/ che-tauri app modules
|
|
```
|
|
|
|
## Backend App Modules
|
|
|
|
Installed modules are registered in `src-tauri/src/apps/mod.rs`:
|
|
|
|
- `users`
|
|
- `frcapp`
|
|
- `projectapp`
|
|
- `personemanagment`
|
|
- `contractapp`
|
|
|
|
Each module usually contains `models.rs`, `serializers.rs`, `filters.rs`, `mod.rs`, and optional `migrations/`.
|
|
|
|
## Generated API
|
|
|
|
Generated files live in `src/generated`:
|
|
|
|
- `api_client.ts`
|
|
- `api.ts`
|
|
- `models.ts`
|
|
|
|
Do not edit generated files manually unless there is a specific reason. After changing backend models, serializers, filters, or resource registration, regenerate them:
|
|
|
|
```bash
|
|
cd src-tauri
|
|
cargo run --bin manage -- generate-ts --out ../src/generated
|
|
```
|
|
|
|
Frontend code should use generated APIs, for example:
|
|
|
|
```ts
|
|
import { taskApi } from "../../../generated/api";
|
|
```
|
|
|
|
Shared list/detail loading should prefer `src/shared/composables/useModelApi.ts`.
|
|
|
|
## Tauri Commands
|
|
|
|
Important commands registered in `src-tauri/src/lib.rs`:
|
|
|
|
- `che_api`: generic model API dispatch used by generated clients.
|
|
- `auth_login`: login against remote API.
|
|
- `auth_set_token`: restore saved auth token into backend state.
|
|
- `auth_logout`: clear backend token.
|
|
- `auth_status`: backend auth status.
|
|
- `current_employee`: fetch current employee from remote API.
|
|
- `sync_contracts`: sync contracts and application files to local SQLite.
|
|
- `load_application_file`: load local file bytes or download from remote URL.
|
|
|
|
## Configuration
|
|
|
|
- `src-tauri/app.toml` contains database and remote API settings.
|
|
- `src-tauri/src/lib.rs` currently creates `AppConfig` inline, so do not assume `app.toml` is always the runtime source of truth.
|
|
- `src-tauri/ewa-mobile.sqlite` is a local SQLite database artifact.
|
|
- Remote API URLs are environment-specific.
|
|
|
|
## Validation
|
|
|
|
Frontend change:
|
|
|
|
```bash
|
|
npm run build
|
|
```
|
|
|
|
Backend change:
|
|
|
|
```bash
|
|
cd src-tauri
|
|
cargo fmt
|
|
cargo check
|
|
```
|
|
|
|
Backend metadata or generated API change:
|
|
|
|
```bash
|
|
cd src-tauri
|
|
cargo fmt
|
|
cargo check
|
|
cargo run --bin manage -- generate-ts --out ../src/generated
|
|
cd ..
|
|
npm run build
|
|
```
|
|
|
|
## Developer Notes
|
|
|
|
- Keep frontend code TypeScript-strict and avoid unused locals/parameters.
|
|
- Keep model, serializer, filter, resource registration, migration and generated TS in sync.
|
|
- Prefer the management CLI for migrations.
|
|
- Avoid editing generated TypeScript and old migration files by hand.
|
|
- Avoid inspecting or modifying `src-tauri/target` and generated Android build artifacts unless needed.
|