ソースを参照

添加单点登录

zy1125 1 年間 前
コミット
ae6b8e23d3
共有4 個のファイルを変更した85 個の追加26 個の削除を含む
  1. 8 0
      public/config.js
  2. 40 2
      src/App.vue
  3. 21 11
      src/components/Login.vue
  4. 16 13
      src/router/index.js

+ 8 - 0
public/config.js

@@ -1,3 +1,11 @@
1
+/*
2
+ * @Author: zy1125 1515706227@qq.com
3
+ * @Date: 2023-11-08 20:40:07
4
+ * @LastEditors: zy1125 1515706227@qq.com
5
+ * @LastEditTime: 2023-12-20 17:22:21
6
+ * @FilePath: \v3_yyz\public\config.js
7
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8
+ */
1 9
 window.g = {
2 10
     // 获取数据请求地址
3 11
     BASE_API: "https://test.lqkj.top//cmioc3-server",

+ 40 - 2
src/App.vue

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

+ 21 - 11
src/components/Login.vue

@@ -1,11 +1,20 @@
1
+<!--
2
+ * @Author: zy1125 1515706227@qq.com
3
+ * @Date: 2023-10-18 14:19:17
4
+ * @LastEditors: zy1125 1515706227@qq.com
5
+ * @LastEditTime: 2023-12-20 18:49:48
6
+ * @FilePath: \v3_yyz\src\components\Login.vue
7
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8
+-->
1 9
 <template>
2 10
     <div class="bg">
3
-      <div style="width: 100%;height: 50px;position: relative;top: 85vh ;z-index: 999;display: flex;align-items: center;justify-content: center;">
4
-        <div class="loginbutton"  @click="login">
5
-            <img :src="loginimg" alt="" style="">
6
-            <span> 登录</span>
11
+        <div
12
+            style="width: 100%;height: 50px;position: relative;top: 85vh ;z-index: 999;display: flex;align-items: center;justify-content: center;">
13
+            <div class="loginbutton" @click="login">
14
+                <img :src="loginimg" alt="" style="">
15
+                <span> 登录</span>
16
+            </div>
7 17
         </div>
8
-      </div>
9 18
 
10 19
     </div>
11 20
 </template>
@@ -17,15 +26,16 @@ import { useRouter } from 'vue-router'
17 26
 // import login from '/''
18 27
 export default ({
19 28
     setup() {
20
-         //首先在setup中定义
29
+        //首先在setup中定义
21 30
         const router = useRouter()
22 31
 
23 32
         const loginimg = ref("./img/login.png")
24 33
         const login = function () {
25
-            // window.open("https://cas.huanghuai.edu.cn/cas/")
26
-            //跳转路由到首页
27
-            router.push('/')
28
-            
34
+            // 跳转到指定的 URL 地址
35
+            location.href = "https://cas.huanghuai.edu.cn/cas/?service=https://weizhi.huanghuai.edu.cn/xyyzioc/#/"
36
+           
37
+    
38
+
29 39
         }
30 40
         return {
31 41
             loginimg,
@@ -38,7 +48,7 @@ export default ({
38 48
 
39 49
 <style scoped lang="scss">
40 50
 .bg {
41
- 
51
+
42 52
     position: absolute;
43 53
     box-sizing: border-box;
44 54
     // height: 200vw;

+ 16 - 13
src/router/index.js

@@ -3,15 +3,16 @@ import Home from '../components/UeVideo.vue'
3 3
 import Login from '../components/Login.vue'
4 4
 
5 5
 const routes = [
6
-    {
7
-        path: '/login',
8
-        name: 'Login',
9
-        component: Login
10
-      },
6
+ 
11 7
     {
12 8
         path: '/',
13 9
         name: 'Home',
14 10
         component: Home
11
+    },
12
+    {
13
+      path: '/login',
14
+      name: 'Login',
15
+      component: Login
15 16
     }
16 17
 ]
17 18
 
@@ -21,13 +22,15 @@ const router = createRouter({
21 22
 })
22 23
 
23 24
 
24
-// router.beforeEach(function(to, from, next) {
25
-//   if (!localStorage.getItem("myAdminToken")) {
26
-//       if (to.path !== '/login') {
27
-//           return next('/login')
28
-//       }
29
-//   }
30
-//   next()
31
-// })
25
+router.beforeEach(function(to, from, next) {
26
+
27
+  let urlA = location.href.indexOf('ticket')
28
+  if (urlA==-1) {
29
+      if (to.path == '/') {
30
+          return next('/login')
31
+      }
32
+  }
33
+  next()
34
+})
32 35
 
33 36
 export default router