Browse Source

repos square

tags/v1.22.12.1^2
chenshihai 3 years ago
parent
commit
0f1baf6e5e
7 changed files with 107 additions and 41 deletions
  1. +4
    -2
      templates/explore/repos/search.tmpl
  2. +12
    -2
      templates/explore/repos/square.tmpl
  3. +13
    -6
      web_src/vuepages/pages/repos/components/RecommendRepos.vue
  4. +34
    -18
      web_src/vuepages/pages/repos/components/SearchBar.vue
  5. +16
    -3
      web_src/vuepages/pages/repos/components/SquareTop.vue
  6. +13
    -6
      web_src/vuepages/pages/repos/search/index.vue
  7. +15
    -4
      web_src/vuepages/pages/repos/square/index.vue

+ 4
- 2
templates/explore/repos/search.tmpl View File

@@ -1,6 +1,8 @@
{{template "base/head_home" .}} {{template "base/head_home" .}}
<link rel="stylesheet" href="{{StaticUrlPrefix}}/css/vp-repos-search.css?v={{MD5 AppVer}}" /> <link rel="stylesheet" href="{{StaticUrlPrefix}}/css/vp-repos-search.css?v={{MD5 AppVer}}" />
<div id="__vue-root">
</div>
<script>
var staticSquareTopics = {{ .SquareTopics }};
</script>
<div id="__vue-root"></div>
<script src="{{StaticUrlPrefix}}/js/vp-repos-search.js?v={{MD5 AppVer}}"></script> <script src="{{StaticUrlPrefix}}/js/vp-repos-search.js?v={{MD5 AppVer}}"></script>
{{template "base/footer" .}} {{template "base/footer" .}}

+ 12
- 2
templates/explore/repos/square.tmpl View File

@@ -1,6 +1,16 @@
{{template "base/head_home" .}} {{template "base/head_home" .}}
{{ if .SquareBanners }}
{{ range .SquareBanners }}
<img preload style="height:0;width:0;position:absolute;left:-2000px;" src="{{.src}}" />
{{ end }}
{{ end }}
<link rel="stylesheet" href="{{StaticUrlPrefix}}/css/vp-repos-square.css?v={{MD5 AppVer}}" /> <link rel="stylesheet" href="{{StaticUrlPrefix}}/css/vp-repos-square.css?v={{MD5 AppVer}}" />
<div id="__vue-root">
</div>
<script>
var staticSquareBanners = {{ .SquareBanners }};
var staticSquarePreferredRepos = {{ .SquarePreferredRepos }};
var staticSquareTopics = {{ .SquareTopics }};
var staticSquareRecommendRepos = {{ .SquareRecommendRepos }};
</script>
<div id="__vue-root"></div>
<script src="{{StaticUrlPrefix}}/js/vp-repos-square.js?v={{MD5 AppVer}}"></script> <script src="{{StaticUrlPrefix}}/js/vp-repos-square.js?v={{MD5 AppVer}}"></script>
{{template "base/footer" .}} {{template "base/footer" .}}

+ 13
- 6
web_src/vuepages/pages/repos/components/RecommendRepos.vue View File

@@ -15,7 +15,10 @@ import { getHomePageData } from '~/apis/modules/repos';


