-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from TC999/tsukai
描述测试
- Loading branch information
Showing
5 changed files
with
90 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Roaming: | ||
# 示例:文件夹名: "描述" | ||
Code: "VSCode" | ||
pip: "pip 网络配置文件" | ||
Mozilla: "Firefox" | ||
#firefox: "Mozilla Firefox 浏览器配置文件" | ||
clash_win: "Clash for Windows 配置文件" | ||
VMWare: "VMWare 配置文件" | ||
Motrix: "Motrix 配置文件" | ||
zen: "Zen 网络配置" | ||
Local: | ||
BCUT: "必剪数据" | ||
Temp: "系统临时文件" | ||
myapp: "自定义应用配置文件" | ||
Packages: "UWP 程序数据" | ||
Chromium: "Chromium 用户数据" | ||
Google: "Google 系软件数据" | ||
pip: "pip 下载目录" | ||
Programs: "Python 解释器安装目录" | ||
Obsidian: "Obsidian 安装位置" | ||
zen: "Zen 浏览器用户数据" | ||
rustdesk: "RustDesk 用户数据" | ||
LocalLow: |
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,36 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use std::collections::HashMap; | ||
use std::fs; | ||
use std::path::Path; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct FolderDescriptions { | ||
pub Roaming: HashMap<String, String>, | ||
pub Local: HashMap<String, String>, | ||
pub LocalLow: HashMap<String, String>, | ||
} | ||
|
||
impl FolderDescriptions { | ||
pub fn load_from_yaml(file_path: &str) -> Result<Self, String> { | ||
let path = Path::new(file_path); | ||
if !path.exists() { | ||
return Err("YAML 文件未找到".to_string()); | ||
} | ||
|
||
let content = fs::read_to_string(path).map_err(|e| format!("读取 YAML 文件失败: {}", e))?; | ||
|
||
let descriptions: FolderDescriptions = | ||
serde_yaml::from_str(&content).map_err(|e| format!("解析 YAML 文件失败: {}", e))?; | ||
|
||
Ok(descriptions) | ||
} | ||
|
||
pub fn get_description(&self, folder_name: &str, folder_type: &str) -> Option<String> { | ||
match folder_type { | ||
"Roaming" => self.Roaming.get(folder_name).cloned(), | ||
"Local" => self.Local.get(folder_name).cloned(), | ||
"LocalLow" => self.LocalLow.get(folder_name).cloned(), | ||
_ => None, | ||
} | ||
} | ||
} |