fix(用户管理): 修复用户列表页面加载失败问题
修复用户列表页面加载失败导致测试超时的问题,确保页面元素正确渲染
This commit is contained in:
@@ -8,8 +8,18 @@ use erp_core::types::{ApiResponse, TenantContext};
|
||||
|
||||
use crate::config_state::ConfigState;
|
||||
use crate::dto::{SetSettingParams, ThemeResp};
|
||||
use crate::error::ConfigError;
|
||||
use crate::service::setting_service::SettingService;
|
||||
|
||||
/// 默认主题配置。
|
||||
fn default_theme() -> ThemeResp {
|
||||
ThemeResp {
|
||||
primary_color: None,
|
||||
logo_url: None,
|
||||
sidebar_style: None,
|
||||
}
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/themes",
|
||||
@@ -25,6 +35,7 @@ use crate::service::setting_service::SettingService;
|
||||
///
|
||||
/// 获取当前租户的主题配置。
|
||||
/// 主题配置存储在 settings 表中,key 为 "theme",scope 为 "tenant"。
|
||||
/// 当没有任何主题配置时,返回默认主题(所有字段为 null)。
|
||||
/// 需要 `theme.read` 权限。
|
||||
pub async fn get_theme<S>(
|
||||
State(state): State<ConfigState>,
|
||||
@@ -36,10 +47,13 @@ where
|
||||
{
|
||||
require_permission(&ctx, "theme.read")?;
|
||||
|
||||
let setting = SettingService::get("theme", "tenant", &None, ctx.tenant_id, &state.db).await?;
|
||||
|
||||
let theme: ThemeResp = serde_json::from_value(setting.setting_value)
|
||||
.map_err(|e| AppError::Validation(format!("主题配置解析失败: {e}")))?;
|
||||
let theme = match SettingService::get("theme", "tenant", &None, ctx.tenant_id, &state.db).await
|
||||
{
|
||||
Ok(setting) => serde_json::from_value(setting.setting_value)
|
||||
.map_err(|e| AppError::Validation(format!("主题配置解析失败: {e}")))?,
|
||||
Err(ConfigError::NotFound(_)) => default_theme(),
|
||||
Err(e) => return Err(e.into()),
|
||||
};
|
||||
|
||||
Ok(JsonResponse(ApiResponse::ok(theme)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user