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.
Files changed (2) hide show
  1. package/index.js +42 -30
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,48 +1,60 @@
1
- const CryptoJS = require('crypto-js');
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
- const counter = JSON.parse(localStorage.getItem('counter'));
9
- if (counter && counter.setting && counter.setting.AccessToken) {
10
- return counter.setting.AccessToken;
11
- }
12
- return null;
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
- if (window.location.hostname === 'localhost') {
18
- return 'localhost';
19
- }
20
- const host = window.location.hostname;
21
- return host;
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
- const bytes = CryptoJS.AES.decrypt(encryptedToken, secretKey);
27
- const decryptedToken = bytes.toString(CryptoJS.enc.Utf8);
28
- return decryptedToken;
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
- function validateAccessToken() {
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
- window.location.reload();
36
- return;
39
+ window.location.reload();
40
+ return;
37
41
  }
42
+
38
43
  const decryptedToken = decryptAccessToken(accessToken, SECRET_KEY);
39
- const domain = getDomain();
40
- if (domain !== 'localhost' && domain !== decryptedToken) {
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-arct",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"