-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dfd325b
commit 8ff7f28
Showing
6 changed files
with
75 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use crate::read_json; | ||
use anyhow::Result; | ||
use serde::{Deserialize, Serialize}; | ||
use serde_json::from_value; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct ServerConfig { | ||
pub adaptive: bool, | ||
#[serde(rename = "enableServer")] | ||
pub enable_server: bool, | ||
#[serde(rename = "forceUpdateExcel")] | ||
pub force_update_excel: bool, | ||
pub gadget: bool, | ||
pub host: String, | ||
#[serde(rename = "maintenanceMsg")] | ||
pub maintenance_msg: String, | ||
pub mode: String, | ||
#[serde(rename = "noProxy")] | ||
pub no_proxy: bool, | ||
pub port: i64, | ||
#[serde(rename = "useSu")] | ||
pub use_su: bool, | ||
} | ||
|
||
impl ServerConfig { | ||
pub fn load() -> Result<Self> { | ||
let value = read_json("./config/server.json")["server"].clone(); | ||
Ok(from_value(value)?) | ||
} | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct RestorePrevState { | ||
is2: bool, | ||
#[serde(rename = "squadsAndFavs")] | ||
sq_n_fav: bool, | ||
ui: bool, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct UserConfig { | ||
#[serde(rename = "activityMaxStartTs")] | ||
pub act_max_start_ts: i64, | ||
#[serde(rename = "activityMinStartTs")] | ||
pub act_min_start_ts: i64, | ||
pub background: String, | ||
#[serde(rename = "fakeTime")] | ||
pub fake_time: i64, | ||
#[serde(rename = "forceEnableBattleReplay")] | ||
pub force_battle_replay: bool, | ||
#[serde(rename = "nickName")] | ||
pub name: String, | ||
#[serde(rename = "nickNumber")] | ||
pub number: String, | ||
#[serde(rename = "restorePreviousStates")] | ||
pub restore_prev_state: RestorePrevState, | ||
pub secretary: String, | ||
#[serde(rename = "secretarySkinId")] | ||
pub secretary_skin: String, | ||
pub theme: String, | ||
pub vision: bool, | ||
} | ||
|
||
impl UserConfig { | ||
pub fn load() -> Result<Self> { | ||
let value = read_json("./config/server.json")["userConfig"].clone(); | ||
Ok(from_value(value)?) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
mod cfg; | ||
mod fs; | ||
mod json; | ||
|
||
pub use self::{ | ||
cfg::{RestorePrevState, ServerConfig, UserConfig}, | ||
fs::mkfile, | ||
json::{read_json, write_json}, | ||
}; |
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 |
---|---|---|
@@ -1,69 +1 @@ | ||
use anyhow::Result; | ||
use common_utils::read_json; | ||
use serde::{Deserialize, Serialize}; | ||
use serde_json::from_value; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct ServerConfig { | ||
pub adaptive: bool, | ||
#[serde(rename = "enableServer")] | ||
pub enable_server: bool, | ||
#[serde(rename = "forceUpdateExcel")] | ||
pub force_update_excel: bool, | ||
pub gadget: bool, | ||
pub host: String, | ||
#[serde(rename = "maintenanceMsg")] | ||
pub maintenance_msg: String, | ||
pub mode: String, | ||
#[serde(rename = "noProxy")] | ||
pub no_proxy: bool, | ||
pub port: i64, | ||
#[serde(rename = "useSu")] | ||
pub use_su: bool, | ||
} | ||
|
||
impl ServerConfig { | ||
pub fn load() -> Result<Self> { | ||
let value = read_json("./config/server.json")["server"].clone(); | ||
Ok(from_value(value)?) | ||
} | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct RestorePrevState { | ||
is2: bool, | ||
#[serde(rename = "squadsAndFavs")] | ||
sq_n_fav: bool, | ||
ui: bool, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct UserConfig { | ||
#[serde(rename = "activityMaxStartTs")] | ||
pub act_max_start_ts: i64, | ||
#[serde(rename = "activityMinStartTs")] | ||
pub act_min_start_ts: i64, | ||
pub background: String, | ||
#[serde(rename = "fakeTime")] | ||
pub fake_time: i64, | ||
#[serde(rename = "forceEnableBattleReplay")] | ||
pub force_battle_replay: bool, | ||
#[serde(rename = "nickName")] | ||
pub name: String, | ||
#[serde(rename = "nickNumber")] | ||
pub number: String, | ||
#[serde(rename = "restorePreviousStates")] | ||
pub restore_prev_state: RestorePrevState, | ||
pub secretary: String, | ||
#[serde(rename = "secretarySkinId")] | ||
pub secretary_skin: String, | ||
pub theme: String, | ||
pub vision: bool, | ||
} | ||
|
||
impl UserConfig { | ||
pub fn load() -> Result<Self> { | ||
let value = read_json("./config/server.json")["userConfig"].clone(); | ||
Ok(from_value(value)?) | ||
} | ||
} |
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