@jx3box/jx3box-editor 1.5.6 → 1.5.8
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 +1 -1
- package/service/cms.js +7 -2
- package/service/resource.js +2 -2
- package/src/GameText.vue +106 -74
- package/src/components/Author.vue +46 -3
package/package.json
CHANGED
package/service/cms.js
CHANGED
|
@@ -17,5 +17,10 @@ function loadEmotions(params){
|
|
|
17
17
|
params: params
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
//获取装扮
|
|
21
|
+
function getDecoration(params) {
|
|
22
|
+
return $cms().get(`/api/cms/user/decoration`,{
|
|
23
|
+
params
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export { uploadFile, loadAuthors, loadEmotions,getDecoration };
|
package/service/resource.js
CHANGED
|
@@ -13,8 +13,8 @@ const $ = axios.create({
|
|
|
13
13
|
baseURL: 'http://localhost:7002/',
|
|
14
14
|
}) */
|
|
15
15
|
|
|
16
|
-
function getResource(
|
|
17
|
-
return $.
|
|
16
|
+
function getResource(type, ids, client = "std") {
|
|
17
|
+
return $.post(`/resource/${client}/${type}/`, { ids });
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export { getResource };
|
package/src/GameText.vue
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
getLink,
|
|
16
16
|
iconLink,
|
|
17
17
|
} from "@jx3box/jx3box-common/js/utils";
|
|
18
|
-
import { getResource } from "../service/resource";
|
|
18
|
+
import { getResource as getResourceFromNode } from "../service/resource";
|
|
19
19
|
import { escape } from "lodash";
|
|
20
20
|
|
|
21
21
|
export default {
|
|
@@ -117,101 +117,133 @@ export default {
|
|
|
117
117
|
/**
|
|
118
118
|
* 获取形如<BUFF 110 1 desc>, <ENCHANT 100>的资源字段并转换
|
|
119
119
|
*/
|
|
120
|
-
renderBuffResource: function () {
|
|
121
|
-
const matches = this.html
|
|
120
|
+
renderBuffResource: async function () {
|
|
121
|
+
const matches = this.html?.match(/<BUFF (\d+) (\d+) (.*?)>/gim);
|
|
122
122
|
if (!matches) return;
|
|
123
|
-
let
|
|
123
|
+
let resourceKeys = [];
|
|
124
|
+
let replaceMap = {};
|
|
124
125
|
//先统计需要的资源,减少请求数量
|
|
125
126
|
for (let match of matches) {
|
|
126
127
|
let [token, id, level, type] = match.match(
|
|
127
128
|
/<BUFF (\d+) (\d+) (.*?)>/i
|
|
128
129
|
);
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
need_replaces[buff_token].push({
|
|
134
|
-
token,
|
|
135
|
-
type,
|
|
136
|
-
});
|
|
130
|
+
resourceKeys.push(`${id}_${level}`);
|
|
131
|
+
if (level != 0) resourceKeys.push(`${id}_0`);
|
|
132
|
+
replaceMap[token] = [id, level, type];
|
|
137
133
|
}
|
|
138
|
-
|
|
139
|
-
for (let
|
|
140
|
-
let
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
134
|
+
await this.getAllResources("buff", resourceKeys, this.client);
|
|
135
|
+
for (let replace in replaceMap) {
|
|
136
|
+
let [id, level, type] = replaceMap[replace];
|
|
137
|
+
// 持续时间
|
|
138
|
+
if (type === "time") {
|
|
139
|
+
let interval;
|
|
140
|
+
let buff = this.getResource("buff", id, level);
|
|
141
|
+
if (buff["Interval"]) interval = buff["Interval"];
|
|
142
|
+
else interval = this.getResource("buff", id, 0)["Interval"];
|
|
143
|
+
if (!interval) {
|
|
144
|
+
console.log(replace, escape(replace));
|
|
145
|
+
this.html = this.html.replace(replace, escape(replace));
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
let time = interval / 16;
|
|
149
|
+
if (time > 60) {
|
|
150
|
+
time = Math.floor(time / 60) + "分钟";
|
|
151
|
+
} else {
|
|
152
|
+
time = time + "秒";
|
|
153
|
+
}
|
|
154
|
+
this.html = this.html.replace(replace, escape(time));
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
// buff描述
|
|
158
|
+
if (type === "desc") {
|
|
159
|
+
let buff = this.getResource("buff", id, level);
|
|
160
|
+
let desc = buff["Desc"];
|
|
161
|
+
if (!desc) desc = this.getResource("buff", id, 0)["Desc"];
|
|
162
|
+
if (!desc) {
|
|
163
|
+
this.html = this.html.replace(replace, escape(replace));
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
// buff的描述里面可能会混着一些buff的属性啥的
|
|
167
|
+
let _matches = desc.match(/<BUFF ([0-9a-zA-Z]+)>/gi);
|
|
168
|
+
if (_matches) {
|
|
169
|
+
for (let _m of _matches) {
|
|
170
|
+
let [_, _attr] = _m.match(/<BUFF ([0-9a-zA-Z]+)>/i);
|
|
171
|
+
for (let i = 1; i < 15; i++) {
|
|
172
|
+
if (buff[`BeginAttrib${i}`] == _attr) {
|
|
173
|
+
desc = desc.replace(
|
|
174
|
+
_m,
|
|
175
|
+
buff[`BeginValue${i}A`]
|
|
176
|
+
);
|
|
182
177
|
}
|
|
183
178
|
}
|
|
184
|
-
this.html = this.html.replace(item.token, value);
|
|
185
179
|
}
|
|
186
|
-
}
|
|
187
|
-
.
|
|
188
|
-
|
|
189
|
-
});
|
|
180
|
+
}
|
|
181
|
+
this.html = this.html.replace(replace, desc);
|
|
182
|
+
}
|
|
190
183
|
}
|
|
191
184
|
},
|
|
192
|
-
renderEnchantResource: function () {
|
|
185
|
+
renderEnchantResource: async function () {
|
|
193
186
|
const matches = this.html.match(/<ENCHANT (\d+)>/gim);
|
|
194
187
|
if (!matches) return;
|
|
188
|
+
let resourceKeys = [];
|
|
189
|
+
let replaceMap = {};
|
|
195
190
|
for (let match of matches) {
|
|
196
191
|
let enchant_id = match.match(/<ENCHANT (\d+)>/i)[1];
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
192
|
+
resourceKeys.push(enchant_id);
|
|
193
|
+
replaceMap[match] = enchant_id;
|
|
194
|
+
}
|
|
195
|
+
await this.getAllResources("enchant", resourceKeys, this.client);
|
|
196
|
+
for (let replace in replaceMap) {
|
|
197
|
+
try {
|
|
198
|
+
let enchant_id = replaceMap[replace];
|
|
199
|
+
let enchant = this.getResource("enchant", enchant_id);
|
|
200
|
+
let time = enchant.Time;
|
|
201
|
+
if (time) time = `,持续${parseInt(time) / 60}分钟。`;
|
|
202
|
+
let result = `${enchant.AttriName}${time ? time : ""}`;
|
|
203
|
+
this.html = this.html.replace(replace, result);
|
|
204
|
+
} catch (e) {
|
|
205
|
+
console.log(e);
|
|
206
|
+
this.html = this.html.replace(replace, escape(replace));
|
|
207
|
+
}
|
|
209
208
|
}
|
|
210
209
|
},
|
|
211
210
|
renderResource: function () {
|
|
212
211
|
this.renderBuffResource();
|
|
213
212
|
this.renderEnchantResource();
|
|
214
213
|
},
|
|
214
|
+
getAllResources: async function (type, ids) {
|
|
215
|
+
let resources = await getResourceFromNode(type, ids, this.client);
|
|
216
|
+
let data = resources.data;
|
|
217
|
+
if (data.length === undefined) data = [data];
|
|
218
|
+
if (type == "buff") {
|
|
219
|
+
for (let item of data) {
|
|
220
|
+
let buff_token = `${item.BuffID}_${item.Level}`;
|
|
221
|
+
sessionStorage.setItem(
|
|
222
|
+
`buff-${this.client}-${buff_token}`,
|
|
223
|
+
JSON.stringify(item)
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
} else if (type == "enchant") {
|
|
227
|
+
for (let item of data) {
|
|
228
|
+
let enchant_token = `${item.ID}`;
|
|
229
|
+
sessionStorage.setItem(
|
|
230
|
+
`enchant-${this.client}-${enchant_token}`,
|
|
231
|
+
JSON.stringify(item)
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
getResource: function (type, id, level) {
|
|
237
|
+
let token = `${id}`;
|
|
238
|
+
if (type == "buff") {
|
|
239
|
+
token = `${id}_${level}`;
|
|
240
|
+
}
|
|
241
|
+
let resource = sessionStorage.getItem(
|
|
242
|
+
`${type}-${this.client}-${token}`
|
|
243
|
+
);
|
|
244
|
+
if (resource) return JSON.parse(resource);
|
|
245
|
+
return null;
|
|
246
|
+
},
|
|
215
247
|
},
|
|
216
248
|
watch: {
|
|
217
249
|
text: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="w-author" v-loading="loading">
|
|
3
|
-
<div class="w-author-wrapper el-popover" v-if="data">
|
|
3
|
+
<div class="w-author-wrapper el-popover" v-if="data" :style="decoration">
|
|
4
4
|
<div class="u-author">
|
|
5
5
|
<Avatar class="u-avatar" :uid="uid" :url="data.user_avatar" :size="68" :frame="data.user_avatar_frame" />
|
|
6
6
|
<div class="u-info">
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
<script>
|
|
46
46
|
import { authorLink, getLink, getThumbnail } from "@jx3box/jx3box-common/js/utils";
|
|
47
47
|
import { getUserInfo, getUserMedals, getUserPublicTeams } from "../../service/author";
|
|
48
|
+
import { getDecoration } from "../../service/cms";
|
|
48
49
|
import { __server, __imgPath,__userLevelColor } from "@jx3box/jx3box-common/data/jx3box.json";
|
|
49
50
|
import User from "@jx3box/jx3box-common/js/user";
|
|
50
51
|
import { __userLevel } from "@jx3box/jx3box-common/data/jx3box.json";
|
|
@@ -61,7 +62,8 @@ export default {
|
|
|
61
62
|
data: null,
|
|
62
63
|
medals: [],
|
|
63
64
|
teams: [],
|
|
64
|
-
loading: false
|
|
65
|
+
loading: false,
|
|
66
|
+
decoration:''
|
|
65
67
|
}),
|
|
66
68
|
computed: {
|
|
67
69
|
super_author_icon: function() {
|
|
@@ -92,6 +94,7 @@ export default {
|
|
|
92
94
|
handler (val) {
|
|
93
95
|
if (val) {
|
|
94
96
|
this.loadData()
|
|
97
|
+
this.getDecoration()
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
}
|
|
@@ -123,7 +126,40 @@ export default {
|
|
|
123
126
|
this.teams = data && data.slice(0, 5);
|
|
124
127
|
});
|
|
125
128
|
},
|
|
126
|
-
|
|
129
|
+
getDecoration(){
|
|
130
|
+
let decoration_atcard=sessionStorage.getItem('decoration_atcard'+this.uid)
|
|
131
|
+
if(decoration_atcard == 'no'){
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
//已有缓存,读取解析
|
|
135
|
+
if(decoration_atcard){
|
|
136
|
+
this.setDecoration(JSON.parse(decoration_atcard))
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
getDecoration({using:1,user_id:this.uid}).then(data=>{
|
|
140
|
+
let res=data.data.data
|
|
141
|
+
if(res.length==0){
|
|
142
|
+
//空 则为无主题,不再加载接口,界面设No
|
|
143
|
+
sessionStorage.setItem('decoration_atcard'+this.uid,'no')
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
let decoration=res.filter(val => {
|
|
147
|
+
return val.type === 'atcard'
|
|
148
|
+
})
|
|
149
|
+
if(decoration.length>0){
|
|
150
|
+
sessionStorage.setItem('decoration_atcard'+this.uid,JSON.stringify(decoration[0]))
|
|
151
|
+
this.setDecoration(decoration[0])
|
|
152
|
+
}else{
|
|
153
|
+
//空 则为无主题,不再加载接口,界面设No
|
|
154
|
+
sessionStorage.setItem('decoration_atcard'+this.uid,'no')
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
},
|
|
158
|
+
setDecoration(decoration_sidebar){
|
|
159
|
+
this.decoration={
|
|
160
|
+
'background-image':'url('+this.showDecoration(decoration_sidebar.val,decoration_sidebar.type)+')'
|
|
161
|
+
}
|
|
162
|
+
},
|
|
127
163
|
showMedalIcon: function(val) {
|
|
128
164
|
return __imgPath + "image/medals/user/" + val + ".gif";
|
|
129
165
|
},
|
|
@@ -139,6 +175,9 @@ export default {
|
|
|
139
175
|
showLevelColor:function (level){
|
|
140
176
|
return __userLevelColor[level]
|
|
141
177
|
},
|
|
178
|
+
showDecoration:function(val,type){
|
|
179
|
+
return __imgPath + `decoration/images/${val}/${type}.png`;
|
|
180
|
+
},
|
|
142
181
|
authorLink
|
|
143
182
|
}
|
|
144
183
|
}
|
|
@@ -148,6 +187,10 @@ export default {
|
|
|
148
187
|
@import "../../assets/css/module/author.less";
|
|
149
188
|
.w-author {
|
|
150
189
|
.w-author-wrapper {
|
|
190
|
+
// background-image: url(https://img.jx3box.com/decoration/images/1_CAT/atcard.png);
|
|
191
|
+
background-repeat: no-repeat;
|
|
192
|
+
background-position: top right;
|
|
193
|
+
background-size: contain;
|
|
151
194
|
.u-author{
|
|
152
195
|
padding:5px 0 15px 0;
|
|
153
196
|
}
|