A modern, extensible chat client built with Tauri, Vue 3, and Rust. Features a powerful plugin architecture that supports dynamic loading and management of chat plugins.
- 🚀 Modern Tech Stack: Built with Tauri, Vue 3, TypeScript, and Rust
- 🔌 Plugin Architecture: Dynamic plugin loading and management system
- 🎨 Responsive UI: Resizable panels with Element Plus components
- 💬 Messaging System: Real-time message display and input handling
- 🔄 Plugin Lifecycle: Full lifecycle management (mount, unmount, connect, disconnect)
- 📦 Cross-Platform: Desktop app support for Windows, macOS, and Linux
- Vue 3 using Composition API and
<script setup>
syntax - Element Plus for UI components
- Pinia for state management
- Vue Router for navigation
- Vite as the build tool
- Tauri framework for desktop app development
- Plugin Interface library for plugin development
- Dynamic Loading via
libloading
crate - Plugin Manager for lifecycle management
- PluginHandler Trait: Defines plugin lifecycle methods
- Dynamic Loading: Runtime plugin loading from
.dll
files - Bidirectional Communication: Plugins can send/receive messages
- Configuration Management: Each plugin has its own
config.toml
-
Clone the repository
git clone https://github.com/luodeb/chat-client.git cd chat-client
-
Install dependencies
pnpm install
-
Run in dev mode
cd ./src-tauri cargo build --workspace pnpm tauri dev
-
Build for production
pnpm tauri build
chat-client/
├── src/ # Vue frontend
│ ├── components/ # Vue components
│ ├── views/ # Vue views
│ ├── stores/ # Pinia state
│ └── api/ # API interfaces
├── src-tauri/ # Rust backend
│ ├── src/
│ │ ├── api/ # Tauri commands
│ │ ├── plugins/ # Plugin management
│ │ └── lib.rs # Main library
│ ├── plugin-interface/ # Plugin dev library
│ └── src/plugins/ # Plugin implementations
└── dist/ # Build output
-
Create a new plugin
cd src-tauri/src/plugins mkdir my-plugin cd my-plugin
-
Add Cargo.toml
[package] name = "my-plugin" version = "0.1.0" edition = "2021" [lib] crate-type = ["cdylib"] [dependencies] plugin-interface = { path = "../../plugin-interface" }
-
Implement the plugin
use plugin_interface::{PluginHandler, PluginMetadata}; pub struct MyPlugin; impl PluginHandler for MyPlugin { fn on_mount(&self) -> Result<(), Box<dyn std::error::Error>> { // Plugin initialization Ok(()) } fn handle_message(&self, message: &str) -> Result<String, Box<dyn std::error::Error>> { // Handle incoming messages Ok(format!("Response: {}", message)) } // Implement other required methods... }
-
Add config.toml
[plugin] id = "my-plugin" name = "My Plugin" description = "An example plugin" version = "1.0.0" author = "Your Name" disabled = false
-
Export plugin functions
#[no_mangle] pub extern "C" fn create_plugin() -> *mut dyn PluginHandler { let plugin = MyPlugin::new(); Box::into_raw(Box::new(plugin)) } #[no_mangle] pub extern "C" fn destroy_plugin(plugin: *mut dyn PluginHandler) { if !plugin.is_null() { unsafe { let _ = Box::from_raw(plugin); } } }
pnpm dev
- Start dev serverpnpm build
- Build Vue frontendpnpm tauri dev
- Run Tauri in dev modepnpm tauri build
- Build Tauri app
The plugin system supports these lifecycle methods:
- on_mount(): Called when plugin mounts
- on_dispose(): Called when plugin unmounts
- on_connect(): Called on connection
- on_disconnect(): Called on disconnection
- handle_message(): Called to process messages
Key components include:
- ConfigPanel: Left-side panel for plugin management
- MessageDisplay: Message display area
- MessageInput: Message input area
The UI supports draggable panel resizing for better UX.
- VS Code + Volar + Tauri + rust-analyzer
- Fork this repo
- Create your branch (
git checkout -b feature/amazing-feature
) - Commit changes (
git commit -m 'Add some amazing feature'
) - Push to branch (
git push origin feature/amazing-feature
) - Open a Pull Request
MIT Licensed. See LICENSE for details.
- Tauri - For the excellent desktop framework
- Vue.js - For the reactive frontend framework
- Element Plus - For beautiful UI components
- Create a folder under
src-tauri/src/plugins/
- Implement the
PluginHandler
trait - Add
config.toml
- Compile to
.dll
- Scan and load in the app
Use src-tauri/src/bin/test_plugins.rs
:
cd src-tauri
cargo run --bin test_plugins
Plugins interact via Tauri's event system, with the frontend acting as a mediator.