e34528c886
Les thèmes ne sont plus codés en dur dans le JS. Chaque thème est un fichier CSS dans src-tauri/resources/themes/, embarqué à la compilation via include_str!. Le backend expose list_themes et get_theme_css comme commandes Tauri ; le frontend charge et met en cache le CSS à la demande. Ajout du thème "Défaut" (basé sur Shell Indigo) avec commentaires sur chaque règle et rendu complet des tableaux (en-têtes en majuscules, bordure extérieure, séparateurs verticaux, lignes alternées) aligné sur MarkdownRender-nodejs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
55 lines
1.3 KiB
Rust
55 lines
1.3 KiB
Rust
use crate::application::theme_service;
|
|
use crate::infrastructure::theme_repository::StaticThemeRepository;
|
|
use serde::Serialize;
|
|
|
|
#[derive(Serialize)]
|
|
pub struct ThemeDto {
|
|
pub id: String,
|
|
pub label: String,
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub fn list_themes() -> Vec<ThemeDto> {
|
|
let repo = StaticThemeRepository;
|
|
theme_service::list_themes(&repo)
|
|
.into_iter()
|
|
.map(|t| ThemeDto { id: t.id, label: t.label })
|
|
.collect()
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub fn get_theme_css(id: String) -> Option<String> {
|
|
let repo = StaticThemeRepository;
|
|
theme_service::get_theme_css(&repo, &id)
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn list_themes_returns_non_empty() {
|
|
let themes = list_themes();
|
|
assert!(!themes.is_empty());
|
|
}
|
|
|
|
#[test]
|
|
fn list_themes_ids_are_non_empty() {
|
|
for theme in list_themes() {
|
|
assert!(!theme.id.is_empty());
|
|
assert!(!theme.label.is_empty());
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn get_theme_css_known() {
|
|
assert!(get_theme_css("dark".into()).is_some());
|
|
assert!(get_theme_css("shell-indigo".into()).is_some());
|
|
}
|
|
|
|
#[test]
|
|
fn get_theme_css_unknown_returns_none() {
|
|
assert!(get_theme_css("does-not-exist".into()).is_none());
|
|
}
|
|
}
|