当前位置:首页 > 文章列表 > 文章 > 前端 > 将 Starlight 转换为 PDF:经验和见解

将 Starlight 转换为 PDF:经验和见解

来源:dev.to 2025-01-15 23:00:50 0浏览 收藏

哈喽!大家好,很高兴又见面了,我是golang学习网的一名作者,今天由我给大家带来一篇《将 Starlight 转换为 PDF:经验和见解》,本文主要会讲到等等知识点,希望大家一起学习进步,也欢迎大家关注、点赞、收藏、转发! 下面就一起来看看吧!

想象一下您收到一项任务:在一周内创建一个新的文档网站。它应该具有视觉吸引力、快速且易于导航。您会收到一堆 *.docs 文件、图像和屏幕截图,以及“完成它”.

的说明

有很多优秀的工具可供选择,例如docusaurus、nextra、vitepress、docus等等。之前,我在使用 starlight 构建文档网站方面获得了丰富的经验,因此我选择了它来完成这项任务。然而,我发现了一个缺失的功能:从文档生成 pdf 的能力。这是要求之一。 “听起来像是一个不错的副业项目,”我自己想的。

解决任务

起初,这似乎很简单:获取页面,解析 html,对内容进行分组,瞧!

星光驱动的网站有一个“下一步”按钮来浏览文档。由于 pdf 本质上是页面数组,因此使用“下一步”按钮逐一解析它们似乎是合乎逻辑的。由于网站生成静态页面,我很快编写了一个脚本来获取 html、查询必要的部分,并将所有内容组合在一起。然而,事实证明,生成保留网站样式的 pdf 更为复杂。经过一番头脑风暴,我意识到 puppeteer 是最好的解决方案。

现在流程变得清晰了:

  1. 确定起始页面。这是带有“下一步”按钮的第一页。
  2. 浏览页面。从每个页面提取标题和主要内容,同时构建目录。
  3. 合并内容。添加分页符和其他样式。
  4. 准备最终的 html。 使用生成的 html 重写初始页面的 。
  5. 加载资源。滚动页面至底部加载所有图片。
  6. 生成 pdf。puppeteer 的 page.pdf() 方法可以解决这个问题。
  7. 完成!

这就是starlight-to-pdf 的工作原理。遵循这种模式,您可以为缺乏 pdf 导出功能的其他文档框架构建类似的工具。

后续步骤

基本功能准备就绪后,就该添加一些额外功能了。以下是最有趣和最具挑战性的功能。

添加页眉和页脚

