文档归位:雪猫 README 门面 + 公告/制作文档/发布工具并入仓库根
Release Tag / validate-version (push) Waiting to run

This commit is contained in:
天天的鸟蛋蛋 committed 2026-11-12 06:29:38 +08:00
1 parent b9655a5ab1
commit e292824161
122 files changed
+90002 -69

No files matched your search

@@ -0,0 +1 @@
import{r as c,j as t}from"./react-vendor-jWT2yUdV.js";import{L as w,k as F,aI as I,O as P,Q as $,R as A,b as v,S as B,T as G,c as H}from"./index-DiaaLdUu.js";import{c as M}from"./chunk-NAV3ZXLI-ChbUTMf0.js";import{t as J}from"./chunk-6LIX6LVT-B246pOuK.js";import{d as O,k as q,c as Q}from"./index-DvErMbt6.js";class z{static async getMirrorList(){const{data:s}=await w.get("/Mirror/List");return s.data}static async setCustomMirror(s){await w.post("/Mirror/SetCustom",{mirror:s})}static async testSingleMirror(s,r="file"){const{data:o}=await w.post("/Mirror/Test",{mirror:s,type:r});return o.data}static testMirrorsSSE(s="file",r){const o=localStorage.getItem(F.token);if(!o)throw new Error("未登录");const u=JSON.parse(o),a=new I.EventSourcePolyfill(`/api/Mirror/Test/SSE?type=${s}`,{headers:{Authorization:`Bearer ${u}`,Accept:"text/event-stream"},withCredentials:!0});return a.onmessage=d=>{var l,m,h,x,f;try{const i=JSON.parse(d.data);switch(i.type){case"start":(l=r.onStart)==null||l.call(r,i);break;case"testing":(m=r.onTesting)==null||m.call(r,i);break;case"result":(h=r.onResult)==null||h.call(r,i);break;case"complete":(x=r.onComplete)==null||x.call(r,i),a.close();break;case"error":(f=r.onError)==null||f.call(r,i.error),a.close();break}}catch(i){console.error("Failed to parse SSE message:",i)}},a.onerror=d=>{var l;console.error("SSE连接出错:",d),(l=r.onError)==null||l.call(r,"连接中断"),a.close()},a}}function Y({isOpen:n,onClose:s,onSelect:r,currentMirror:o,type:u="file"}){const[a,d]=c.useState([]),[l,m]=c.useState(o||"auto"),[h,x]=c.useState(new Map),[f,i]=c.useState(!1),[C,S]=c.useState(0),[T,p]=c.useState(""),[N,E]=c.useState(null);c.useEffect(()=>{n&&R()},[n]);const R=async()=>{try{const e=await z.getMirrorList(),g=u==="raw"?e.rawMirrors:e.fileMirrors;d(g),e.customMirror&&m(e.customMirror)}catch(e){console.error("Failed to load mirrors:",e)}},L=()=>{i(!0),S(0),x(new Map),E(null),p("准备测速..."),z.testMirrorsSSE(u,{onStart:e=>{p(e.message)},onTesting:e=>{S(e.index/e.total*100),p(e.message)},onResult:e=>{x(g=>{const j=new Map(g);return j.set(e.result.mirror,e.result),j}),S((e.index+1)/e.total*100)},onComplete:e=>{i(!1),S(100),p(e.message),e.fastest&&E(e.fastest.mirror)},onError:e=>{i(!1),p(`测速失败: ${e}`)}})},b=()=>{r(l==="auto"?void 0:l),s()};return t.jsx(P,{isOpen:n,onClose:s,size:"2xl",scrollBehavior:"inside",classNames:{backdrop:"z-[200]",wrapper:"z-[200]"},children:t.jsxs($,{className:"rounded-3xl border border-white/70 dark:border-white/10 bg-white/92 dark:bg-zinc-900/92 backdrop-blur-2xl shadow-2xl shadow-primary-900/15",children:[t.jsxs(A,{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center justify-between pr-8",children:[t.jsx("span",{children:"选择镜像源"}),t.jsx(v,{size:"sm",color:"primary",variant:"flat",startContent:!f&&t.jsx(O,{}),onPress:L,isLoading:f,children:f?"测速中...":"一键测速"})]}),f&&t.jsxs("div",{className:"mt-2",children:[t.jsx("div",{className:"w-full bg-default-200 rounded-full h-2",children:t.jsx("div",{className:"bg-primary h-2 rounded-full transition-all duration-300",style:{width:`${C}%`}})}),t.jsx("p",{className:"text-xs text-default-500 mt-1",children:T})]})]}),t.jsx(B,{children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(y,{value:"auto",label:"自动选择",description:"系统自动选择最快的镜像源",isSelected:l==="auto",onSelect:()=>m("auto"),badge:t.jsx(M,{size:"sm",color:"primary",variant:"flat",children:"推荐"})}),t.jsx(y,{value:"https://github.com",label:"GitHub 原始",description:"直连 GitHub(可能较慢)",isSelected:l==="https://github.com",onSelect:()=>m("https://github.com"),testResult:h.get("https://github.com (原始)"),isFastest:N==="https://github.com (原始)"}),a.map(e=>{if(!e)return null;const g=h.get(e),j=N===e;let _=e;try{_=new URL(e).hostname}catch{}return t.jsx(y,{value:e,label:_,description:e,isSelected:l===e,onSelect:()=>m(e),testResult:g,isFastest:j},e)})]})}),t.jsxs(G,{children:[t.jsx(v,{variant:"light",onPress:s,children:"取消"}),t.jsx(v,{color:"primary",onPress:b,children:"确认选择"})]})]})})}function y({label:n,description:s,isSelected:r,onSelect:o,testResult:u,isFastest:a,badge:d}){return t.jsxs("div",{className:H("flex items-center justify-between p-3 rounded-lg cursor-pointer transition-all","bg-content1 hover:bg-content2 border-2",r?"border-primary":"border-transparent",a&&"ring-2 ring-success"),onClick:o,children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium",children:n}),t.jsx("p",{className:"text-xs text-default-500 truncate",children:s})]}),t.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[d,a&&!d&&t.jsx(M,{size:"sm",color:"success",variant:"flat",children:"最快"}),u&&t.jsx(U,{result:u})]})]})}function U({result:n}){const s=o=>o>=5e3?">5s":o>=1e3?`${(o/1e3).toFixed(1)}s`:`${o}ms`;if(!n.success)return t.jsx(J,{content:n.error||"连接失败",children:t.jsx(M,{size:"sm",color:"dangerLine truncated