From 8e274ad3a2fa88571b769d563b4061e3f9bf0bad Mon Sep 17 00:00:00 2001 From: Rock070 Date: Fri, 1 Sep 2023 01:46:21 +0800 Subject: [PATCH] feat(plugin): set initial options by plugin, and override by useNoti() (#10) --- packages/core/src/components/Noti.vue | 12 +++++--- packages/core/src/composables/useNoti.ts | 9 +++--- .../core/src/composables/useNotiContext.ts | 18 ++++++++++++ packages/core/src/constant.ts | 4 +-- packages/core/src/plugins/noti.ts | 11 +++----- packages/core/src/types/index.ts | 5 ++-- playground/src/App.vue | 28 +++++++++++++++---- playground/src/main.ts | 10 ++++++- 8 files changed, 70 insertions(+), 27 deletions(-) create mode 100644 packages/core/src/composables/useNotiContext.ts diff --git a/packages/core/src/components/Noti.vue b/packages/core/src/components/Noti.vue index 6178d2c..83e1e25 100644 --- a/packages/core/src/components/Noti.vue +++ b/packages/core/src/components/Noti.vue @@ -1,8 +1,11 @@ @@ -29,10 +36,14 @@ function callNoti() {
- - +
+ + +
@@ -53,4 +64,9 @@ function callNoti() { .logo.vue:hover { filter: drop-shadow(0 0 2em #42b883aa); } +.button-group { + display: flex; + gap: 1em; + margin-top: 1em; +} diff --git a/playground/src/main.ts b/playground/src/main.ts index 05f7daa..ea0d640 100644 --- a/playground/src/main.ts +++ b/playground/src/main.ts @@ -1,6 +1,14 @@ import { NotiPlugin } from '@vue3-noti/core' +import type { NotiOptions } from '@vue3-noti/core' import { createApp } from 'vue' import './style.css' import App from './App.vue' -createApp(App).use(NotiPlugin).mount('#app') +const notiOptions: NotiOptions = { + message: 'Hello', + type: 'success', + duration: 1000, + position: 'top-right', +} + +createApp(App).use(NotiPlugin, notiOptions).mount('#app')