Pārlūkot izejas kodu

取消登录的提示改为静默登录

zhangyujun 3 gadi atpakaļ
vecāks
revīzija
cd213d6fdc
2 mainītis faili ar 5 papildinājumiem un 86 dzēšanām
  1. 0 81
      code.html
  2. 5 5
      src/route/guard.ts

+ 0 - 81
code.html

@@ -1,81 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
-    <meta charset="UTF-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Document</title>
-</head>
-
-<body>
-    <div>code:</div>
-    <div id="code"></div>
-    <button style="margin-top: 15px;">
-        <a
-            href="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx67ca1b8c9816ef28&redirect_uri=https://jpcj-h51.zzxcx.net/code.html&response_type=code&scope=snsapi_userinfo&state=LOGIN#wechat_redirect">
-            重新获取code</a>
-    </button>
-    <script>
-        function getAllUrlParams(urls) {
-            var url = urls || location.href
-            // 用JS拿到URL,如果函数接收了URL,那就用函数的参数。如果没传参,就使用当前页面的URL
-            var queryString = url ? url.split('?')[1] : window.location.search.slice(1);
-            // 用来存储我们所有的参数
-            var obj = {};
-            // 如果没有传参,返回一个空对象
-            if (!queryString) {
-                return obj;
-            }
-            // stuff after # is not part of query string, so get rid of it
-            queryString = queryString.split('#')[0];
-            // 将参数分成数组
-            var arr = queryString.split('&');
-            for (var i = 0; i < arr.length; i++) {
-                // 分离成key:value的形式
-                var a = arr[i].split('=');
-                // 将undefined标记为true
-                var paramName = a[0];
-                var paramValue = typeof (a[1]) === 'undefined' ? true : a[1];
-                if (paramName.match(/\[(\d+)?\]$/)) {
-                    // 如果paramName不存在,则创建key
-                    var key = paramName.replace(/\[(\d+)?\]/, '');
-                    if (!obj[key]) obj[key] = [];
-                    // 如果是索引数组 e.g. colors[2]
-                    if (paramName.match(/\[\d+\]$/)) {
-                        // 获取索引值并在对应的位置添加值
-                        var index = /\[(\d+)\]/.exec(paramName)[1];
-                        obj[key][index] = paramValue;
-                    } else {
-                        // 如果是其它的类型,也放到数组中
-                        obj[key].push(paramValue);
-                    }
-                } else {
-                    // 处理字符串类型
-                    if (!obj[paramName]) {
-                        // 如果如果paramName不存在,则创建对象的属性
-                        obj[paramName] = paramValue;
-                    } else if (obj[paramName] && typeof obj[paramName] === 'string') {
-                        // 如果属性存在,并且是个字符串,那么就转换为数组
-                        obj[paramName] = [obj[paramName]];
-                        obj[paramName].push(paramValue);
-                    } else {
-                        // 如果是其它的类型,还是往数组里丢
-                        obj[paramName].push(paramValue);
-                    }
-                }
-            }
-            return obj;
-        }
-        function getCode() {
-            if (getAllUrlParams()["code"]) {
-                document.getElementById("code").textContent = getAllUrlParams()["code"]
-            }
-        }
-        // console.log(getAllUrlParams()["code"])
-        //hello
-        getCode()
-    </script>
-</body>
-
-</html>

+ 5 - 5
src/route/guard.ts

@@ -14,11 +14,11 @@ const guard = (router: Router) => {
 		}
 		//监听到登陆事件
 		if (to.query.state === "LOGIN") {
-			const toast = Toast.loading({
-				duration: 0, // 持续展示 toast
-				forbidClick: true,
-				message: "登陆中",
-			});
+			// const toast = Toast.loading({
+			// 	duration: 0, // 持续展示 toast
+			// 	forbidClick: true,
+			// 	message: "登陆中",
+			// });
 			await useLogin(to.query);
 			// Toast("登录成功")
 			next("./")