zy1125 1 год назад
Родитель
Сommit
7bd05f7426
3 измененных файлов с 56 добавлено и 32 удалено
  1. 9 17
      src/App.vue
  2. 14 0
      src/request/api.js
  3. 33 15
      src/router/index.js

+ 9 - 17
src/App.vue

@@ -2,43 +2,35 @@
2
  * @Author: zy1125 1515706227@qq.com
2
  * @Author: zy1125 1515706227@qq.com
3
  * @Date: 2023-10-18 10:46:30
3
  * @Date: 2023-10-18 10:46:30
4
  * @LastEditors: zy1125 1515706227@qq.com
4
  * @LastEditors: zy1125 1515706227@qq.com
5
- * @LastEditTime: 2023-12-20 18:51:36
5
+ * @LastEditTime: 2023-12-22 14:46:51
6
  * @FilePath: \v3_yyz\src\App.vue
6
  * @FilePath: \v3_yyz\src\App.vue
7
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
7
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8
 -->
8
 -->
9
 
9
 
10
 <template >
10
 <template >
11
-      <router-view />
11
+    <router-view />
12
     <!-- <UeVideo /> -->
12
     <!-- <UeVideo /> -->
13
 </template>
13
 </template>
14
 <script >
14
 <script >
15
-import { ref,onBeforeMount } from "vue";
15
+import { ref, onBeforeMount } from "vue";
16
 import { useRouter } from 'vue-router'
16
 import { useRouter } from 'vue-router'
17
 
17
 
18
+
19
+
18
 // import login from '/''
20
 // import login from '/''
19
 export default ({
21
 export default ({
20
     setup() {
22
     setup() {
21
-         //首先在setup中定义
23
+        //首先在setup中定义
22
         const router = useRouter()
24
         const router = useRouter()
23
 
25
 
24
-    
25
-
26
-
27
-        onBeforeMount(() => {
28
-
29
-            let urlA = location.href.indexOf('ticket')
30
-            if (urlA==-1) {
31
-                router.push('/login')
32
-            }
33
-
34
-        })
26
+     
35
 
27
 
36
         return {
28
         return {
37
-           
29
+
38
         }
30
         }
39
     }
31
     }
40
 })
32
 })
41
-    
33
+
42
 
34
 
43
 
35
 
44
 
36
 

+ 14 - 0
src/request/api.js

@@ -1,3 +1,11 @@
1
+/*
2
+ * @Author: zy1125 1515706227@qq.com
3
+ * @Date: 2023-10-18 10:46:30
4
+ * @LastEditors: zy1125 1515706227@qq.com
5
+ * @LastEditTime: 2023-12-22 14:06:54
6
+ * @FilePath: \v3_yyz\src\request\api.js
7
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8
+ */
1
 
9
 
2
 import { service, post } from './http'
10
 import { service, post } from './http'
3
 
11
 
@@ -20,3 +28,9 @@ export const getvideo = (data) => service.post("/camera/getUrl",data)
20
 export const getClassDetail = (deviceCode) => service.get(`/wisdomClass/deviceDetail/${deviceCode}`)
28
 export const getClassDetail = (deviceCode) => service.get(`/wisdomClass/deviceDetail/${deviceCode}`)
21
 
29
 
22
 export const getVideoUrl = (data) => service.post(`/camera/getUrl`, data)
30
 export const getVideoUrl = (data) => service.post(`/camera/getUrl`, data)
31
+
32
+//单点登录ticket校验
33
+export const getvalidateLogin = (params) => service.get(`/wisdomClass/validateLogin`, {params})
34
+
35
+
36
+

+ 33 - 15
src/router/index.js

@@ -1,19 +1,20 @@
1
 import { createRouter, createWebHashHistory } from 'vue-router'
1
 import { createRouter, createWebHashHistory } from 'vue-router'
2
 import Home from '../components/UeVideo.vue'
2
 import Home from '../components/UeVideo.vue'
3
 import Login from '../components/Login.vue'
3
 import Login from '../components/Login.vue'
4
+import { getvalidateLogin } from '../request/api'
4
 
5
 
5
 const routes = [
6
 const routes = [
6
- 
7
-    {
8
-        path: '/',
9
-        name: 'Home',
10
-        component: Home
11
-    },
12
-    {
13
-      path: '/login',
14
-      name: 'Login',
15
-      component: Login
16
-    }
7
+
8
+  {
9
+    path: '/',
10
+    name: 'Home',
11
+    component: Home
12
+  },
13
+  {
14
+    path: '/login',
15
+    name: 'Login',
16
+    component: Login
17
+  }
17
 ]
18
 ]
18
 
19
 
19
 const router = createRouter({
20
 const router = createRouter({
@@ -22,13 +23,30 @@ const router = createRouter({
22
 })
23
 })
23
 
24
 
24
 
25
 
25
-router.beforeEach(function(to, from, next) {
26
+router.beforeEach(function (to, from, next) {
26
 
27
 
27
   let urlA = location.href.indexOf('ticket')
28
   let urlA = location.href.indexOf('ticket')
28
-  if (urlA==-1) {
29
-      if (to.path == '/') {
30
-          return next('/login')
29
+  if (urlA == -1) {
30
+    if (to.path == '/') {
31
+      return next('/login')
32
+    }
33
+  } else {
34
+    const url = window.location.href;
35
+    const paramStr = url.split("?")[1].split("#")[0];
36
+    console.log('sadasd' ,paramStr);
37
+    let query = {
38
+      casLoginUrl: "https://cas.huanghuai.edu.cn/cas/serviceValidate?ticket=" + paramStr + '&service=weizhi.huanghuai.edu.cn/xyyzioc/#/'
39
+    }
40
+    console.log('aslddddd',query);
41
+    getvalidateLogin(query).then(res => {
42
+      console.log('yzzzzzzz',res);
43
+
44
+      if (res.code == -1) {
45
+        window.location.href='https://weizhi.huanghuai.edu.cn/xyyzioc/#/login'
31
       }
46
       }
47
+
48
+    })
49
+
32
   }
50
   }
33
   next()
51
   next()
34
 })
52
 })