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

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