feat: Specta works!
This commit is contained in:
parent
366637c25f
commit
963762669c
2 changed files with 50 additions and 4 deletions
|
|
@ -1,13 +1,19 @@
|
|||
use crate::api;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use onelauncher::{cluster, data::{Loader, PackageData}};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specta::Type;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! collect_commands {
|
||||
() => {
|
||||
{
|
||||
use crate::api::commands::*;
|
||||
use $crate::api::commands::*;
|
||||
tauri_specta::ts::builder()
|
||||
.commands(tauri_specta::collect_commands![
|
||||
is_dev
|
||||
is_dev,
|
||||
create_cluster
|
||||
])
|
||||
}
|
||||
};
|
||||
|
|
@ -17,4 +23,39 @@ macro_rules! collect_commands {
|
|||
#[tauri::command]
|
||||
pub fn is_dev() -> bool {
|
||||
cfg!(debug_assertions)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Type)]
|
||||
pub struct CreateCluster {
|
||||
name: String,
|
||||
mc_version: String,
|
||||
mod_loader: Loader,
|
||||
loader_version: Option<String>,
|
||||
icon: Option<PathBuf>,
|
||||
icon_url: Option<String>,
|
||||
package_data: Option<PackageData>,
|
||||
skip: Option<bool>,
|
||||
skip_watch: Option<bool>,
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn create_cluster(props: CreateCluster) -> Result<Uuid, String> {
|
||||
let path = cluster::create::create_cluster(
|
||||
props.name,
|
||||
props.mc_version,
|
||||
props.mod_loader,
|
||||
props.loader_version,
|
||||
props.icon,
|
||||
props.icon_url,
|
||||
props.package_data,
|
||||
props.skip,
|
||||
props.skip_watch,
|
||||
).await?;
|
||||
|
||||
if let Some(cluster) = cluster::get(&path, None).await? {
|
||||
Ok(cluster.uuid)
|
||||
} else {
|
||||
Err("Cluster does not exist".to_string())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import Button from '../components/base/Button';
|
|||
import Tag from '../components/base/Tag';
|
||||
import TextField from '../components/base/TextField';
|
||||
import ClusterCover from '~ui/components/game/ClusterCover';
|
||||
import { bridge } from '~index';
|
||||
|
||||
// TODO: Replace this into it's own component
|
||||
// possibly with the core ui lirbary with autogenerated and optimized svgs pls
|
||||
|
|
@ -184,6 +185,10 @@ function HomePage() {
|
|||
// const [clusters, { refetch }] = createResource(getClustersGrouped);
|
||||
|
||||
async function newInstance() {
|
||||
// bridge.commands.createCluster({
|
||||
|
||||
// });
|
||||
|
||||
// await createCluster({
|
||||
// name: '1.0 cluster',
|
||||
// version: 'a1.0.11',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue