保存用户自选主题

This commit is contained in:
wenli 2024-09-08 11:26:55 +08:00
parent bba3297181
commit 40f0367ed1
2 changed files with 7 additions and 4 deletions

View File

@ -40,14 +40,14 @@ public class ConfigController {
@PostMapping("/create")
@Operation(summary = "创建参数配置")
@PreAuthorize("@ss.hasPermission('infra:config:create')")
// @PreAuthorize("@ss.hasPermission('infra:config:create')")
public CommonResult<Long> createConfig(@Valid @RequestBody ConfigSaveReqVO createReqVO) {
return success(configService.createConfig(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "修改参数配置")
@PreAuthorize("@ss.hasPermission('infra:config:update')")
// @PreAuthorize("@ss.hasPermission('infra:config:update')")
public CommonResult<Boolean> updateConfig(@Valid @RequestBody ConfigSaveReqVO updateReqVO) {
configService.updateConfig(updateReqVO);
return success(true);

View File

@ -3,6 +3,7 @@
package com.lw.fx.theme;
import atlantafx.base.theme.*;
import cn.hutool.core.util.StrUtil;
import com.lw.fx.Resources;
import com.lw.fx.event.DefaultEventBus;
import com.lw.fx.event.EventBus;
@ -88,16 +89,18 @@ public final class ThemeManager {
}
public void setTheme(String themeName) {
SamplerTheme samplerTheme = getDefaultTheme();
SamplerTheme samplerTheme = null;
// 使用Stream查找name为"abc"的SamplerTheme
Optional<SamplerTheme> result = getRepository().getAll().stream()
.filter(theme -> themeName.equals(theme.getName()))
.filter(theme -> StrUtil.equals(themeName,theme.getName()))
.findFirst();
// 处理查找到的结果
if (result.isPresent()) {
samplerTheme = result.get();
}else {
samplerTheme=getDefaultTheme();
}
setTheme(samplerTheme);
}