更新到 2.12.20

This commit is contained in:
shenjack 2024-09-19 23:52:45 +08:00
parent cb87108804
commit 91aa3f7bd9
Signed by: shenjack
GPG Key ID: 7B1134A979775551
3 changed files with 31 additions and 1 deletions

View File

@ -11,7 +11,7 @@ use crate::error::{ClientResult, IcaError};
use crate::{version_str, StopGetter};
/// icalingua 客户端的兼容版本号
pub const ICA_PROTOCOL_VERSION: &str = "2.12.12";
pub const ICA_PROTOCOL_VERSION: &str = "2.12.20";
pub async fn start_ica(config: &IcaConfig, stop_reciver: StopGetter) -> ClientResult<(), IcaError> {
let span = span!(Level::INFO, "Icalingua Client");

View File

@ -57,6 +57,14 @@ impl PluginConfigFile {
}
}
fn get_table(&self) -> Option<&Table> {
self.data.get(CONFIG_KEY).and_then(|item| item.as_table())
}
fn get_table_mut(&mut self) -> Option<&mut Table> {
self.data.get_mut(CONFIG_KEY).and_then(|item| item.as_table_mut())
}
/// 获取插件状态
/// 默认为 true
pub fn get_status(&self, path: &Path) -> bool {
@ -73,6 +81,23 @@ impl PluginConfigFile {
true
}
/// 删掉一个状态
pub fn remove_status(&mut self, path: &Path) -> Option<bool> {
let path_str = path.to_str().unwrap();
if let Some(table) = self.get_table_mut() {
if let Some(item) = table.get_mut(path_str) {
if let Some(bool) = item.as_bool() {
table.remove(path_str);
return Some(bool);
} else {
table.remove(path_str);
return Some(false);
}
}
}
None
}
/// 设置插件状态
pub fn set_status(&mut self, path: &Path, status: bool) {
self.verify_and_init();

View File

@ -41,6 +41,11 @@ impl PyStatus {
pub fn add_file(path: PathBuf, plugin: PyPlugin) { Self::get_map_mut().insert(path, plugin); }
/// 删除一个插件
pub fn delete_file(path: &PathBuf) -> Option<PyPlugin> {
Self::get_map_mut().remove(path)
}
pub fn verify_file(path: &PathBuf) -> bool {
Self::get_map().get(path).map_or(false, |plugin| plugin.verifiy())
}