main.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div style="height:100%">
  3. <Header></Header>
  4. <div class="container" v-if="isLogin" >
  5. <div class="container-left" :style="leftShow ? {width:0}:{width:'240px'}">
  6. <div :class="activeIndex == 0 ? 'container-left-top active' : 'container-left-top'" @click="activeIndex = 0">
  7. <img class="icon-img" :src="activeIndex == 0 ? img1 : img11" alt="教学中心" />教学中心
  8. </div>
  9. <div class="container-left-top" @click="dialogVisible = !dialogVisible">
  10. <span>
  11. <img class="icon-img" :src="img2" alt="AI 应用" />AI 应用
  12. <img v-if="dialogVisible" class="up" :src="img3" alt="up" />
  13. <img v-else class="up" :src="down" alt="down" />
  14. </span>
  15. </div>
  16. <transition name="fade">
  17. <div v-if="dialogVisible">
  18. <div :class="activeIndex == 1 ? 'container-left-top active' : 'container-left-top'" @click="clickSwitch(1)">
  19. 应用中心
  20. </div>
  21. <div :class="activeIndex == 2 ? 'container-left-top active' : 'container-left-top'" @click="clickSwitch(2)">
  22. 创建应用
  23. </div>
  24. <!-- <div :class="activeIndex == 3 ? 'container-left-top active' : 'container-left-top'" @click="clickSwitch(3)">
  25. AI
  26. 应用精选</div> -->
  27. </div>
  28. </transition>
  29. <div class="container-left-show" :style="leftShow ? {width:'35px'}:{width:'240px'}" @click="leftShow = !leftShow">
  30. <img :src="shows" alt="">
  31. </div>
  32. </div>
  33. <div class="main" :style="leftShow ? {width:'100%'}:''" v-if="activeIndex == 0">
  34. <!-- <BannerVue></BannerVue> -->
  35. <CourseSelect></CourseSelect>
  36. <DemoCurourse />
  37. <resource></resource>
  38. <Practice></Practice>
  39. <!-- <other v-if="!isupdateCourse"></other> -->
  40. <Edu v-if="isLogin"></Edu>
  41. <Feedback></Feedback>
  42. </div>
  43. <div class="iframe" v-else-if="activeIndex == 1" v-loading="loading">
  44. <iframe ref="iframeRef1" :src="iframeRef1Url" frameborder="0"></iframe>
  45. </div>
  46. <div class="iframe" v-else-if="activeIndex == 2" v-loading="loading">
  47. <iframe ref="iframeRef2" :src="iframeRef2Url" frameborder="0"></iframe>
  48. <el-dialog v-model="iframeRef2Dialog" width="450" @close="clickSwitch(1)">
  49. <template #header="{ }">
  50. <div class="my-header">
  51. <h4 style="display: flex;align-items: center;color: #0354D7;font-weight: bold;"><img :src="info" alt="" style="margin-right: 5px;" />无权访问 !</h4>
  52. </div>
  53. </template>
  54. <div class="dialog-content">
  55. 暂无开通权限,请通过<span style="color: #0354D7;font-weight: bold;">“support@cocorobo.cc”</span>联系管理员。
  56. </div>
  57. <template #footer="{ }">
  58. <div class="dialog-footer" style="text-align: right;">
  59. <el-button @click="clickSwitch(1)">返回</el-button>
  60. <el-button type="primary" @click="copyEmail">复制邮箱</el-button>
  61. </div>
  62. </template>
  63. </el-dialog>
  64. </div>
  65. <div class="iframe" v-else-if="activeIndex == 3" v-loading="loading">
  66. <iframe ref="iframeRef" src="//app.cocorobo.cn/#/appSelection" frameborder="0"></iframe>
  67. </div>
  68. </div>
  69. </div>
  70. </template>
  71. <script setup>
  72. import { ref, watchEffect,onMounted } from 'vue';
  73. import img1 from '@/assets/icon/1.png'
  74. import img11 from '@/assets/icon/1-1.png'
  75. import img2 from '@/assets/icon/2.png'
  76. import img3 from '@/assets/icon/up.png'
  77. import down from '@/assets/icon/down.png'
  78. import info from '@/assets/icon/info.png'
  79. import shows from '@/assets/icon/show.png'
  80. import BannerVue from '@/components/main/banner.vue'
  81. import CourseSelect from '@/components/main/courseSelect.vue'
  82. import DemoCurourse from '@/components/main/demoCourse.vue'
  83. import resource from '@/components/main/resource.vue';
  84. import Practice from '@/components/main/Practice.vue';
  85. import other from '@/components/main/other.vue';
  86. import Edu from '@/components/main/edu.vue';
  87. import Feedback from '@/components/main/feedback.vue';
  88. import Header from './header.vue'
  89. import { userCurrentRole, userInfoStore } from '../stores/counter'
  90. const user = userInfoStore()
  91. const CurrentRole = userCurrentRole()
  92. const isupdateCourse = ref(false)
  93. const isLogin = ref(false)
  94. const activeIndex = ref(0)
  95. const dialogVisible = ref(true)
  96. const iframeRef = ref(null)
  97. const iframeRef1 = ref(null)
  98. const iframeRef2 = ref(null)
  99. const loading = ref(false)
  100. const iframeRef1Url = ref('')
  101. const iframeRef2Url = ref('')
  102. const iframeRef2Dialog = ref(false)
  103. const leftShow = ref(false)
  104. onMounted(() => {
  105. let timer = setInterval(() => {
  106. if(JSON.stringify(user.user) != "{}") {
  107. clickSwitch(1)
  108. clearInterval(timer)
  109. }
  110. }, 10);
  111. })
  112. watchEffect(() => {
  113. // console.log('111111111111',CurrentRole, user.user)
  114. if (JSON.stringify(user.user) != "{}") {
  115. isLogin.value = true
  116. 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) {
  117. isupdateCourse.value = true
  118. }
  119. }
  120. })
  121. const clickSwitch = (index) => {
  122. console.log('clickSwitch', activeIndex.value)
  123. if (index == 1 && activeIndex.value != 1) {
  124. loading.value = true
  125. iframeRef1Url.value = `//app.cocorobo.cn/#/appManagement?userid=${user.user.userid}&oid=${user.user.organizeid}&org=${user.user.org}&role=${user.user.role}`
  126. setTimeout(() => {
  127. iframeRef1.value.onload = () => {
  128. loading.value = false
  129. }
  130. }, 10)
  131. } else if (index == 3 && activeIndex.value != 3) {
  132. loading.value = true
  133. setTimeout(() => {
  134. iframeRef.value.onload = () => {
  135. loading.value = false
  136. }
  137. }, 10)
  138. } else if (index == 2 && activeIndex.value != 2) {
  139. loading.value = true
  140. iframeRef2Url.value = `//app.cocorobo.cn/#/AppList?userid=${user.user.userid}&oid=${user.user.organizeid}&org=${user.user.org}&role=${user.user.role}`
  141. setTimeout(() => {
  142. iframeRef2.value.onload = () => {
  143. loading.value = false
  144. }
  145. }, 10)
  146. }
  147. activeIndex.value = index
  148. }
  149. const copyEmail = () => {
  150. navigator.clipboard.writeText('support@cocorobo.cc').then(() => {
  151. console.log('复制成功');
  152. }).catch((error) => {
  153. console.error('复制失败:', error);
  154. });
  155. }
  156. const show = () => {
  157. console.log('show')
  158. }
  159. </script>
  160. <style lang="scss">
  161. .container {
  162. display: flex;
  163. overflow: hidden;
  164. align-items: center;
  165. .container-left {
  166. height: calc(100vh - 60px);
  167. width: 240px;
  168. background: #fff;
  169. overflow: hidden;
  170. padding-top: 15px;
  171. .container-left-top {
  172. margin: 0 10px 0 10px;
  173. font-size: 14px;
  174. color: #111;
  175. font-weight: 500;
  176. padding: 10px 0 10px 40px;
  177. position: relative;
  178. cursor: pointer;
  179. transition: all 0.7s ease 0ms;
  180. .icon-img {
  181. position: absolute;
  182. top: 10px;
  183. left: 15px;
  184. }
  185. .up {
  186. position: absolute;
  187. top: 15px;
  188. left: 140px;
  189. }
  190. div {
  191. background-color: #fff;
  192. padding: 5px 0;
  193. color: #00000099;
  194. }
  195. }
  196. .container-left-show{
  197. width: 240px;
  198. position: fixed;
  199. bottom: 0;
  200. left: 0;
  201. border: 1px solid #E7E7E7;
  202. cursor: pointer;
  203. background-color: #fff;
  204. height: 35px;
  205. }
  206. }
  207. .main {
  208. background: #F0F2F5;
  209. padding: 20px 10%;
  210. width: calc(100% - 240px);
  211. height: calc(100vh - 60px);
  212. overflow: auto;
  213. }
  214. .iframe {
  215. width: calc(100% - 150px);
  216. height: calc(100vh - 60px);
  217. position: relative;
  218. .el-overlay {
  219. position: absolute !important;
  220. .el-overlay-dialog {
  221. position: absolute !important;
  222. .el-dialog__header{
  223. text-align: left;
  224. }
  225. }
  226. }
  227. iframe {
  228. width: 100%;
  229. height: 100%;
  230. }
  231. }
  232. }
  233. .active {
  234. background: #F0F2F5;
  235. color: #0061FF !important;
  236. border-radius: 5px;
  237. }
  238. /* 渐入渐出动画 */
  239. .fade-enter-active,
  240. .fade-leave-active {
  241. transition: opacity 0.5s;
  242. }
  243. .fade-enter-from,
  244. .fade-leave-to {
  245. opacity: 0;
  246. }
  247. </style>