Research.tsx 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import { css } from "@linaria/core";
  2. import Image from "@/components/Image";
  3. import { useArticle } from "@/modules";
  4. import { ArrowRightOutlined } from "@ant-design/icons-vue";
  5. import { Empty } from "ant-design-vue";
  6. import dayjs from "dayjs";
  7. import { defineComponent, onMounted, reactive } from "vue";
  8. import { RouterLink, useRouter } from "vue-router";
  9. import { renderSummary, renderTitle } from "@/modules/objects";
  10. export default defineComponent({
  11. setup() {
  12. const storeArt = useArticle();
  13. const router = useRouter();
  14. const categoryId = "6464b7398dcb7ddb98b57a60";
  15. const state = reactive({
  16. list: [],
  17. });
  18. onMounted(() => {
  19. getList();
  20. });
  21. const getList = async () => {
  22. const query = {
  23. page: 1,
  24. size: 4,
  25. query: JSON.stringify({ cid: categoryId }),
  26. };
  27. const res = await storeArt.getArticleList(query);
  28. const list = res.list || [];
  29. state.list = list;
  30. };
  31. const turnPage = (aid: string) => {
  32. router.push({
  33. name: "article",
  34. params: { id: categoryId },
  35. query: { aid },
  36. });
  37. };
  38. return () => (
  39. <div class={[page, "home_lay_item_box"]}>
  40. <div class={"global_w"}>
  41. <div class={"home_lay_title white "}>
  42. 科研创作<span>/</span>
  43. <span>Scientific Research</span>
  44. </div>
  45. {state.list.length > 0 ? (
  46. <div class={"tab_list"}>
  47. {state.list.map((e: ArticleItem) => {
  48. return (
  49. <div class={"list_item"}>
  50. <div
  51. class={"item"}
  52. onClick={() => {
  53. turnPage(e._id);
  54. }}
  55. >
  56. <div class={"list_img"}>
  57. <Image src={e.cover} />
  58. </div>
  59. <div class={"info_box"}>
  60. <div class={"item_tit"}>{renderTitle(e.title)}</div>
  61. <div class={"item_desc"}>
  62. {renderSummary(e.summary)}
  63. </div>
  64. <div class={"item_date"}>
  65. {dayjs(e.createTime).format("YYYY.MM.DD")}
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. );
  71. })}
  72. </div>
  73. ) : (
  74. <div class={"ant-list-empty-text"}>
  75. <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
  76. </div>
  77. )}
  78. <div class={"list_more"}>
  79. <RouterLink to={`/detail/${categoryId}`}>
  80. 查看更多
  81. <ArrowRightOutlined class={"arrow"} />
  82. </RouterLink>
  83. </div>
  84. </div>
  85. </div>
  86. );
  87. },
  88. });
  89. const page = css`
  90. position: relative;
  91. background: url("@/assets/bg_research.png") no-repeat center top/100% auto;
  92. .tab_list {
  93. display: grid;
  94. grid-template-columns: repeat(4, 1fr);
  95. gap: 24px;
  96. .list_item {
  97. width: 100%;
  98. background-color: #fff;
  99. overflow: hidden;
  100. position: relative;
  101. .item {
  102. position: relative;
  103. display: block;
  104. border-bottom: 2px solid rgba(159, 159, 159, 0.5);
  105. cursor: pointer;
  106. &::before {
  107. content: "";
  108. position: absolute;
  109. bottom: 0;
  110. right: 0;
  111. border-width: 6px;
  112. border-color: transparent rgba(159, 159, 159, 0.5)
  113. rgba(159, 159, 159, 0.5) transparent;
  114. }
  115. &::after {
  116. content: "";
  117. position: absolute;
  118. bottom: -2px;
  119. right: 0;
  120. width: 0;
  121. height: 2px;
  122. background-color: var(--vt-c-primary);
  123. transition: width 0.3s ease-in-out;
  124. }
  125. &:hover {
  126. &::before {
  127. border-color: transparent var(--vt-c-primary) var(--vt-c-primary)
  128. transparent;
  129. }
  130. &::after {
  131. width: 100%;
  132. }
  133. img {
  134. transform: scale(1.2);
  135. }
  136. }
  137. }
  138. .list_img {
  139. width: 100%;
  140. height: 390px;
  141. overflow: hidden;
  142. }
  143. img {
  144. width: 100%;
  145. height: 390px;
  146. object-fit: cover;
  147. transition: all 0.3s ease-in-out;
  148. }
  149. .info_box {
  150. padding: 20px 18px;
  151. }
  152. .item_tit {
  153. height: 56px;
  154. font-size: 20px;
  155. line-height: 28px;
  156. color: #333333;
  157. overflow: hidden;
  158. }
  159. .item_desc {
  160. height: 72px;
  161. overflow: hidden;
  162. margin-top: 20px;
  163. font-size: 16px;
  164. line-height: 24px;
  165. font-weight: 400;
  166. color: #666666;
  167. word-break: break-all;
  168. }
  169. .item_date {
  170. font-size: 14px;
  171. margin-top: 30px;
  172. font-weight: 300;
  173. color: #999999;
  174. }
  175. }
  176. }
  177. .list_more {
  178. margin-top: 35px;
  179. text-align: center;
  180. a {
  181. color: var(--vt-c-primary);
  182. }
  183. .arrow {
  184. margin-left: 8px;
  185. padding: 2px;
  186. border: 1px solid var(--vt-c-primary);
  187. font-size: 12px;
  188. border-radius: 50%;
  189. }
  190. }
  191. `;