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: 0 additions & 2 deletions src/components/DownloadSection/constant-en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export interface DownloadContent {
intelDownloadText: string;
appleDownloadUrl: string;
appleDownloadText: string;
macSecurityUrl: string;
};
};
server: {
Expand Down Expand Up @@ -70,7 +69,6 @@ const CONTENT: DownloadContent = {
intelDownloadText: "for Intel processor",
appleDownloadUrl: "https://apk.jit.pro/latest/darwin/arm/JitAI-installer-apple.dmg",
appleDownloadText: "for Apple silicon",
macSecurityUrl: "/download/mac-security",
},
},

Expand Down
2 changes: 0 additions & 2 deletions src/components/DownloadSection/constant-zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export interface DownloadContent {
intelDownloadText: string;
appleDownloadUrl: string;
appleDownloadText: string;
macSecurityUrl: string;
};
};
server: {
Expand Down Expand Up @@ -67,7 +66,6 @@ const CONTENT: DownloadContent = {
intelDownloadText: "Intel芯片安装包",
appleDownloadUrl: "https://apk.jit.pro/latest/darwin/arm/JitAI-installer-apple.dmg",
appleDownloadText: "Apple芯片安装包",
macSecurityUrl: "/zh/download/mac-security",
},
},

Expand Down
23 changes: 14 additions & 9 deletions src/components/DownloadSection/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect } from 'react';
import styles from './styles.module.css';
import globalStyles from '../../pages/index.module.css';
import CONTENT_EN from './constant-en';
import CONTENT_ZH from './constant-zh';

Expand Down Expand Up @@ -41,12 +40,15 @@ const DownloadSection: React.FC<DownloadSectionProps> = ({ currentLocale }) => {
};

const handleMacDownload = (url: string) => {
// 先打开安全提示页面
window.open(url);
// 延迟打开下载链接,避免浏览器拦截
const iframe = document.createElement("iframe");
iframe.src = url;
iframe.style.display = "none";
iframe.setAttribute("aria-hidden", "true");
document.body.appendChild(iframe);

setTimeout(() => {
window.location.href = CONTENT.desktop.mac.macSecurityUrl;
}, 100);
iframe.remove();
}, 30000);
};

const renderMobileContent = () => (
Expand Down Expand Up @@ -96,13 +98,15 @@ const DownloadSection: React.FC<DownloadSectionProps> = ({ currentLocale }) => {
<h2 className={styles.versionTitle}>{CONTENT.desktop.mac.title}</h2>
<p className={styles.versionDescription}>{CONTENT.desktop.mac.description}</p>
<div className={styles.downloadActions}>
<button
<button
type="button"
onClick={() => handleMacDownload(CONTENT.desktop.mac.appleDownloadUrl)}
className={`${styles.downloadButton} ${'analytics-downloadMac' + (isMobile ? '-mobile' : '')} ${'analytics-downloadMacApple' + (isMobile ? '-mobile' : '')}`}
>
{CONTENT.desktop.mac.appleDownloadText}
</button>
<button
<button
type="button"
onClick={() => handleMacDownload(CONTENT.desktop.mac.intelDownloadUrl)}
className={`${styles.downloadButtonSecondary} ${'analytics-downloadMac' + (isMobile ? '-mobile' : '')} ${'analytics-downloadMacIntel' + (isMobile ? '-mobile' : '')}`}
>
Expand Down Expand Up @@ -140,6 +144,7 @@ const DownloadSection: React.FC<DownloadSectionProps> = ({ currentLocale }) => {
{/* 复制按钮 - 位于代码块外面右下角 */}
<div className={styles.codeActions}>
<button
type="button"
className={`${styles.copyButton} ${'analytics-copyDocker' + (isMobile ? '-mobile' : '')}`}
onClick={handleCopy}
>
Expand All @@ -155,7 +160,7 @@ const DownloadSection: React.FC<DownloadSectionProps> = ({ currentLocale }) => {
return (
<section id="download-section" className={`${styles.download}`}>
{isMobile && renderMobileContent()}
<div className={`${globalStyles.sectionContent} ${styles.sectionContent}`}>
<div className={styles.sectionContent}>
{/* 页面标题 */}
<div className={`${styles.pageHeader}`}>
<h1 className={styles.pageTitle}>{CONTENT.title}</h1>
Expand Down
Loading
Loading