mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
36 lines
8.8 KiB
JavaScript
36 lines
8.8 KiB
JavaScript
import{_ as n,o as a,c as s,f as e}from"./app.005e0daf.js";const t={},p=e(`<h1 id="fesjs-plugin-watermark" tabindex="-1"><a class="header-anchor" href="#fesjs-plugin-watermark" aria-hidden="true">#</a> @fesjs/plugin-watermark</h1><h2 id="介绍" tabindex="-1"><a class="header-anchor" href="#介绍" aria-hidden="true">#</a> 介绍</h2><p>给页面添加水印效果</p><h2 id="启用方式" tabindex="-1"><a class="header-anchor" href="#启用方式" aria-hidden="true">#</a> 启用方式</h2><p>在 <code>package.json</code> 中引入依赖:</p><div class="language-json line-numbers-mode" data-ext="json"><pre class="language-json"><code><span class="token punctuation">{</span>
|
||
<span class="token property">"dependencies"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
|
||
<span class="token property">"@fesjs/fes"</span><span class="token operator">:</span> <span class="token string">"^3.0.0"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"@fesjs/plugin-watermark"</span><span class="token operator">:</span> <span class="token string">"^3.0.0"</span>
|
||
<span class="token punctuation">}</span>
|
||
<span class="token punctuation">}</span>
|
||
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="编译时配置" tabindex="-1"><a class="header-anchor" href="#编译时配置" aria-hidden="true">#</a> 编译时配置</h2><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
|
||
<span class="token literal-property property">watermark</span><span class="token operator">:</span> <span class="token punctuation">{</span>
|
||
<span class="token literal-property property">disabled</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">}</span><span class="token punctuation">;</span>
|
||
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="disabled" tabindex="-1"><a class="header-anchor" href="#disabled" aria-hidden="true">#</a> disabled</h3><p>是否禁用水印,默认是<code>false</code>。</p><p>可以在开发环境关闭水印:</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
|
||
<span class="token literal-property property">watermark</span><span class="token operator">:</span> <span class="token punctuation">{</span>
|
||
<span class="token literal-property property">disabled</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">}</span><span class="token punctuation">;</span>
|
||
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="api" tabindex="-1"><a class="header-anchor" href="#api" aria-hidden="true">#</a> API</h2><h3 id="createwatermark" tabindex="-1"><a class="header-anchor" href="#createwatermark" aria-hidden="true">#</a> createWatermark</h3><p>创建水印功能,通过 <code>@fesjs/fes</code> 导入 API:</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> createWatermark<span class="token punctuation">,</span> destroyWatermark <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@fesjs/fes'</span><span class="token punctuation">;</span>
|
||
|
||
<span class="token function">createWatermark</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token literal-property property">content</span><span class="token operator">:</span> <span class="token string">'我是水印'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 生成水印</span>
|
||
<span class="token function">destroyWatermark</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 销毁水印</span>
|
||
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>默认参数是:</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token punctuation">{</span>
|
||
<span class="token punctuation">(</span>content <span class="token operator">=</span> <span class="token string">'请勿外传'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">(</span>container <span class="token operator">=</span> document<span class="token punctuation">.</span>body<span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">(</span>width <span class="token operator">=</span> <span class="token number">300</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">(</span>height <span class="token operator">=</span> <span class="token number">300</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">(</span>textAlign <span class="token operator">=</span> <span class="token string">'center'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">(</span>textBaseline <span class="token operator">=</span> <span class="token string">'middle'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">(</span>fontSize <span class="token operator">=</span> <span class="token string">'14px'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">(</span>fontFamily <span class="token operator">=</span> <span class="token string">'Microsoft Yahei'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">(</span>fillStyle <span class="token operator">=</span> <span class="token string">'rgba(184, 184, 184, 0.3)'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">(</span>rotate <span class="token operator">=</span> <span class="token number">25</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">(</span>zIndex <span class="token operator">=</span> <span class="token number">99999</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">(</span>timestamp <span class="token operator">=</span> <span class="token string">'YYYY-MM-DD HH:mm'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
<span class="token punctuation">}</span>
|
||
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>如果不需要时间戳,则可以设置<code>timestamp</code>为<code>false</code>。</p>`,19),o=[p];function c(i,l){return a(),s("div",null,o)}const u=n(t,[["render",c],["__file","watermark.html.vue"]]);export{u as default};
|