index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div class="demo-list-wrapper">
  3. <a href="https://github.com/jdf2e/nutui/" target="_blank" class="github-btn">Github</a>
  4. <h1 class="logo"></h1>
  5. <div class="version">NutUI 2.0</div>
  6. <p>一套京东风格的移动端Vue组件库</p>
  7. <div :class="['demo-list-box',{'unfold':foldStatus[item]}]" v-for="item in sorts" :key="item">
  8. <h4 @click="toggleFold(item)">
  9. {{oriSorts[item]}}
  10. <i></i>
  11. </h4>
  12. <ul>
  13. <template v-for="cpt in packages">
  14. <li v-if="cpt.showDemo !== false && cpt.sort == item" :key="cpt.name">
  15. <a :href="'./demo.html#/'+cpt.name">
  16. {{cpt.name}}
  17. <span>{{cpt.chnName}}</span>
  18. <nut-rate class="cpt-rec" v-if="cpt.star" :total="5" :value="cpt.star" :size="8" :spacing="3" :readOnly="true"></nut-rate>
  19. </a>
  20. </li>
  21. </template>
  22. </ul>
  23. </div>
  24. <div id="demo-footer">京东用户体验设计部(JDC) · 前端开发部 · v{{version}}</div>
  25. </div>
  26. </template>
  27. <script>
  28. import { version } from '../../../package.json';
  29. import { packages, sorts } from "../../../src/config.json";
  30. export default {
  31. name: "index",
  32. data() {
  33. return {
  34. path: "",
  35. packages: {},
  36. version,
  37. sortedPackages: [],
  38. oriSorts: [],
  39. sorts: [1, 2, 0, 3, 4, 5],
  40. foldStatus: []
  41. };
  42. },
  43. methods: {
  44. // showCode(){
  45. // this.$dialog({
  46. // type:"image",
  47. // link:"",
  48. // imgSrc:"https://img14.360buyimg.com/imagetools/s350x350_jfs/t1/23439/7/11643/155926/5c90d554E7f03c831/bd45cd0ee2daa2fa.jpg.dpg",
  49. // onClickImageLink(){
  50. // return false; //返回false可阻止默认的链接跳转行为
  51. // }
  52. // });
  53. // },
  54. toggleFold(idx) {
  55. this.foldStatus.splice(idx, 1, !this.foldStatus[idx]);
  56. sessionStorage.setItem("foldStatus", JSON.stringify(this.foldStatus));
  57. }
  58. },
  59. created() {
  60. this.packages = packages;
  61. this.oriSorts = sorts;
  62. this.foldStatus = Array(this.sorts.length)
  63. .join(",")
  64. .split(",")
  65. .map(function(key, index) {
  66. return 0;
  67. });
  68. },
  69. activated() {
  70. const seVal = sessionStorage.getItem("foldStatus");
  71. if (seVal && seVal !== "false") {
  72. this.foldStatus = JSON.parse(seVal);
  73. }
  74. }
  75. };
  76. </script>
  77. <style lang="scss" scoped>
  78. .demo-list-wrapper {
  79. #demo-footer{
  80. font-size:10px;
  81. color:#BBB;
  82. text-shadow:1px 1px #FFF;
  83. text-align: center;
  84. margin:10px 0;
  85. }
  86. position: relative;
  87. padding: 8px;
  88. box-sizing: border-box;
  89. .github-btn {
  90. position: absolute;
  91. top: -25px;
  92. right: 10px;
  93. height: 26px;
  94. width: 26px;
  95. font-size: 0;
  96. background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 16 16' version='1.1' width='24' aria-hidden='true'%3E%3Cpath fill-rule='evenodd' fill='rgb(150,150,150)' d='M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z'%3E%3C/path%3E%3C/svg%3E")
  97. no-repeat;
  98. &:hover,
  99. &:active {
  100. opacity: 0.7;
  101. }
  102. }
  103. .logo {
  104. background: url(../asset/img/logo.png) no-repeat;
  105. background-size: contain;
  106. height: 100px;
  107. width: 100px;
  108. text-align: center;
  109. margin: 5px auto 15px;
  110. animation: swing 2.5s;
  111. }
  112. .version {
  113. text-align: center;
  114. font-size: 24px;
  115. }
  116. p {
  117. text-align: center;
  118. color: #848484;
  119. margin: 20px 0 30px;
  120. }
  121. }
  122. .demo-list-box {
  123. margin: 15px auto;
  124. width: 95%;
  125. background: #fff;
  126. border-radius: 5px;
  127. overflow: hidden;
  128. h4 {
  129. position: relative;
  130. margin: 0;
  131. height: 50px;
  132. font-weight: normal;
  133. line-height: 50px;
  134. padding: 0 15px;
  135. &:active {
  136. background-color: rgba(200, 200, 200, 0.1);
  137. }
  138. i {
  139. position: absolute;
  140. right: 15px;
  141. top: 50%;
  142. margin-top: -5px;
  143. height: 10px;
  144. width: 10px;
  145. transform: rotate(0deg);
  146. 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")
  147. no-repeat center;
  148. background-size: contain;
  149. transition: transform 0.3s;
  150. }
  151. }
  152. &.unfold {
  153. h4 i {
  154. transform: rotate(-180deg);
  155. }
  156. ul {
  157. display: block;
  158. }
  159. }
  160. ul {
  161. display: none;
  162. padding: 0 5px;
  163. }
  164. li {
  165. margin: 0 5px;
  166. overflow: hidden;
  167. border-top: 1px solid #edeef1;
  168. border-radius: 2px;
  169. 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")
  170. no-repeat right 10px center;
  171. background-size: 10px 10px;
  172. a {
  173. display: flex;
  174. align-items:center;
  175. height: 100%;
  176. padding: 20px 10px 20px 10px;
  177. text-decoration: none;
  178. color: #2e2d2d;
  179. }
  180. span {
  181. margin-left: 10px;
  182. font-size: 14px;
  183. color: #848484;
  184. }
  185. &:active {
  186. background-color: rgba(200, 200, 200, 0.1);
  187. }
  188. }
  189. }
  190. ul,
  191. li {
  192. list-style: none;
  193. margin: 0;
  194. padding: 0;
  195. }
  196. .cpt-rec{
  197. display:inline-flex;
  198. margin-left:5px;
  199. }
  200. @-webkit-keyframes swing {
  201. from {
  202. -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  203. transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  204. -webkit-animation-timing-function: ease-in;
  205. animation-timing-function: ease-in;
  206. opacity: 0;
  207. }
  208. 40% {
  209. -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -40deg);
  210. transform: perspective(400px) rotate3d(0, 1, 0, -40deg);
  211. -webkit-animation-timing-function: ease-in;
  212. animation-timing-function: ease-in;
  213. }
  214. 60% {
  215. -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 25deg);
  216. transform: perspective(400px) rotate3d(0, 1, 0, 25deg);
  217. opacity: 1;
  218. }
  219. 80% {
  220. -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -10deg);
  221. transform: perspective(400px) rotate3d(0, 1, 0, -10deg);
  222. }
  223. to {
  224. -webkit-transform: perspective(400px);
  225. transform: perspective(400px);
  226. }
  227. }
  228. </style>