2026-06-28 03:37:07 +08:00
|
|
|
|
import { useConfigStore } from "@/stores/configStore";
|
2026-07-26 06:42:41 +08:00
|
|
|
|
import { Slider, RadioGroup, Radio, Input } from "@heroui/react";
|
2026-08-28 02:08:12 +08:00
|
|
|
|
import { SettingCard, PageHeader, SectionTitle, fieldCls } from "@/components/setting";
|
2026-06-20 12:46:08 +08:00
|
|
|
|
|
|
|
|
|
|
const downloadSources = [
|
|
|
|
|
|
{ value: "mirror", label: "尽量使用镜像源(推荐国内用户)" },
|
|
|
|
|
|
{ value: "official", label: "优先使用官方源" },
|
|
|
|
|
|
{ value: "official-only", label: "仅使用官方源" },
|
|
|
|
|
|
];
|
|
|
|
|
|
|
2026-06-20 03:49:58 +08:00
|
|
|
|
export function DownloadSetting() {
|
2026-06-28 03:37:07 +08:00
|
|
|
|
const dl = useConfigStore((s) => s.config.download);
|
|
|
|
|
|
const setDownload = useConfigStore((s) => s.setDownload);
|
2026-06-20 12:46:08 +08:00
|
|
|
|
|
2026-06-20 03:49:58 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<div>
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<PageHeader title="下载" desc="配置游戏资源下载源、并发数与存储路径" />
|
2026-06-20 12:46:08 +08:00
|
|
|
|
|
|
|
|
|
|
<div className="space-y-6">
|
|
|
|
|
|
<div>
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<SectionTitle>下载源</SectionTitle>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
<div className="space-y-3">
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<SettingCard>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
|
<p className="text-sm font-medium text-foreground">文件下载源</p>
|
|
|
|
|
|
<p className="text-[13px] text-muted-foreground">游戏文件(jar、lib)的下载来源</p>
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<RadioGroup
|
|
|
|
|
|
value={dl.fileSource}
|
2026-08-28 02:08:12 +08:00
|
|
|
|
onChange={(v) => setDownload({ fileSource: String(v) })}
|
2026-07-26 06:42:41 +08:00
|
|
|
|
className="mt-2 space-y-2"
|
|
|
|
|
|
>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
{downloadSources.map((opt) => (
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<Radio key={opt.value} value={opt.value}>
|
|
|
|
|
|
<Radio.Content>{opt.label}</Radio.Content>
|
|
|
|
|
|
</Radio>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
))}
|
2026-07-26 06:42:41 +08:00
|
|
|
|
</RadioGroup>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
</div>
|
2026-07-26 06:42:41 +08:00
|
|
|
|
</SettingCard>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<SettingCard>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
|
<p className="text-sm font-medium text-foreground">版本列表源</p>
|
|
|
|
|
|
<p className="text-[13px] text-muted-foreground">获取可用游戏版本列表的来源</p>
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<RadioGroup
|
|
|
|
|
|
value={dl.versionSource}
|
2026-08-28 02:08:12 +08:00
|
|
|
|
onChange={(v) => setDownload({ versionSource: String(v) })}
|
2026-07-26 06:42:41 +08:00
|
|
|
|
className="mt-2 space-y-2"
|
|
|
|
|
|
>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
{downloadSources.map((opt) => (
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<Radio key={opt.value} value={opt.value}>
|
|
|
|
|
|
<Radio.Content>{opt.label}</Radio.Content>
|
|
|
|
|
|
</Radio>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
))}
|
2026-07-26 06:42:41 +08:00
|
|
|
|
</RadioGroup>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
</div>
|
2026-07-26 06:42:41 +08:00
|
|
|
|
</SettingCard>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div>
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<SectionTitle>并发控制</SectionTitle>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
<div className="space-y-3">
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<SettingCard>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<div className="flex items-center justify-between mb-1.5">
|
|
|
|
|
|
<div className="flex-1 min-w-0">
|
|
|
|
|
|
<p className="text-sm font-medium text-foreground">最大下载线程数</p>
|
|
|
|
|
|
<p className="text-[13px] text-muted-foreground mt-0.5">同时下载的文件数量,过高可能导致不稳定</p>
|
|
|
|
|
|
</div>
|
2026-06-28 03:37:07 +08:00
|
|
|
|
<span className="text-[13px] text-muted-foreground tabular-nums shrink-0 ml-4">{dl.threads}</span>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<Slider
|
2026-07-26 06:42:41 +08:00
|
|
|
|
value={dl.threads}
|
|
|
|
|
|
onChange={(v) => setDownload({ threads: typeof v === "number" ? v : v[0] })}
|
|
|
|
|
|
minValue={1}
|
|
|
|
|
|
maxValue={64}
|
2026-06-20 12:46:08 +08:00
|
|
|
|
step={1}
|
2026-07-26 06:42:41 +08:00
|
|
|
|
>
|
|
|
|
|
|
<Slider.Track>
|
|
|
|
|
|
<Slider.Fill />
|
|
|
|
|
|
<Slider.Thumb />
|
|
|
|
|
|
</Slider.Track>
|
|
|
|
|
|
</Slider>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
<div className="flex justify-between mt-1">
|
|
|
|
|
|
<span className="text-[11px] text-muted-foreground/50">1</span>
|
|
|
|
|
|
<span className="text-[11px] text-muted-foreground/50">64</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-07-26 06:42:41 +08:00
|
|
|
|
</SettingCard>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div>
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<SectionTitle>速度限制</SectionTitle>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
<div className="space-y-3">
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<SettingCard>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
|
<p className="text-sm font-medium text-foreground">下载速度上限</p>
|
|
|
|
|
|
<p className="text-[13px] text-muted-foreground">单位 KB/s,0 表示不限速</p>
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2026-07-26 06:42:41 +08:00
|
|
|
|
<Input
|
2026-06-20 12:46:08 +08:00
|
|
|
|
type="number"
|
2026-07-26 06:42:41 +08:00
|
|
|
|
value={String(dl.speedLimit)}
|
2026-06-28 03:37:07 +08:00
|
|
|
|
onChange={(e) => setDownload({ speedLimit: Number(e.target.value) })}
|
2026-08-28 02:08:12 +08:00
|
|
|
|
className={`w-28 ${fieldCls}`}
|
2026-06-20 12:46:08 +08:00
|
|
|
|
/>
|
|
|
|
|
|
<span className="text-[13px] text-muted-foreground">KB/s</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-07-26 06:42:41 +08:00
|
|
|
|
</SettingCard>
|
2026-06-20 12:46:08 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-06-20 03:49:58 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|