headerRight.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="header_right">
  3. <div>
  4. <el-button @click="goBack()">返回人工智能专栏</el-button>
  5. </div>
  6. <div v-if="isLogin" class="loginAdmin">
  7. <div v-if="admin">
  8. <img src="" alt="">
  9. <!-- <span>管理后台</span> -->
  10. <router-link to="" @click="adminClick()"><span>管理后台</span></router-link>
  11. </div>
  12. <div>
  13. <img src="" alt="">
  14. <span>{{ userName }}</span>
  15. </div>
  16. </div>
  17. <div v-else>
  18. <!-- <el-button @click="studentLogin()">学生登录</el-button> -->
  19. <el-button @click="linkLogin()">教师登录</el-button>
  20. </div>
  21. </div>
  22. </template>
  23. <script setup>
  24. import { ref, onMounted, watchEffect } from "vue"
  25. import { userCurrentRole,userInfoStore } from '../../stores/counter'
  26. const user = userInfoStore()
  27. const isLogin = ref(false)
  28. const admin = ref(false)
  29. const userName = ref('')
  30. const CurrentRole = userCurrentRole()
  31. const linkLogin = () => {
  32. top.location.href = `http://szedutest.changyan.cn/thirdauth/oauth2/authorize?service=initService&scope=all&response_type=code&app_id=94c720f0634b4bad890dc9223de01166&redirect_uri=https://cloud.cocorobo.cn/testapi`
  33. }
  34. const adminClick = () => {
  35. console.log('admin')
  36. top.U.MD.D.I.openApplication('evaluate')
  37. }
  38. const goBack=()=>{
  39. top.location.href = "https://zy.szedu.cn/ai/"
  40. }
  41. watchEffect(() => {
  42. // console.log(user, 2222222222)
  43. if (JSON.stringify(user.user) != "{}") {
  44. isLogin.value = true
  45. userName.value = user.user.username
  46. if (CurrentRole.currentRole == "edupersonnel" || CurrentRole.currentRole == "areaAdministrator" || CurrentRole.currentRole == "userAdministrator" || CurrentRole.currentRole == "securityAuditor" || CurrentRole.currentRole == "schoolAdministrator" || CurrentRole.currentRole == "schoolSecurityAuditor" || CurrentRole.currentRole == "teacher" || user.user.type != 2) {
  47. admin.value = true
  48. }
  49. }
  50. })
  51. </script>
  52. <style scoped lang="scss">
  53. .header_right {
  54. display: flex;
  55. .loginAdmin {
  56. display: flex;
  57. }
  58. div {
  59. line-height: 60px;
  60. padding-right: 20px;
  61. img {
  62. vertical-align: middle;
  63. }
  64. span {
  65. padding: 10px;
  66. line-height: 60px;
  67. }
  68. .el-button {
  69. background: rgba(54, 129, 252, 1);
  70. color: #fff;
  71. }
  72. }
  73. }
  74. </style>