整理下下载功能

This commit is contained in:
Tw93
2023-04-07 11:29:02 +08:00
parent 0cead9fbc6
commit 9bf73d937c
2 changed files with 10 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
use std::fs;
use tauri::{api, command, AppHandle, Manager};
#[command]
@@ -19,3 +20,9 @@ pub fn fullscreen(app: AppHandle) {
pub fn open_browser(app: AppHandle, url: String) {
api::shell::open(&app.shell_scope(), url, None).unwrap();
}
#[command]
pub fn download(_app: AppHandle, name: String, blob: Vec<u8>) {
let path = api::path::download_dir().unwrap().join(name);
fs::write(&path, blob).unwrap();
}