收口 Makelore 客户端变更
This commit is contained in:
1 parent
253bad8b40
commit
f4113a872f
232 files changed
+4617
-20121
No files matched your search
@@ -7,6 +7,31 @@ import { useAuthStore } from '@/stores/auth';
|
||||
import { useProviderStore } from '@/stores/providers';
|
||||
import logoSvg from '@/assets/logo.svg';
|
||||
|
||||
const LOGIN_SERVICE_ERROR_MESSAGE = '登录服务暂时不可用,请稍后重试。';
|
||||
const LOGIN_ERROR_MESSAGE = '登录失败,请稍后重试。';
|
||||
|
||||
function getLoginErrorMessage(error: string | null): string | null {
|
||||
const message = error?.trim();
|
||||
if (!message) return null;
|
||||
|
||||
const normalized = message.toLowerCase();
|
||||
if (
|
||||
message.length > 180
|
||||
|| /<!doctype\b|<html\b|<head\b|<body\b/i.test(message)
|
||||
|| /\b50[234]\b/.test(normalized)
|
||||
|| normalized.includes('bad gateway')
|
||||
|| normalized.includes('service unavailable')
|
||||
) {
|
||||
return LOGIN_SERVICE_ERROR_MESSAGE;
|
||||
}
|
||||
|
||||
if (normalized.includes('timeout') || normalized.includes('timed out') || message.includes('超时')) {
|
||||
return '登录超时,请稍后重试。';
|
||||
}
|
||||
|
||||
return /[\u3400-\u9fff]/.test(message) ? message : LOGIN_ERROR_MESSAGE;
|
||||
}
|
||||
|
||||
export function Login() {
|
||||
const navigate = useNavigate();
|
||||
const loginWithBrowser = useAuthStore((state) => state.loginWithBrowser);
|
||||
@@ -17,6 +42,7 @@ export function Login() {
|
||||
const importUserModelConfig = useProviderStore((state) => state.importUserModelConfig);
|
||||
const [submitError, setSubmitError] = useState<string | null>(null);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const displayError = getLoginErrorMessage(submitError || error);
|
||||
|
||||
useEffect(() => {
|
||||
if (isAuthenticated() && !submitting) {
|
||||
@@ -55,18 +81,18 @@ export function Login() {
|
||||
<img src={logoSvg} alt="Makelore" className="h-9 w-12 shrink-0 object-contain" />
|
||||
<div className="min-w-0">
|
||||
<CardTitle className="text-xl tracking-normal">Makelore</CardTitle>
|
||||
<p className="text-sm text-muted-foreground">Sign in to your Makelore account</p>
|
||||
<p className="text-sm text-muted-foreground">登录 Makelore 账户</p>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<p className="text-sm leading-6 text-muted-foreground">
|
||||
Continue in your browser to sign in and approve access for this desktop app.
|
||||
请在浏览器中完成登录,并授权此桌面应用访问。
|
||||
</p>
|
||||
|
||||
{(submitError || error) && (
|
||||
<div className="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">
|
||||
{submitError || error}
|
||||
{displayError && (
|
||||
<div role="alert" className="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">
|
||||
{displayError}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -76,12 +102,12 @@ export function Login() {
|
||||
) : (
|
||||
<ExternalLink className="mr-2 h-4 w-4" />
|
||||
)}
|
||||
Continue in browser
|
||||
在浏览器中继续
|
||||
</Button>
|
||||
|
||||
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<LogIn className="h-3.5 w-3.5" />
|
||||
Your password stays on the secure sign-in page and is never entered into this app.
|
||||
你的密码会留在安全的登录页面中,不会输入到此应用。
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
Reference in new issue
Block a user