2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[602],{14862:(a,b,c)=>{c.d(b,{p:()=>g});var d=c(71209),e=c(22885),f=c(64455);let g=e.forwardRef(({className:a,type:b,...c},e)=>(0,d.jsx)("input",{type:b,className:(0,f.cn)("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",a),ref:e,...c}));g.displayName="Input"},18521:(a,b,c)=>{c.d(b,{E:()=>f});var d=c(71209),e=c(64455);function f({className:a,...b}){return(0,d.jsx)("div",{className:(0,e.cn)("animate-pulse rounded-md bg-primary/10",a),...b})}},27220:(a,b,c)=>{c.d(b,{Cf:()=>m,Es:()=>o,L3:()=>p,c7:()=>n,lG:()=>i,rr:()=>q,zM:()=>j});var d=c(71209),e=c(22885),f=c(29973),g=c(58549),h=c(64455);let i=f.bL,j=f.l9,k=f.ZL;f.bm;let l=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.hJ,{ref:c,className:(0,h.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...b}));l.displayName=f.hJ.displayName;let m=e.forwardRef(({className:a,children:b,...c},e)=>(0,d.jsxs)(k,{children:[(0,d.jsx)(l,{}),(0,d.jsxs)(f.UC,{ref:e,className:(0,h.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...c,children:[b,(0,d.jsxs)(f.bm,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,d.jsx)(g.A,{className:"h-4 w-4"}),(0,d.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));m.displayName=f.UC.displayName;let n=({className:a,...b})=>(0,d.jsx)("div",{className:(0,h.cn)("flex flex-col space-y-1.5 text-center sm:text-left",a),...b});n.displayName="DialogHeader";let o=({className:a,...b})=>(0,d.jsx)("div",{className:(0,h.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...b});o.displayName="DialogFooter";let p=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.hE,{ref:c,className:(0,h.cn)("text-lg font-semibold leading-none tracking-tight",a),...b}));p.displayName=f.hE.displayName;let q=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.VY,{ref:c,className:(0,h.cn)("text-sm text-muted-foreground",a),...b}));q.displayName=f.VY.displayName},32924:(a,b,c)=>{c.d(b,{d:()=>h});var d=c(71209),e=c(22885),f=c(6803),g=c(64455);let h=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.bL,{className:(0,g.cn)("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",a),...b,ref:c,children:(0,d.jsx)(f.zi,{className:(0,g.cn)("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));h.displayName=f.bL.displayName},60408:(a,b,c)=>{c.d(b,{P:()=>q});var d=c(71209),e=c(6549),f=c(89730),g=c(66264),h=c(12932),i=c(14862),j=c(61090),k=c(80443),l=c(91630),m=c(32924),n=c(22885),o=c(81469);let p=g.Ik({id:g.Yj().optional(),title:g.Yj().min(2,{message:"网站标题至少需要2个字符"}),href:g.Yj().url({message:"请输入有效的网站链接"}),icon:g.Yj().optional(),description:g.Yj().optional(),enabled:g.zM().default(!0)});function q({onSubmit:a,onCancel:b,defaultValues:c}){let{toast:g}=(0,o.dj)(),q=(0,e.mN)({resolver:(0,f.u)(p),defaultValues:c||{id:String(Date.now()),title:"",href:"",icon:"",description:"",enabled:!0}}),r=q.formState.isSubmitting,[s,t]=(0,n.useState)(!1),[u,v]=(0,n.useState)(!1);q.watch("href");let w=async a=>{if(!u){v(!0);try{let b=await fetch("/api/website-metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:a})});if(!b.ok)throw Error("获取网站信息失败");let c=await b.json();q.getValues("title")||q.setValue("title",c.title),q.getValues("description")||q.setValue("description",c.description),!q.getValues("icon")&&c.icon&&q.setValue("icon",c.icon),g({title:"成功",description:"已自动获取网站信息"})}catch(a){console.error("Failed to fetch website metadata:",a),g({title:"提示",description:"自动获取网站信息失败,请手动填写",variant:"destructive"})}finally{v(!1)}}};return(0,d.jsx)(j.lV,{...q,children:(0,d.jsxs)("form",{onSubmit:q.handleSubmit(async b=>{try{let c={id:b.id||crypto.randomUUID(),title:b.title,href:b.href,description:b.description,icon:b.icon,enabled:b.enabled};await a(c)}catch(a){console.error("保存失败:",a)}}),className:"space-y-4",children:[(0,d.jsx)(j.zB,{control:q.control,name:"href",render:({field:a})=>(0,d.jsxs)(j.eI,{children:[(0,d.jsx)(j.lR,{children:"网站链接"}),(0,d.jsx)(j.MJ,{children:(0,d.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,d.jsxs)("div",{className:"relative flex-1",children:[(0,d.jsx)(i.p,{placeholder:"输入网站链接,将自动获取网站信息",...a}),u&&(0,d.jsx)("div",{className:"absolute right-3 top-1/2 transform -translate-y-1/2",children:(0,d.jsx)(k.F.loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),(0,d.jsx)(h.$,{type:"button",variant:"outline",size:"sm",disabled:!a.value||!(a=>{try{return new URL(a),!0}catch(a){return!1}})(a.value)||u,onClick:()=>w(a.value),children:u?(0,d.jsx)(k.F.loader2,{className:"h-4 w-4 animate-spin"}):(0,d.jsx)(k.F.refresh,{className:"h-4 w-4"})})]})}),(0,d.jsx)(j.Rr,{children:"输入完整的网站链接后,系统将自动获取网站标题、描述和图标"}),(0,d.jsx)(j.C5,{})]})}),(0,d.jsx)(j.zB,{control:q.control,name:"title",render:({field:a})=>(0,d.jsxs)(j.eI,{children:[(0,d.jsx)(j.lR,{children:"网站标题"}),(0,d.jsx)(j.MJ,{children:(0,d.jsx)(i.p,{placeholder:"网站标题(可自动获取)",...a})}),(0,d.jsx)(j.C5,{})]})}),(0,d.jsx)(j.zB,{control:q.control,name:"icon",render:({field:a})=>(0,d.jsxs)(j.eI,{children:[(0,d.jsx)(j.lR,{children:"图标"}),(0,d.jsx)(j.MJ,{children:(0,d.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,d.jsxs)("div",{className:"flex-1 relative",children:[(0,d.jsx)(i.p,{placeholder:"图标URL(可自动获取)",...a}),a.value&&(0,d.jsx)("div",{className:"absolute right-3 top-1/2 transform -translate-y-1/2",children:(0,d.jsx)("img",{src:a.value,alt:"图标预览",className:"w-4 h-4 object-contain",onError:a=>{a.target.style.display="none"}})})]}),(0,d.jsxs)(h.$,{type:"button",variant:"outline",className:"relative",disabled:s,onClick:()=>{let a=document.getElementById("icon-upload");a?.click()},children:[s?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(k.F.loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"上传中..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(k.F.upload,{className:"mr-2 h-4 w-4"}),"上传图片"]}),(0,d.jsx)("input",{id:"icon-upload",type:"file",accept:"image/*",onChange:async b=>{let c=b.target.files?.[0];if(c)try{t(!0);let b=await new Promise((a,b)=>{let d=new FileReader;d.onload=()=>a(d.result),d.onerror=b,d.readAsDataURL(c)}),d=await fetch("/api/resource",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:b})});if(!d.ok)throw Error(`上传失败: ${d.status} ${d.statusText}`);let e=await d.json();if(e.imageUrl)a.onChange(`${e.imageUrl}`);else throw Error("未获取到上传后的图片URL")}catch(a){console.error("上传失败:",a),alert(a instanceof Error?a.message:"上传失败,请重试")}finally{t(!1);let a=document.getElementById("icon-upload");a&&(a.value="")}},className:"hidden"})]})]})}),(0,d.jsx)(j.Rr,{children:"系统会自动获取网站图标,也可手动输入URL或上传本地图片"}),(0,d.jsx)(j.C5,{})]})}),(0,d.jsx)(j.zB,{control:q.control,name:"description",render:({field:a})=>(0,d.jsxs)(j.eI,{children:[(0,d.jsx)(j.lR,{children:"网站描述"}),(0,d.jsx)(j.MJ,{children:(0,d.jsx)(l.T,{placeholder:"输入网站描述",className:"resize-none",...a})}),(0,d.jsx)(j.C5,{})]})}),(0,d.jsx)(j.zB,{control:q.control,name:"enabled",render:({field:a})=>(0,d.jsxs)(j.eI,{className:"flex flex-row items-center justify-between rounded-lg p-4",children:[(0,d.jsxs)("div",{className:"space-y-0.5",children:[(0,d.jsx)(j.lR,{className:"text-base",children:"启用状态"}),(0,d.jsx)(j.Rr,{children:"设置该导航项是否启用"})]}),(0,d.jsx)(j.MJ,{children:(0,d.jsx)(m.d,{checked:a.value,onCheckedChange:a.onChange})})]})}),(0,d.jsxs)("div",{className:"flex justify-end space-x-2",children:[(0,d.jsxs)(h.$,{type:"submit",disabled:r,children:[r&&(0,d.jsx)(k.F.loader2,{className:"mr-2 h-4 w-4 animate-spin"}),r?"保存中...":"保存"]}),(0,d.jsx)(h.$,{type:"button",variant:"outline",onClick:b,disabled:r,children:"取消"})]})]})})}},61090:(a,b,c)=>{c.d(b,{C5:()=>s,MJ:()=>q,Rr:()=>r,eI:()=>o,lR:()=>p,lV:()=>j,zB:()=>l});var d=c(71209),e=c(22885),f=c(10797),g=c(6549),h=c(64455),i=c(92904);let j=g.Op,k=e.createContext({}),l=({...a})=>(0,d.jsx)(k.Provider,{value:{name:a.name},children:(0,d.jsx)(g.xI,{...a})}),m=()=>{let a=e.useContext(k),b=e.useContext(n),{getFieldState:c,formState:d}=(0,g.xW)(),f=c(a.name,d);if(!a)throw Error("useFormField should be used within <FormField>");let{id:h}=b;return{id:h,name:a.name,formItemId:`${h}-form-item`,formDescriptionId:`${h}-form-item-description`,formMessageId:`${h}-form-item-message`,...f}},n=e.createContext({}),o=e.forwardRef(({className:a,...b},c)=>{let f=e.useId();return(0,d.jsx)(n.Provider,{value:{id:f},children:(0,d.jsx)("div",{ref:c,className:(0,h.cn)("space-y-2",a),...b})})});o.displayName="FormItem";let p=e.forwardRef(({className:a,...b},c)=>{let{error:e,formItemId:f}=m();return(0,d.jsx)(i.J,{ref:c,className:(0,h.cn)(e&&"text-destructive",a),htmlFor:f,...b})});p.displayName="FormLabel";let q=e.forwardRef(({...a},b)=>{let{error:c,formItemId:e,formDescriptionId:g,formMessageId:h}=m();return(0,d.jsx)(f.DX,{ref:b,id:e,"aria-describedby":c?`${g} ${h}`:`${g}`,"aria-invalid":!!c,...a})});q.displayName="FormControl";let r=e.forwardRef(({className:a,...b},c)=>{let{formDescriptionId:e}=m();return(0,d.jsx)("p",{ref:c,id:e,className:(0,h.cn)("text-[0.8rem] text-muted-foreground",a),...b})});r.displayName="FormDescription";let s=e.forwardRef(({className:a,children:b,...c},e)=>{let{error:f,formMessageId:g}=m(),i=f?String(f?.message):b;return i?(0,d.jsx)("p",{ref:e,id:g,className:(0,h.cn)("text-[0.8rem] font-medium text-destructive",a),...c,children:i}):null});s.displayName="FormMessage"},80443:(a,b,c)=>{c.d(b,{F:()=>ax});var d=c(99276),e=c(15525),f=c(5209),g=c(39965),h=c(1155),i=c(5033),j=c(58074),k=c(26233),l=c(86059),m=c(96784),n=c(19256),o=c(91685),p=c(13068),q=c(72101),r=c(59926),s=c(80846),t=c(82232),u=c(86411),v=c(44801),w=c(21922),x=c(46135),y=c(69154),z=c(54392),A=c(93080),B=c(22378),C=c(61533),D=c(52409),E=c(33696),F=c(80774),G=c(23678),H=c(87953),I=c(23045),J=c(21283),K=c(96794),L=c(59962),M=c(9883),N=c(32382),O=c(92100),P=c(7011),Q=c(46929),R=c(42970),S=c(64215),T=c(56538),U=c(86769),V=c(31616),W=c(83049),X=c(43280),Y=c(73353),Z=c(12365),$=c(39005),_=c(1786),aa=c(42133),ab=c(84585),ac=c(34296),ad=c(89472),ae=c(10561),af=c(99264),ag=c(58920),ah=c(95822),ai=c(30209),aj=c(68131),ak=c(34828),al=c(47217),am=c(15952),an=c(87483),ao=c(45035),ap=c(1744),aq=c(38686),ar=c(45033),as=c(67010),at=c(58549),au=c(33354),av=c(51839),aw=c(35150);let ax={arrowLeft:d.A,bookOpen:e.A,bookmark:f.A,briefcase:g.A,calendar:h.A,check:i.A,chevronLeft:j.A,chevronRight:k.A,clock:l.A,cloud:m.A,code:n.A,coffee:o.A,command:p.A,compass:q.A,cornerDownRight:r.A,crown:s.A,database:t.A,fileText:u.A,folder:v.A,folderOpen:w.A,gift:x.A,github:y.A,globe:z.A,gripVertical:A.A,headphones:B.A,heart:C.A,home:D.A,image:E.A,layoutDashboard:F.A,library:G.A,link:H.A,list:I.A,loader2:J.A,logOut:K.A,mail:L.A,map:M.A,menu:N.A,messageSquare:O.A,monitor:P.A,moreVertical:Q.A,music:R.A,navigation:S.A,newspaper:T.A,package:U.A,panelLeftClose:V.A,panelRightOpen:W.A,pencil:X.A,phone:Y.A,plus:Z.A,printer:$.A,radio:_.A,refresh:aa.A,rocket:ab.A,save:ac.A,scan:ad.A,search:ae.A,settings:af.A,shield:ag.A,smartphone:ah.A,star:ai.A,sun:aj.A,target:ak.A,terminal:al.A,trash:am.A,trophy:an.A,tv:ao.A,upload:ap.A,user:aq.A,users:ar.A,video:as.A,x:at.A,zap:au.A,category:v.A,placeholder:v.A,logo:S.A,spinner:J.A,chevronsUp:av.A,chevronsDown:aw.A}},84088:(a,b,c)=>{c.d(b,{bq:()=>m,eb:()=>q,gC:()=>p,l6:()=>k,yv:()=>l});var d=c(71209),e=c(22885),f=c(66882),g=c(98091),h=c(60902),i=c(5033),j=c(64455);let k=f.bL;f.YJ;let l=f.WT,m=e.forwardRef(({className:a,children:b,...c},e)=>(0,d.jsxs)(f.l9,{ref:e,className:(0,j.cn)("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...c,children:[b,(0,d.jsx)(f.In,{asChild:!0,children:(0,d.jsx)(g.A,{className:"h-4 w-4 opacity-50"})})]}));m.displayName=f.l9.displayName;let n=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.PP,{ref:c,className:(0,j.cn)("flex cursor-default items-center justify-center py-1",a),...b,children:(0,d.jsx)(h.A,{className:"h-4 w-4"})}));n.displayName=f.PP.displayName;let o=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.wn,{ref:c,className:(0,j.cn)("flex cursor-default items-center justify-center py-1",a),...b,children:(0,d.jsx)(g.A,{className:"h-4 w-4"})}));o.displayName=f.wn.displayName;let p=e.forwardRef(({className:a,children:b,position:c="popper",...e},g)=>(0,d.jsx)(f.ZL,{children:(0,d.jsxs)(f.UC,{ref:g,className:(0,j.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===c&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:c,...e,children:[(0,d.jsx)(n,{}),(0,d.jsx)(f.LM,{className:(0,j.cn)("p-1","popper"===c&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:b}),(0,d.jsx)(o,{})]})}));p.displayName=f.UC.displayName,e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.JU,{ref:c,className:(0,j.cn)("px-2 py-1.5 text-sm font-semibold",a),...b})).displayName=f.JU.displayName;let q=e.forwardRef(({className:a,children:b,...c},e)=>(0,d.jsxs)(f.q7,{ref:e,className:(0,j.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...c,children:[(0,d.jsx)("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,d.jsx)(f.VF,{children:(0,d.jsx)(i.A,{className:"h-4 w-4"})})}),(0,d.jsx)(f.p4,{children:b})]}));q.displayName=f.q7.displayName,e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.wv,{ref:c,className:(0,j.cn)("-mx-1 my-1 h-px bg-muted",a),...b})).displayName=f.wv.displayName},91630:(a,b,c)=>{c.d(b,{T:()=>g});var d=c(71209),e=c(22885),f=c(64455);let g=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)("textarea",{className:(0,f.cn)("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",a),ref:c,...b}));g.displayName="Textarea"},92739:(a,b,c)=>{c.d(b,{E:()=>h});var d=c(71209);c(22885);var e=c(50780),f=c(64455);let g=(0,e.F)("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function h({className:a,variant:b,...c}){return(0,d.jsx)("div",{className:(0,f.cn)(g({variant:b}),a),...c})}},92904:(a,b,c)=>{c.d(b,{J:()=>j});var d=c(71209),e=c(22885),f=c(30787),g=c(50780),h=c(64455);let i=(0,g.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),j=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.b,{ref:c,className:(0,h.cn)(i(),a),...b}));j.displayName=f.b.displayName}}]);
|
||
//# sourceMappingURL=602.js.map
|