diff --git a/dev-dist/sw.js b/dev-dist/sw.js index 9101110..9e0f48b 100644 --- a/dev-dist/sw.js +++ b/dev-dist/sw.js @@ -82,7 +82,7 @@ define(['./workbox-b5f7729d'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "index.html", - "revision": "0.rijo4jsbfi8" + "revision": "0.f6gfohgemco" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { diff --git a/package-lock.json b/package-lock.json index 83b9d00..2b2fa04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "vue": "^3.4.29", "vue-material-design-icons": "^5.2.0", "vue-router": "^4.3.3", + "vue3-toastify": "^0.2.2", "workbox-precaching": "^7.1.0" }, "devDependencies": { @@ -8922,6 +8923,27 @@ "typescript": "*" } }, + "node_modules/vue3-toastify": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/vue3-toastify/-/vue3-toastify-0.2.2.tgz", + "integrity": "sha512-D8pmIp2UeU8MU1OY7GktA70HviZ38b1RagN82P7tFu3abUD86w+PjfmbdRch4QVtjVxK+eqKLvi5cXJRndwJfw==", + "workspaces": [ + "docs", + "playground" + ], + "engines": { + "node": ">=18.18.0", + "npm": ">=9.0.0" + }, + "peerDependencies": { + "vue": ">=3.2.0" + }, + "peerDependenciesMeta": { + "vue": { + "optional": true + } + } + }, "node_modules/w3c-xmlserializer": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", diff --git a/package.json b/package.json index 5e7b1f1..3f321fb 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "vue": "^3.4.29", "vue-material-design-icons": "^5.2.0", "vue-router": "^4.3.3", + "vue3-toastify": "^0.2.2", "workbox-precaching": "^7.1.0" }, "devDependencies": { diff --git a/src/plugins/index.ts b/src/plugins/index.ts index f80343f..69acc00 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -1,3 +1,4 @@ import { Api } from "./axios/api"; +import { showMessage } from "./toast/toastify"; -export { Api } \ No newline at end of file +export { Api, showMessage } \ No newline at end of file diff --git a/src/plugins/toast/toastify.ts b/src/plugins/toast/toastify.ts new file mode 100644 index 0000000..a5cc3ba --- /dev/null +++ b/src/plugins/toast/toastify.ts @@ -0,0 +1,28 @@ +import { toast } from "vue3-toastify"; + +/** + * Displays a toast notification with specified options. + * + * @param {string} message - The message to be displayed in the toast notification. It can contain HTML. + * @param {'success'|'error'|'info'|'warning'} type - The type of the toast notification. Defaults to 'default'. + * @param {number} time - The duration (in milliseconds) for which the toast should be visible. + * @param {'top-left'|'top-center'|'top-right'|'bottom-left'|'bottom-center'|'bottom-right'} position - The position of the toast notification on the screen. Defaults to 'top-right'. + * @param {'auto'|'light'|'dark'|'colored'} theme - The theme of the toast notification. Defaults to 'auto'. + * @param {boolean} bar - Determines if the progress bar should be visible. Defaults to false. + * + * @example + * showMessage('This is a success message', 'success', 3000, 'top-right', 'light', true); + */ +async function showMessage(message: any, type: any, time: number, position: any, theme: any, bar: boolean ) { + toast(message, { + "theme": theme || 'auto', + "type": type || 'default', + "position": position || 'top-right', + "pauseOnFocusLoss": false, + "autoClose": time, + "hideProgressBar": bar || false, + "dangerouslyHTMLString": true + }) +} + +export { showMessage } \ No newline at end of file