export default { export default {
name: "RecommendRepos", name: "RecommendRepos",
props: {},
props: {
static: { type: Boolean, default: false },
staticSwiperData: { type: Array, default: () => [] },
},
components: {}, components: {},
data() { data() {
return { return {
@@ -93,11 +96,15 @@ export default {
} }
}, },
mounted() { mounted() {
getHomePageData().then(res => {
this.renderRepos(res.data.repo);
}).catch(err => {
console.log(err);
});
if (this.static) {
this.renderRepos(this.staticSwiperData);
} else {
getHomePageData().then(res => {
this.renderRepos(res.data.repo);
}).catch(err => {
console.log(err);
});
}
}, },
}; };
</script> </script>


+ 34
- 18
web_src/vuepages/pages/repos/components/SearchBar.vue View File

@@ -66,6 +66,8 @@ export default {
searchValue: { type: String, default: '' }, searchValue: { type: String, default: '' },
topic: { type: String, default: '' }, topic: { type: String, default: '' },
sort: { type: String, default: '' }, sort: { type: String, default: '' },
static: { type: Boolean, default: false },
staticTopicsData: { type: String, default: '[]' },
}, },
components: {}, components: {},
data() { data() {
@@ -83,6 +85,10 @@ export default {
setDefaultSearch(params) { setDefaultSearch(params) {
this.searchInputValue = params.q || ''; this.searchInputValue = params.q || '';
this.selectTopic = params.topic || ''; this.selectTopic = params.topic || '';
this.selectTopic && this.changeTopic({
k: this.selectTopic.toLocaleLowerCase(),
v: this.selectTopic,
})
}, },
changeTopic(topicItem) { changeTopic(topicItem) {
const index_ori = this.topicOri.findIndex((item) => { const index_ori = this.topicOri.findIndex((item) => {
@@ -108,21 +114,7 @@ export default {
} }
this.search(); this.search();
}, },
search() {
if (this.type == 'square') {
window.location.href = `/explore/repos?q=${this.searchInputValue}&sort=${this.sort}&topic=${this.selectTopic}`;
} else {
this.$emit('change', {
q: this.searchInputValue,
topic: this.selectTopic,
});
}
}
},
watch: {},
mounted() {
getPromoteData('/repos/recommend_topics').then(res => {
const data = res.data;
handlerTopicsData(data) {
try { try {
const topicsData = JSON.parse(data); const topicsData = JSON.parse(data);
const topics = topicsData.map((item) => { const topics = topicsData.map((item) => {
@@ -148,9 +140,33 @@ export default {
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} }
}).catch(err => {
console.log(err);
});
},
search() {
if (this.type == 'square') {
window.location.href = `/explore/repos?q=${this.searchInputValue}&sort=${this.sort}&topic=${this.selectTopic}`;
} else {
this.$emit('change', {
q: this.searchInputValue,
topic: this.selectTopic,
});
}
}
},
mounted() {
if (this.static) {
try {
this.handlerTopicsData(this.staticTopicsData);
} catch (err) {
console.log(err);
}
} else {
getPromoteData('/repos/recommend_topics').then(res => {
const data = res.data;
this.handlerTopicsData(data);
}).catch(err => {
console.log(err);
});
}
}, },
}; };
</script> </script>


+ 16
- 3
web_src/vuepages/pages/repos/components/SquareTop.vue View File

@@ -40,7 +40,11 @@ import { getReposSquareTabData } from '~/apis/modules/repos';


export default { export default {
name: "SquareTop", name: "SquareTop",
props: {},
props: {
static: { type: Boolean, default: false },
staticSwiperData: { type: Array, default: () => [] },
staticBannerData: { type: String, default: '[]' },
},
components: {}, components: {},
data() { data() {
return { return {
@@ -147,8 +151,17 @@ export default {
}, },
mounted() { mounted() {
this.initSwiper(); this.initSwiper();
this.getBannerData();
this.getTabData();
if (this.static) {
try {
this.bannerData = JSON.parse(this.staticBannerData);
} catch (err) {
console.log(err);
}
this.renderSwiper(this.staticSwiperData);
} else {
this.getBannerData();
this.getTabData();
}
}, },
}; };
</script> </script>


+ 13
- 6
web_src/vuepages/pages/repos/search/index.vue View File

@@ -1,8 +1,9 @@
<template> <template>
<div> <div>
<div class="ui container"> <div class="ui container">
<SearchBar ref="searchBarRef" type="search" :sort="reposListSortType" :searchValue="reposListQurey"
:topic="reposListTopic" @change="searchBarChange"></SearchBar>
<SearchBar ref="searchBarRef" type="search" :static="true" :staticTopicsData="staticSquareTopics"
:sort="reposListSortType" :searchValue="reposListQurey" :topic="reposListTopic" @change="searchBarChange">
</SearchBar>
</div> </div>
<div class="ui container"> <div class="ui container">
<div class="ui grid"> <div class="ui grid">
@@ -34,12 +35,16 @@ import ActiveUsers from '../components/ActiveUsers.vue';
import ActiveOrgs from '../components/ActiveOrgs.vue'; import ActiveOrgs from '../components/ActiveOrgs.vue';
import { getUrlSearchParams } from '~/utils'; import { getUrlSearchParams } from '~/utils';


const staticSquareTopics = JSON.stringify(window.staticSquareTopics || []);

export default { export default {
data() { data() {
return { return {
reposListSortType: 'mostpopular', reposListSortType: 'mostpopular',
reposListQurey: '', reposListQurey: '',
reposListTopic: '', reposListTopic: '',

staticSquareTopics: staticSquareTopics,
}; };
}, },
components: { components: {
@@ -71,10 +76,12 @@ export default {
this.reposListTopic = urlParams.topic || ''; this.reposListTopic = urlParams.topic || '';
this.reposListSortType = urlParams.sort || 'mostpopular'; this.reposListSortType = urlParams.sort || 'mostpopular';
this.search(); this.search();
this.$refs.reposFiltersRef.setDefaultFilter(this.reposListSortType);
this.$refs.searchBarRef.setDefaultSearch({
q: this.reposListQurey,
topic: this.reposListTopic,
this.$nextTick(() => {
this.$refs.reposFiltersRef.setDefaultFilter(this.reposListSortType);
this.$refs.searchBarRef.setDefaultSearch({
q: this.reposListQurey,
topic: this.reposListTopic,
});
}); });
}, },
beforeDestroy() { }, beforeDestroy() { },


+ 15
- 4
web_src/vuepages/pages/repos/square/index.vue View File

@@ -1,14 +1,15 @@
<template> <template>
<div> <div>
<div> <div>
<SquareTop></SquareTop>
<SquareTop :static="true" :staticBannerData="staticSquareBanners" :staticSwiperData="staticSquarePreferredRepos">
</SquareTop>
</div> </div>
<div class="ui container"> <div class="ui container">
<SearchBar ref="searchBarRef" type="square" :sort="``" :searchValue="reposListQurey" :topic="``"
@change="searchBarChange"></SearchBar>
<SearchBar :static="true" :staticTopicsData="staticSquareTopics" ref="searchBarRef" type="square" :sort="``"
:searchValue="reposListQurey" :topic="``" @change="searchBarChange"></SearchBar>
</div> </div>
<div class="recommend-repos-c"> <div class="recommend-repos-c">
<RecommendRepos></RecommendRepos>
<RecommendRepos :static="true" :staticSwiperData="staticSquareRecommendRepos"></RecommendRepos>
</div> </div>
<div class="ui container"> <div class="ui container">
<div class="ui grid"> <div class="ui grid">
@@ -41,12 +42,22 @@ import ReposList from '../components/ReposList.vue';
import ActiveUsers from '../components/ActiveUsers.vue'; import ActiveUsers from '../components/ActiveUsers.vue';
import ActiveOrgs from '../components/ActiveOrgs.vue'; import ActiveOrgs from '../components/ActiveOrgs.vue';


const staticSquareBanners = JSON.stringify(window.staticSquareBanners || []);
const staticSquarePreferredRepos = window.staticSquarePreferredRepos || [];
const staticSquareTopics = JSON.stringify(window.staticSquareTopics || []);
const staticSquareRecommendRepos = window.staticSquareRecommendRepos || [];

export default { export default {
data() { data() {
return { return {
reposListSortType: 'mostpopular', reposListSortType: 'mostpopular',
reposListQurey: '', reposListQurey: '',
reposListTopic: '', reposListTopic: '',

staticSquareBanners: staticSquareBanners,
staticSquarePreferredRepos: staticSquarePreferredRepos,
staticSquareTopics: staticSquareTopics,
staticSquareRecommendRepos: staticSquareRecommendRepos,
}; };
}, },
components: { components: {


Loading…
Cancel
Save