diff --git a/src/views/home/index.vue b/src/views/home/index.vue index 36776c3..6d62c27 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -15,7 +15,7 @@
  • 登录账号
    {{ userData.username }}
  • 用户昵称
    {{ userData.name }}
  • 手机号
    {{ userData.phone }}
  • -
  • 当前账户时长
    {{ userData.remainingTimes }} (秒)
  • +
  • 当前账户时长
    {{ userData.remainingTimes }} (秒)
  • 安全设置
    @@ -62,32 +62,24 @@ const userData = ref({ isAdmin: '', localDeploy: '' }); -function getUserFn() { - getUser().then(res => { - userData.value = res.data - localStorage.setItem("username", res.data.username); - localStorage.setItem("isAdmin", res.data.isAdmin); // isAdmin=1,为管理人员(邃芒后台) , isAdmin=0,为API接入方登录后台 isAmin=1&&localDeploy=true,就是私有化部署的管理后台 - - if (res.data.isAdmin === 1 && res.data.localDeploy || res.data.isAdmin === 0) { - getTime() - } - }) -} -function localDeployFn() { - localDeployApi().then(res => { - userData.value.localDeploy = res.data - localStorage.setItem("localDeploy", res.data); - }) -} +const localDeploy = ref('') +const getData = async () => { + let userRes = await getUser() + let localDeployRes = await localDeployApi() + userData.value = userRes.data + localStorage.setItem("username", userRes.data.username); + localStorage.setItem("isAdmin", userRes.data.isAdmin); // isAdmin=1,为管理人员(邃芒后台) , isAdmin=0,为API接入方登录后台 isAmin=1&&localDeploy=true,就是私有化部署的管理后台 + userData.value.localDeploy = localDeployRes.data + localDeploy.value = localDeployRes.data + localStorage.setItem("localDeploy", localDeployRes.data); // 当前账户时长 -async function getTime() { - let res = userData.isAdmin === 1 && userData.localDeploy ? await privateDeployAdminCurrent() : await current() - userData.value.remainingTimes = res.data.remainingTimes + let res = userData.isAdmin === 1 && localDeploy ? await privateDeployAdminCurrent() : await current() + userData.value.remainingTimes = res.data.remainingTimes + } onMounted(async () => { - await getUserFn() - await localDeployFn() + getData() });