refactor: use specta for commands (#192)
* feat: add tauri-specta * refactor: system library * chore: format
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use std::process::Command;
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn show_in_folder(path: String) {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user