- 修复: LiveKit 回环候选生效(宿主机浏览器可直连推流) - 修复: 回放预签名 URL 403(公开端点直接签名,SignedHeaders=host) - 修复: 录像探针补 fileSize/durationSeconds - 修复: 家长录像列表被权限过滤误伤为 0 条;教师/家长列表按角色精确隔离 - 修复: 巡课静音失效(LiveKit attach 强制 unmute,静音时不挂载音轨) - 修复: 教室页自动请求摄像头/麦克风权限,分辨率失败自动降级 - 新增: 浏览器端到端验证脚本 scripts/e2e-browser.mjs(9 项断言全过: 教师推流/家长观看含音频电平实测/巡课默认静音/Egress 录像双轨齐全/ DPlayer 回放/录像权限隔离) - 新增: /parent/today 家长今日课程表、网站 Logo 上传与公开读取 - UI 重做: 虎牙风直播播放器 + DPlayer 回放播放器(视觉统一) - 分角色控制台: 管理端 /admin(16 模块)、教师端 /teacher、家长端 /parent - 直播/录像列表返回班级、课程、教师名称与在线人数 - 18088 本地预览改为 Vite 热更新,README/实现状态文档同步更新 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Code <noreply@anthropic.com>
105 lines
3.4 KiB
Java
105 lines
3.4 KiB
Java
package com.xh.xunke.settings;
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Map;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
@Service
|
|
public class SettingsService {
|
|
private final SettingRepository repository;
|
|
private final StringRedisTemplate redis;
|
|
private final Map<String, String> cache = new ConcurrentHashMap<>();
|
|
private volatile String loadedVersion = "";
|
|
|
|
public SettingsService(SettingRepository repository, StringRedisTemplate redis) {
|
|
this.repository = repository;
|
|
this.redis = redis;
|
|
}
|
|
|
|
public String text(String key, String fallback) {
|
|
refresh();
|
|
return cache.getOrDefault(key, fallback);
|
|
}
|
|
|
|
public boolean flag(String key, boolean fallback) {
|
|
String value = text(key, null);
|
|
if (value == null) {
|
|
return fallback;
|
|
}
|
|
return "true".equalsIgnoreCase(value) || "1".equals(value);
|
|
}
|
|
|
|
public int integer(String key, int fallback) {
|
|
try {
|
|
return Integer.parseInt(text(key, Integer.toString(fallback)));
|
|
} catch (NumberFormatException ex) {
|
|
return fallback;
|
|
}
|
|
}
|
|
|
|
public Map<String, String> byPrefix(String prefix) {
|
|
refresh();
|
|
Map<String, String> result = new LinkedHashMap<>();
|
|
cache.forEach((key, value) -> {
|
|
if (key.startsWith(prefix)) {
|
|
result.put(key, value);
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
|
|
public Map<String, Object> publicSite() {
|
|
Map<String, Object> site = new LinkedHashMap<>();
|
|
byPrefix("site.").forEach(site::put);
|
|
if (!text("site.logo.key", "").isBlank()) {
|
|
site.put("site.logo.url", "/api/public/site-logo");
|
|
}
|
|
site.put("registrationEnabled", flag("reg.enabled", true));
|
|
site.put("emailVerify", flag("reg.emailVerify", false));
|
|
site.put("smsVerify", flag("reg.smsVerify", false));
|
|
site.put("requireApproval", flag("reg.requireApproval", true));
|
|
site.put("allowUsername", flag("reg.allowUsername", true));
|
|
site.put("allowEmail", flag("reg.allowEmail", true));
|
|
site.put("allowPhone", flag("reg.allowPhone", true));
|
|
site.put("passwordMin", integer("sec.password.min", 8));
|
|
site.put("passwordMix", flag("sec.password.mix", true));
|
|
return site;
|
|
}
|
|
|
|
@Transactional
|
|
public void update(Map<String, String> values) {
|
|
values.forEach((key, value) -> {
|
|
if (key == null || !key.matches("[a-z0-9.]+") || value == null) {
|
|
return;
|
|
}
|
|
repository.save(new SystemSetting(key, value));
|
|
});
|
|
redis.opsForValue().increment("settings:ver");
|
|
loadedVersion = "";
|
|
}
|
|
|
|
private void refresh() {
|
|
String version;
|
|
try {
|
|
version = redis.opsForValue().get("settings:ver");
|
|
} catch (RuntimeException ex) {
|
|
version = loadedVersion;
|
|
}
|
|
if (version == null) {
|
|
version = "0";
|
|
}
|
|
if (version.equals(loadedVersion) && !cache.isEmpty()) {
|
|
return;
|
|
}
|
|
synchronized (this) {
|
|
cache.clear();
|
|
repository.findAll().forEach(item -> cache.put(item.getSettingKey(), item.getSettingValue()));
|
|
loadedVersion = version;
|
|
}
|
|
}
|
|
}
|