zerolaunch_plugin_api/services/resource/
app_resource.rs1use dashmap::DashMap;
2use std::path::PathBuf;
3
4pub struct AppResourceService {
8 icon_paths: DashMap<String, String>,
10 icons_dir: String,
12}
13
14impl AppResourceService {
15 pub fn new(icons_dir: String) -> Self {
22 let icon_paths = DashMap::new();
23
24 let icons_dir_path = PathBuf::from(&icons_dir);
25
26 let icons = [
27 ("tray_icon", "32x32.png"),
28 ("web_pages", "web_pages.png"),
29 ("tips", "tips.png"),
30 ("terminal", "terminal.png"),
31 ("settings", "settings.png"),
32 ("refresh", "refresh.png"),
33 ("register", "register.png"),
34 ("game", "game.png"),
35 ("exit", "exit.png"),
36 ];
37
38 for (name, filename) in icons {
39 let path = icons_dir_path.join(filename);
40 icon_paths.insert(name.to_string(), path.to_string_lossy().to_string());
41 }
42
43 Self {
44 icon_paths,
45 icons_dir,
46 }
47 }
48
49 pub fn get_icon_path(&self, name: &str) -> Option<String> {
56 self.icon_paths.get(name).map(|v| v.value().clone())
57 }
58
59 pub fn icons_dir(&self) -> &str {
63 &self.icons_dir
64 }
65}