@jx3box/jx3box-vue3-ui 1.1.3 → 1.1.5
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/package.json +2 -2
- package/service/header.js +8 -1
- package/src/Header.vue +81 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jx3box/jx3box-vue3-ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "JX3BOX Vue3 UI",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@jx3box/jx3box-data": "^3.8.9",
|
|
31
31
|
"@jx3box/jx3box-emotion": "^1.2.14",
|
|
32
32
|
"@jx3box/jx3box-macro": "^1.0.1",
|
|
33
|
-
"@jx3box/jx3box-talent": "^1.3.
|
|
33
|
+
"@jx3box/jx3box-talent": "^1.3.10",
|
|
34
34
|
"@jx3box/reporter": "^0.0.4",
|
|
35
35
|
"@tinymce/tinymce-vue": "^5.1.1",
|
|
36
36
|
"@vueuse/core": "^9.13.0",
|
package/service/header.js
CHANGED
|
@@ -28,4 +28,11 @@ function getGames() {
|
|
|
28
28
|
return axios.get(JX3BOX.__dataPath + "data/product/games.json");
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
// 获取全局配置
|
|
32
|
+
function getGlobalConfig() {
|
|
33
|
+
return axios.get(`${JX3BOX.__ossRoot}config/global.json`).then((res) => {
|
|
34
|
+
return res.data;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { getMsg, getNav, getPanel, getBox, getMenu, getGames, getGlobalConfig };
|
package/src/Header.vue
CHANGED
|
@@ -38,6 +38,8 @@ import user from "./header/User.vue";
|
|
|
38
38
|
import Box from "../src/Box.vue";
|
|
39
39
|
import { isMiniProgram, miniprogramHack } from "@jx3box/jx3box-common/js/utils";
|
|
40
40
|
import miniprogram from "@jx3box/jx3box-common/data/miniprogram.json";
|
|
41
|
+
import User from "@jx3box/jx3box-common/js/user";
|
|
42
|
+
import { getGlobalConfig } from "../service/header.js";
|
|
41
43
|
|
|
42
44
|
export default {
|
|
43
45
|
name: "CommonHeader",
|
|
@@ -54,21 +56,29 @@ export default {
|
|
|
54
56
|
},
|
|
55
57
|
},
|
|
56
58
|
methods: {
|
|
59
|
+
// webView检测
|
|
57
60
|
// webView检测
|
|
58
61
|
checkIsWebView: function () {
|
|
59
62
|
if (window.navigator.userAgent.includes(KW)) {
|
|
60
63
|
document.documentElement.classList.add("env-app");
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
67
|
+
const from = urlParams.get("from");
|
|
68
|
+
from && sessionStorage.setItem("from", from);
|
|
63
69
|
if (isMiniProgram()) {
|
|
64
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
65
70
|
const appid = urlParams.get("appid");
|
|
66
71
|
const item = miniprogram?.find((item) => item.appid === appid);
|
|
72
|
+
const from = urlParams.get("_from");
|
|
67
73
|
|
|
68
74
|
document.documentElement.classList.add("v-miniprogram");
|
|
69
75
|
|
|
76
|
+
if (from) {
|
|
77
|
+
document.documentElement.classList.add("from-" + from);
|
|
78
|
+
}
|
|
79
|
+
|
|
70
80
|
if (appid && item) {
|
|
71
|
-
document.documentElement.classList.add("env-miniprogram" + item.id);
|
|
81
|
+
document.documentElement.classList.add("env-miniprogram-" + item.id);
|
|
72
82
|
|
|
73
83
|
window.JX3BOX_ENV = item.id?.toUpperCase() + "_MINIPROGRAM";
|
|
74
84
|
} else {
|
|
@@ -80,11 +90,80 @@ export default {
|
|
|
80
90
|
miniprogramHack();
|
|
81
91
|
}
|
|
82
92
|
}
|
|
93
|
+
|
|
94
|
+
// 如果来自推栏
|
|
95
|
+
if (sessionStorage.getItem("from") == 'tl') {
|
|
96
|
+
document.documentElement.classList.add("v-miniprogram");
|
|
97
|
+
}
|
|
98
|
+
|
|
83
99
|
},
|
|
84
100
|
|
|
85
101
|
// 检查
|
|
86
102
|
init: function () {
|
|
87
103
|
this.checkIsWebView();
|
|
104
|
+
|
|
105
|
+
const token = this.getUrlParam("__token");
|
|
106
|
+
|
|
107
|
+
token && localStorage.setItem("__token", token);
|
|
108
|
+
|
|
109
|
+
if (User.isLogin()) {
|
|
110
|
+
this.loadAsset();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 获取全局配置
|
|
114
|
+
getGlobalConfig().then(async (res) => {
|
|
115
|
+
const global_token_version = res.token_version;
|
|
116
|
+
const token_version = localStorage.getItem("token_version");
|
|
117
|
+
|
|
118
|
+
if (User.isLogin()) {
|
|
119
|
+
// 对于没有token_version或者token_version不是最新的用户,都需要登出
|
|
120
|
+
if (!token_version || token_version != global_token_version) {
|
|
121
|
+
// 先保存最新的token_version
|
|
122
|
+
localStorage.setItem("token_version", global_token_version);
|
|
123
|
+
// 然后执行登出操作
|
|
124
|
+
User.destroy().then(() => {
|
|
125
|
+
this.$refs.user?.logout();
|
|
126
|
+
// 清除马甲所有马甲信息
|
|
127
|
+
let keys = Object.keys(localStorage);
|
|
128
|
+
let alternate = keys.filter((key) => key.startsWith("jx3box-alternate-"));
|
|
129
|
+
|
|
130
|
+
alternate.forEach((key) => {
|
|
131
|
+
localStorage.removeItem(key);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
if (
|
|
135
|
+
location.pathname.startsWith("/dashboard") ||
|
|
136
|
+
location.pathname.startsWith("/publish")
|
|
137
|
+
) {
|
|
138
|
+
location.href = this.siteRoot;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
// 非登录状态也更新token_version,确保用户下次登录时使用新版本
|
|
144
|
+
if (global_token_version) {
|
|
145
|
+
localStorage.setItem("token_version", global_token_version);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
getUrlParam(name) {
|
|
152
|
+
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
|
153
|
+
var r = window.location.search.substr(1).match(reg);
|
|
154
|
+
return r ? decodeURIComponent(r[2]) : null;
|
|
155
|
+
},
|
|
156
|
+
// 资产
|
|
157
|
+
loadAsset: function () {
|
|
158
|
+
User.getAsset().then((data) => {
|
|
159
|
+
this.asset = data;
|
|
160
|
+
|
|
161
|
+
const level = User.getLevel(this.asset?.experience);
|
|
162
|
+
|
|
163
|
+
if (level > 2) {
|
|
164
|
+
document.documentElement.classList.add("is-comment-show");
|
|
165
|
+
}
|
|
166
|
+
});
|
|
88
167
|
},
|
|
89
168
|
},
|
|
90
169
|
created: function () {
|