ray-template/docs/assets/reference_components_qr-code.md.BtXSFJtd.js

16 lines
6.5 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as i,o as a,c as n,a3 as e}from"./chunks/framework.BNdm2jZV.js";const E=JSON.parse('{"title":"二维码","description":"","frontmatter":{},"headers":[],"relativePath":"reference/components/qr-code.md","filePath":"reference/components/qr-code.md"}'),t={name:"reference/components/qr-code.md"};function p(l,s,h,k,d,r){return a(),n("div",null,[...s[0]||(s[0]=[e(`<h1 id="二维码" tabindex="-1">二维码 <a class="header-anchor" href="#二维码" aria-label="Permalink to &quot;二维码&quot;">​</a></h1><p>Ray Template 直接使用 <code>vue3-next-qrcode</code> 的 <code>Vue3NextQrcode</code>,公开实例类型为 <code>QRCodeInst</code>。组件演示和登录扫码占位页分别使用它。</p><div class="language-tsx vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">tsx</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { NButton } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;naive-ui&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { defineComponent, ref } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;vue&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { Vue3NextQrcode, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">type</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> QRCodeInst } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;vue3-next-qrcode&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> default</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> defineComponent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">({</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> setup</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">() {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> qr</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ref</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&lt;</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">QRCodeInst</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt;()</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> () </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=&gt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> &lt;&gt;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> &lt;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">Vue3NextQrcode</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ref</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{qr} </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">text</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;https://example.com/report&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> /&gt;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> &lt;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">NButton</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> onClick</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=&gt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> qr.value?.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">downloadQRCode</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()}&gt;下载&lt;/</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">NButton</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> &lt;/&gt;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> )</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">})</span></span></code></pre></div><p><code>text</code> 设置内容,默认可随内容变化重绘。<code>logoImage</code>、<code>backgroundImage</code>、<code>gifBackgroundURL</code>、<code>dotScale</code>、<code>colorDark</code> 可调整样式。带背景的二维码要实际扫码检查清晰度,远程素材还受跨域和浏览器加载限制。</p><p><code>status</code> 可显示 <code>loading</code>、<code>error</code> 等状态,<code>onReload</code> 在重试时通知调用方。<code>downloadQRCode()</code> 等到实例挂载后调用。二维码只表达数据,生成成功与扫码认证成功是两回事;登录需要业务后端签发和验证对应凭据。</p><p><a href="https://github.com/XiaoDaiGua-Ray/ray-template/blob/403fdd589abbe37b38e1240d34f8daf2a60d3690/apps/admin/src/views/demo/qrcode/index.tsx" target="_blank" rel="noreferrer">二维码示例</a> · <a href="https://github.com/XiaoDaiGua-Ray/ray-template/blob/403fdd589abbe37b38e1240d34f8daf2a60d3690/apps/admin/src/views/login/components/QRCodeSigning/index.tsx" target="_blank" rel="noreferrer">登录页扫码入口</a></p>`,6)])])}const c=i(t,[["render",p]]);export{E as __pageData,c as default};