4.3 KiB
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:
npm install
Run frontend dev server:
npm run dev
Run the Tauri app in development mode:
npm run tauri dev
Build frontend:
npm run build
Build Tauri app:
npm run tauri build
Backend Commands
Run backend checks:
cd src-tauri
cargo fmt
cargo check
Apply migrations:
cd src-tauri
cargo run --bin manage -- migrate
Generate TypeScript API from Rust metadata:
cd src-tauri
cargo run --bin manage -- generate-ts --out ../src/generated
Create and apply migrations for one app:
cd src-tauri
cargo run --bin manage -- makemigrations <app>
cargo run --bin manage -- migrate <app>
Project Structure
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:
usersfrcappprojectapppersonemanagmentcontractapp
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.tsapi.tsmodels.ts
Do not edit generated files manually unless there is a specific reason. After changing backend models, serializers, filters, or resource registration, regenerate them:
cd src-tauri
cargo run --bin manage -- generate-ts --out ../src/generated
Frontend code should use generated APIs, for example:
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.tomlcontains database and remote API settings.src-tauri/src/lib.rscurrently createsAppConfiginline, so do not assumeapp.tomlis always the runtime source of truth.src-tauri/ewa-mobile.sqliteis a local SQLite database artifact.- Remote API URLs are environment-specific.
Validation
Frontend change:
npm run build
Backend change:
cd src-tauri
cargo fmt
cargo check
Backend metadata or generated API change:
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/targetand generated Android build artifacts unless needed.