@jx3box/jx3box-editor 0.8.3 → 0.8.4

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-editor",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "description": "JX3BOX Article & Editor",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/service/item.js CHANGED
@@ -1,14 +1,16 @@
1
1
  import $http from "axios";
2
- import { __helperUrl } from "@jx3box/jx3box-common/data/jx3box.json";
2
+ import {__helperUrl} from "@jx3box/jx3box-common/data/jx3box.json";
3
+ import {jx3ClientType} from "@jx3box/jx3box-common/js/utils";
3
4
 
4
5
  // 获取物品
5
- function get_item(item_id, jx3_client_type = 1) {
6
+ function get_item(item_id, jx3_client_type = null) {
6
7
  if (!item_id) return;
8
+
7
9
  return $http({
8
10
  url: `${__helperUrl}api/item/${item_id}`,
9
11
  headers: {
10
12
  Accept: "application/prs.helper.v2+json",
11
- "JX3-Client-Type": jx3_client_type,
13
+ "JX3-Client-Type": jx3_client_type === null ? jx3ClientType() : jx3_client_type,
12
14
  },
13
15
  withCredentials: true,
14
16
  });
@@ -18,9 +20,9 @@ function get_item(item_id, jx3_client_type = 1) {
18
20
  function get_plan(plan_id) {
19
21
  return $http({
20
22
  url: `${__helperUrl}api/item_plan/${plan_id}`,
21
- headers: { Accept: "application/prs.helper.v2+json" },
23
+ headers: {Accept: "application/prs.helper.v2+json"},
22
24
  withCredentials: true,
23
25
  });
24
26
  }
25
27
 
26
- export { get_item, get_plan };
28
+ export {get_item, get_plan};
package/src/Item.vue CHANGED
@@ -278,38 +278,28 @@ export default {
278
278
  handler() {
279
279
  if (this.item_id) {
280
280
  // 提取本地数据
281
- let cache = sessionStorage.getItem(`item-${this.item_id}`);
282
- let cache_created = sessionStorage.getItem(
283
- `item-${this.item_id}-created`
284
- );
281
+ let cacheName = `item-${this.jx3ClientType}-${this.item_id}`;
282
+ let cache = sessionStorage.getItem(cacheName);
283
+ let createdCacheName = `${cacheName}-created`;
284
+ let createdCache = sessionStorage.getItem(createdCacheName);
285
285
  // 查看是否存在缓存
286
286
  if (
287
287
  (cache === false || cache) &&
288
- Math.round(new Date() / 1000) - cache_created <= 3600
288
+ Math.round(new Date() / 1000) - createdCache <= 3600
289
289
  ) {
290
- this.source =
291
- cache === false ? null : JSON.parse(cache);
290
+ this.source = cache === false ? null : JSON.parse(cache);
292
291
  return;
293
292
  }
294
293
 
295
294
  // 没有缓存则发起请求获取
296
- get_item(this.item_id,this.jx3ClientType).then((res) => {
295
+ get_item(this.item_id, this.jx3ClientType).then((res) => {
297
296
  let data = res.data;
298
297
  if (data.code === 200) {
299
298
  let item = data.data.item;
300
- this.source =
301
- JSON.stringify(item) !== "{}" ? item : null;
299
+ this.source = JSON.stringify(item) !== "{}" ? item : null;
302
300
  // 记录本地数据
303
- sessionStorage.setItem(
304
- `item-${this.source.id}`,
305
- this.source
306
- ? JSON.stringify(this.source)
307
- : false
308
- );
309
- sessionStorage.setItem(
310
- `item-${this.source.id}-created`,
311
- Math.round(new Date() / 1000)
312
- );
301
+ sessionStorage.setItem(cacheName, this.source ? JSON.stringify(this.source) : false);
302
+ sessionStorage.setItem(createdCacheName, Math.round(new Date() / 1000));
313
303
  }
314
304
  });
315
305
  } else if (typeof this.item_id !== "undefined") {