Resource.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <doc-header></doc-header>
  3. <div class="resource-main">
  4. <div class="resource-main-content">
  5. <h3 class="sub-title">资源</h3>
  6. <p class="sub-desc">这里汇总了 NutUI 相关的所有的资源</p>
  7. </div>
  8. </div>
  9. <!-- 设计资源 -->
  10. <div class="resource-content">
  11. <div class="resource-block" v-if="articleList.length === 0">
  12. <h4 class="sub-title">设计资源</h4>
  13. <p class="sub-desc"
  14. >这里提供 NUTUI
  15. 相关设计资源和设计工具的下载,更多设计资源正在整理和完善中。你可以在这个<span
  16. class="sub-red"
  17. >地址</span
  18. >中反馈对新版本 Sketch Symbols 组件的意见。</p
  19. >
  20. <div class="no-data">
  21. <img class="nodata-img-joy" src="../../assets/images/img-joy.png" />
  22. <p class="nodata-desc">敬请期待</p>
  23. </div>
  24. </div>
  25. <div class="resource-block" v-else>
  26. <h4 class="sub-title">设计资源</h4>
  27. <p class="sub-desc"
  28. >想要了解 NutUI
  29. 设计体系背后的故事?如何才能更好的应用?你可以查阅下述我们为你精挑细选的文章。也欢迎关注
  30. NutUI 官方专栏,这里常有关于 NutUI
  31. 设计体系下相关话题内容的最新分享和讨论。</p
  32. >
  33. <div class="tab-box">
  34. <div class="tab-hd">
  35. <div
  36. class="tab-hd-item"
  37. :class="{ active: activeIndex === index }"
  38. v-for="(item, index) in tabData"
  39. :key="index"
  40. @click="clickTab(index)"
  41. >
  42. {{ item.title }}
  43. </div>
  44. </div>
  45. <div class="tab-bd" v-show="activeIndex === 0">
  46. <div
  47. class="design-item"
  48. v-for="item in articleList"
  49. :key="item.id"
  50. @click="toLink(item.id)"
  51. >
  52. <img class="img-design" :src="item.cover_image" />
  53. <p class="design-title" v-hover>{{ item.title }}</p>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <!-- 社区文章 -->
  59. <div class="resource-block">
  60. <h4 class="sub-title">社区文章</h4>
  61. <p class="sub-desc"></p>
  62. <ul class="article-box">
  63. <li
  64. class="article-item"
  65. v-for="item in communityArticleList"
  66. :key="item.id"
  67. >
  68. <a class="article-link" target="_blank" :href="item.link">
  69. {{ item.title }} - {{ item.user_name }}
  70. </a>
  71. </li>
  72. </ul>
  73. </div>
  74. </div>
  75. <doc-footer></doc-footer>
  76. </template>
  77. <script lang="ts">
  78. import { defineComponent, onMounted, reactive, toRefs } from 'vue';
  79. import {
  80. onBeforeRouteUpdate,
  81. RouteLocationNormalized,
  82. useRoute
  83. } from 'vue-router';
  84. import Header from '@/sites/doc/components/Header.vue';
  85. import Footer from '@/sites/doc/components/Footer.vue';
  86. import { currentRoute } from '@/sites/assets/util/ref';
  87. import { ApiService } from '@/sites/service/ApiService';
  88. export default defineComponent({
  89. name: 'doc',
  90. components: {
  91. [Header.name]: Header,
  92. [Footer.name]: Footer
  93. },
  94. setup() {
  95. const articleList: any[] = [];
  96. const communityArticleList: any[] = [];
  97. const data = reactive({
  98. articleList,
  99. communityArticleList,
  100. tabData: [
  101. {
  102. title: '全部文章'
  103. }
  104. // {
  105. // title: '性能体验'
  106. // },
  107. // {
  108. // title: '性能体验'
  109. // }
  110. ],
  111. activeIndex: 0
  112. });
  113. const watchDemoUrl = (router: RouteLocationNormalized) => {
  114. currentRoute.value = router.name as string;
  115. };
  116. onMounted(() => {
  117. // 路由
  118. const route = useRoute();
  119. watchDemoUrl(route);
  120. // 文章列表接口
  121. const apiService = new ApiService();
  122. apiService.getArticle().then(res => {
  123. if (res?.state == 0) {
  124. (res.value.data.arrays as any[]).forEach(element => {
  125. if (element.type == 1) {
  126. data.articleList.push(element);
  127. } else {
  128. data.communityArticleList.push(element);
  129. }
  130. });
  131. }
  132. });
  133. });
  134. onBeforeRouteUpdate(to => {
  135. watchDemoUrl(to);
  136. });
  137. const clickTab = (index: number) => {
  138. data.activeIndex = index;
  139. };
  140. const toLink = (id: number) => {
  141. window.open('//jelly.jd.com/article/' + id);
  142. };
  143. return {
  144. ...toRefs(data),
  145. clickTab,
  146. toLink
  147. };
  148. }
  149. });
  150. </script>
  151. <style lang="scss" scoped>
  152. $mainRed: #fa685d;
  153. .resource {
  154. &-main {
  155. background-color: #1d1d1d;
  156. &-content {
  157. max-width: 1200px;
  158. margin: 0 auto;
  159. padding-top: 48px;
  160. padding-bottom: 53px;
  161. background: url('../../assets/images/bg-article.png') no-repeat;
  162. background-size: 307px 200px;
  163. background-position: right 280px top 0;
  164. .sub-title {
  165. margin-left: 8px;
  166. margin-bottom: 40px;
  167. line-height: 36px;
  168. font-size: 30px;
  169. color: $white;
  170. }
  171. .sub-desc {
  172. line-height: 22px;
  173. font-size: 16px;
  174. color: $white;
  175. }
  176. }
  177. }
  178. &-content {
  179. max-width: 1200px;
  180. margin: 0 auto;
  181. padding: 50px 0;
  182. }
  183. &-block {
  184. margin-bottom: 50px;
  185. text-align: left;
  186. .sub-title {
  187. margin-bottom: 15px;
  188. line-height: 42px;
  189. font-size: 30px;
  190. color: #1a1a1a;
  191. }
  192. .sub-desc {
  193. margin-bottom: 40px;
  194. line-height: 22px;
  195. font-size: 16px;
  196. color: #959fb1;
  197. }
  198. .sub-red {
  199. color: #fa2c19;
  200. }
  201. }
  202. }
  203. .no-data {
  204. text-align: center;
  205. .nodata-img-joy {
  206. width: 269px;
  207. height: 153px;
  208. margin-bottom: 30px;
  209. }
  210. .nodata-desc {
  211. font-size: 16px;
  212. color: #959fb1;
  213. }
  214. }
  215. .tab {
  216. &-box {
  217. }
  218. &-hd {
  219. display: flex;
  220. margin-bottom: 30px;
  221. }
  222. &-bd {
  223. display: flex;
  224. width: 100%;
  225. flex-wrap: wrap;
  226. justify-content: flex-start;
  227. }
  228. &-hd-item {
  229. margin-right: 40px;
  230. line-height: 25px;
  231. font-size: 18px;
  232. color: #808080;
  233. cursor: pointer;
  234. &:first-child {
  235. color: #1a1a1a;
  236. }
  237. &.active {
  238. color: #e32c36;
  239. }
  240. }
  241. }
  242. .design {
  243. &-item {
  244. width: 280px;
  245. margin-right: 26px;
  246. margin-bottom: 45px;
  247. cursor: pointer;
  248. &:nth-child(4n) {
  249. margin-right: 0;
  250. }
  251. .img-design {
  252. width: 280px;
  253. height: 170px;
  254. margin-bottom: 20px;
  255. border-radius: 5px;
  256. }
  257. }
  258. &-title {
  259. width: 280px;
  260. height: 44px;
  261. line-height: 22px;
  262. font-size: 16px;
  263. color: #1d1d21;
  264. text-overflow: -o-ellipsis-lastline;
  265. overflow: hidden;
  266. text-overflow: ellipsis;
  267. display: -webkit-box;
  268. -webkit-line-clamp: 2;
  269. line-clamp: 2;
  270. -webkit-box-orient: vertical;
  271. }
  272. }
  273. .article {
  274. &-item {
  275. position: relative;
  276. padding-left: 34px;
  277. margin-bottom: 20px;
  278. color: $mainRed;
  279. &:before {
  280. content: '';
  281. display: inline-block;
  282. position: absolute;
  283. top: 50%;
  284. left: 0;
  285. margin-top: -8px;
  286. width: 12px;
  287. height: 12px;
  288. border: 2px solid #fa2c19;
  289. border-radius: 50%;
  290. }
  291. }
  292. &-link {
  293. line-height: 22px;
  294. font-size: 14px;
  295. color: $mainRed;
  296. cursor: pointer;
  297. }
  298. }
  299. </style>