@jx3box/jx3box-common-ui 6.5.4 → 6.5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jx3box/jx3box-common-ui",
3
- "version": "6.5.4",
3
+ "version": "6.5.5",
4
4
  "description": "JX3BOX UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/service/cms.js CHANGED
@@ -7,10 +7,15 @@ function getPostAuthors(post_id) {
7
7
  function uploadImage(formData){
8
8
  return $cms().post(`/api/cms/upload/avatar`, formData);
9
9
  }
10
-
10
+ //获取装扮
11
+ function getDecoration(params) {
12
+ return $cms().get(`/api/cms/user/decoration`,{
13
+ params
14
+ });
15
+ }
11
16
  // 通用上传
12
17
  function upload(formData){
13
18
  return $cms().post(`/api/cms/upload`, formData);
14
19
  }
15
20
 
16
- export { getPostAuthors, uploadImage, upload };
21
+ export { getPostAuthors, uploadImage, upload,getDecoration };
@@ -1,12 +1,13 @@
1
1
  <template>
2
2
  <aside
3
- class="c-sidebar-left c-sidebar"
3
+ class="c-sidebar-left c-sidebar m-theme"
4
4
  :class="{
5
5
  isclose: !isOpen,
6
6
  isopen: isOpen,
7
7
  'without-bread': withoutBread,
8
8
  }"
9
9
  v-if="!isApp"
10
+ :style="decoration"
10
11
  >
11
12
  <div class="c-sidebar-left-inner">
12
13
  <slot></slot>
@@ -36,6 +37,8 @@
36
37
  <script>
37
38
  import Bus from "../service/bus";
38
39
  import { isApp } from "../assets/js/app.js";
40
+ import {getDecoration} from "../service/cms"
41
+ import { __imgPath } from "@jx3box/jx3box-common/data/jx3box.json";
39
42
  export default {
40
43
  name: "LeftSidebar",
41
44
  props: ["open", "withoutBread"],
@@ -43,6 +46,7 @@ export default {
43
46
  return {
44
47
  isOpen: true,
45
48
  isApp: isApp(),
49
+ decoration:{}
46
50
  };
47
51
  },
48
52
  computed: {
@@ -60,6 +64,44 @@ export default {
60
64
  let status = !this.isOpen;
61
65
  Bus.$emit("toggleLeftSide", status);
62
66
  },
67
+ showDecoration:function(val,type){
68
+ return __imgPath + `decoration/images/${val}/${type}.png`;
69
+ },
70
+ getDecoration(){
71
+ let decoration_sidebar=sessionStorage.getItem('decoration_sidebar')
72
+ if(decoration_sidebar == 'no'){
73
+ return;
74
+ }
75
+ //已有缓存,读取解析
76
+ if(decoration_sidebar){
77
+ this.setDecoration(JSON.parse(decoration_sidebar))
78
+ return;
79
+ }
80
+ getDecoration({using:1,type:'sidebar'}).then(data=>{
81
+ let res=data.data.data
82
+ if(res.length==0){
83
+ //空 则为无主题,不再加载接口,界面设No
84
+ sessionStorage.setItem('decoration_sidebar','no')
85
+ return;
86
+ }
87
+ let decoration=res.filter(val => {
88
+ return val.type === 'sidebar'
89
+ })
90
+ console.log(decoration)
91
+ if(decoration.length>0){
92
+ sessionStorage.setItem('decoration_sidebar',JSON.stringify(decoration[0]))
93
+ this.setDecoration(decoration[0])
94
+ }else{
95
+ //空 则为无主题,不再加载接口,界面设No
96
+ sessionStorage.setItem('decoration_sidebar','no')
97
+ }
98
+ })
99
+ },
100
+ setDecoration(decoration_sidebar){
101
+ this.decoration={
102
+ 'background-image':'url('+this.showDecoration(decoration_sidebar.val,decoration_sidebar.type)+')'
103
+ }
104
+ }
63
105
  },
64
106
  mounted: function () {
65
107
  Bus.$on("toggleLeftSide", (data) => {
@@ -76,10 +118,18 @@ export default {
76
118
  },
77
119
  created: function () {
78
120
  this.isOpen = this.open === undefined ? true : this.open;
121
+ this.getDecoration()
79
122
  },
80
123
  };
81
124
  </script>
82
125
 
83
126
  <style lang="less">
84
127
  @import "../assets/css/left-sidebar.less";
128
+ // 虚拟装扮主题
129
+ .m-theme{
130
+ // background: url(../assets/testbg.png) no-repeat;
131
+ background-repeat: no-repeat;
132
+ background-size: contain;
133
+ background-position: top right;
134
+ }
85
135
  </style>