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 4.2 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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>{{ $t('repos.activeUsers') }}</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. <a class="name" :href="`/${item.User.Name}`" :title="(item.User.FullName || item.User.Name)">
  12. <img class="avatar" :src="item.User.RelAvatarLink">
  13. <div class="name-c">
  14. {{ item.User.FullName || item.User.Name }}
  15. </div>
  16. </a>
  17. </div>
  18. <div class="item-r">
  19. <template v-if="item.ShowButton">
  20. <a class="op-btn" v-if="!item.Followed" href="javascript:;" @click="following(item, index, true)">
  21. {{ $t('repos.follow') }}</a>
  22. <a class="op-btn" v-if="item.Followed" href="javascript:;" @click="following(item, index, false)">
  23. {{ $t('repos.unFollow') }}</a>
  24. </template>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import { getActiveUsers, followingUsers } from '~/apis/modules/repos';
  33. export default {
  34. name: "ActiveUsers",
  35. props: {},
  36. components: {},
  37. data() {
  38. return {
  39. list: [],
  40. };
  41. },
  42. methods: {
  43. following(userInfo, index, followingOrNot) {
  44. followingUsers(userInfo.User.Name, followingOrNot).then(res => {
  45. if (res.status == 204) { // 成功
  46. userInfo.Followed = !userInfo.Followed;
  47. } else {
  48. console.log(res);
  49. }
  50. }).catch(err => {
  51. if (err.response.status == 401) { // 未登陆
  52. window.location.href = `/user/login?redirect_to=${encodeURIComponent(window.location.href)}`;
  53. } else {
  54. console.log(err);
  55. }
  56. });
  57. }
  58. },
  59. mounted() {
  60. getActiveUsers().then(res => {
  61. res = res.data;
  62. if (res.Code == 0) {
  63. this.list = res.Data.Users || [];
  64. } else {
  65. this.list = [];
  66. }
  67. }).catch(err => {
  68. console.log(err);
  69. this.list = [];
  70. });
  71. },
  72. };
  73. </script>
  74. <style scoped lang="less">
  75. .title {
  76. height: 43px;
  77. border-color: rgba(16, 16, 16, 0.05);
  78. border-width: 1px 0px;
  79. border-style: solid;
  80. display: flex;
  81. align-items: center;
  82. font-size: 18px;
  83. color: rgba(47, 9, 69, 0.74);
  84. 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");
  85. }
  86. .content {
  87. padding: 6px 0;
  88. }
  89. .item {
  90. display: flex;
  91. align-items: center;
  92. height: 48px;
  93. padding: 0 8px;
  94. font-size: 14px;
  95. color: rgba(16, 16, 16, 1);
  96. }
  97. .item>div {
  98. display: flex;
  99. align-items: center;
  100. }
  101. .item-l {
  102. flex: 1;
  103. overflow: hidden;
  104. a {
  105. display: flex;
  106. align-items: center;
  107. overflow: hidden;
  108. }
  109. }
  110. .item-r {
  111. width: 80px;
  112. justify-content: flex-end;
  113. }
  114. .item .avatar {
  115. width: 32px;
  116. height: 32px;
  117. border-radius: 50%;
  118. margin-right: 10px;
  119. }
  120. .item .name-c {
  121. flex: 1;
  122. overflow: hidden;
  123. width: 100%;
  124. text-overflow: ellipsis;
  125. white-space: nowrap;
  126. }
  127. .item .name {
  128. color: rgba(16, 16, 16, 1);
  129. &:hover {
  130. opacity: 0.8;
  131. }
  132. }
  133. .item .op-btn {
  134. border-color: rgb(50, 145, 248);
  135. border-width: 1px;
  136. border-style: solid;
  137. color: rgb(50, 145, 248);
  138. font-size: 12px;
  139. padding: 0px 6px;
  140. border-radius: 3px;
  141. }
  142. </style>