mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-03 03:10:50 +08:00
Added hostname checking function. If it is not localhost or 127.0.0.1, the OAuth login box will be hidden to improve user experience; Added unique IDs to each OAuth card for easier operation.
This commit is contained in:
41
app.js
41
app.js
@@ -109,6 +109,47 @@ class CLIProxyManager {
|
|||||||
this.setupThemeSwitcher();
|
this.setupThemeSwitcher();
|
||||||
// loadSettings 将在登录成功后调用
|
// loadSettings 将在登录成功后调用
|
||||||
this.updateLoginConnectionInfo();
|
this.updateLoginConnectionInfo();
|
||||||
|
// 检查主机名,如果不是 localhost 或 127.0.0.1,则隐藏 OAuth 登录框
|
||||||
|
this.checkHostAndHideOAuth();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查主机名并隐藏 OAuth 登录框
|
||||||
|
checkHostAndHideOAuth() {
|
||||||
|
const hostname = window.location.hostname;
|
||||||
|
const isLocalhost = hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '::1';
|
||||||
|
|
||||||
|
if (!isLocalhost) {
|
||||||
|
// 隐藏所有 OAuth 登录卡片
|
||||||
|
const oauthCards = [
|
||||||
|
'codex-oauth-card',
|
||||||
|
'anthropic-oauth-card',
|
||||||
|
'gemini-cli-oauth-card',
|
||||||
|
'qwen-oauth-card',
|
||||||
|
'iflow-oauth-card'
|
||||||
|
];
|
||||||
|
|
||||||
|
oauthCards.forEach(cardId => {
|
||||||
|
const card = document.getElementById(cardId);
|
||||||
|
if (card) {
|
||||||
|
card.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 如果找不到具体的卡片 ID,尝试通过类名查找
|
||||||
|
const oauthCardElements = document.querySelectorAll('.card');
|
||||||
|
oauthCardElements.forEach(card => {
|
||||||
|
const cardText = card.textContent || '';
|
||||||
|
if (cardText.includes('Codex OAuth') ||
|
||||||
|
cardText.includes('Anthropic OAuth') ||
|
||||||
|
cardText.includes('Gemini CLI OAuth') ||
|
||||||
|
cardText.includes('Qwen OAuth') ||
|
||||||
|
cardText.includes('iFlow OAuth')) {
|
||||||
|
card.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`当前主机名: ${hostname},已隐藏 OAuth 登录框`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查登录状态
|
// 检查登录状态
|
||||||
|
|||||||
10
index.html
10
index.html
@@ -434,7 +434,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Codex OAuth -->
|
<!-- Codex OAuth -->
|
||||||
<div class="card">
|
<div class="card" id="codex-oauth-card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3><i class="fas fa-code"></i> <span data-i18n="auth_login.codex_oauth_title">Codex
|
<h3><i class="fas fa-code"></i> <span data-i18n="auth_login.codex_oauth_title">Codex
|
||||||
OAuth</span></h3>
|
OAuth</span></h3>
|
||||||
@@ -469,7 +469,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Anthropic OAuth -->
|
<!-- Anthropic OAuth -->
|
||||||
<div class="card">
|
<div class="card" id="anthropic-oauth-card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3><i class="fas fa-brain"></i> <span
|
<h3><i class="fas fa-brain"></i> <span
|
||||||
data-i18n="auth_login.anthropic_oauth_title">Anthropic OAuth</span></h3>
|
data-i18n="auth_login.anthropic_oauth_title">Anthropic OAuth</span></h3>
|
||||||
@@ -505,7 +505,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Gemini CLI OAuth -->
|
<!-- Gemini CLI OAuth -->
|
||||||
<div class="card">
|
<div class="card" id="gemini-cli-oauth-card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3><i class="fab fa-google"></i> <span
|
<h3><i class="fab fa-google"></i> <span
|
||||||
data-i18n="auth_login.gemini_cli_oauth_title">Gemini CLI OAuth</span></h3>
|
data-i18n="auth_login.gemini_cli_oauth_title">Gemini CLI OAuth</span></h3>
|
||||||
@@ -552,7 +552,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Qwen OAuth -->
|
<!-- Qwen OAuth -->
|
||||||
<div class="card">
|
<div class="card" id="qwen-oauth-card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3><i class="fas fa-robot"></i> <span data-i18n="auth_login.qwen_oauth_title">Qwen
|
<h3><i class="fas fa-robot"></i> <span data-i18n="auth_login.qwen_oauth_title">Qwen
|
||||||
OAuth</span></h3>
|
OAuth</span></h3>
|
||||||
@@ -587,7 +587,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- iFlow OAuth -->
|
<!-- iFlow OAuth -->
|
||||||
<div class="card">
|
<div class="card" id="iflow-oauth-card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3><i class="fas fa-stream"></i> <span
|
<h3><i class="fas fa-stream"></i> <span
|
||||||
data-i18n="auth_login.iflow_oauth_title">iFlow OAuth</span></h3>
|
data-i18n="auth_login.iflow_oauth_title">iFlow OAuth</span></h3>
|
||||||
|
|||||||
Reference in New Issue
Block a user