refactor: 清理遗留设置模型与无用代码
- 删除 settings 的 sections 与 sidebar 六个旧排序/显隐字段,前后端类型与校验同步 - 删除旧分类模型 types、旧 /api/catalog 客户端、旧路由解析与 settings CRUD - 删除未使用的 AppProject::initial - 删除 27 条已无组件的 CSS 规则(159 行) - 保持现有首页/接口页渲染,cargo test 52 passed
This commit is contained in:
@@ -92,13 +92,6 @@ impl Default for SidebarSettings {
|
||||
show_profile: true,
|
||||
show_service: true,
|
||||
show_nav: true,
|
||||
hidden: Vec::new(),
|
||||
order: Vec::new(),
|
||||
hidden_groups: Vec::new(),
|
||||
shown_groups: Vec::new(),
|
||||
group_order: std::collections::HashMap::new(),
|
||||
tree_hidden: Vec::new(),
|
||||
tree_order: std::collections::HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,33 +108,6 @@ pub struct SidebarSettings {
|
||||
/// 是否显示「分组导航」卡片(首页 / 分组树)
|
||||
#[serde(default = "default_true")]
|
||||
pub show_nav: bool,
|
||||
/// 隐藏的分类 id
|
||||
pub hidden: Vec<String>,
|
||||
/// 分类显示顺序(id);未列出的排在后面,保持原有顺序
|
||||
pub order: Vec<String>,
|
||||
/// 隐藏的分组,键为 `分区id/分组id`
|
||||
pub hidden_groups: Vec<String>,
|
||||
/// 强制显示的分组(覆盖数据库里的 show_in_sidebar=0)
|
||||
pub shown_groups: Vec<String>,
|
||||
/// 每个分区下分组的顺序:分区 id → 分组 id 列表
|
||||
pub group_order: std::collections::HashMap<String, Vec<String>>,
|
||||
/// 新模型:侧栏隐藏的分组 key(任意层级)
|
||||
pub tree_hidden: Vec<String>,
|
||||
/// 新模型:每级分组的顺序,键是父分组 key(根级用空串)
|
||||
pub tree_order: std::collections::HashMap<String, Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
|
||||
#[serde(default)]
|
||||
pub struct SectionsSettings {
|
||||
/// 隐藏的首页卡片(分类 id)
|
||||
pub hidden: Vec<String>,
|
||||
/// 卡片顺序(分类 id)
|
||||
pub order: Vec<String>,
|
||||
/// 标题覆盖:id → 标题
|
||||
pub titles: std::collections::HashMap<String, String>,
|
||||
/// 预览条数覆盖:id → 条数
|
||||
pub limits: std::collections::HashMap<String, u32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
@@ -254,7 +220,6 @@ impl Default for SiteMetaSettings {
|
||||
pub struct Settings {
|
||||
pub header: HeaderSettings,
|
||||
pub sidebar: SidebarSettings,
|
||||
pub sections: SectionsSettings,
|
||||
pub profile: ProfileSettings,
|
||||
pub site: SiteMetaSettings,
|
||||
}
|
||||
@@ -298,33 +263,6 @@ pub fn validate(settings: &Settings) -> Result<(), StashError> {
|
||||
}
|
||||
}
|
||||
}
|
||||
if settings.sidebar.hidden.len() > 100 || settings.sidebar.order.len() > 100 {
|
||||
return Err(StashError::InvalidDirectory("侧栏配置过长".into()));
|
||||
}
|
||||
if settings.sidebar.hidden_groups.len() > 200
|
||||
|| settings.sidebar.shown_groups.len() > 200
|
||||
|| settings.sidebar.group_order.len() > 100
|
||||
|| settings.sidebar.tree_hidden.len() > 500
|
||||
|| settings.sidebar.tree_order.len() > 200
|
||||
{
|
||||
return Err(StashError::InvalidDirectory("侧栏分组配置过长".into()));
|
||||
}
|
||||
if settings.sections.hidden.len() > 100 || settings.sections.order.len() > 100 {
|
||||
return Err(StashError::InvalidDirectory("首页卡片配置过长".into()));
|
||||
}
|
||||
if settings.sections.titles.len() > 100 || settings.sections.limits.len() > 100 {
|
||||
return Err(StashError::InvalidDirectory("首页卡片配置过长".into()));
|
||||
}
|
||||
for title in settings.sections.titles.values() {
|
||||
if title.chars().count() > 40 {
|
||||
return Err(StashError::InvalidDirectory("卡片标题最多 40 个字".into()));
|
||||
}
|
||||
}
|
||||
for limit in settings.sections.limits.values() {
|
||||
if *limit > 60 {
|
||||
return Err(StashError::InvalidDirectory("卡片条数最多 60".into()));
|
||||
}
|
||||
}
|
||||
if settings.profile.name.chars().count() > 40 {
|
||||
return Err(StashError::InvalidDirectory("名称最多 40 个字".into()));
|
||||
}
|
||||
@@ -457,7 +395,6 @@ mod tests {
|
||||
let settings = Settings::default();
|
||||
assert!(settings.header.enabled);
|
||||
assert_eq!(settings.header.items.len(), 3);
|
||||
assert!(settings.sections.hidden.is_empty());
|
||||
assert!(validate(&settings).is_ok());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,17 +7,6 @@ pub struct AppProject {
|
||||
pub route_path: String,
|
||||
}
|
||||
|
||||
impl AppProject {
|
||||
pub fn initial(&self) -> String {
|
||||
self.name
|
||||
.chars()
|
||||
.next()
|
||||
.unwrap_or('A')
|
||||
.to_uppercase()
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scan_projects(root: &Path) -> Vec<AppProject> {
|
||||
let mut projects = Vec::new();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user