|
@@ -5,24 +5,29 @@
|
|
|
<script setup lang="ts">
|
|
|
import { onMounted, ref, provide, inject } from 'vue'
|
|
|
import { useStore } from '@/store/index'
|
|
|
-interface GlobalPopup {
|
|
|
- showSuccess: (msg: string, time: number) => void
|
|
|
- showError: (msg: string, time: number) => void
|
|
|
- showWarning: (msg: string, time: number) => void
|
|
|
-}
|
|
|
+import { ElNotification } from 'element-plus'
|
|
|
const { setAsyncRoutesMark } = useStore()
|
|
|
window.addEventListener('beforeunload', () => beforeunloadFn())
|
|
|
const beforeunloadFn = (() => {
|
|
|
setAsyncRoutesMark(false)
|
|
|
})
|
|
|
|
|
|
-provide('globalPopup', {
|
|
|
- showSuccess: (msg: string, time: number) => { console.log(msg, '执行成功', time) }, //!SECTION 成功
|
|
|
- showError: (msg: string, time: number) => { console.log(msg, '执行成功'), time }, //!SECTION 失败
|
|
|
- showWarning: (msg: string, time: number) => { console.log(msg, '执行成功'), time }, //!SECTION 警告
|
|
|
+provide<GlobalPopup>('globalPopup', {
|
|
|
+ showSuccess: (msg: string, time: number, icon: string) => { notificationTiop }, //!SECTION 成功
|
|
|
+ showError: (msg: string, time: number, icon: string) => { notificationTiop }, //!SECTION 失败
|
|
|
+ showWarning: (msg: string, time: number, icon: string) => { notificationTiop }, //!SECTION 警告
|
|
|
+ showInfo: (msg: string, time: number, icon: string) => { notificationTiop }, //!SECTION 文本
|
|
|
})
|
|
|
|
|
|
-
|
|
|
+const notificationTiop = (msg: string, time: number, icon: string, type: string) => {
|
|
|
+ let obj: any = {}
|
|
|
+ obj.title = '提示'
|
|
|
+ obj.message = msg
|
|
|
+ time ? obj.duration = time : obj.duration = 2000
|
|
|
+ icon ? obj.iconClass = icon : obj.iconClass = ''
|
|
|
+ type ? obj.type = type : obj.type = 'success'
|
|
|
+ ElNotification(obj)
|
|
|
+}
|
|
|
|
|
|
</script>
|
|
|
|