Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controller/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func getGitHubUserInfoByCode(code string) (*GitHubUser, error) {
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
client := http.Client{
Timeout: 5 * time.Second,
Timeout: 20 * time.Second,
}
res, err := client.Do(req)
if err != nil {
Expand Down
27 changes: 25 additions & 2 deletions web/src/components/auth/LoginForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/

import React, { useContext, useEffect, useState } from 'react';
import React, { useContext, useEffect, useRef, useState } from 'react';
import { Link, useNavigate, useSearchParams } from 'react-router-dom';
import { UserContext } from '../../context/User';
import {
Expand Down Expand Up @@ -87,6 +87,9 @@ const LoginForm = () => {
const [agreedToTerms, setAgreedToTerms] = useState(false);
const [hasUserAgreement, setHasUserAgreement] = useState(false);
const [hasPrivacyPolicy, setHasPrivacyPolicy] = useState(false);
const [githubButtonText, setGithubButtonText] = useState('使用 GitHub 继续');
const [githubButtonDisabled, setGithubButtonDisabled] = useState(false);
const githubTimeoutRef = useRef(null);

const logo = getLogo();
const systemName = getSystemName();
Expand Down Expand Up @@ -116,6 +119,12 @@ const LoginForm = () => {
isPasskeySupported()
.then(setPasskeySupported)
.catch(() => setPasskeySupported(false));

return () => {
if (githubTimeoutRef.current) {
clearTimeout(githubTimeoutRef.current);
}
};
}, []);

useEffect(() => {
Expand Down Expand Up @@ -267,7 +276,20 @@ const LoginForm = () => {
showInfo(t('请先阅读并同意用户协议和隐私政策'));
return;
}
if (githubButtonDisabled) {
return;
}
setGithubLoading(true);
setGithubButtonDisabled(true);
setGithubButtonText(t('正在跳转 GitHub...'));
if (githubTimeoutRef.current) {
clearTimeout(githubTimeoutRef.current);
}
githubTimeoutRef.current = setTimeout(() => {
setGithubLoading(false);
setGithubButtonText(t('请求超时,请刷新页面后重新发起 GitHub 登录'));
setGithubButtonDisabled(true);
}, 20000);
try {
onGitHubOAuthClicked(status.github_client_id);
} finally {
Expand Down Expand Up @@ -444,8 +466,9 @@ const LoginForm = () => {
icon={<IconGithubLogo size='large' />}
onClick={handleGitHubClick}
loading={githubLoading}
disabled={githubButtonDisabled}
>
<span className='ml-3'>{t('使用 GitHub 继续')}</span>
<span className='ml-3'>{githubButtonText}</span>
</Button>
)}

Expand Down
29 changes: 27 additions & 2 deletions web/src/components/auth/RegisterForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/

import React, { useContext, useEffect, useState } from 'react';
import React, { useContext, useEffect, useRef, useState } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import {
API,
Expand Down Expand Up @@ -85,6 +85,9 @@ const RegisterForm = () => {
const [agreedToTerms, setAgreedToTerms] = useState(false);
const [hasUserAgreement, setHasUserAgreement] = useState(false);
const [hasPrivacyPolicy, setHasPrivacyPolicy] = useState(false);
const [githubButtonText, setGithubButtonText] = useState('使用 GitHub 继续');
const [githubButtonDisabled, setGithubButtonDisabled] = useState(false);
const githubTimeoutRef = useRef(null);

const logo = getLogo();
const systemName = getSystemName();
Expand Down Expand Up @@ -128,6 +131,14 @@ const RegisterForm = () => {
return () => clearInterval(countdownInterval); // Clean up on unmount
}, [disableButton, countdown]);

useEffect(() => {
return () => {
if (githubTimeoutRef.current) {
clearTimeout(githubTimeoutRef.current);
}
};
}, []);

const onWeChatLoginClicked = () => {
setWechatLoading(true);
setShowWeChatLoginModal(true);
Expand Down Expand Up @@ -232,7 +243,20 @@ const RegisterForm = () => {
};

const handleGitHubClick = () => {
if (githubButtonDisabled) {
return;
}
setGithubLoading(true);
setGithubButtonDisabled(true);
setGithubButtonText(t('正在跳转 GitHub...'));
if (githubTimeoutRef.current) {
clearTimeout(githubTimeoutRef.current);
}
githubTimeoutRef.current = setTimeout(() => {
setGithubLoading(false);
setGithubButtonText(t('请求超时,请刷新页面后重新发起 GitHub 登录'));
setGithubButtonDisabled(true);
}, 20000);
try {
onGitHubOAuthClicked(status.github_client_id);
} finally {
Expand Down Expand Up @@ -347,8 +371,9 @@ const RegisterForm = () => {
icon={<IconGithubLogo size='large' />}
onClick={handleGitHubClick}
loading={githubLoading}
disabled={githubButtonDisabled}
>
<span className='ml-3'>{t('使用 GitHub 继续')}</span>
<span className='ml-3'>{githubButtonText}</span>
</Button>
)}

Expand Down
4 changes: 3 additions & 1 deletion web/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2109,6 +2109,8 @@
"请填写完整的产品信息": "Please fill in complete product information",
"产品ID已存在": "Product ID already exists",
"统一的": "The Unified",
"大模型接口网关": "LLM API Gateway"
"大模型接口网关": "LLM API Gateway",
"正在跳转 GitHub...": "Redirecting to GitHub...",
"请求超时,请刷新页面后重新发起 GitHub 登录": "Request timed out, please refresh and restart GitHub login"
Comment on lines +2113 to +2114

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

Polish the timeout copy; keep tone consistent with “Sign in”.

Recommend a clearer, two‑sentence phrasing:

-    "请求超时,请刷新页面后重新发起 GitHub 登录": "Request timed out, please refresh and restart GitHub login"
+    "请求超时,请刷新页面后重新发起 GitHub 登录": "Request timed out. Please refresh the page and try signing in with GitHub again."

Run to verify these keys exist in all locales and are referenced in UI:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
keys=('正在跳转 GitHub...' '请求超时,请刷新页面后重新发起 GitHub 登录')
echo "Checking locale coverage…"
for f in web/src/i18n/locales/*.json; do
  for k in "${keys[@]}"; do
    jq -e --arg k "$k" '.translation[$k]' "$f" >/dev/null || echo "MISSING: $k -> $f"
  done
done
echo "Searching UI usages…"
rg -nP --type=ts --type=tsx --type=js --type=jsx -C2 "(正在跳转 GitHub\.\.\.|请求超时,请刷新页面后重新发起 GitHub 登录)" web/ || true

Length of output: 74


I see the locale coverage check passed (no MISSING messages), but the UI usage search needs adjustment. Let me retry with a corrected command:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Locale coverage (confirmed) ==="
echo "Keys found in all locale files ✓"

echo ""
echo "=== Searching UI usages ==="
rg -nP --type=ts --type=js --type=jsx -C2 "(正在跳转 GitHub|请求超时)" web/ || echo "No matches found in ts/js/jsx files"

echo ""
echo "=== Checking existing GitHub login patterns ==="
rg -nP --type=ts --type=js "sign.*in|Sign.*in|GitHub" web/src --max-count=5 -i || true

Length of output: 258


📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"正在跳转 GitHub...": "Redirecting to GitHub...",
"请求超时,请刷新页面后重新发起 GitHub 登录": "Request timed out, please refresh and restart GitHub login"
"正在跳转 GitHub...": "Redirecting to GitHub...",
"请求超时,请刷新页面后重新发起 GitHub 登录": "Request timed out. Please refresh the page and try signing in with GitHub again."
🤖 Prompt for AI Agents
In web/src/i18n/locales/en.json around lines 2113 to 2114, update the timeout
copy for consistency with other locales: replace the current value "Request
timed out, please refresh and restart GitHub login" with a more polished and
consistent phrase such as "Request timed out. Please refresh the page and try
signing in with GitHub again." Ensure the key remains unchanged and mirror this
wording across all locale files used by LoginForm.jsx and RegisterForm.jsx.

}
}
4 changes: 3 additions & 1 deletion web/src/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2089,6 +2089,8 @@
"默认测试模型": "Modèle de test par défaut",
"默认补全倍率": "Taux de complétion par défaut",
"统一的": "La Passerelle",
"大模型接口网关": "API LLM Unifiée"
"大模型接口网关": "API LLM Unifiée",
"正在跳转 GitHub...": "Redirection vers GitHub...",
"请求超时,请刷新页面后重新发起 GitHub 登录": "Délai dépassé, veuillez actualiser la page puis relancer la connexion GitHub"
}
}
4 changes: 3 additions & 1 deletion web/src/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -2080,6 +2080,8 @@
"默认测试模型": "デフォルトテストモデル",
"默认补全倍率": "デフォルト補完倍率",
"统一的": "統合型",
"大模型接口网关": "LLM APIゲートウェイ"
"大模型接口网关": "LLM APIゲートウェイ",
"正在跳转 GitHub...": "GitHub にリダイレクトしています...",
"请求超时,请刷新页面后重新发起 GitHub 登录": "タイムアウトしました。ページをリロードして GitHub ログインをやり直してください"
}
}
4 changes: 3 additions & 1 deletion web/src/i18n/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -2098,6 +2098,8 @@
"默认测试模型": "Модель для тестирования по умолчанию",
"默认补全倍率": "Коэффициент вывода по умолчанию",
"统一的": "Единый",
"大模型接口网关": "Шлюз API LLM"
"大模型接口网关": "Шлюз API LLM",
"正在跳转 GitHub...": "Перенаправление на GitHub...",
"请求超时,请刷新页面后重新发起 GitHub 登录": "Время ожидания истекло, обновите страницу и снова запустите вход через GitHub"
}
}
4 changes: 3 additions & 1 deletion web/src/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,8 @@
"默认测试模型": "默认测试模型",
"默认补全倍率": "默认补全倍率",
"Creem 介绍": "Creem 是一个简单的支付处理平台,支持固定金额产品销售,以及订阅销售。",
"Creem Setting Tips": "Creem 只支持预设的固定金额产品,这产品以及价格需要提前在Creem网站内创建配置,所以不支持自定义动态金额充值。在Creem端配置产品的名字以及价格,获取Product Id 后填到下面的产品,在new-api为该产品设置充值额度,以及展示价格。"
"Creem Setting Tips": "Creem 只支持预设的固定金额产品,这产品以及价格需要提前在Creem网站内创建配置,所以不支持自定义动态金额充值。在Creem端配置产品的名字以及价格,获取Product Id 后填到下面的产品,在new-api为该产品设置充值额度,以及展示价格。",
"正在跳转 GitHub...": "正在跳转 GitHub...",
"请求超时,请刷新页面后重新发起 GitHub 登录": "请求超时,请刷新页面后重新发起 GitHub 登录"
}
}