index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div class="demo-list-wrapper">
  3. <h1 class="logo"></h1>
  4. <div class="version">NutUI 2.0</div>
  5. <p>NutUI 是一套京东风格的移动端Vue组件库</p>
  6. <div
  7. :class="['demo-list-box',{'unfold':foldStatus[item]}]"
  8. v-for="item in sorts"
  9. :key="item"
  10. >
  11. <h4 @click="toggleFold(item)">
  12. {{oriSorts[item]}}
  13. <i></i>
  14. </h4>
  15. <ul>
  16. <template v-for="cpt in packages">
  17. <li v-if="cpt.showDemo !== false && cpt.sort == item" :key="cpt.name">
  18. <a :href="'./demo.html#/'+cpt.name">
  19. {{cpt.name}}
  20. <span>{{cpt.chnName}}</span>
  21. </a>
  22. </li>
  23. </template>
  24. </ul>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. import { packages,sorts } from "../../../src/config.json";
  30. export default {
  31. name: "index",
  32. data() {
  33. return {
  34. path: "",
  35. packages: {},
  36. sortedPackages: [],
  37. oriSorts:[],
  38. sorts: [1,2,0,3,4,5],
  39. foldStatus: []
  40. };
  41. },
  42. methods: {
  43. toggleFold(idx) {
  44. this.foldStatus.splice(idx, 1, !this.foldStatus[idx]);
  45. sessionStorage.setItem("foldStatus", JSON.stringify(this.foldStatus));
  46. }
  47. },
  48. created() {
  49. this.packages = packages;
  50. this.oriSorts = sorts;
  51. this.foldStatus = Array(this.sorts.length)
  52. .join(",")
  53. .split(",")
  54. .map(function(key, index) {
  55. return 0;
  56. });
  57. },
  58. activated() {
  59. const seVal = sessionStorage.getItem("foldStatus");
  60. if (seVal && seVal !== "false") {
  61. this.foldStatus = JSON.parse(seVal);
  62. }
  63. }
  64. };
  65. </script>
  66. <style lang="scss" scoped>
  67. .demo-list-wrapper {
  68. padding: 8px;
  69. box-sizing: border-box;
  70. .logo {
  71. background: url(../asset/img/logo.png) no-repeat;
  72. background-size: contain;
  73. height: 100px;
  74. width: 100px;
  75. text-align: center;
  76. margin: 5px auto 15px;
  77. }
  78. .version {
  79. text-align: center;
  80. font-size: 24px;
  81. }
  82. p {
  83. text-align: center;
  84. color: #848484;
  85. margin: 20px 0 30px;
  86. }
  87. }
  88. .demo-list-box {
  89. margin: 15px auto;
  90. width: 95%;
  91. background: #fff;
  92. border-radius: 5px;
  93. h4 {
  94. position: relative;
  95. margin: 0;
  96. height: 50px;
  97. line-height: 50px;
  98. padding: 0 15px;
  99. i {
  100. position: absolute;
  101. right: 15px;
  102. top: 50%;
  103. margin-top: -5px;
  104. height: 10px;
  105. width: 10px;
  106. transform: rotate(0deg);
  107. background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='rgb(132,132,132)' viewBox='0 0 30 11'%3E%3Cpath d='M15 7.757L27.737.21a1.5 1.5 0 0 1 1.53 2.58c-4.5 2.668-9 5.334-13.5 8a1.503 1.503 0 0 1-1.53 0c-4.5-2.666-9-5.332-13.5-8A1.5 1.5 0 1 1 2.266.21C6.51 2.726 10.756 5.24 15 7.757' fill-rule='evenodd'/%3E%3C/svg%3E")
  108. no-repeat center;
  109. background-size: contain;
  110. transition: transform 0.3s;
  111. }
  112. }
  113. &.unfold {
  114. h4 i {
  115. transform: rotate(-180deg);
  116. }
  117. ul {
  118. display: block;
  119. }
  120. }
  121. ul {
  122. display: none;
  123. padding: 0 5px;
  124. }
  125. li {
  126. margin: 0 5px;
  127. overflow: hidden;
  128. border-top: 1px solid #edeef1;
  129. border-radius: 2px;
  130. background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 30'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cpath d='M-11 0h30v30h-30z'/%3E%3Cpath d='M7.757 15C5.241 10.755 2.727 6.51.21 2.266A1.5 1.5 0 0 1 2.79.736l8 13.499c.28.472.28 1.058 0 1.53l-8 13.5a1.499 1.499 0 1 1-2.58-1.53L7.757 15z' fill='rgb(132,132,132)' /%3E%3C/g%3E%3C/svg%3E")
  131. no-repeat right 15px center;
  132. background-size: 10px 10px;
  133. a {
  134. display: block;
  135. height: 100%;
  136. padding: 20px;
  137. text-decoration: none;
  138. color: #2e2d2d;
  139. }
  140. span {
  141. margin-left: 10px;
  142. font-size: 14px;
  143. color: #848484;
  144. }
  145. &:active {
  146. background-color: rgba(200, 200, 200, 0.1);
  147. }
  148. }
  149. }
  150. ul,
  151. li {
  152. list-style: none;
  153. margin: 0;
  154. padding: 0;
  155. }
  156. </style>