1 line
5.3 KiB
JavaScript
1 line
5.3 KiB
JavaScript
module.exports=[1851,(a,b,c)=>{"use strict";b.exports=a.r(2827).vendored.contexts.AppRouterContext},21813,(a,b,c)=>{"use strict";b.exports=a.r(2827).vendored["react-ssr"].ReactServerDOMTurbopackClient},47721,a=>{a.v({backToTop:"EbookViewer-module__9mAIqq__backToTop",book:"EbookViewer-module__9mAIqq__book",chunkAppear:"EbookViewer-module__9mAIqq__chunkAppear",chunkEnter:"EbookViewer-module__9mAIqq__chunkEnter",chunkPlaceholder:"EbookViewer-module__9mAIqq__chunkPlaceholder",drawer:"EbookViewer-module__9mAIqq__drawer",drawerItem:"EbookViewer-module__9mAIqq__drawerItem",drawerMask:"EbookViewer-module__9mAIqq__drawerMask",drawerMaskOpen:"EbookViewer-module__9mAIqq__drawerMaskOpen",drawerOpen:"EbookViewer-module__9mAIqq__drawerOpen",header:"EbookViewer-module__9mAIqq__header",headerLeft:"EbookViewer-module__9mAIqq__headerLeft",headerMiddle:"EbookViewer-module__9mAIqq__headerMiddle",headerRight:"EbookViewer-module__9mAIqq__headerRight",headerRightActive:"EbookViewer-module__9mAIqq__headerRightActive",headerRightText:"EbookViewer-module__9mAIqq__headerRightText",headerSpacer:"EbookViewer-module__9mAIqq__headerSpacer",markdownBody:"EbookViewer-module__9mAIqq__markdownBody",progressBar:"EbookViewer-module__9mAIqq__progressBar",readingProgress:"EbookViewer-module__9mAIqq__readingProgress",readingTime:"EbookViewer-module__9mAIqq__readingTime",shimmer:"EbookViewer-module__9mAIqq__shimmer"})},75645,a=>{"use strict";var b=a.i(81629),c=a.i(84365),d=a.i(97823),e=a.i(47721);function f({html:a,estimatedHeight:d,forceVisible:f}){let[g,h]=(0,c.useState)(f),i=(0,c.useRef)(null),j=f||g;return((0,c.useEffect)(()=>{if(f||g)return;let a=i.current;if(!a)return;let b=new IntersectionObserver(([a])=>{a.isIntersecting&&(h(!0),b.disconnect())},{rootMargin:"1200px 0px"});return b.observe(a),()=>b.disconnect()},[f,g]),j)?(0,b.jsx)("div",{className:`${e.default.chunkEnter} animate__animated animate__fadeInUp`,style:{animationDuration:"0.5s",animationFillMode:"both"},dangerouslySetInnerHTML:{__html:a}}):(0,b.jsx)("div",{ref:i,className:e.default.chunkPlaceholder,style:{minHeight:d}})}function g({data:a,config:g}){let[h,i]=(0,c.useState)(!1),[j,k]=(0,c.useState)(0),[l,m]=(0,c.useState)(!1),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(null),r=(0,c.useRef)(null),{chunks:s,headers:t}=a,u=g.estimatedMinutes??null;(0,c.useEffect)(()=>{let a=!1,b=()=>{a||(a=!0,requestAnimationFrame(()=>{let b=window.scrollY||document.documentElement.scrollTop,c=document.documentElement.scrollHeight-window.innerHeight;k(c>0?Math.min(100,b/c*100):0),m(b>600),u&&c>0&&q(Math.ceil(Math.max(0,u*(1-b/c)))),a=!1}))};return window.addEventListener("scroll",b,{passive:!0}),()=>window.removeEventListener("scroll",b)},[u]);let v=(0,c.useCallback)(a=>{o(!0),i(!1);let b=()=>{let b=r.current;if(!b)return;let c=b.querySelectorAll("h1"),d=b.querySelectorAll("h2"),e=(c.length>0?c:d)[a];if(e)try{e.scrollIntoView({behavior:"smooth",block:"start"})}catch{let a=e.getBoundingClientRect().top+(window.pageYOffset||document.documentElement.scrollTop)-60;window.scrollTo({top:Math.max(0,a),behavior:"smooth"})}};b(),setTimeout(b,100),setTimeout(b,300),setTimeout(b,600)},[]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:e.default.readingProgress,style:{width:`${j}%`}}),(0,b.jsx)("div",{className:e.default.headerSpacer}),(0,b.jsxs)("header",{className:`${e.default.header} animate__animated animate__fadeInDown`,style:{animationFillMode:"both"},children:[(0,b.jsx)(d.default,{href:g.backHref,className:e.default.headerLeft,"aria-label":"返回",children:(0,b.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,b.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,b.jsxs)("div",{className:e.default.headerMiddle,children:[g.title,null!==p&&p>0&&(0,b.jsxs)("span",{className:e.default.readingTime,children:[" · 约 ",p," 分钟"]})]}),(0,b.jsxs)("button",{type:"button",className:`${e.default.headerRight} ${h?e.default.headerRightActive:""}`,onClick:()=>i(!h),"aria-label":"目录",children:[(0,b.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,b.jsx)("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),(0,b.jsx)("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),(0,b.jsx)("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]}),(0,b.jsx)("span",{className:e.default.headerRightText,children:"目录"})]})]}),(0,b.jsx)("div",{className:e.default.book,children:(0,b.jsx)("div",{ref:r,className:`markdown-body ${e.default.markdownBody}`,children:s.map((a,c)=>(0,b.jsx)(f,{html:a.html,estimatedHeight:a.estimatedHeight,forceVisible:n||0===c},c))})}),(0,b.jsx)("div",{className:`${e.default.drawerMask} ${h?e.default.drawerMaskOpen:""}`,onClick:()=>i(!1),"aria-hidden":"true"}),(0,b.jsx)("aside",{className:`${e.default.drawer} ${h?e.default.drawerOpen:""}`,children:t.map((a,c)=>(0,b.jsx)("div",{role:"button",tabIndex:0,className:e.default.drawerItem,onClick:()=>v(c),onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&v(c)},children:a},c))}),l&&(0,b.jsx)("button",{type:"button",className:e.default.backToTop,onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),"aria-label":"回到顶部",children:(0,b.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,b.jsx)("path",{d:"M18 15l-6-6-6 6"})})})]})}a.s(["EbookViewer",()=>g])}]; |