MenuRight.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div class="menu-box">
  3. <template v-for="(item,index) in list">
  4. <template v-if="!(item.type==='list'&&!$route.query.iss_id)">
  5. <div class="menu-item" :key="index" @click="handleChange($event,index,item)" :style="{background:activeIndex===index?colorObj.menuBg:'',color:activeIndex===index?colorObj.statisticValue:colorObj.glossaryTitle}" v-if="index<6||foldFlag">
  6. <svg-icon :icon-class="item.icon" v-if="item.icon"></svg-icon>
  7. <el-switch
  8. v-else
  9. v-model="item.flag"
  10. active-color="#175DFF"
  11. inactive-color="#D0D3D9">
  12. </el-switch>
  13. <span>{{item.name}}</span>
  14. </div>
  15. </template>
  16. <el-divider :key="index" v-if="index===4||index===6||index===0" :style="{backgroundColor:colorObj.glossaryBg}"></el-divider>
  17. </template>
  18. <!-- <a class="flod-btn" @click="foldFlag=!foldFlag">{{foldFlag?'收起':'展开'}}<svg-icon :icon-class="foldFlag?'Up-line':'Down-line'"></svg-icon></a> -->
  19. </div>
  20. </template>
  21. <script>
  22. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  23. //例如:import 《组件名称》from ‘《组件路径》';
  24. export default {
  25. //import引入的组件需要注入到对象中才能使用
  26. components: {},
  27. props: ["colorObj"],
  28. data() {
  29. //这里存放数据
  30. return {
  31. list:[
  32. {
  33. icon:'list',
  34. name:'目录',
  35. type:'list'
  36. },
  37. {
  38. icon:'Book-open',
  39. name:'原文',
  40. type: 'original'
  41. },
  42. {
  43. icon:'Doc-add',
  44. name:'生词及短语',
  45. type:'newWord'
  46. },
  47. {
  48. icon:'record',
  49. name:'朗读练习',
  50. type:'practice'
  51. },
  52. {
  53. icon:'search-text',
  54. name:'文内检索',
  55. type:'search'
  56. },
  57. {
  58. icon:'print',
  59. name:'打印文章',
  60. type:'print'
  61. },
  62. {
  63. icon:'share',
  64. name:'分享',
  65. type:'share'
  66. },
  67. {
  68. icon:'cloud',
  69. name:'词云',
  70. type:'cloud'
  71. },
  72. {
  73. icon:'filtrate',
  74. name:'词汇类型',
  75. type:'filtrate'
  76. },
  77. {
  78. icon:'chart',
  79. name:'文章信息',
  80. type:'chart'
  81. },
  82. {
  83. icon:'Notebook-and-pen',
  84. name:'显示笔记',
  85. type:'notebook'
  86. }
  87. ],
  88. activeIndex:1,
  89. foldFlag:true
  90. }
  91. },
  92. //计算属性 类似于data概念
  93. computed: {},
  94. //监控data中数据变化
  95. watch: {
  96. },
  97. //方法集合
  98. methods: {
  99. handleChange(e,index,item){
  100. this.activeIndex = index
  101. this.$emit('changeArticleType',item.type,e)
  102. },
  103. handleChangeSwitch(value){
  104. this.switchFlag = value
  105. if(!this.switchFlag) this.activeIndex = null
  106. }
  107. },
  108. //生命周期 - 创建完成(可以访问当前this实例)
  109. created() {
  110. },
  111. //生命周期 - 挂载完成(可以访问DOM元素)
  112. mounted() {
  113. },
  114. //生命周期-创建之前
  115. beforeCreated() { },
  116. //生命周期-挂载之前
  117. beforeMount() { },
  118. //生命周期-更新之前
  119. beforUpdate() { },
  120. //生命周期-更新之后
  121. updated() { },
  122. //生命周期-销毁之前
  123. beforeDestory() { },
  124. //生命周期-销毁完成
  125. destoryed() { },
  126. //如果页面有keep-alive缓存功能,这个函数会触发
  127. activated() { }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. /* @import url(); 引入css类 */
  132. .menu-box{
  133. .menu-item{
  134. margin: 1px 0;
  135. cursor: pointer;
  136. font-weight: 400;
  137. font-size: 14px;
  138. line-height: 22px;
  139. color: #2F3742;
  140. padding: 0 8px;
  141. border-radius: 6px;
  142. display: flex;
  143. align-items: center;
  144. height: 32px;
  145. .svg-icon{
  146. width: 32px;
  147. height: 32px;
  148. padding: 8px;
  149. }
  150. .el-switch{
  151. width: 28px;
  152. height: 16px;
  153. line-height: 16px;
  154. margin: 0 6px;
  155. }
  156. span{
  157. margin-left: 8px;
  158. }
  159. }
  160. .flod-btn{
  161. display: block;
  162. width: 168px;
  163. height: 28px;
  164. text-align: center;
  165. font-size: 12px;
  166. line-height: 28px;
  167. color: #99A29E;
  168. .svg-icon{
  169. margin-left: 4px;
  170. }
  171. }
  172. }
  173. </style>
  174. <style lang="scss">
  175. .menu-box{
  176. .el-switch__core{
  177. height: 16px;
  178. }
  179. .el-switch__core:after{
  180. width: 12px;
  181. height: 12px;
  182. }
  183. .el-switch.is-checked .el-switch__core::after{
  184. margin-left: -14px;
  185. }
  186. .el-divider{
  187. margin: 0 auto;
  188. width: 128px;
  189. }
  190. }
  191. </style>