Sfoglia il codice sorgente

添加单点登录

zy1125 1 anno fa
parent
commit
ae6b8e23d3
4 ha cambiato i file con 85 aggiunte e 26 eliminazioni
  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
 window.g = {
9
 window.g = {
2
     // 获取数据请求地址
10
     // 获取数据请求地址
3
     BASE_API: "https://test.lqkj.top//cmioc3-server",
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
 <template >
10
 <template >
3
       <router-view />
11
       <router-view />
4
     <!-- <UeVideo /> -->
12
     <!-- <UeVideo /> -->
5
 </template>
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
 </script>
46
 </script>
9
 <style scoped>
47
 <style scoped>
10
 #app {
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
 <template>
9
 <template>
2
     <div class="bg">
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
         </div>
17
         </div>
8
-      </div>
9
 
18
 
10
     </div>
19
     </div>
11
 </template>
20
 </template>
@@ -17,15 +26,16 @@ import { useRouter } from 'vue-router'
17
 // import login from '/''
26
 // import login from '/''
18
 export default ({
27
 export default ({
19
     setup() {
28
     setup() {
20
-         //首先在setup中定义
29
+        //首先在setup中定义
21
         const router = useRouter()
30
         const router = useRouter()
22
 
31
 
23
         const loginimg = ref("./img/login.png")
32
         const loginimg = ref("./img/login.png")
24
         const login = function () {
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
         return {
40
         return {
31
             loginimg,
41
             loginimg,
@@ -38,7 +48,7 @@ export default ({
38
 
48
 
39
 <style scoped lang="scss">
49
 <style scoped lang="scss">
40
 .bg {
50
 .bg {
41
- 
51
+
42
     position: absolute;
52
     position: absolute;
43
     box-sizing: border-box;
53
     box-sizing: border-box;
44
     // height: 200vw;
54
     // height: 200vw;

+ 16 - 13
src/router/index.js

@@ -3,15 +3,16 @@ import Home from '../components/UeVideo.vue'
3
 import Login from '../components/Login.vue'
3
 import Login from '../components/Login.vue'
4
 
4
 
5
 const routes = [
5
 const routes = [
6
-    {
7
-        path: '/login',
8
-        name: 'Login',
9
-        component: Login
10
-      },
6
+ 
11
     {
7
     {
12
         path: '/',
8
         path: '/',
13
         name: 'Home',
9
         name: 'Home',
14
         component: Home
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
 export default router
36
 export default router