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

zg-message

v0.0.15

Published

```html <script src="path_of_zg-message/zg-message.umd.js"></script> <link rel="stylesheet" type="text/css" href="path_of_zg-message/style.min.css"> ```

Downloads

5

Readme

浏览器脚本引入

<script src="path_of_zg-message/zg-message.umd.js"></script>
<link rel="stylesheet" type="text/css" href="path_of_zg-message/style.min.css">

使用方式

window.$ZgMessage.info('消息')
window.$ZgMessage.success('成功')
window.$ZgMessage.warning('警告')
window.$ZgMessage.error('错误')
window.$ZgMessage.info({ content: '内容', type: 'info' })

npm方式引入

npm i zg-message

使用方式

// 引入库
import ZgMessage from 'zg-message'
// 引入样式文件
import 'zg-message/dist/style.css'

// 使用
ZgMessage.info('消息')
ZgMessage.success('成功')
ZgMessage.warning('警告')
ZgMessage.error('错误')
ZgMessage.info({ content: '内容', type: 'info' })

配置参数:

interface Options {
  /**
   * 消息类型
   */
  type: MessageType
  /**
   * 消息内容,可以是字符串,也可以是html节点
   * escapeMarkup配置为false时,字符串类型默认按照html内容渲染
   * escapeMarkup配置为ture时,字符串会作为纯字符串渲染
   */
  content?: string | Node
  /**
   * 时长,为0时为不自动消失;默认值:5000
   * @default 5000
   */
  duration?: number | undefined
  /**
   *
   */
  selector?: string | Node | undefined
  /**
   * 是否显示关闭图标,默认显示
   */
  close?: boolean | undefined
  /**
   * 垂直方向位置
   */
  gravity?: 'top' | 'bottom' | undefined
  /**
   * 水平方向位置
   */
  position?: 'left' | 'center' | 'right' | undefined
  /**
   * Announce the toast to screen readers
   * @default 'polite'
   */
  ariaLive?: 'off' | 'polite' | 'assertive' | undefined
  /**
   * 类名
   */
  className?: string | undefined
  /**
   * 聚焦阻止自动隐藏,默认阻止
   * @default true
   */
  stopOnFocus?: boolean | undefined
  /**
   * 隐藏回调
   */
  callback?: (() => void) | undefined
  /**
   * 点击回调
   */
  onClick?: (() => void) | undefined
  /**
   * 偏移
   */
  offset?: {
    x: number | string
    y: number | string
  } | undefined
  /**
   * 是否对content进行HTML 转义,默认为false,不转义(选择然按钮标签等标签)
   */
  escapeMarkup?: boolean | undefined
  /**
   * 样式
   */
  style?: CSSStyleDeclaration
  /**
   * 最早消息显示靠前,默认为true
   * @default true
   */
  oldestFirst?: boolean | undefined
}

方法:

/**
 * 配置默认选项
 * @param options 默认选项
 */
function setup(options: Partial<Options>)

// 显示消息,需要传入type类型
function message(options: Options)

// 显示info类型的消息,options中不需要type参数
function info(content: string | Node, options?: Options)

// 显示warning类型的消息,options中不需要type参数
function warning(content: string | Node, options?: Options)

// 显示success类型的消息,options中不需要type参数
function success(content: string | Node, options?: Options)

// 错误平台错误信息类型,从平台获取到的错误消息体内容类型
interface ErrorModelType {
  code?: number | string
  message: string
  // 帮助链接
  link?: string
  // 是否支持【不再提醒】
  isSetHide?: 0 | 1
  // 【不再提醒】时长
  hideTime?: number
}
// 显示error类型的消息,options中不需要type参数
function error(error?: string | Error | ErrorModelType, options?: Options)