refactor: use specta for commands (#192)

* feat: add tauri-specta

* refactor: system library

* chore: format
This commit is contained in:
雨宮蓮
2024-05-25 15:21:40 +07:00
committed by GitHub
parent 7449000f5f
commit bba324ea53
92 changed files with 2164 additions and 2071 deletions

View File

@@ -1,6 +1,7 @@
use std::process::Command;
#[tauri::command]
#[specta::specta]
pub async fn show_in_folder(path: String) {
#[cfg(target_os = "windows")]
{

View File

@@ -1,16 +0,0 @@
use std::time::Duration;
use webpage::{Opengraph, Webpage, WebpageOptions};
#[tauri::command]
pub fn fetch_opg(url: String) -> Result<Opengraph, String> {
let mut options = WebpageOptions::default();
options.allow_insecure = true;
options.max_redirections = 2;
options.timeout = Duration::from_secs(10);
if let Ok(data) = Webpage::from_url(&url, options) {
Ok(data.html.opengraph)
} else {
Err("Get open graph failed".into())
}
}

View File

@@ -10,6 +10,7 @@ use tauri::{LogicalPosition, LogicalSize, Manager, WebviewUrl};
use tauri_plugin_decorum::WebviewWindowExt;
#[tauri::command]
#[specta::specta]
pub fn create_column(
label: &str,
x: f32,
@@ -45,6 +46,7 @@ pub fn create_column(
}
#[tauri::command]
#[specta::specta]
pub fn close_column(label: &str, app_handle: tauri::AppHandle) -> Result<bool, ()> {
match app_handle.get_webview(label) {
Some(webview) => {
@@ -59,6 +61,7 @@ pub fn close_column(label: &str, app_handle: tauri::AppHandle) -> Result<bool, (
}
#[tauri::command]
#[specta::specta]
pub fn reposition_column(
label: &str,
x: f32,
@@ -78,6 +81,7 @@ pub fn reposition_column(
}
#[tauri::command]
#[specta::specta]
pub fn resize_column(
label: &str,
width: f32,
@@ -97,6 +101,7 @@ pub fn resize_column(
}
#[tauri::command]
#[specta::specta]
pub fn open_window(
label: &str,
title: &str,
@@ -166,6 +171,7 @@ pub fn open_window(
}
#[tauri::command]
#[specta::specta]
pub fn set_badge(count: i32) {
#[cfg(target_os = "macos")]
unsafe {