Lijy 1 éve
szülő
commit
7f7e956f27

+ 14 - 4
fhKeeper/formulahousekeeper/customerBuler-crm/src/App.vue

@@ -5,6 +5,7 @@
 <script setup lang="ts">
 import { onMounted, ref, provide, inject } from 'vue'
 import { useStore } from '@/store/index'
+import { ElNotification } from 'element-plus'
 const { setAsyncRoutesMark } = useStore()
 window.addEventListener('beforeunload', () => beforeunloadFn())
 const beforeunloadFn = (() => {
@@ -12,12 +13,21 @@ const beforeunloadFn = (() => {
 })
 
 provide<GlobalPopup>('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 警告
+  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>
 

+ 1 - 6
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/login.vue

@@ -51,11 +51,6 @@ import { post } from "@/utils/request";
 import { LOGIN } from "./api";
 const { setRouters } = useStore()
 const router = useRouter();
-// type GlobalPopup = {
-//   showSuccess: (msg: string, time: number) => void
-//   showError: (msg: string, time: number) => void
-//   showWarning: (msg: string, time: number) => void
-// }
 const globalPopup = inject<GlobalPopup>('globalPopup')
 const ruleFormRef = ref<FormInstance>();
 const ruleForm = ref({
@@ -81,7 +76,7 @@ const login = (formEl: FormInstance | undefined) => {
     console.log(ruleForm.value);
     post(LOGIN, { ...ruleForm.value }).then(res => {
       console.log(res);
-      globalPopup?.showSuccess('登录成功',1000)
+      globalPopup?.showSuccess('登录成功', 1000, '')
       // if(res.code == 'error') {
       //   ElMessage.error({
       //     message: "登录失败",

+ 4 - 3
fhKeeper/formulahousekeeper/customerBuler-crm/src/type.d.ts

@@ -1,5 +1,6 @@
 type GlobalPopup = {
-  showSuccess: (msg: string, time: number) => void;
-  showError: (msg: string, time: number) => void;
-  showWarning: (msg: string, time: number) => void;
+  showSuccess: (msg: string, time: number, icon: string) => void;
+  showError: (msg: string, time: number, icon: string) => void;
+  showWarning: (msg: string, time: number, icon: string) => void;
+  showInfo: (msg: string, time: number, icon: string) => void;
 };