npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simple-water

v2.1.0

Published

一款用于生成水印的插件,使用简单,可以用在工程化的项目中,支持ts。

Downloads

5

Readme

simple-water

一款用于生成水印的JS插件,使用简单,支持TS

核心代码

  • 设置水印

    // 方式1:水印'admin' 将设置到整个html标签上
    setWaterMark('admin')
      
    // 方式2:水印'admin' 将设置到id为app的盒子上
    setWaterMark('admin', '#app')
      
    // 方式3:水印'admin' 将设置到div变量所指向的DOM盒子上
    const div = document.querySelector('#app')
    setWaterMark('admin', div)
  • 移除水印

    // 移除之前添加的水印
    removeWaterMark()

使用步骤

  1. 安装

    npm i simple-water
    或
    yarn add simple-water
    或
    pnpm add simple-water
  2. 导入

    import { setWaterMark  } from "simple-water";
  3. 使用(以vue3项目为例)

    <script setup lang="ts">
    import { onMounted } from "vue";
    import { setWaterMark  } from "simple-water";
       
    onMounted(()=>{
      setWaterMark('admin')
    })
    </script>

    呈现效果

    DEMO

配置对象

支持传递配置项进行配置setWaterMark(水印文本, DOM或选择器, 配置对象)

核心代码如下:

// 完整的配置对象,其中每个属性都是非必须的
const option = {
        blockWdith: 150,      // 每块宽度
        blockHeight: 80,      // 每块高度 
        rotate: 20,     	  // 文字倾斜角度
        font: "18px Vedana",  // 水印文字字体
        fillStyle: '#666666', // 水印文字颜色
        zIndex: 10000,        // 水印层级
    	opacity: 0.08         // 水印透明度
}

// 方式1:水印'admin' 将设置到整个html标签上
setWaterMark('admin', null, option)

// 方式2:水印'admin' 将设置到id为app的盒子上
setWaterMark('admin', '#app', option)

// 方式3:水印'admin' 将设置到div变量所指向的DOM盒子上
const div = document.querySelector('#app')
setWaterMark('admin', div, option)

其中option配置项可以写到一个.json的配置文件中再导入使用

仓库地址

gitee上的仓库地址:https://gitee.com/tang-lang/simple-water