feat(group): Added group management functionality
- Added database interaction logic, supported inserting new group data, and integrated the Tauri SQL plugin for local data storage - Added a floating button on the nodes page to redirect to the addGroup page - Modified the app icon and title to improve the user experience - Adjusted the Tauri configuration file, optimized window settings, and app identifiers
This commit is contained in:
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
14
src-tauri/src/group.rs
Normal file
14
src-tauri/src/group.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
#[tauri::command]
|
||||
pub fn add_group(
|
||||
group_name: String,
|
||||
group_subscribe_url: Option<String>,
|
||||
group_arguments: Option<String>,
|
||||
) {
|
||||
let message = match (&group_subscribe_url, &group_arguments) {
|
||||
(Some(url), Some(args)) => format!("add_group: {} {} {}", group_name, url, args),
|
||||
(Some(url), None) => format!("add_group: {} {}", group_name, url),
|
||||
(None, Some(args)) => format!("add_group: {} {}", group_name, args),
|
||||
(None, None) => format!("add_group: {}", group_name),
|
||||
};
|
||||
println!("{}", message);
|
||||
}
|
||||
@@ -1,13 +1,29 @@
|
||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||
|
||||
use crate::group::add_group;
|
||||
use crate::spary::spary_switch;
|
||||
use tauri_plugin_sql::{Migration, MigrationKind};
|
||||
mod group;
|
||||
mod spary;
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
let migrations = vec![
|
||||
Migration {
|
||||
version: 1,
|
||||
description: "create_initial_tables",
|
||||
sql: "CREATE TABLE `group`(id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(60) NOT NULL,url TEXT NULL, arguments JSON NOT NULL default '{}', created_at DATETIME DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP)",
|
||||
kind: MigrationKind::Up,
|
||||
}
|
||||
];
|
||||
tauri::Builder::default()
|
||||
.plugin(
|
||||
tauri_plugin_sql::Builder::default()
|
||||
.add_migrations("sqlite:spary.db", migrations)
|
||||
.build(),
|
||||
)
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.invoke_handler(tauri::generate_handler![spary_switch])
|
||||
.invoke_handler(tauri::generate_handler![spary_switch, add_group])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use once_cell::sync::OnceCell;
|
||||
use sea_orm::DatabaseConnection;
|
||||
|
||||
mod entity;
|
||||
|
||||
static DB: OnceCell<DatabaseConnection> = OnceCell::new();
|
||||
|
||||
|
||||
fn main() {
|
||||
spary_lib::run()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#[tauri::command]
|
||||
pub fn spary_switch(status:bool) {
|
||||
pub fn spary_switch(status: bool) {
|
||||
println!("Spraying {status}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user