You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ActiveUsers.vue 3.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div>
  3. <div class="container">
  4. <div class="title">
  5. <i style="margin-left:10px;margin-right:8px;font-size:20px;" class="ri-account-pin-circle-line"></i>
  6. <span>活跃用户</span>
  7. </div>
  8. <div class="content">
  9. <div class="item" v-for="(item, index) in list" :key="index">
  10. <div class="item-l">
  11. <img class="avatar" :src="item.User.RelAvatarLink">
  12. <div class="name-c"><a class="name" :href="`/${item.User.Name}`"
  13. :title="(item.User.FullName || item.User.Name)">{{ item.User.FullName || item.User.Name
  14. }}</a></div>
  15. </div>
  16. <div class="item-r">
  17. <template v-if="item.ShowButton">
  18. <a class="op-btn" v-if="!item.Followed" href="javascript:;" @click="following(item, index, true)">关注</a>
  19. <a class="op-btn" v-if="item.Followed" href="javascript:;" @click="following(item, index, false)">取消关注</a>
  20. </template>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import { getActiveUsers, followingUsers } from '~/apis/modules/repos';
  29. export default {
  30. name: "ActiveUsers",
  31. props: {},
  32. components: {},
  33. data() {
  34. return {
  35. list: [],
  36. };
  37. },
  38. methods: {
  39. following(userInfo, index, followingOrNot) {
  40. followingUsers(userInfo.User.Name, followingOrNot).then(res => {
  41. if (res.status == 204) { // 成功
  42. userInfo.Followed = !userInfo.Followed;
  43. }
  44. }).catch(err => {
  45. if (err.response.status == 401) { // 未登陆
  46. window.location.href = '/user/login';
  47. }
  48. });
  49. }
  50. },
  51. mounted() {
  52. getActiveUsers().then(res => {
  53. res = res.data;
  54. if (res.Code == 0) {
  55. this.list = res.Data.Users || [];
  56. }
  57. }).catch(err => {
  58. console.log(err);
  59. });
  60. },
  61. };
  62. </script>
  63. <style scoped lang="less">
  64. .title {
  65. height: 43px;
  66. border-color: rgba(16, 16, 16, 0.05);
  67. border-width: 1px 0px;
  68. border-style: solid;
  69. display: flex;
  70. align-items: center;
  71. font-size: 18px;
  72. color: rgba(47, 9, 69, 0.74);
  73. background: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22matrix(-1.007%2C%200.0010000000000001494%2C%20-0.000018400023883213844%2C%20-1.007%2C%201.003%2C%200.008)%22%3E%3Cstop%20stop-color%3D%22%23eee9da%22%20stop-opacity%3D%220%22%20offset%3D%220%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23f3e7f7%22%20stop-opacity%3D%220.26%22%20offset%3D%220.29%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23d0e7ff%22%20stop-opacity%3D%220.3%22%20offset%3D%221%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E");
  74. }
  75. .content {
  76. padding: 6px 0;
  77. }
  78. .item {
  79. display: flex;
  80. align-items: center;
  81. height: 48px;
  82. padding: 0 8px;
  83. font-size: 14px;
  84. color: rgba(16, 16, 16, 1);
  85. }
  86. .item>div {
  87. display: flex;
  88. align-items: center;
  89. }
  90. .item-l {
  91. flex: 1;
  92. overflow: hidden;
  93. }
  94. .item-r {
  95. width: 80px;
  96. justify-content: flex-end;
  97. }
  98. .item .avatar {
  99. width: 32px;
  100. height: 32px;
  101. border-radius: 50%;
  102. margin-right: 10px;
  103. }
  104. .item .name-c {
  105. flex: 1;
  106. overflow: hidden;
  107. width: 100%;
  108. text-overflow: ellipsis;
  109. white-space: nowrap;
  110. }
  111. .item .name {
  112. color: rgba(16, 16, 16, 1);
  113. &:hover {
  114. opacity: 0.8;
  115. }
  116. }
  117. .item .op-btn {
  118. border-color: rgb(50, 145, 248);
  119. border-width: 1px;
  120. border-style: solid;
  121. color: rgb(50, 145, 248);
  122. font-size: 12px;
  123. padding: 0px 6px;
  124. border-radius: 3px;
  125. }
  126. </style>