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.9 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. <img class="avatar" :src="item.User.RelAvatarLink">
  12. <div class="name-c">
  13. <a class="name" :href="`/${item.User.Name}`" :title="(item.User.FullName || item.User.Name)">
  14. {{ item.User.FullName || item.User.Name }}
  15. </a>
  16. </div>
  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. }
  48. }).catch(err => {
  49. if (err.response.status == 401) { // 未登陆
  50. window.location.href = '/user/login';
  51. }
  52. });
  53. }
  54. },
  55. mounted() {
  56. getActiveUsers().then(res => {
  57. res = res.data;
  58. if (res.Code == 0) {
  59. this.list = res.Data.Users || [];
  60. }
  61. }).catch(err => {
  62. console.log(err);
  63. });
  64. },
  65. };
  66. </script>
  67. <style scoped lang="less">
  68. .title {
  69. height: 43px;
  70. border-color: rgba(16, 16, 16, 0.05);
  71. border-width: 1px 0px;
  72. border-style: solid;
  73. display: flex;
  74. align-items: center;
  75. font-size: 18px;
  76. color: rgba(47, 9, 69, 0.74);
  77. 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");
  78. }
  79. .content {
  80. padding: 6px 0;
  81. }
  82. .item {
  83. display: flex;
  84. align-items: center;
  85. height: 48px;
  86. padding: 0 8px;
  87. font-size: 14px;
  88. color: rgba(16, 16, 16, 1);
  89. }
  90. .item>div {
  91. display: flex;
  92. align-items: center;
  93. }
  94. .item-l {
  95. flex: 1;
  96. overflow: hidden;
  97. }
  98. .item-r {
  99. width: 80px;
  100. justify-content: flex-end;
  101. }
  102. .item .avatar {
  103. width: 32px;
  104. height: 32px;
  105. border-radius: 50%;
  106. margin-right: 10px;
  107. }
  108. .item .name-c {
  109. flex: 1;
  110. overflow: hidden;
  111. width: 100%;
  112. text-overflow: ellipsis;
  113. white-space: nowrap;
  114. }
  115. .item .name {
  116. color: rgba(16, 16, 16, 1);
  117. &:hover {
  118. opacity: 0.8;
  119. }
  120. }
  121. .item .op-btn {
  122. border-color: rgb(50, 145, 248);
  123. border-width: 1px;
  124. border-style: solid;
  125. color: rgb(50, 145, 248);
  126. font-size: 12px;
  127. padding: 0px 6px;
  128. border-radius: 3px;
  129. }
  130. </style>