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

vuetify-pro-dialog

v2.0.3

Published

functional components snackbar and dialog for vuetify

Downloads

24

Readme

Vuetify Pro Dialog

函数式调用Vuetify SnackbarDialog 的插件

查看演示

安装

安装依赖

  • Vue-Badge
  • Vuetify-Badge
# npm
npm i vuetify-pro-dialog -S
# yarn
yarn add vuetify-pro-dialog
# pnpm
pnpm add vuetify-pro-dialog

配置

import VuetifyProDialog, { InstallationOptions } from 'vuetify-pro-dialog'

// 额外配置,可选,text也可使用国际化函数
const actions: Omit<InstallationOptions, 'vuetify'> = {
  false: {},
  true: {},
  confirm: {
    false: {
      text: () => locale.i18nRender('dialog.cancel.text'),
      color: 'error'
    },
    true: {
      text: () => locale.i18nRender('dialog.ok.text'),
      color: 'primary'
    },
    width: 450
  },
  alert: {},
  prompt: {}
}

App.use(VuetifyProDialog, {
  vuetify,
  ...actions
})

i18n国际化

import { locale } from 'vuetify-pro-dialog'

locale.setMessage('en', {
  'dialog.cancel.text': 'cancel',
  'dialog.ok.text': 'ok'
})

locale.set('en_US')

国际化默认zh_CN和en_US两种,如需添加请属使用locale.setMessage函数

RTL

this.$vuetify.rtl = true
this.$dialog.setRTL(true) // 设置RTL必须调用setRTL函数,不然会还原

使用

Message

this.$dialog.message('这是一段信息')
this.$dialog.message.info('这是一段信息')
this.$dialog.message.success('这是一段信息')
this.$dialog.message.warning('这是一段信息')
this.$dialog.message.error('这是一段信息')

// 或使用
import { Message } from 'vuetify-pro-dialog'

Message.open('这是一段信息')
Message.info('这是一段信息')
Message.success('这是一段信息')
Message.warning('这是一段信息')
Message.error('这是一段信息')

更新message

this.$dialog.message('这是一段信息', { key: 'test' })
this.$dialog.message('这是第二段信息', { key: 'test' })

Notify

this.$dialog.notify('这是一段信息')
this.$dialog.notify.info('这是一段信息')
this.$dialog.notify.success('这是一段信息')
this.$dialog.notify.warning('这是一段信息')
this.$dialog.notify.error('这是一段信息')

// 或使用
import { Message } from 'vuetify-pro-dialog'

Message.notify.open('这是一段信息')
Message.notify.info('这是一段信息')
Message.notify.success('这是一段信息')
Message.notify.warning('这是一段信息')
Message.notify.error('这是一段信息')

Loading

const loading = this.$dialog.loading('加载中...')
setTimeout(() => { loading.close() }, 5000)

// 或使用
import { Message } from 'vuetify-pro-dialog'
const loading = Message.loading('加载中...')
setTimeout(() => { loading.close() }, 5000)

Comfirm

const res = await this.$dialog.comfirm('是否确认删除?')

// 或使用
import { MessageBox } from 'vuetify-pro-dialog'
const res = await MessageBox.comfirm('是否确认删除?')

Alert

const res = await this.$dialog.alert('是否确认删除?')

// 或使用
import { MessageBox } from 'vuetify-pro-dialog'
const res = await MessageBox.alert('是否确认删除?')

Prompt

const res = await this.$dialog.prompt('密码', {
  rules: [(v: string) => !!v || '请输入密码'],
  textFieldProps: { type: 'possword' },
  beforeClose: (text: string) => {
    // 异步操作放此处,必须返回promise, 返回true表示继续, false表示暂停错误
    return new Promise(resolve => {
      setTimeout(() => resolve(true), 2000)
    })
  }
})

// 或使用
import { MessageBox } from 'vuetify-pro-dialog'
const res = await MessageBox.prompt('密码', {
  rules: [(v: string) => !!v || '请输入密码'],
  textFieldProps: { type: 'possword' },
  beforeClose: (text: string) => {
    return new Promise(resolve => {
      setTimeout(() => resolve(true), 2000)
    })
  }
})

CloseAll

this.$dialog.message.closeAll() // 关闭所有message
this.$dialog.msgbox.closeAll() // 关闭所有messagebox

// 或使用
import { Message, MessageBox } from 'vuetify-pro-dialog'
Message.closeAll()
MessageBox.closeAll()