refactor: 统一存放配置项的默认值
This commit is contained in:
@@ -8,11 +8,11 @@ use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
use crate::bilibili::{Credential, DanmakuOption, FilterOption};
|
||||
use crate::config::default::{default_auth_token, default_bind_address, default_time_format};
|
||||
use crate::config::item::{
|
||||
ConcurrentLimit, NFOTimeType, SkipOption, Trigger, default_collection_path, default_favorite_path,
|
||||
default_submission_path,
|
||||
use crate::config::default::{
|
||||
default_auth_token, default_bind_address, default_collection_path, default_favorite_path, default_submission_path,
|
||||
default_time_format,
|
||||
};
|
||||
use crate::config::item::{ConcurrentLimit, NFOTimeType, SkipOption, Trigger};
|
||||
use crate::notifier::Notifier;
|
||||
use crate::utils::model::{load_db_config, save_db_config};
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
use rand::seq::IndexedRandom;
|
||||
|
||||
pub(super) fn default_time_format() -> String {
|
||||
"%Y-%m-%d".to_string()
|
||||
}
|
||||
|
||||
/// 默认的 auth_token 实现,生成随机 16 位字符串
|
||||
pub(super) fn default_auth_token() -> String {
|
||||
let byte_choices = b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+-=";
|
||||
@@ -16,3 +12,19 @@ pub(super) fn default_auth_token() -> String {
|
||||
pub(crate) fn default_bind_address() -> String {
|
||||
"0.0.0.0:12345".to_string()
|
||||
}
|
||||
|
||||
pub(super) fn default_time_format() -> String {
|
||||
"%Y-%m-%d".to_string()
|
||||
}
|
||||
|
||||
pub fn default_favorite_path() -> String {
|
||||
"收藏夹/{{name}}".to_owned()
|
||||
}
|
||||
|
||||
pub fn default_collection_path() -> String {
|
||||
"合集/{{name}}".to_owned()
|
||||
}
|
||||
|
||||
pub fn default_submission_path() -> String {
|
||||
"投稿/{{name}}".to_owned()
|
||||
}
|
||||
|
||||
@@ -98,15 +98,3 @@ impl PathSafeTemplate for handlebars::Handlebars<'_> {
|
||||
Ok(filenamify(&self.render(name, data)?).replace("__SEP__", std::path::MAIN_SEPARATOR_STR))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_favorite_path() -> String {
|
||||
"收藏夹/{{name}}".to_owned()
|
||||
}
|
||||
|
||||
pub fn default_collection_path() -> String {
|
||||
"合集/{{name}}".to_owned()
|
||||
}
|
||||
|
||||
pub fn default_submission_path() -> String {
|
||||
"投稿/{{name}}".to_owned()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user