How szhhwh/r-tools works
Project type and purpose
• This is a desktop “full‑stack” application built with Tauri.
• Frontend: Vue 3 + Element‑Plus, bundled by Vite.
• Backend: Rust code (Tauri commands) exposing functionality such as random‑entry selection from Excel files and time‑lapse photography calculations.
• Purpose: A small toolbox (“R‑Tools”) with two utilities:
• CalaRand – random number/entry generator (reads Excel).
• TimeLapsephoto – calculates time‑lapse photography parameters.
File structure
• Top‑level:
• .vscode, .github, .gitignore, package.json, tsconfig*, vite.config.ts – IDE, CI, build & lint configs.
• index.html, splashscreen.html – desktop app shell and splash screen.
• src/ – Vue frontend (App.vue, components/, views/, router/, main.ts).
• Patterns & modules in src-tauri/src:
• main.rs + lib.rs – Tauri setup & entry point.
• app/ – application logic: menu, windows, commands (cmd.rs), setup, readers (Excel parser), Calarand logic.
• conf.rs, error.rs – configuration and error‑handling.
• Frontend modules:
• components/app & calculators & random – Vue components for each tool.
• views – top‑level pages for each feature (CalculatorView, RandomView).
• router – navigation between views.
README for additional insights
• Confirms tech stack: “Tauri / Rust+Vue3+Element‑Plus”.
• Describes two features, matching source: CalaRand and TimeLapsephoto.
Main components and interactions
a. Frontend (Vue3 + Element‑Plus)
• Views: Home, Calculator, Random, Settings, UpdateDialog
• Components: MkRender, CalaRand.vue, TimeLapsephoto.vue
• Router & Vite dev/build pipeline
b. Backend (Rust/Tauri)
• Tauri core (main.rs + tauri.conf.json + build.rs)
• Command dispatcher (cmd.rs) – defines JS‑invokable functions
• Business logic modules:
– calarand.rs (random selection & Excel handling)
– readers/calareader.rs (Excel parsing using Calamine or similar crate)
– setup.rs, menu.rs, windows.rs (app initialization, custom menus, window management)
• Support: conf.rs (settings), error.rs (error types)
• Cargo.toml (dependencies & build config)
c. External/local resources
• Excel files on the user’s file system
d. Data flows & interactions
1. User clicks a button in Vue →
2. JavaScript invokes Tauri command (e.g., invoke("generate_random", args)) →
3. Rust cmd.rs routes call to calarand.rs or calculator module →
4. Excel file is read via readers/calareader.rs (if needed) →
5. Calculation or random selection is performed →
6. Result returned to JS as JSON/primitives →
7. Vue updates UI with result.
Architectural patterns & design principles
• Clear separation of concerns: UI vs. native code.
• Modular Rust code mapped to features.
• Single‑page‑style Vue app with router.
• IPC boundary: Tauri’s invoke API (JS ↔ Rust).
• Config & error handling centralized.
Detail
• Every directory/module as its own component if it plays a distinct role.
• How configuration (tauri.conf.json, Cargo.toml, vite.config.ts) plugs into the build.