页眉或页脚中包含页码和一些附加信息是很好的。 puppeteer 的 page.pdf() 方法接受 headertemplate 和 footertemplate 选项。这些选项接受 html 字符串。 puppeteer 自动将值注入到具有特定实用程序类的元素中:

  • .date:格式化日期;
  • .title:网页的标签值;</li> <li> .url: 调用打印函数的页面 url;</li> <li> .pagenumber:当前页码;</li> <li> .totalpages: 文档的总页数。</li> </ul><p>当我们在打印之前将所有内容合并在一页上时,标题和网址对我们来说没有太大价值:插入的值将始终保持不变。然而,其他课程有很大帮​​助。这是页脚模板示例:<br></p> <pre class="brush:php;toolbar:false"><style> .footer-container { --color: #000; display: flex; align-items: center; justify-content: space-between; border-block-start: 1px solid var(--color); color: var(--color); font-size: 10px; font-family: arial, helvetica, sans-serif; margin-inline: 1.5cm 1cm; padding-block: 0.25cm 0.5cm; width: 100%; } </style> <div class="footer-container"> <div>awesome docs</div> <div> <!-- numbers inside the elements with `.pagenumber` and `.totalpages` classes are injected automatically by puppeteer --> <span class="pagenumber"></span> / <span class="totalpages"></span> </div> <!-- same for the `.date` class value --> <div class="date"></div> </div> </pre> <p>要使用此功能,请不要忘记将 displayheaderfooter 属性设置为 true:<br></p> <pre class="brush:php;toolbar:false">import puppeteer from 'puppeteer'; const browser = await puppeteer.launch(); const page = await browser.newpage(); await page.goto('https://someurl'); const footertemplatestr = '<style>...<style><div>...</div>' // replace with the html string from the example above await page.pdf({ displayheaderfooter: true, footertemplate: footertemplatestr }) </pre> <p>以下是您应该牢记的一些发现:</p> <ul><li>模板必须是有效的 html 结构。</li> <li>定义 font-size css 属性,puppeteer 的默认值为 0。</li> <li>使用内联 <style> 标签来定义您的样式。网站样式在模板内不可用。</li> <li>图像应编码为 base64 字符串。</li> <li>使用 puppeteer 的边距选项来实现所需的布局。</li> </ul><h3> cli 样式怎么样? </h3> <p>一切正常,生成的 pdf 看起来很棒,但终端消息感觉平淡无奇。对细节的关注将好与伟大区分开来,不是吗?让我们的消息更加丰富多彩、更易于阅读。</p> <p>这就是 ansi 转义序列的魔力。我认为 4 位颜色足以完成这项工作。假设您想要红色背景上的白色文本<em>(这就是我用于[错误]:错误消息之前的前缀)</em>。以下是实现这种外观的方法:<br></p> <pre class="brush:php;toolbar:false">console.log('\x1b[37;41m', 'white on red message'); </pre> <p>让我们来分解一下:</p> <ul><li> x1b[ 是十六进制转义码(您也可以使用 u001b 作为 unicode 替代);</li> <li> 37 是前景色白色,其中 3 代表前景色,7 代表白色;</li> <li> 41 是背景红色,其中 4 代表背景,1 代表红色。</li> </ul><p>一切正常,但现在我们所有的 console.log() 输出都将以这种方式设置样式。要将样式重置回默认值,只需在末尾添加重置序列 x1b[0m:<br></p> <pre class="brush:php;toolbar:false">console.log('\x1b[37;41m', 'white on red message', '\x1b[0m'); </pre> <p>好多了。如果我们想要在灰色背景上显示粗体青色文本<em>(4 位颜色名称中的亮黑色)</em>,该怎么办?很简单:<br></p> 98262315536​​3 <p>以下是每个部分的作用:</p> <ul><li> 1 转义码后应用粗体效果;</li> <li> 36 设置文本颜色为青色;</li> <li> 100 将背景更改为亮黑色,其中 10 表示<em>明亮</em>,0 是<em>黑色</em>的代码。</li> </ul><p>利用这些知识,您可以使您的 cli 工具在视觉上更具吸引力。例如,我在项目中将所有 url 和文件路径设置为带下划线的蓝色文本:<br></p> <pre class="brush:php;toolbar:false">console.log('\x1b[4;34m', './underlined/blue', '\x1b[0m') </pre> <p>查看此备忘单以了解有关该主题的更多信息。</p> <h2> 总结 </h2> <p>你永远不知道日常任务什么时候可能会激发出有益的副业项目。 starlight-to-pdf 的开发为 puppeteer 和 cli 样式提供了宝贵的经验,并且开源社区中出现了一种新工具。这是一个快速演示:</p> <p><img src="/uploads/20250115/17369532276787cd8b80721.gif" alt="starlight-to-pdf usage demo" loading="lazy" style="max-width:100%" style="max-width:100%" data-animated="true"></p> <p>本篇关于《将 Starlight 转换为 PDF:经验和见解》的介绍就到此结束啦,但是学无止境,想要了解学习更多关于文章的相关知识,请关注golang学习网公众号!</p> </div> <div class="labsList"> </div> <div class="claration"> <div class="clarationTit">版本声明</div>本文转载于:dev.to 如有侵犯,请联系<a href="javascript:;" class="aRed">study_golang@163.com</a>删除 </div> <div class="cateBox"> <div class="cateItem"> <a href="/article/179268.html" title="NextJs:如何为索引页创建专用布局文件" class="img_box"> <img src="/uploads/20250115/17369530476787ccd7b6ac1.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="NextJs:如何为索引页创建专用布局文件">NextJs:如何为索引页创建专用布局文件 </a> <dl> <dt class="lineOverflow"><a href="/article/179268.html" title="NextJs:如何为索引页创建专用布局文件" class="aBlack">上一篇<i></i></a></dt> <dd class="lineTwoOverflow">NextJs:如何为索引页创建专用布局文件</dd> </dl> </div> <div class="cateItem"> <a href="/article/179270.html" title="linux如何排查cpu持续飙高原因" class="img_box"> <img src="/uploads/20250116/173699571967887387eb176.png" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="linux如何排查cpu持续飙高原因"> </a> <dl> <dt class="lineOverflow"><a href="/article/179270.html" class="aBlack" title="linux如何排查cpu持续飙高原因">下一篇<i></i></a></dt> <dd class="lineTwoOverflow">linux如何排查cpu持续飙高原因</dd> </dl> </div> </div> </div> </div> <div class="leftContBox pt0"> <div class="pdl20"> <div class="contTit"> <a href="/articlelist.html" class="more" title="查看更多">查看更多<i class="iconfont"></i></a> <div class="tit">最新文章</div> </div> </div> <ul class="newArticleList"> <li> <div class="contBox"> <a href="/article/630393.html" class="img_box" title="INP 偏高时如何定位长任务与交互延迟"> <img src="/uploads/20261009/1791504762-5cff7a2b3d-a9e2867d18-cover-640.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="INP 偏高时如何定位长任务与交互延迟"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/88_new_0_1.html" class="aLightGray" title="前端">前端</a>   |  1小时前  |   <a href="/articletag/4701_new_0_1.html" class="aLightGray" title="javascript">javascript</a> · <a href="javascript:;" class="aLightGray" title="前端性能">前端性能</a> <a href="javascript:;" class="aLightGray" title="长任务">长任务</a> <a href="javascript:;" class="aLightGray" title="INP优化">INP优化</a> <a href="javascript:;" class="aLightGray" title="交互延迟">交互延迟</a> <a href="javascript:;" class="aLightGray" title="web-vitals">web-vitals</a> <a href="javascript:;" class="aLightGray" title="Long Animation Frames">Long Animation Frames</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/630393.html" class="aBlack" target="_blank" title="INP 偏高时如何定位长任务与交互延迟">INP 偏高时如何定位长任务与交互延迟</a> </dt> <dd class="cont2"> <span><i class="view"></i>257浏览</span> <span class="collectBtn user_collection" data-id="630393" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/630369.html" class="img_box" title="Web Components 声明式 Shadow DOM 如何用于服务端渲染"> <img src="/uploads/20261009/1791497083-b96d6b4ac2-80946a9a41-cover-640.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Web Components 声明式 Shadow DOM 如何用于服务端渲染"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/88_new_0_1.html" class="aLightGray" title="前端">前端</a>   |  3小时前  |   <a href="/articletag/243_new_0_1.html" class="aLightGray" title="前端">前端</a> · <a href="javascript:;" class="aLightGray" title="Web Components">Web Components</a> <a href="javascript:;" class="aLightGray" title="服务端渲染">服务端渲染</a> <a href="javascript:;" class="aLightGray" title="shadowrootmode">shadowrootmode</a> <a href="javascript:;" class="aLightGray" title="声明式 Shadow DOM">声明式 Shadow DOM</a> <a href="javascript:;" class="aLightGray" title="Custom Elements hydration">Custom Elements hydration</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/630369.html" class="aBlack" target="_blank" title="Web Components 声明式 Shadow DOM 如何用于服务端渲染">Web Components 声明式 Shadow DOM 如何用于服务端渲染</a> </dt> <dd class="cont2"> <span><i class="view"></i>315浏览</span> <span class="collectBtn user_collection" data-id="630369" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/630345.html" class="img_box" title="HTML Popover API 怎样处理嵌套弹层与焦点"> <img src="/uploads/20261009/1791489594-16f1e0ff55-22b5d6054e-cover-640.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="HTML Popover API 怎样处理嵌套弹层与焦点"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/88_new_0_1.html" class="aLightGray" title="前端">前端</a>   |  6小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/630345.html" class="aBlack" target="_blank" title="HTML Popover API 怎样处理嵌套弹层与焦点">HTML Popover API 怎样处理嵌套弹层与焦点</a> </dt> <dd class="cont2"> <span><i class="view"></i>356浏览</span> <span class="collectBtn user_collection" data-id="630345" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/630321.html" class="img_box" title="View Transition API 如何为列表重排添加过渡"> <img src="/uploads/20261009/1791482162-097ce760ab-80084b1cba-cover-640.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="View Transition API 如何为列表重排添加过渡"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/88_new_0_1.html" class="aLightGray" title="前端">前端</a>   |  8小时前  |   <a href="/articletag/5401_new_0_1.html" class="aLightGray" title="前端开发">前端开发</a> · <a href="javascript:;" class="aLightGray" title="前端动画">前端动画</a> <a href="javascript:;" class="aLightGray" title="View Transition API">View Transition API</a> <a href="javascript:;" class="aLightGray" title="列表重排">列表重排</a> <a href="javascript:;" class="aLightGray" title="match-element">match-element</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/630321.html" class="aBlack" target="_blank" title="View Transition API 如何为列表重排添加过渡">View Transition API 如何为列表重排添加过渡</a> </dt> <dd class="cont2"> <span><i class="view"></i>158浏览</span> <span class="collectBtn user_collection" data-id="630321" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/630298.html" class="img_box" title="CSS Anchor Positioning 如何配置 position-try 回退位置"> <img src="/uploads/20261009/1791476070-fa68d20ce0-fd66c15447-cover-640.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="CSS Anchor Positioning 如何配置 position-try 回退位置"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/88_new_0_1.html" class="aLightGray" title="前端">前端</a>   |  9小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/630298.html" class="aBlack" target="_blank" title="CSS Anchor Positioning 如何配置 position-try 回退位置">CSS Anchor Positioning 如何配置 position-try 回退位置</a> </dt> <dd class="cont2"> <span><i class="view"></i>234浏览</span> <span class="collectBtn user_collection" data-id="630298" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/630262.html" class="img_box" title="前端性能预算怎么落地:图片、脚本与交互延迟阈值"> <img src="/uploads/20261008/1791462634-8e78231356-b845a79e95-cover-640.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="前端性能预算怎么落地:图片、脚本与交互延迟阈值"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/88_new_0_1.html" class="aLightGray" title="前端">前端</a>   |  13小时前  |   <a href="/articletag/243_new_0_1.html" class="aLightGray" title="前端">前端</a> · <a href="/articletag/729_new_0_1.html" class="aLightGray" title="性能优化">性能优化</a> · </span> </dd> <dt class="lineOverflow"> <a href="/article/630262.html" class="aBlack" target="_blank" title="前端性能预算怎么落地:图片、脚本与交互延迟阈值">前端性能预算怎么落地:图片、脚本与交互延迟阈值</a> </dt> <dd class="cont2"> <span><i class="view"></i>446浏览</span> <span class="collectBtn user_collection" data-id="630262" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/630238.html" class="img_box" title="表单校验怎样同时服务键盘用户与屏幕阅读器"> <img src="/uploads/20261008/1791454455-032a184610-817e6ed609-cover-640.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="表单校验怎样同时服务键盘用户与屏幕阅读器"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/88_new_0_1.html" class="aLightGray" title="前端">前端</a>   |  15小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/630238.html" class="aBlack" target="_blank" title="表单校验怎样同时服务键盘用户与屏幕阅读器">表单校验怎样同时服务键盘用户与屏幕阅读器</a> </dt> <dd class="cont2"> <span><i class="view"></i>225浏览</span> <span class="collectBtn user_collection" data-id="630238" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/630214.html" class="img_box" title="CSS 层叠层解决组件库与业务样式优先级冲突"> <img src="/uploads/20261008/1791446536-502f93f526-4475f2647a-cover-640.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="CSS 层叠层解决组件库与业务样式优先级冲突"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/88_new_0_1.html" class="aLightGray" title="前端">前端</a>   |  18小时前  |   <a href="/articletag/243_new_0_1.html" class="aLightGray" title="前端">前端</a> · <a href="/articletag/4729_new_0_1.html" class="aLightGray" title="css">css</a> · </span> </dd> <dt class="lineOverflow"> <a href="/article/630214.html" class="aBlack" target="_blank" title="CSS 层叠层解决组件库与业务样式优先级冲突">CSS 层叠层解决组件库与业务样式优先级冲突</a> </dt> <dd class="cont2"> <span><i class="view"></i>464浏览</span> <span class="collectBtn user_collection" data-id="630214" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/630191.html" class="img_box" title="浏览器缓存命中却仍请求服务器:强缓存与协商缓存排查"> <img src="/uploads/20261008/1791438436-1a46c593a4-74f080fc90-cover-640.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="浏览器缓存命中却仍请求服务器:强缓存与协商缓存排查"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/88_new_0_1.html" class="aLightGray" title="前端">前端</a>   |  20小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/630191.html" class="aBlack" target="_blank" title="浏览器缓存命中却仍请求服务器:强缓存与协商缓存排查">浏览器缓存命中却仍请求服务器:强缓存与协商缓存排查</a> </dt> <dd class="cont2"> <span><i class="view"></i>477浏览</span> <span class="collectBtn user_collection" data-id="630191" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/630166.html" class="img_box" title="用 IntersectionObserver 构建可停止的懒加载队列"> <img src="/uploads/20261008/1791430162-b2143f180d-4e92a306b7-cover-640.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="用 IntersectionObserver 构建可停止的懒加载队列"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/88_new_0_1.html" class="aLightGray" title="前端">前端</a>   |  22小时前  |   <a href="/articletag/4701_new_0_1.html" class="aLightGray" title="javascript">javascript</a> · <a href="javascript:;" class="aLightGray" title="懒加载">懒加载</a> <a href="javascript:;" class="aLightGray" title="IntersectionObserver">IntersectionObserver</a> <a href="javascript:;" class="aLightGray" title="前端队列">前端队列</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/630166.html" class="aBlack" target="_blank" title="用 IntersectionObserver 构建可停止的懒加载队列">用 IntersectionObserver 构建可停止的懒加载队列</a> </dt> <dd class="cont2"> <span><i class="view"></i>401浏览</span> <span class="collectBtn user_collection" data-id="630166" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/630144.html" class="img_box" title="前端状态更新频繁时,批处理与去抖分别解决什么"> <img src="/uploads/20261007/1791362972-ae57678373-4cae5f28c0-cover-640.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="前端状态更新频繁时,批处理与去抖分别解决什么"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/88_new_0_1.html" class="aLightGray" title="前端">前端</a>   |  1天前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/630144.html" class="aBlack" target="_blank" title="前端状态更新频繁时,批处理与去抖分别解决什么">前端状态更新频繁时,批处理与去抖分别解决什么</a> </dt> <dd class="cont2"> <span><i class="view"></i>227浏览</span> <span class="collectBtn user_collection" data-id="630144" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/630120.html" class="img_box" title="可访问弹窗的焦点陷阱、关闭恢复与背景隔离"> <img src="/uploads/20261007/1791355130-00f20d91ca-0222176e54-cover-640.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="可访问弹窗的焦点陷阱、关闭恢复与背景隔离"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/88_new_0_1.html" class="aLightGray" title="前端">前端</a>   |  1天前  |   <a href="/articletag/243_new_0_1.html" class="aLightGray" title="前端">前端</a> · <a href="/articletag/40050_new_0_1.html" class="aLightGray" title="可访问性">可访问性</a> · <a href="javascript:;" class="aLightGray" title="焦点陷阱">焦点陷阱</a> <a href="javascript:;" class="aLightGray" title="HTML dialog">HTML dialog</a> <a href="javascript:;" class="aLightGray" title="焦点恢复">焦点恢复</a> <a href="javascript:;" class="aLightGray" title="inert">inert</a> <a href="javascript:;" class="aLightGray" title="无障碍弹窗">无障碍弹窗</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/630120.html" class="aBlack" target="_blank" title="可访问弹窗的焦点陷阱、关闭恢复与背景隔离">可访问弹窗的焦点陷阱、关闭恢复与背景隔离</a> </dt> <dd class="cont2"> <span><i class="view"></i>309浏览</span> <span class="collectBtn user_collection" data-id="630120" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> </ul> </div> </div> <div class="mainRight"> <!-- 右侧广告位banner --> <div class="rightContBox" style="margin-top: 0px;"> <div class="rightTit"> <a href="/courselist.html" class="more" title="查看更多">查看更多<i class="iconfont"></i></a> <div class="tit lineOverflow">课程推荐</div> </div> <ul class="lessonRecomRList"> <li> <a href="/course/9.html" class="img_box" target="_blank" title="前端进阶之JavaScript设计模式"> <img src="/uploads/20221222/52fd0f23a454c71029c2c72d206ed815.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="前端进阶之JavaScript设计模式"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/9.html" target="_blank" class="aBlack" title="前端进阶之JavaScript设计模式">前端进阶之JavaScript设计模式</a></dt> <dd class="cont1 lineTwoOverflow"> 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。 </dd> <dd class="cont2">543次学习</dd> </dl> </li> <li> <a href="/course/2.html" class="img_box" target="_blank" title="GO语言核心编程课程"> <img src="/uploads/20221221/634ad7404159bfefc6a54a564d437b5f.png" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="GO语言核心编程课程"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/2.html" target="_blank" class="aBlack" title="GO语言核心编程课程">GO语言核心编程课程</a></dt> <dd class="cont1 lineTwoOverflow"> 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。 </dd> <dd class="cont2">516次学习</dd> </dl> </li> <li> <a href="/course/74.html" class="img_box" target="_blank" title="简单聊聊mysql8与网络通信"> <img src="/uploads/20240103/bad35fe14edbd214bee16f88343ac57c.png" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="简单聊聊mysql8与网络通信"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/74.html" target="_blank" class="aBlack" title="简单聊聊mysql8与网络通信">简单聊聊mysql8与网络通信</a></dt> <dd class="cont1 lineTwoOverflow"> 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让 </dd> <dd class="cont2">500次学习</dd> </dl> </li> <li> <a href="/course/57.html" class="img_box" target="_blank" title="JavaScript正则表达式基础与实战"> <img src="/uploads/20221226/bbe4083bb3cb0dd135fb02c31c3785fb.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="JavaScript正则表达式基础与实战"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/57.html" target="_blank" class="aBlack" title="JavaScript正则表达式基础与实战">JavaScript正则表达式基础与实战</a></dt> <dd class="cont1 lineTwoOverflow"> 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。 </dd> <dd class="cont2">487次学习</dd> </dl> </li> <li> <a href="/course/28.html" class="img_box" target="_blank" title="从零制作响应式网站—Grid布局"> <img src="/uploads/20221223/ac110f88206daeab6c0cf38ebf5fe9ed.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="从零制作响应式网站—Grid布局"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/28.html" target="_blank" class="aBlack" title="从零制作响应式网站—Grid布局">从零制作响应式网站—Grid布局</a></dt> <dd class="cont1 lineTwoOverflow"> 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。 </dd> <dd class="cont2">485次学习</dd> </dl> </li> </ul> </div> <div class="rightContBox"> <div class="rightTit"> <a href="/ai.html" class="more" title="查看更多">查看更多<i class="iconfont"></i></a> <div class="tit lineOverflow">AI推荐</div> </div> <ul class="lessonRecomRList"> <li> <a href="/ai/13900.html" target="_blank" title="PubMedQA数据集详解:生物医学问答基准、功能与应用指南" class="img_box"> <img src="/uploads/20260908/6a9f83280940e7.65575695.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="PubMedQA数据集详解:生物医学问答基准、功能与应用指南" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13900.html" class="aBlack" target="_blank" title="PubMedQA">PubMedQA</a></dt> <dd class="cont1 lineTwoOverflow"> 深入了解PubMedQA生物医学问答数据集,涵盖其核心功能、使用方法及在临床决策、药物研发等场景的应用,助力提升NLP模型性能。 </dd> <dd class="cont2">386次使用</dd> </dl> </li> <li> <a href="/ai/13899.html" target="_blank" title="H2O EvalGPT:开源LLM大模型评估与排行榜工具" class="img_box"> <img src="/uploads/20260908/17887986376a9ee6adaf3f5.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="H2O EvalGPT:开源LLM大模型评估与排行榜工具" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13899.html" class="aBlack" target="_blank" title="H2O EvalGPT">H2O EvalGPT</a></dt> <dd class="cont1 lineTwoOverflow"> H2O EvalGPT是H2O.ai推出的开源LLM评估平台,提供详细的大模型性能排行榜、行业特定基准测试及A/B测试功能,助您快速选择最适合项目的高性能大语言模型。 </dd> <dd class="cont2">468次使用</dd> </dl> </li> <li> <a href="/ai/13898.html" target="_blank" title="LMArena是什么?伯克利AI模型评估平台使用指南与功能解析" class="img_box"> <img src="/uploads/20260908/6a9f862dbcfec7.27385604.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="LMArena是什么?伯克利AI模型评估平台使用指南与功能解析" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13898.html" class="aBlack" target="_blank" title="LMArena">LMArena</a></dt> <dd class="cont1 lineTwoOverflow"> LMArena是加州大学伯克利分校推出的AI模型匿名评测平台。通过盲测投票机制,用户可对比不同大模型回答并生成实时排行榜,助力开发者优化模型及用户选择最佳AI工具。 </dd> <dd class="cont2">475次使用</dd> </dl> </li> <li> <a href="/ai/13897.html" target="_blank" title="斯坦福HELM:大语言模型Holistic Evaluation整体评估框架详解" class="img_box"> <img src="/uploads/20260908/6a9f86b31ed789.06773114.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="斯坦福HELM:大语言模型Holistic Evaluation整体评估框架详解" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13897.html" class="aBlack" target="_blank" title="HELM">HELM</a></dt> <dd class="cont1 lineTwoOverflow"> 深入了解斯坦福推出的HELM(Holistic Evaluation of Language Models)大模型评测体系。本文解析其核心功能、安装配置步骤及应用场景,涵盖准确性、公平性、鲁棒性等多维度指标,助力开发者全面优化语言模型性能。 </dd> <dd class="cont2">415次使用</dd> </dl> </li> <li> <a href="/ai/13896.html" target="_blank" title="MMBench详解:多模态大模型基准测试、功能特点与使用指南" class="img_box"> <img src="/uploads/20260908/6a9f86d3eed3e7.18564236.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="MMBench详解:多模态大模型基准测试、功能特点与使用指南" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13896.html" class="aBlack" target="_blank" title="MMBench">MMBench</a></dt> <dd class="cont1 lineTwoOverflow"> MMBench是由上海人工智能实验室等机构联合推出的多模态基准测试平台,提供细粒度能力评估、大规模数据集及VLMEvalKit工具。本文详细介绍其核心功能、安装使用方法及应用场景,助力开发者全面评估多模态模型性能。 </dd> <dd class="cont2">241次使用</dd> </dl> </li> </ul> </div> <!-- 相关文章 --> <div class="rightContBox"> <div class="rightTit"> <a href="/articlelist.html" class="more" title="查看更多">查看更多<i class="iconfont"></i></a> <div class="tit lineOverflow">相关文章</div> </div> <ul class="aboutArticleRList"> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/207000.html" class="aBlack" title="JavaScript函数定义及示例详解">JavaScript函数定义及示例详解</a></dt> <dd> <span class="left">2025-05-11</span> <span class="right">502浏览</span> </dd> </dl> </li> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/621422.html" class="aBlack" title="智能体安全引领产业升级——国内AI安全产品市场深度分析">智能体安全引领产业升级——国内AI安全产品市场深度分析</a></dt> <dd> <span class="left">2026-08-21</span> <span class="right">501浏览</span> </dd> </dl> </li> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/619053.html" class="aBlack" title="CSS变量简化按钮悬停效果技巧">CSS变量简化按钮悬停效果技巧</a></dt> <dd> <span class="left">2026-05-31</span> <span class="right">501浏览</span> </dd> </dl> </li> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/618916.html" class="aBlack" title="JavaScript符号类型详解与应用">JavaScript符号类型详解与应用</a></dt> <dd> <span class="left">2026-05-31</span> <span class="right">501浏览</span> </dd> </dl> </li> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/612539.html" class="aBlack" title="HTML剪贴板复制粘贴怎么用">HTML剪贴板复制粘贴怎么用</a></dt> <dd> <span class="left">2026-05-26</span> <span class="right">501浏览</span> </dd> </dl> </li> </ul> </div> </div> </div> <div class="footer"> <div class="footerIn"> <div class="footLeft"> <div class="linkBox"> <a href="/about/1.html" target="_blank" class="aBlack" title="关于我们">关于我们</a> <a href="/about/5.html" target="_blank" class="aBlack" title="免责声明">免责声明</a> <a href="#" class="aBlack" title="意见反馈">意见反馈</a> <a href="/about/2.html" class="aBlack" target="_blank" title="联系我们">联系我们</a> <a href="/send.html" class="aBlack" title="广告合作">内容提交</a> <a href="/manual/go/" target="_blank" class="aBlack" title="手册">手册</a> </div> <div class="footTip">Golang学习网:公益在线Go学习平台,帮助Go学习者快速成长!</div> <div class="shareBox"> <span><i class="qq"></i>技术交流群</span> </div> <div class="copyRight"> Copyright 2023 http://www.17golang.com/ All Rights Reserved | <a href="https://beian.miit.gov.cn/" target="_blank" title="备案">湘ICP备19018815号-4</a> </div> </div> <div class="footRight"> <ul class="encodeList"> <li> <div class="encodeImg"> <img src="/assets/examples/qrcode_for_gh.jpg" alt="Golang学习网"> </div> <div class="tit">关注公众号</div> <div class="tip">Golang学习网</div> </li> <div class="clear"></div> </ul> </div> <div class="clear"></div> </div> </div> <!-- 微信登录弹窗 --> <style> .popupBg .n-error{ color: red; } </style> <div class="popupBg"> <div class="loginBoxBox"> <div class="imgbg"> <img src="/assets/images/leftlogo.jpg" alt=""> </div> <!-- 微信登录 --> <div class="loginInfo encodeLogin" style="display: none;"> <div class="closeIcon" onclick="$('.popupBg').hide();"></div> <div class="changeLoginType cursorPointer create_wxqrcode" onclick="$('.loginInfo').hide();$('.passwordLogin').show();"> <div class="tip">密码登录在这里</div> </div> <div class="encodeInfo"> <div class="tit"><i></i> 微信扫码登录或注册</div> <div class="encodeImg"> <span id="wx_login_qrcode"><img src="/assets/examples/code.png" alt="二维码"></span> <!-- <div class="refreshBox"> <p>二维码失效</p> <button type="button" class="create_wxqrcode">刷新1111</button> </div> --> </div> <div class="tip">打开微信扫一扫,快速登录/注册</div> </div> <div class="beforeLoginTip">登录即同意 <a href="#" class="aBlue" title="用户协议">用户协议</a> 和 <a href="#" class="aBlue" title="隐私政策">隐私政策</a></div> </div> <!-- 密码登录 --> <div class="loginInfo passwordLogin"> <div class="closeIcon" onclick="$('.popupBg').hide();"></div> <div class="changeLoginType cursorPointer create_wxqrcode" onclick="$('.loginInfo').hide();$('.encodeLogin').show();"> <div class="tip">微信登录更方便</div> </div> <div class="passwordInfo"> <ul class="logintabs selfTabMenu"> <li class="selfTabItem loginFormLi curr">密码登录</li> <li class="selfTabItem registerFormBox ">注册账号</li> </ul> <div class="selfTabContBox"> <div class="selfTabCont loginFormBox" style="display: block;"> <form name="form" id="login-form" class="form-vertical form" method="POST" action="/index/user/login"> <input type="hidden" name="url" value="//www.17golang.com/article/179269.html"/> <input type="hidden" name="__token__" value="2157ff3a3489c7b55936eda40672032c" /> <div class="form-group" style="height:70px;"> <input class="form-control" id="account" type="text" name="account" value="" data-rule="required" placeholder="邮箱/用户名" autocomplete="off"> </div> <div class="form-group" style="height:70px;"> <input class="form-control" id="password" type="password" name="password" data-rule="required;password" placeholder="密码" autocomplete="off"> </div> <div class="codeBox" style="height:70px;"> <div class="form-group" style="height:70px; width:205px; float: left;"> <input type="text" name="captcha" class="form-control" placeholder="验证码" data-rule="required;length(4)" /> </div> <span class="input-group-btn" style="padding:0;border:none;"> <img src="/captcha.html" width="100" height="45" onclick="this.src = '/captcha.html?r=' + Math.random();"/> </span> </div> <div class="other"> <a href="#" class="forgetPwd aGray" onclick="$('.loginInfo').hide();$('.passwordForget').show();" title="忘记密码">忘记密码</a> </div> <div class="loginBtn mt25"> <button type="submit">登录</button> </div> </form> </div> <div class="selfTabCont registerFormBox" style="display: none;"> <form name="form1" id="register-form" class="form-vertical form" method="POST" action="/index/user/register"> <input type="hidden" name="invite_user_id" value="0"/> <input type="hidden" name="url" value="//www.17golang.com/article/179269.html"/> <input type="hidden" name="__token__" value="2157ff3a3489c7b55936eda40672032c" /> <div class="form-group" style="height:70px;"> <input type="text" name="email" id="email2" data-rule="required;email" class="form-control" placeholder="邮箱"> </div> <div class="form-group" style="height:70px;"> <input type="text" id="username" name="username" data-rule="required;username" class="form-control" placeholder="用户名必须3-30个字符"> </div> <div class="form-group" style="height:70px;"> <input type="password" id="password2" name="password" data-rule="required;password" class="form-control" placeholder="密码必须6-30个字符"> </div> <div class="codeBox" style="height:70px;"> <div class="form-group" style="height:70px; width:205px; float: left;"> <input type="text" name="captcha" class="form-control" placeholder="验证码" data-rule="required;length(4)" /> </div> <span class="input-group-btn" style="padding:0;border:none;"> <img src="/captcha.html" width="100" height="45" onclick="this.src = '/captcha.html?r=' + Math.random();"/> </span> </div> <div class="loginBtn"> <button type="submit">注册</button> </div> </form> </div> </div> </div> <div class="beforeLoginTip">登录即同意 <a href="https://www.17golang.com/about/3.html" target="_blank" class="aBlue" title="用户协议">用户协议</a> 和 <a href="https://www.17golang.com/about/4.html" target="_blank" class="aBlue" title="隐私政策">隐私政策</a></div> </div> <!-- 重置密码 --> <div class="loginInfo passwordForget"> <div class="closeIcon" onclick="$('.popupBg').hide();"></div> <div class="returnLogin cursorPointer" onclick="$('.passwordForget').hide();$('.passwordLogin').show();">返回登录</div> <div class="passwordInfo"> <ul class="logintabs selfTabMenu"> <li class="selfTabItem">重置密码</li> </ul> <div class="selfTabContBox"> <div class="selfTabCont"> <form id="resetpwd-form" class="form-horizontal form-layer nice-validator n-default n-bootstrap form" method="POST" action="/api/user/resetpwd.html" novalidate="novalidate"> <div style="height:70px;"> <input type="text" class="form-control" id="email" name="email" value="" placeholder="输入邮箱" aria-invalid="true"> </div> <div class="codeBox" style="height:70px;"> <div class="form-group" style="height:70px; width:205px; float: left;"> <input type="text" name="captcha" class="form-control" placeholder="验证码" /> </div> <span class="input-group-btn" style="padding:0;border:none;"> <a href="javascript:;" class="btn btn-primary btn-captcha cursorPointer" style="background: #2080F8; border-radius: 4px; color: #fff; padding: 12px; position: absolute;" data-url="/api/ems/send.html" data-type="email" data-event="resetpwd">发送验证码</a> </span> </div> <input type="password" class="form-control" id="newpassword" name="newpassword" value="" placeholder="请输入6-18位密码"> <div class="loginBtn mt25"> <button type="submit">重置密码</button> </div> </form> </div> </div> </div> </div> </div> </div> <script src="/assets/js/juejin-theme.js?v=20260613b" defer></script> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?e34c3e8ab31ba35d7e1c48ea8d77315f"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> <script src="/assets/js/frontend/common.js"></script> </body> </html>