feat: i18n supports

This commit is contained in:
GyDi
2022-03-12 23:07:45 +08:00
parent a393b8b122
commit 4991f7ff39
19 changed files with 254 additions and 60 deletions

View File

@@ -1,6 +1,6 @@
use crate::log_if_err;
use crate::{
core::Clash,
log_if_err,
utils::{config, dirs, sysopt::SysProxyConfig},
};
use anyhow::{bail, Result};
@@ -12,6 +12,9 @@ use tauri::{async_runtime::Mutex, utils::platform::current_exe};
/// ### `verge.yaml` schema
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct VergeConfig {
// i18n
pub language: Option<String>,
/// `light` or `dark`
pub theme_mode: Option<String>,
@@ -188,6 +191,9 @@ impl Verge {
/// so call the save_file at the end is savely
pub fn patch_config(&mut self, patch: VergeConfig) -> Result<()> {
// only change it
if patch.language.is_some() {
self.config.language = patch.language;
}
if patch.theme_mode.is_some() {
self.config.theme_mode = patch.theme_mode;
}

View File

@@ -21,6 +21,7 @@ items: ~
/// template for `verge.yaml`
pub const VERGE_CONFIG: &[u8] = b"# Defaulf Config For Clash Verge
language: en
theme_mode: light
theme_blur: false
traffic_graph: true