vue3-arct 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +42 -30
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,48 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
import CryptoJS from 'crypto-js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const SECRET_KEY = 'your-secret-key';
|
|
3
|
+
const SECRET_KEY = 'KRkwV3zZ';
|
|
5
4
|
|
|
6
|
-
// 从localStorage获取AccessToken
|
|
7
5
|
function getAccessToken() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const counter = JSON.parse(localStorage.getItem('counter'));
|
|
7
|
+
if (counter && counter.setting && counter.setting.AccessToken) {
|
|
8
|
+
return counter.setting.AccessToken;
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
// 获取项目运行的域名
|
|
16
13
|
function getDomain() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
if (window.location.hostname === 'localhost') {
|
|
15
|
+
return 'localhost';
|
|
16
|
+
}
|
|
17
|
+
const host = window.location.hostname;
|
|
18
|
+
return host;
|
|
22
19
|
}
|
|
23
20
|
|
|
24
|
-
// 使用AES解密AccessToken
|
|
25
21
|
function decryptAccessToken(encryptedToken, secretKey) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const bytes = CryptoJS.AES.decrypt(encryptedToken, secretKey);
|
|
23
|
+
const decryptedToken = bytes.toString(CryptoJS.enc.Utf8);
|
|
24
|
+
return decryptedToken;
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
function vdata() {
|
|
28
|
+
// 在页面加载完成后10秒执行
|
|
29
|
+
setTimeout(() => {
|
|
33
30
|
const accessToken = getAccessToken();
|
|
31
|
+
const domain = getDomain();
|
|
32
|
+
|
|
33
|
+
// 如果在localhost环境下,不进行验证和刷新操作
|
|
34
|
+
if (domain === 'localhost') {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
34
38
|
if (!accessToken) {
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
window.location.reload();
|
|
40
|
+
return;
|
|
37
41
|
}
|
|
42
|
+
|
|
38
43
|
const decryptedToken = decryptAccessToken(accessToken, SECRET_KEY);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
window.location.href = 'https://orence.cn';
|
|
44
|
+
if (domain !== decryptedToken) {
|
|
45
|
+
window.location.href = 'https://hmh-ai.com';
|
|
42
46
|
}
|
|
47
|
+
}, 10000); // 10000毫秒即10秒
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function addAnalytics() {
|
|
51
|
+
const _hmt = _hmt || [];
|
|
52
|
+
(function() {
|
|
53
|
+
const hm = document.createElement("script");
|
|
54
|
+
hm.src = "https://hm.baidu.com/hm.js?472d15d5f38465434ca2c0e525672fb5";
|
|
55
|
+
const s = document.getElementsByTagName("script")[0];
|
|
56
|
+
s.parentNode.insertBefore(hm, s);
|
|
57
|
+
})();
|
|
43
58
|
}
|
|
44
59
|
|
|
45
|
-
|
|
46
|
-
module.exports = {
|
|
47
|
-
validateAccessToken
|
|
48
|
-
};
|
|
60
|
+
export { vdata, addAnalytics };
|