Skip to content

Commit 97996bc

Browse files
committed
fix
1 parent 45b0edf commit 97996bc

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

src/components/download-form-next/DownloadFormNext.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ export default function DownloadFormNext(): JSX.Element {
4242
const changeCPU = (val: string) => {
4343
setCPU(val);
4444
const nextDownloadInfo = cpus.find(item => item.value === val);
45+
if (!nextDownloadInfo || typeof nextDownloadInfo.gz !== 'string') {
46+
setDownloadInfo({});
47+
return;
48+
}
4549
const filename = nextDownloadInfo.gz.split(ORIGIN)[1];
4650
nextDownloadInfo.filename = filename;
4751
setDownloadInfo(nextDownloadInfo);
@@ -97,9 +101,19 @@ export default function DownloadFormNext(): JSX.Element {
97101

98102
useEffect(() => {
99103
const currentVersion = DORIS_VERSIONS.find(doris_version => doris_version.value === version);
104+
if (!currentVersion || !Array.isArray(currentVersion.children)) {
105+
setCpus([]);
106+
setCPU(CPUEnum.X64);
107+
setDownloadInfo({});
108+
return;
109+
}
100110
setCpus(currentVersion.children);
101111
setCPU(CPUEnum.X64);
102112
const nextDownloadInfo: any = currentVersion.children.find(item => item.value === CPUEnum.X64);
113+
if (!nextDownloadInfo || typeof nextDownloadInfo.gz !== 'string') {
114+
setDownloadInfo({});
115+
return;
116+
}
103117
const filename = nextDownloadInfo.gz.split(ORIGIN)[1];
104118
nextDownloadInfo.filename = filename;
105119
setDownloadInfo(nextDownloadInfo);
@@ -385,7 +399,7 @@ export default function DownloadFormNext(): JSX.Element {
385399
<ul className="mt-10 grid gap-x-6 gap-y-3 lg:grid-cols-3 lg:gap-y-0">
386400
{RUN_ANYWHERE.map(item => (
387401
<div
388-
onClick={() => window.open(item.link)}
402+
onClick={() => window.open(item.link, '_blank', 'noopener,noreferrer')}
389403
key={item.title}
390404
className="run-anywhere-card relative bg-white flex cursor-pointer flex-col items-center justify-center overflow-hidden rounded-lg border-b-4 border-b-primary py-[2rem] px-4 lg:px-[1.5rem] shadow-[inset_0_0_0_1px_#11A679] hover:no-underline"
391405
>

src/components/home-next/LayoutNext.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ export function LayoutNext({ title, description, onSwitchBack, children }: Layou
5151
return;
5252
}
5353
if (typeof window !== 'undefined') {
54-
window.localStorage.removeItem('doris-home-version');
54+
try {
55+
window.localStorage.removeItem('doris-home-version');
56+
} catch {
57+
// localStorage may be unavailable (private mode / disabled cookies)
58+
}
5559
window.location.assign('/');
5660
}
5761
}}

src/components/home-next/NavbarNext.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ const GITHUB_REPO = 'apache/doris';
1010
const FALLBACK_STARS = '-';
1111
const HOME_VERSION_KEY = 'doris-home-version';
1212

13+
function safeSetLocalStorage(key: string, value: string): void {
14+
try {
15+
window.localStorage.setItem(key, value);
16+
} catch {
17+
// localStorage may be unavailable (Safari private mode, disabled cookies, quota errors)
18+
}
19+
}
20+
1321
function formatStars(n: number): string {
1422
if (n >= 1000) return `${(n / 1000).toFixed(1)}k`;
1523
return String(n);
@@ -175,7 +183,7 @@ export function NavbarNext(): JSX.Element {
175183
className="navbar-next__logo"
176184
aria-label="Apache Doris"
177185
onClick={() => {
178-
window.localStorage.setItem(HOME_VERSION_KEY, 'next');
186+
safeSetLocalStorage(HOME_VERSION_KEY, 'next');
179187
}}
180188
>
181189
<img src="/images/logo-doris.svg" alt="Apache Doris" />

0 commit comments

Comments
 (0)