Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: specta #29

Merged
merged 8 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@
"editor.formatOnSave": true,
"editor.inlayHints.enabled": "off"
},
"cSpell.words": ["consts", "directx", "fullscreen", "nvapi", "tauri"],
"cSpell.words": [
"consts",
"directx",
"fullscreen",
"nvapi",
"rspc",
"specta",
"tauri"
],
"tailwindCSS.experimental.classRegex": [
"tv\\(([^)(]*(?:\\([^)(]*(?:\\([^)(]*(?:\\([^)(]*\\)[^)(]*)*\\)[^)(]*)*\\)[^)(]*)*)\\)"
]
Expand Down
3 changes: 3 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
"formatter": {
"indentStyle": "space",
"indentWidth": 2
},
"files": {
"ignore": ["src/rspc/**"]
}
}
82 changes: 82 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ winapi = { version = "0.3", features = ["dxgi"] }
regex = "1.11.1"
tempfile = "3.14.0"
sys-locale = "0.3.2"
tauri-specta = { version = "=2.0.0-rc.20", features = ["derive", "typescript"] }
specta-typescript = "0.0.7"
specta="=2.0.0-rc.20"

[dependencies.uuid]
version = "1.11.0"
Expand Down
7 changes: 6 additions & 1 deletion src-tauri/src/commands/background_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use base64::Engine;
use image::load_from_memory;
use image::ImageFormat;
use serde::{Deserialize, Serialize};
use specta::Type;
use tauri::command;
use tokio::fs;
use tokio::io::AsyncWriteExt;
Expand All @@ -19,6 +20,7 @@ const BG_IMG_DIR_NAME: &str = "BgImages";
/// - `file_id`: 画像ファイルID
///
#[command]
#[specta::specta]
pub async fn get_background_image(file_id: String) -> Result<String, String> {
let dir_path = get_app_data_dir(BG_IMG_DIR_NAME);

Expand All @@ -43,7 +45,7 @@ pub async fn get_background_image(file_id: String) -> Result<String, String> {
/// - `file_id` : 画像ファイルID
/// - `image_data` : 画像データのBase64文字列
///
#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, Type)]
#[serde(rename_all = "camelCase")]
pub struct BackgroundImage {
pub file_id: String,
Expand All @@ -54,6 +56,7 @@ pub struct BackgroundImage {
/// BG_IMG_DIR_NAME ディレクトリ内の背景画像一覧を取得
///
#[command]
#[specta::specta]
pub async fn get_background_images() -> Result<Vec<BackgroundImage>, String> {
let dir_path = get_app_data_dir(BG_IMG_DIR_NAME);

Expand Down Expand Up @@ -100,6 +103,7 @@ pub async fn get_background_images() -> Result<Vec<BackgroundImage>, String> {
/// - returns: `file_id`
///
#[command]
#[specta::specta]
pub async fn save_background_image(image_data: String) -> Result<String, String> {
let dir_path = get_app_data_dir(BG_IMG_DIR_NAME);

Expand Down Expand Up @@ -159,6 +163,7 @@ pub async fn save_background_image(image_data: String) -> Result<String, String>
/// - `file_id`: 画像ファイルID
///
#[tauri::command]
#[specta::specta]
pub async fn delete_background_image(file_id: String) -> Result<(), String> {
let dir_path = get_app_data_dir(BG_IMG_DIR_NAME);
let file_name = FILE_NAME_FORMAT.replace("{}", &file_id);
Expand Down
Loading