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

@ophiuchus/notify

v1.0.1

Published

### 介绍

Downloads

2

Readme

Notify 消息提示

介绍

在页面顶部展示消息提示,支持函数调用和组件调用两种方式。

函数调用

Notify 是一个函数,调用后会直接在页面中弹出相应的消息提示。

import Notify from '@ophiuchus/notify';

Notify('通知内容');

组件调用

通过组件调用 Notify 时,可以通过下面的方式进行注册:

import Vue from 'vue';
import Notify from '@ophiuchus/notify';

// 全局注册
Vue.use(Notify);

// 局部注册
export default {
  components: {
    [Notify.Component.name]: Notify.Component,
  },
};

代码演示

基础用法

Notify('通知内容');

通知类型

支持 primarysuccesswarningdanger 四种通知类型,默认为 danger

// 主要通知
Notify({ type: 'primary', message: '通知内容' });

// 成功通知
Notify({ type: 'success', message: '通知内容' });

// 危险通知
Notify({ type: 'danger', message: '通知内容' });

// 警告通知
Notify({ type: 'warning', message: '通知内容' });

自定义通知

自定义消息通知的颜色和展示时长。

Notify({
  message: '自定义颜色',
  color: '#ad0000',
  background: '#ffe1e1',
});

Notify({
  message: '自定义时长',
  duration: 1000,
});

全局方法

引入 Notify 组件后,会自动在 Vue 的 prototype 上挂载 $notify 方法,便于在组件内调用。

export default {
  mounted() {
    this.$notify('提示文案');
  },
};

组件调用

如果需要在 Notify 内嵌入组件或其他自定义内容,可以使用组件调用的方式。

<sf-button type="primary" text="组件调用" @click="showNotify" />
<sf-notify v-model="show" type="success">
  <sf-icon name="bell" style="margin-right: 4px;" />
  <span>通知内容</span>
</sf-notify>
export default {
  data() {
    return {
      show: false,
    };
  },
  methods: {
    showNotify() {
      this.show = true;
      setTimeout(() => {
        this.show = false;
      }, 2000);
    },
  },
};

API

方法

| 方法名 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | | Notify | 展示提示 | options | message | notify 实例 | | Notify.clear | 关闭提示 | - | void | | Notify.setDefaultOptions | 修改默认配置,对所有 Notify 生效 | options | void | | Notify.resetDefaultOptions | 重置默认配置,对所有 Notify 生效 | - | void |

Options

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | type | 类型,可选值为 primary success warning | string | danger | | message | 展示文案,支持通过\n换行 | string | - | | duration | 展示时长(ms),值为 0 时,notify 不会消失 | number | string | 3000 | | color | 字体颜色 | string | white | | background | 背景颜色 | string | - | | className | 自定义类名 | any | - | | onClick | 点击时的回调函数 | Function | - | | onOpened | 完全展示后的回调函数 | Function | - | | onClose | 关闭时的回调函数 | Function | - |

样式变量

组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考主题定制

| 名称 | 默认值 | 描述 | | -------------------------------- | ------------------------- | ---- | | @notify-text-color | @white | - | | @notify-padding | @padding-xs @padding-md | - | | @notify-font-size | @font-size-md | - | | @notify-line-height | @line-height-md | - | | @notify-primary-background-color | @blue | - | | @notify-success-background-color | @green | - | | @notify-danger-background-color | @red | - | | @notify-warning-background-color | @orange | - |