-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
244 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::path::{Path, PathBuf}; | ||
use tauri::{AppHandle, Manager}; | ||
|
||
pub fn get_background_dir_relative_path( | ||
manga_dir: &str, | ||
width: u32, | ||
height: u32, | ||
) -> anyhow::Result<PathBuf> { | ||
let manga_dir_name = Path::new(manga_dir) | ||
.file_name() | ||
.ok_or(anyhow::anyhow!("获取漫画目录名失败"))? | ||
.to_str() | ||
.ok_or(anyhow::anyhow!("漫画目录名包含非UTF-8字符"))?; | ||
let relative_path = format!("背景水印图/{manga_dir_name}{width}x{height}"); | ||
Ok(PathBuf::from(relative_path)) | ||
} | ||
|
||
pub fn get_background_dir_abs_path( | ||
app: &AppHandle, | ||
manga_dir: &str, | ||
width: u32, | ||
height: u32, | ||
) -> anyhow::Result<PathBuf> { | ||
let resource_dir = app.path().resource_dir()?; | ||
let relative_path = get_background_dir_relative_path(manga_dir, width, height)?; | ||
let abs_path = resource_dir.join(relative_path); | ||
Ok(abs_path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.