@jx3box/jx3box-ui 2.2.0 → 2.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jx3box/jx3box-ui",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "JX3BOX Vue3 UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -80,44 +80,53 @@ export default {
80
80
  methods: {
81
81
  // webView检测
82
82
  checkIsWebView: function () {
83
- if (window.navigator.userAgent.includes(KW)) {
84
- document.documentElement.classList.add("env-app");
85
- }
86
-
83
+ // 参数处理
87
84
  const urlParams = new URLSearchParams(window.location.search);
88
- const from = urlParams.get("from");
89
- from && sessionStorage.setItem("from", from);
90
- if (checkIsApp()) {
85
+
86
+ // 环境判断缓存
87
+ const isApp = checkIsApp();
88
+ const isMp = isMiniProgram();
89
+
90
+ // App 环境缓存
91
+ if (isApp) {
91
92
  localStorage.setItem("__env", "app");
92
93
  }
93
- if (isMiniProgram() || checkIsApp()) {
94
- const appid = urlParams.get("appid");
95
- const item = miniprogram?.find((item) => item.appid === appid);
96
- const from = urlParams.get("_from");
97
-
98
- document.documentElement.classList.add("v-miniprogram");
99
94
 
100
- if (from) {
101
- document.documentElement.classList.add("from-" + from);
102
- }
95
+ // 小程序环境缓存
96
+ if (isMp) {
97
+ document.documentElement.classList.add("wechat-miniprogram");
98
+ window.JX3BOX_ENV = "MINIPROGRAM";
99
+ miniprogramHack();
100
+ }
103
101
 
104
- if (appid && item) {
105
- document.documentElement.classList.add("env-miniprogram-" + item.id);
102
+ // 来源参数缓存
103
+ const from = urlParams.get("from")?.replace(/[^a-zA-Z0-9_-]/g, "");
104
+ if (from) {
105
+ sessionStorage.setItem("from", from);
106
+ document.documentElement.classList.add("from-" + from);
107
+ }
106
108
 
107
- window.JX3BOX_ENV = item.id?.toUpperCase() + "_MINIPROGRAM";
108
- } else {
109
- document.documentElement.classList.add("wechat-miniprogram");
109
+ // 如果来自推栏 App
110
+ if (sessionStorage.getItem("from") === "tl") {
111
+ document.documentElement.classList.add("v-miniprogram");
112
+ }
110
113
 
111
- window.JX3BOX_ENV = "MINIPROGRAM";
114
+ // 移动容器模式:包含小程序或 App 内嵌环境
115
+ if (isMp || isApp) {
116
+ document.documentElement.classList.add("v-miniprogram");
117
+ }
112
118
 
113
- // 微信小程序hack
114
- miniprogramHack();
115
- }
119
+ // 来自自身小程序
120
+ const appid = urlParams.get("appid");
121
+ const internalApp = miniprogram?.find((item) => item.appid === appid);
122
+ if (appid && internalApp) {
123
+ document.documentElement.classList.add("env-miniprogram-" + internalApp.id);
124
+ window.JX3BOX_ENV = internalApp.id?.toUpperCase() + "_MINIPROGRAM";
116
125
  }
117
126
 
118
- // 如果来自推栏
119
- if (sessionStorage.getItem("from") == "tl") {
120
- document.documentElement.classList.add("v-miniprogram");
127
+ // 仅安卓有效,基本不使用
128
+ if (window.navigator.userAgent.includes(KW)) {
129
+ document.documentElement.classList.add("env-app");
121
130
  }
122
131
  },
123
132
 
@@ -139,6 +139,10 @@ export default {
139
139
  if (["achievement", "item", "quest", "knowledge"].includes(this.post?.post_type)) {
140
140
  this.form.type = "wiki";
141
141
  }
142
+ // 当传入的 post 对象包含 subtype 字段时,优先使用 subtype 作为类型
143
+ if (this.post?.subtype) {
144
+ this.form.type = this.post.subtype;
145
+ }
142
146
  }
143
147
  this.loadLogs();
144
148
 
@@ -191,7 +195,7 @@ export default {
191
195
  },
192
196
  loadLogs() {
193
197
  if (!this.post?.ID) return;
194
- getDesignTask({ source_id: this.post?.ID }).then((res) => {
198
+ getDesignTask({ source_id: this.post?.ID, source_type: this.post?.post_type }).then((res) => {
195
199
  this.logs = res.data.data || [];
196
200
  });
197
201
  },