index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="extend-gallery-wrap d-flex flex-column" :style="wrapStyle">
  3. <div class="extend-gallery-title flex-grow-0 flex-shrink-0">{{$t('dashboard.text_93')}}</div>
  4. <div class="extend-gallery-tips flex-grow-0 flex-shrink-0 d-flex">
  5. <div>{{$t('dashboard.text_94', [ options.length ])}}</div>
  6. <div class="flex-fill text-right">{{$t('dashboard.text_95')}}</div>
  7. </div>
  8. <div class="flex-fill extend-list overflow-auto position-relative">
  9. <ul>
  10. <li
  11. class="extend-gallery-item d-flex align-items-center"
  12. v-for="item in options"
  13. :key="item.component"
  14. :data-component="item.component">
  15. <div class="extend-thumb flex-shrink-0 flex-grow-0"><icon :type="item.icon" class="dashboard-icon" /></div>
  16. <div class="extend-content ml-4 flex-fill">
  17. <div class="extend-title">{{ item.label }}</div>
  18. <div class="extend-desc text-color-help mt-1">{{ item.desc }}</div>
  19. </div>
  20. </li>
  21. </ul>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import { mapGetters, mapState } from 'vuex'
  27. import store from '@/store'
  28. import options from '@scope/extends/config'
  29. import ceOptions from '@Dashboard/extends/config'
  30. export default {
  31. name: 'ExtendGallery',
  32. data () {
  33. const opts = store.getters.isSysCE ? ceOptions : options
  34. const extendsOptions = {}
  35. for (let i = 0, len = opts.length; i < len; i++) {
  36. extendsOptions[opts[i].component] = { ...opts[i] }
  37. }
  38. return {
  39. opts,
  40. extendsOptions,
  41. }
  42. },
  43. computed: {
  44. ...mapGetters(['scope', 'globalConfig']),
  45. ...mapState('common', ['openCloudShell', 'cloudShellHeight']),
  46. wrapStyle () {
  47. return {
  48. height: this.openCloudShell ? `calc(100% - ${this.cloudShellHeight}px)` : '100%',
  49. }
  50. },
  51. options () {
  52. const ret = this.opts.filter(item => {
  53. let effective = true
  54. if (item.scope && !item.scope.includes(this.scope)) {
  55. effective = false
  56. }
  57. if (!this.globalConfig.enable_quota_check && (item.component === 'Quota' || item.component === 'ProjectQuota')) {
  58. effective = false
  59. }
  60. // 开源版本过滤
  61. if (process.env.VUE_APP_PLATFORM === 'cmp_public' && ['ConsumptionPercent', 'ConsumptionTrend', 'SuggestsysAlertsOverview', 'SuggestsysAlertsDetail', 'Quota', 'BillHistoryLine', 'ResourceHistoryLine', 'Log', 'AccountHealth'].includes(item.component)) {
  62. effective = false
  63. }
  64. return effective
  65. })
  66. return ret
  67. },
  68. },
  69. }
  70. </script>
  71. <style lang="less" scoped>
  72. @import '~@/styles/less/theme';
  73. .extend-gallery-wrap {
  74. background-color: #fff;
  75. width: 300px;
  76. min-width: 300px;
  77. }
  78. .extend-gallery-item {
  79. &.drag {
  80. position: absolute;
  81. top: 0;
  82. }
  83. }
  84. .extend-gallery-title {
  85. padding: 15px;
  86. font-size: 16px;
  87. border-bottom: 1px solid #eee;
  88. }
  89. .extend-gallery-tips {
  90. font-size: 12px;
  91. padding: 15px;
  92. border-bottom: 1px solid #eee;
  93. }
  94. .extend-list {
  95. > ul {
  96. list-style: none;
  97. margin: 0;
  98. padding: 0 15px;
  99. li {
  100. padding: 15px 10px;
  101. border-bottom: 1px solid #eee;
  102. background-color: #fff;
  103. touch-action: none;
  104. // height: 86px;
  105. width: 100%;
  106. min-width: 100%;
  107. position: relative;
  108. z-index: 99;
  109. > li {
  110. position: absolute;
  111. left: 0;
  112. top: 0;
  113. z-index: 99;
  114. }
  115. }
  116. }
  117. }
  118. .extend-thumb {
  119. width: 40px;
  120. height: 40px;
  121. overflow: hidden;
  122. > img {
  123. width: 100%;
  124. vertical-align: middle;
  125. text-align: center;
  126. }
  127. }
  128. .extend-desc {
  129. font-size: 12px;
  130. }
  131. .dashboard-icon {
  132. font-size: 40px;
  133. color: @primary-color;
  134. }
  135. </style>