/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
For commercial licensing, please contact support@quantumnous.com
*/
// WeyAi 桌面端下载页(方案 4.8)。两种挂载方式,同一个组件:
// - /weyai/download 独立公开路由,不需要登录,自带顶部让位与页面背景;
// - /user-center/weyai-download 嵌在用户中心里(embedded),侧栏保留、背景由 shell 提供。
// 结构:hero(版本/动作)→ 为你推荐 → 客户端能做什么 → 全部安装包 → 三步开始。
// 加载失败 / 未开放 / 暂无安装包三种状态都保留 hero 与说明区,只替换安装包区域。
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
import {
Download as ActionDownload,
RefreshCw as ActionRefreshCw,
Globe as ActionGlobe,
ExternalLink as ActionExternalLink,
} from '@/components/common/icons/ActionIcons';
import React, { useContext, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Button, Skeleton, Tag } from '@/components/ui';
import {
AlertTriangle,
Cpu,
Laptop,
LogIn,
Monitor,
MonitorDown,
Package,
RefreshCw,
Smartphone,
Terminal,
Wallet,
} from 'lucide-react';
import { API } from '../../helpers/api';
import { StatusContext } from '../../context/Status';
import { UserContext } from '../../context/User';
import PageBackground from '../../components/common/PageBackground';
import UserCenterBreadcrumb from '../../components/common/UserCenterBreadcrumb';
import { useWeyAiWebEntry } from '../../hooks/common/useWeyAiWebEntry';
import {
PLATFORMS,
detectClient,
formatSize,
groupByPlatform,
normalizeRelease,
pickRecommended,
} from './release';
import './weyai-download.css';
// 不带动作只唤起应用(navigate 动作要求目标路由在桌面端白名单里)
const OPEN_APP_URL = 'weyai://';
const ALL_PACKAGES_ID = 'weyai-download-all';
// 更新源清单里的 releaseDate 是 ISO 时间串(2026-09-20T08:00:00.000Z),
// 展示只需要日期。固定用 ISO 日期(UTC):按语种本地化会让泰语走佛历、
// 让 UTC-9 以西的访客看到前一天;解析不了的原样返回,绝不因此把 hero 弄空
function formatReleaseDate(value) {
if (!value) return '';
const date = new Date(value);
if (Number.isNaN(date.getTime())) return value;
return date.toISOString().slice(0, 10);
}
const PLATFORM_LABEL = { windows: 'Windows', mac: 'macOS', linux: 'Linux' };
const PLATFORM_ICON = { windows: Monitor, mac: Laptop, linux: Terminal };
function PlatformIcon({ platform, size = 18 }) {
const Icon = PLATFORM_ICON[platform] || MonitorDown;
return ;
}
// 状态卡:加载失败 / 未开放 / 暂无安装包共用一个壳
function StateCard({ icon, title, desc, danger, actions }) {
return (