@jx3box/jx3box-editor 1.5.6 → 1.5.7
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/resource.js +2 -2
- package/src/GameText.vue +106 -74
package/package.json
CHANGED
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: {
|