mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 15:14:35 +01:00
(misc) Enable window.startDragging for Tauri
This commit is contained in:
25
src-tauri/src/http.rs
Normal file
25
src-tauri/src/http.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use core::error::Error;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
/// Downloads a file from the given URL.
|
||||
/// Saves it to the specified file.
|
||||
/// This will overwrite the file if it already exists.
|
||||
/// url: The URL to download from.
|
||||
/// to_file: The file to save to.
|
||||
#[tauri::command]
|
||||
pub async fn download_file(url: String, to_file: String) -> Result<String, Box<dyn Error>> {
|
||||
let mut response = reqwest::get(&url).await?;
|
||||
let mut dest = {
|
||||
let fname = Path::new(&to_file);
|
||||
match File::create(&fname) {
|
||||
Ok(f) => f,
|
||||
Err(e) => return Err(Box::new(e)),
|
||||
}
|
||||
};
|
||||
while let Some(chunk) = response.chunk().await? {
|
||||
dest.write_all(&chunk).await?;
|
||||
}
|
||||
Ok("Downloaded".to_string())
|
||||
}
|
||||
@@ -15,6 +15,9 @@
|
||||
"shell": {
|
||||
"all": false,
|
||||
"open": true
|
||||
},
|
||||
"window": {
|
||||
"startDragging": true
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
@@ -36,6 +39,7 @@
|
||||
{
|
||||
"fullscreen": false,
|
||||
"resizable": true,
|
||||
"decorations": false,
|
||||
"title": "Cultivation",
|
||||
"width": 1280,
|
||||
"height": 730
|
||||
|
||||
28
src/backend/stores/mihoyo.ts
Normal file
28
src/backend/stores/mihoyo.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { create } from "zustand";
|
||||
import { persist, createJSONStorage } from "zustand/middleware";
|
||||
|
||||
import { invoke } from "@tauri-apps/api";
|
||||
|
||||
export type GenshinStore = {
|
||||
backgroundHash: string;
|
||||
};
|
||||
|
||||
export const useGenshinStore = create(
|
||||
persist(
|
||||
(): GenshinStore => ({
|
||||
backgroundHash: ""
|
||||
}),
|
||||
{
|
||||
name: "genshin",
|
||||
storage: createJSONStorage(() => localStorage)
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* React hook which returns the URL of the locally cached background image.
|
||||
*/
|
||||
export function useBackground() {
|
||||
const { backgroundHash } = useGenshinStore();
|
||||
const [background, setBackground] = useState<string | null>(null);
|
||||
}
|
||||
Reference in New Issue
Block a user