diff --git a/web/src/components/settings/OperationSetting.jsx b/web/src/components/settings/OperationSetting.jsx index 92591db4571b..b75b4d1fff72 100644 --- a/web/src/components/settings/OperationSetting.jsx +++ b/web/src/components/settings/OperationSetting.jsx @@ -37,6 +37,8 @@ const OperationSetting = () => { QuotaForInviter: 0, QuotaForInvitee: 0, 'quota_setting.enable_free_model_pre_consume': true, + 'oidc_quota_reset.enabled': false, + 'oidc_quota_reset.amount': 500000, /* 通用设置 */ TopUpLink: '', diff --git a/web/src/i18n/locales/en.json b/web/src/i18n/locales/en.json index df6fb8fec216..3e1b63fa178c 100644 --- a/web/src/i18n/locales/en.json +++ b/web/src/i18n/locales/en.json @@ -316,7 +316,7 @@ "使用 GitHub 继续": "Continue with GitHub", "使用 JSON 对象格式,格式为:{\"组名\": [最多请求次数, 最多请求完成次数]}": "Use JSON object format, format: {\"group_name\": [max_requests, max_completions]}", "使用 LinuxDO 继续": "Continue with LinuxDO", - "使用 OIDC 继续": "Continue with OIDC", + "使用 OIDC 继续": "Continue with Duke NetID", "使用 Passkey 实现免密且更安全的登录体验": "Use Passkey for password-free and more secure login experience", "使用 Passkey 登录": "Sign in with Passkey", "使用 Passkey 验证": "Verify with Passkey", @@ -390,6 +390,17 @@ "保存通用设置": "Save General Settings", "保存邮箱域名白名单设置": "Save Email Domain Whitelist Settings", "保存额度设置": "Save Quota Settings", + "OIDC 用户月度额度重置": "OIDC User Monthly Quota Reset", + "启用月度自动重置": "Enable Monthly Auto Reset", + "每月 1 日自动重置所有 OIDC 用户额度": "Auto reset all OIDC users quota on 1st of each month", + "重置额度": "Reset Quota", + "每次重置时设置的额度值": "Quota value to set on each reset", + "立即重置所有 OIDC 用户额度": "Reset All OIDC Users Quota Now", + "确认重置": "Confirm Reset", + "确定要立即重置所有 OIDC 用户的额度吗?": "Are you sure you want to reset all OIDC users quota now?", + "重置成功,已重置 {{count}} 个用户的额度为 {{quota}}": "Reset successful, {{count}} users quota reset to {{quota}}", + "重置失败": "Reset failed", + "重置失败:": "Reset failed: ", "修复数据库一致性": "Fix database consistency", "修改为": "Modify to", "修改子渠道优先级": "Modify sub-channel priority", @@ -776,7 +787,7 @@ "多密钥渠道操作项目组": "Multi-key channel operation project group", "多密钥管理": "Multi-key management", "多种充值方式,安全便捷": "Multiple recharge methods, safe and convenient", - "大模型接口网关": "LLM API Gateway", + "大模型接口网关": "Gateway", "天": "day", "天前": "days ago", "失败": "Failed", @@ -1858,7 +1869,7 @@ "绘图任务记录": "Drawing task records", "绘图日志": "Drawing Logs", "绘图设置": "Drawing settings", - "统一的": "The Unified", + "统一的": "DKU AI Service", "统计Tokens": "Statistical Tokens", "统计次数": "Statistical count", "统计额度": "Statistical quota", diff --git a/web/src/i18n/locales/zh.json b/web/src/i18n/locales/zh.json index 56a9a8902da5..86ca9a7f4d44 100644 --- a/web/src/i18n/locales/zh.json +++ b/web/src/i18n/locales/zh.json @@ -312,7 +312,7 @@ "使用 GitHub 继续": "使用 GitHub 继续", "使用 JSON 对象格式,格式为:{\"组名\": [最多请求次数, 最多请求完成次数]}": "使用 JSON 对象格式,格式为:{\"组名\": [最多请求次数, 最多请求完成次数]}", "使用 LinuxDO 继续": "使用 LinuxDO 继续", - "使用 OIDC 继续": "使用 OIDC 继续", + "使用 OIDC 继续": "使用 Duke NetID 继续", "使用 Passkey 实现免密且更安全的登录体验": "使用 Passkey 实现免密且更安全的登录体验", "使用 Passkey 登录": "使用 Passkey 登录", "使用 Passkey 验证": "使用 Passkey 验证", @@ -386,6 +386,17 @@ "保存通用设置": "保存通用设置", "保存邮箱域名白名单设置": "保存邮箱域名白名单设置", "保存额度设置": "保存额度设置", + "OIDC 用户月度额度重置": "OIDC 用户月度额度重置", + "启用月度自动重置": "启用月度自动重置", + "每月 1 日自动重置所有 OIDC 用户额度": "每月 1 日自动重置所有 OIDC 用户额度", + "重置额度": "重置额度", + "每次重置时设置的额度值": "每次重置时设置的额度值", + "立即重置所有 OIDC 用户额度": "立即重置所有 OIDC 用户额度", + "确认重置": "确认重置", + "确定要立即重置所有 OIDC 用户的额度吗?": "确定要立即重置所有 OIDC 用户的额度吗?", + "重置成功,已重置 {{count}} 个用户的额度为 {{quota}}": "重置成功,已重置 {{count}} 个用户的额度为 {{quota}}", + "重置失败": "重置失败", + "重置失败:": "重置失败:", "修复数据库一致性": "修复数据库一致性", "修改为": "修改为", "修改子渠道优先级": "修改子渠道优先级", @@ -769,7 +780,7 @@ "多密钥渠道操作项目组": "多密钥渠道操作项目组", "多密钥管理": "多密钥管理", "多种充值方式,安全便捷": "多种充值方式,安全便捷", - "大模型接口网关": "大模型接口网关", + "大模型接口网关": "接口网关", "天": "天", "天前": "天前", "失败": "失败", @@ -1844,7 +1855,7 @@ "绘图任务记录": "绘图任务记录", "绘图日志": "绘图日志", "绘图设置": "绘图设置", - "统一的": "统一的", + "统一的": "DKU AI服务", "统计Tokens": "统计Tokens", "统计次数": "统计次数", "统计额度": "统计额度", diff --git a/web/src/pages/Setting/Operation/SettingsCreditLimit.jsx b/web/src/pages/Setting/Operation/SettingsCreditLimit.jsx index a5208a502325..9106b24f7409 100644 --- a/web/src/pages/Setting/Operation/SettingsCreditLimit.jsx +++ b/web/src/pages/Setting/Operation/SettingsCreditLimit.jsx @@ -18,7 +18,7 @@ For commercial licensing, please contact support@quantumnous.com */ import React, { useEffect, useState, useRef } from 'react'; -import { Button, Col, Form, Row, Spin } from '@douyinfe/semi-ui'; +import { Button, Col, Form, Row, Spin, Popconfirm } from '@douyinfe/semi-ui'; import { useTranslation } from 'react-i18next'; import { compareObjects, @@ -28,6 +28,8 @@ import { showWarning, } from '../../../helpers'; +const SYNC_SERVICE_URL = '/api/sync'; + export default function SettingsCreditLimit(props) { const { t } = useTranslation(); const [loading, setLoading] = useState(false); @@ -37,9 +39,12 @@ export default function SettingsCreditLimit(props) { QuotaForInviter: '', QuotaForInvitee: '', 'quota_setting.enable_free_model_pre_consume': true, + 'oidc_quota_reset.enabled': false, + 'oidc_quota_reset.amount': 500000, }); const refForm = useRef(); const [inputsRow, setInputsRow] = useState(inputs); + const [resetting, setResetting] = useState(false); function onSubmit() { const updateArray = compareObjects(inputs, inputsRow); @@ -76,10 +81,44 @@ export default function SettingsCreditLimit(props) { }); } + async function handleManualReset() { + setResetting(true); + try { + const response = await fetch(`${SYNC_SERVICE_URL}/reset-oidc-quota`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + }); + const data = await response.json(); + if (data.success) { + showSuccess(t('重置成功,已重置 {{count}} 个用户的额度为 {{quota}}', { + count: data.affected, + quota: data.quota, + })); + } else { + showError(data.message || t('重置失败')); + } + } catch (error) { + showError(t('重置失败:') + error.message); + } finally { + setResetting(false); + } + } + useEffect(() => { - const currentInputs = {}; + const defaultInputs = { + QuotaForNewUser: '', + PreConsumedQuota: '', + QuotaForInviter: '', + QuotaForInvitee: '', + 'quota_setting.enable_free_model_pre_consume': true, + 'oidc_quota_reset.enabled': false, + 'oidc_quota_reset.amount': 500000, + }; + const currentInputs = { ...defaultInputs }; for (let key in props.options) { - if (Object.keys(inputs).includes(key)) { + if (Object.keys(defaultInputs).includes(key)) { currentInputs[key] = props.options[key]; } } @@ -189,6 +228,63 @@ export default function SettingsCreditLimit(props) { + + + + + + setInputs({ + ...inputs, + 'oidc_quota_reset.enabled': value, + }) + } + /> + + + + setInputs({ + ...inputs, + 'oidc_quota_reset.amount': String(value), + }) + } + /> + + + + + + + + + + + + +