mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-09-04 23:19:17 +08:00
feat(update): 实现应用内更新检查和版本显示
- 新增 `VERSION` 文件用于跟踪当前应用版本 (当前为 2.0.7)。
- 创建 `app/service/update/update_service.py` 服务,用于:
- 从 `VERSION` 文件读取当前版本。
- 通过 GitHub API 获取指定仓库 (`GITHUB_REPO_OWNER`/`GITHUB_REPO_NAME`) 的最新 Release Tag。
- 使用 `packaging` 库比较版本,判断是否有可用更新。
- 在应用启动 (`app/core/application.py`) 时异步调用更新检查服务。
- 将当前版本和更新检查结果(是否可用、最新版本号、错误信息)存储在 `app.state.update_info` 中,供模板使用。
- 在基础模板 (`app/templates/base.html`) 的页脚动态显示当前版本。
- 如果检测到新版本,在页脚显示更新提示和指向最新 Release 的链接。
- 如果更新检查失败,在页脚显示错误提示。
- 在 `app/config/config.py` 中添加 `GITHUB_REPO_OWNER` 和 `GITHUB_REPO_NAME` 配置项,并提供默认值。
- 在 `requirements.txt` 中添加 `packaging` 依赖。
- 添加 `update_service` 专用的 logger (`app/log/logger.py`)。
- 改进配置编辑器 (`config_editor.js`, `config_editor.html`):
- 限制预算输入框 (`budget_map`) 的值在 0 到 24576 之间。
- 移除了预算映射项的删除按钮(预算项应随模型列表自动增删)。
- 更新了预算输入的提示文本。
This commit is contained in:
@@ -702,21 +702,30 @@ function createAndAppendBudgetMapItem(mapKey, mapValue, modelId) {
|
||||
valueInput.value = isNaN(intValue) ? 0 : intValue;
|
||||
valueInput.placeholder = '预算 (整数)';
|
||||
valueInput.className = 'map-value-input w-24 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-primary-500 focus:ring focus:ring-primary-200 focus:ring-opacity-50';
|
||||
valueInput.min = 0; // 添加最小值
|
||||
valueInput.max = 24576; // 添加最大值
|
||||
valueInput.addEventListener('input', function() {
|
||||
this.value = this.value.replace(/[^0-9]/g, ''); // Remove non-digit characters
|
||||
// 限制输入为0到24576之间的整数
|
||||
let value = this.value.replace(/[^0-9]/g, '');
|
||||
if (value !== '') {
|
||||
value = parseInt(value, 10);
|
||||
if (value < 0) value = 0;
|
||||
if (value > 24576) value = 24576;
|
||||
}
|
||||
this.value = value;
|
||||
});
|
||||
|
||||
// Remove Button - Disabled
|
||||
const removeBtn = document.createElement('button');
|
||||
removeBtn.type = 'button';
|
||||
removeBtn.className = 'remove-btn text-gray-300 cursor-not-allowed focus:outline-none';
|
||||
removeBtn.innerHTML = '<i class="fas fa-trash-alt"></i>';
|
||||
removeBtn.title = '请从上方模型列表删除';
|
||||
removeBtn.disabled = true;
|
||||
// Remove Button - Removed for budget map items
|
||||
// const removeBtn = document.createElement('button');
|
||||
// removeBtn.type = 'button';
|
||||
// removeBtn.className = 'remove-btn text-gray-300 cursor-not-allowed focus:outline-none'; // Kept original class for reference
|
||||
// removeBtn.innerHTML = '<i class="fas fa-trash-alt"></i>';
|
||||
// removeBtn.title = '请从上方模型列表删除';
|
||||
// removeBtn.disabled = true;
|
||||
|
||||
mapItem.appendChild(keyInput);
|
||||
mapItem.appendChild(valueInput);
|
||||
mapItem.appendChild(removeBtn);
|
||||
// mapItem.appendChild(removeBtn); // Do not append the remove button
|
||||
|
||||
container.appendChild(mapItem);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user