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.

index.vue 2.5 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div>
  3. <div class="ui container">
  4. <SearchBar ref="searchBarRef" type="search" :sort="reposListSortType" :searchValue="reposListQurey"
  5. :topic="reposListTopic" @change="searchBarChange"></SearchBar>
  6. </div>
  7. <div class="ui container">
  8. <div class="ui grid">
  9. <div class="computer only ui two wide computer column">
  10. <ReposFilters ref="reposFiltersRef" @change="filtersChange"></ReposFilters>
  11. </div>
  12. <div class="ui sixteen wide mobile twelve wide tablet ten wide computer column">
  13. <ReposList ref="reposListRef" :sort="reposListSortType" :q="reposListQurey" :topic="reposListTopic">
  14. </ReposList>
  15. </div>
  16. <div class="computer only ui four wide computer column">
  17. <div>
  18. <ActiveUsers></ActiveUsers>
  19. </div>
  20. <div class="active-org-c">
  21. <ActiveOrgs></ActiveOrgs>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. import SearchBar from '../components/SearchBar.vue';
  30. import ReposFilters from '../components/ReposFilters.vue';
  31. import ReposList from '../components/ReposList.vue';
  32. import ActiveUsers from '../components/ActiveUsers.vue';
  33. import ActiveOrgs from '../components/ActiveOrgs.vue';
  34. import { getUrlSearchParams } from '~/utils';
  35. export default {
  36. data() {
  37. return {
  38. reposListSortType: 'mostpopular',
  39. reposListQurey: '',
  40. reposListTopic: '',
  41. };
  42. },
  43. components: {
  44. SearchBar,
  45. ReposFilters,
  46. ReposList,
  47. ActiveUsers,
  48. ActiveOrgs,
  49. },
  50. methods: {
  51. filtersChange(condition) {
  52. this.reposListSortType = condition.key;
  53. this.search();
  54. },
  55. searchBarChange(params) {
  56. this.reposListQurey = params.q || '';
  57. this.reposListTopic = params.topic || '';
  58. this.search();
  59. },
  60. search() {
  61. this.$nextTick(() => {
  62. this.$refs.reposListRef.search();
  63. });
  64. }
  65. },
  66. mounted() {
  67. const urlParams = getUrlSearchParams();
  68. this.reposListQurey = urlParams.q || '';
  69. this.reposListTopic = urlParams.topic || '';
  70. this.reposListSortType = urlParams.sort || 'mostpopular';
  71. this.search();
  72. this.$refs.reposFiltersRef.setDefaultFilter(this.reposListSortType);
  73. this.$refs.searchBarRef.setDefaultSearch({
  74. q: this.reposListQurey,
  75. topic: this.reposListTopic,
  76. });
  77. },
  78. beforeDestroy() { },
  79. };
  80. </script>
  81. <style scoped lang="less">
  82. .recommend-repos-c {
  83. margin: 0 0 54px;
  84. }
  85. .active-org-c {
  86. margin-top: 32px;
  87. }
  88. </style>