Skip to content

Commit eda400b

Browse files
author
SolonCode
committed
重构模型同步逻辑,始终更新模型属性以增强一致性;添加并应用自定义选择样式以改善表单外观
1 parent 277d0e1 commit eda400b

3 files changed

Lines changed: 47 additions & 10 deletions

File tree

soloncode-cli/src/main/java/org/noear/solon/codecli/portal/web/WebSettingsController.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,7 +1947,7 @@ public Result providersUpdate(@Body String json) throws Exception {
19471947
}
19481948
// 防御性:补回前端可能遗漏的手动模型
19491949
if (existing.getModels() != null) {
1950-
java.util.Set<String> newModelIds = new java.util.HashSet<>();
1950+
Set<String> newModelIds = new HashSet<>();
19511951
for (ModelInfo mi : models) {
19521952
newModelIds.add(mi.getId());
19531953
}
@@ -2119,12 +2119,12 @@ public Result providersSyncModels(@Body String json) throws Exception {
21192119
syncCount++;
21202120
} else {
21212121
// 模型已存在,检查是否需要同步状态
2122-
ModelDo existingModel = (ModelDo) settings.getModels().get(modelName);
2122+
ModelDo existingModel = settings.getModels().get(modelName);
21232123
if (providerName.equals(existingModel.getProvider())) {
2124-
if (existingModel.isVisibled() != provider.isEnabled()) {
2125-
existingModel.setVisibled(provider.isEnabled());
2126-
syncCount++;
2127-
}
2124+
syncCount++;
2125+
2126+
existingModel.setVisibled(provider.isEnabled());
2127+
21282128
// 更新 contextLength:优先 maxInputTokens,其次 maxTokens,最后从 models.json 查询
21292129
long newContextLength = 0;
21302130
if (modelInfo.getMaxInputTokens() != null && modelInfo.getMaxInputTokens() > 0) {
@@ -2140,8 +2140,12 @@ public Result providersSyncModels(@Body String json) throws Exception {
21402140
}
21412141
if (newContextLength > 0 && existingModel.getContextLength() != newContextLength) {
21422142
existingModel.setContextLength(newContextLength);
2143-
syncCount++;
21442143
}
2144+
2145+
existingModel.setStandard(provider.getStandard());
2146+
existingModel.setApiUrl(provider.getApiUrl());
2147+
existingModel.setApiKey(provider.getApiKey());
2148+
existingModel.setScope(provider.getScope());
21452149
}
21462150
}
21472151
}

soloncode-cli/src/main/resources/static/css/settings.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,29 @@
304304
.skills-market-select { padding: 7px 26px 7px 28px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-primary); color: var(--text-primary); font-size: 12px; font-weight: 500; outline: none; cursor: pointer; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; transition: border-color 0.2s, box-shadow 0.2s; }
305305
.skills-market-select:hover { border-color: var(--accent); }
306306
.skills-market-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 59,130,246), 0.15); }
307+
308+
/* 通用自定义 select 样式(用于日志级别、接口规范等原生 select) */
309+
.form-select-custom {
310+
padding: 7px 26px 7px 12px;
311+
border: 1px solid var(--border-color);
312+
border-radius: 8px;
313+
background: var(--bg-input-box);
314+
color: var(--text-primary);
315+
font-size: 13px;
316+
outline: none;
317+
cursor: pointer;
318+
appearance: none;
319+
-webkit-appearance: none;
320+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
321+
background-repeat: no-repeat;
322+
background-position: right 9px center;
323+
transition: border-color 0.2s, box-shadow 0.2s;
324+
font-family: inherit;
325+
box-sizing: border-box;
326+
width: 100%;
327+
}
328+
.form-select-custom:hover { border-color: var(--accent); }
329+
.form-select-custom:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 59,130,246), 0.15); }
307330
.skills-search-input-wrap { position: relative; display: flex; align-items: center; flex: 1; }
308331
.skills-search-icon { position: absolute; left: 10px; color: var(--text-secondary); pointer-events: none; }
309332
.skills-search-input-wrap input { width: 100%; padding: 7px 32px 7px 30px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-primary); color: var(--text-primary); font-size: 13px; outline: none; box-sizing: border-box; transition: border-color 0.2s, box-shadow 0.2s; }
@@ -458,6 +481,16 @@
458481
box-sizing: border-box;
459482
font-family: inherit;
460483
}
484+
/* general-input 用在 select 上时,应用自定义下拉箭头样式 */
485+
.general-input:is(select) {
486+
padding: 7px 26px 7px 12px;
487+
appearance: none;
488+
-webkit-appearance: none;
489+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
490+
background-repeat: no-repeat;
491+
background-position: right 9px center;
492+
cursor: pointer;
493+
}
461494
.general-input:focus {
462495
border-color: var(--accent);
463496
box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 79,110,247), 0.12);

soloncode-cli/src/main/resources/static/web.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@
700700
<div class="general-field-row">
701701
<div class="general-field">
702702
<label class="general-field-label">日志级别</label>
703-
<select class="general-input" id="generalLogLevel">
703+
<select class="general-input form-select-custom" id="generalLogLevel">
704704
<option value="">默认 (DEBUG)</option>
705705
<option value="TRACE">TRACE</option>
706706
<option value="DEBUG">DEBUG</option>
@@ -822,7 +822,7 @@
822822
</div>
823823
<div class="form-group">
824824
<label>接口规范</label>
825-
<select id="llmStandard">
825+
<select id="llmStandard" class="form-select-custom">
826826
<option value="">FullUrl / 完整地址(自动检测)</option>
827827
<option value="openai">OpenAI Chat Completions BaseUrl / 兼容接口</option>
828828
<option value="openai-responses">OpenAI Responses BaseUrl / 兼容接口</option>
@@ -1374,7 +1374,7 @@
13741374
</div>
13751375
<div class="form-group">
13761376
<label>接口规范</label>
1377-
<select id="providerStandard">
1377+
<select id="providerStandard" class="form-select-custom">
13781378
<option value="openai">OpenAI Chat Completions BaseUrl / 兼容接口</option>
13791379
<option value="openai-responses">OpenAI Responses BaseUrl / 兼容接口</option>
13801380
<option value="anthropic">Anthropic BaseUrl / 兼容接口</option>

0 commit comments

Comments
 (0)