feat: 调整预先检查的代码
This commit is contained in:
parent
c252294dd7
commit
d04e00fc2c
@ -1,4 +1,3 @@
|
|||||||
import { c as _c } from "react/compiler-runtime";
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { logEvent } from 'src/services/analytics/index.js';
|
import { logEvent } from 'src/services/analytics/index.js';
|
||||||
@ -75,76 +74,61 @@ async function checkEndpoints(): Promise<PreflightCheckResult> {
|
|||||||
interface PreflightStepProps {
|
interface PreflightStepProps {
|
||||||
onSuccess: () => void;
|
onSuccess: () => void;
|
||||||
}
|
}
|
||||||
export function PreflightStep(t0) {
|
export function PreflightStep({ onSuccess }: PreflightStepProps) {
|
||||||
const $ = _c(12);
|
const [result, setResult] = useState<PreflightCheckResult | null>(null);
|
||||||
const {
|
|
||||||
onSuccess
|
|
||||||
} = t0;
|
|
||||||
const [result, setResult] = useState(null);
|
|
||||||
const [isChecking, setIsChecking] = useState(true);
|
const [isChecking, setIsChecking] = useState(true);
|
||||||
const showSpinner = useTimeout(1000) && isChecking;
|
const showSpinner = useTimeout(1000) && isChecking;
|
||||||
let t1;
|
|
||||||
let t2;
|
useEffect(() => {
|
||||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
checkEndpoints().then((checkResult) => {
|
||||||
t1 = () => {
|
setResult(checkResult);
|
||||||
const run = async function run() {
|
setIsChecking(false);
|
||||||
const checkResult = await checkEndpoints();
|
});
|
||||||
setResult(checkResult);
|
}, []);
|
||||||
setIsChecking(false);
|
|
||||||
};
|
useEffect(() => {
|
||||||
run();
|
if (result?.success) {
|
||||||
};
|
onSuccess();
|
||||||
t2 = [];
|
} else if (result && !result.success) {
|
||||||
$[0] = t1;
|
logError(result.error ?? 'Preflight connectivity check failed');
|
||||||
$[1] = t2;
|
onSuccess();
|
||||||
} else {
|
}
|
||||||
t1 = $[0];
|
}, [result, onSuccess]);
|
||||||
t2 = $[1];
|
|
||||||
|
let content = null;
|
||||||
|
if (isChecking && showSpinner) {
|
||||||
|
content = (
|
||||||
|
<Box paddingLeft={1}>
|
||||||
|
<Spinner />
|
||||||
|
<Text>Checking connectivity...</Text>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
} else if (!result?.success && !isChecking) {
|
||||||
|
content = (
|
||||||
|
<Box flexDirection="column" gap={1}>
|
||||||
|
<Text color="error">Unable to connect to Anthropic services</Text>
|
||||||
|
<Text color="error">{result?.error}</Text>
|
||||||
|
{result?.sslHint ? (
|
||||||
|
<Box flexDirection="column" gap={1}>
|
||||||
|
<Text>{result.sslHint}</Text>
|
||||||
|
<Text color="suggestion">See https://code.claude.com/docs/en/network-config</Text>
|
||||||
|
</Box>
|
||||||
|
) : (
|
||||||
|
<Box flexDirection="column" gap={1}>
|
||||||
|
<Text>Please check your internet connection and network settings.</Text>
|
||||||
|
<Text>
|
||||||
|
Note: Claude Code might not be available in your country. Check supported countries at{" "}
|
||||||
|
<Text color="suggestion">https://anthropic.com/supported-countries</Text>
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
useEffect(t1, t2);
|
|
||||||
let t3;
|
return (
|
||||||
let t4;
|
<Box flexDirection="column" gap={1} paddingLeft={1}>
|
||||||
if ($[2] !== onSuccess || $[3] !== result) {
|
{content}
|
||||||
t3 = () => {
|
</Box>
|
||||||
if (result?.success) {
|
);
|
||||||
onSuccess();
|
|
||||||
} else {
|
|
||||||
if (result && !result.success) {
|
|
||||||
const timer = setTimeout(_temp, 100);
|
|
||||||
return () => clearTimeout(timer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
t4 = [result, onSuccess];
|
|
||||||
$[2] = onSuccess;
|
|
||||||
$[3] = result;
|
|
||||||
$[4] = t3;
|
|
||||||
$[5] = t4;
|
|
||||||
} else {
|
|
||||||
t3 = $[4];
|
|
||||||
t4 = $[5];
|
|
||||||
}
|
|
||||||
useEffect(t3, t4);
|
|
||||||
let t5;
|
|
||||||
if ($[6] !== isChecking || $[7] !== result || $[8] !== showSpinner) {
|
|
||||||
t5 = isChecking && showSpinner ? <Box paddingLeft={1}><Spinner /><Text>Checking connectivity...</Text></Box> : !result?.success && !isChecking && <Box flexDirection="column" gap={1}><Text color="error">Unable to connect to Anthropic services</Text><Text color="error">{result?.error}</Text>{result?.sslHint ? <Box flexDirection="column" gap={1}><Text>{result.sslHint}</Text><Text color="suggestion">See https://code.claude.com/docs/en/network-config</Text></Box> : <Box flexDirection="column" gap={1}><Text>Please check your internet connection and network settings.</Text><Text>Note: Claude Code might not be available in your country. Check supported countries at{" "}<Text color="suggestion">https://anthropic.com/supported-countries</Text></Text></Box>}</Box>;
|
|
||||||
$[6] = isChecking;
|
|
||||||
$[7] = result;
|
|
||||||
$[8] = showSpinner;
|
|
||||||
$[9] = t5;
|
|
||||||
} else {
|
|
||||||
t5 = $[9];
|
|
||||||
}
|
|
||||||
let t6;
|
|
||||||
if ($[10] !== t5) {
|
|
||||||
t6 = <Box flexDirection="column" gap={1} paddingLeft={1}>{t5}</Box>;
|
|
||||||
$[10] = t5;
|
|
||||||
$[11] = t6;
|
|
||||||
} else {
|
|
||||||
t6 = $[11];
|
|
||||||
}
|
|
||||||
return t6;
|
|
||||||
}
|
|
||||||
function _temp() {
|
|
||||||
return process.exit(1);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user