Преглед на файлове

设置减少循环时间-》减少等待时间

lifanagju_citu преди 10 месеца
родител
ревизия
72519ab868
променени са 2 файла, в които са добавени 6 реда и са изтрити 5 реда
  1. 1 1
      src/store/user.js
  2. 5 4
      src/views/recruit/personal/shareJob/sendResume/simple.vue

+ 1 - 1
src/store/user.js

@@ -75,7 +75,7 @@ export const useUserStore = defineStore('user',
           const api = this.loginType ? null : getBaseInfo
           if (!api) return
           const data = await api({ userId: userId || this.accountInfo.userId })
-          if (!data) return localStorage.setItem('baseInfo', JSON.stringify({ sex: null }))
+          if (!data) return localStorage.setItem('baseInfo', JSON.stringify('{}'))
           this.baseInfo = await this.getFieldText(data)
           localStorage.setItem('baseInfo', JSON.stringify(this.baseInfo))
         } catch (error) {

+ 5 - 4
src/views/recruit/personal/shareJob/sendResume/simple.vue

@@ -26,16 +26,17 @@ const info = ref(null)
 
 // 查询用户基本信息
 const timer = ref(null)
-timer.value = setInterval(() => { getUserInfoVerify() }, 1000)
+timer.value = setInterval(() => { getUserInfoVerify() }, 100)
 // 十秒后停止获取清除timer
 setTimeout(() => { if (!info.value) getUserInfoFail() }, 10000);
 
 // 查询用户基本信息
 const getUserInfoVerify = () => {
+  console.log('1', info.value)
   if (info.value) {
-    clearInterval(timer.value); timer.value = null
+    if (timer.value) clearInterval(timer.value); timer.value = null
     const keyArr = ['name', 'phone', 'jobStatus', 'expType', 'eduType'] // 必填人才信息
-    const simpleInfoReady = keyArr.every(e => info.value[e] && info.value[e] !== 0) // 校验必填人才信息
+    const simpleInfoReady = Object.keys(info.value).length && keyArr.every(e => info.value[e] && info.value[e] !== 0) // 校验必填人才信息
     if (simpleInfoReady) emit('simpleInfoReady') // 存在
     else {
       openDialog.value = true // 不存在
@@ -47,7 +48,7 @@ const getUserInfoVerify = () => {
 
 // 查询用户基本信息-失败 
 const getUserInfoFail = () => {
-  clearInterval(timer.value); timer.value = null
+  if (timer.value) clearInterval(timer.value); timer.value = null
   Snackbar.success(t('login.getUserInfoFailed')+','+t('login.loginAgain'))
 }