Browse Source

Merge remote-tracking branch 'origin/repo-square' into repo-square

tags/v1.22.12.1^2
chenyifan01 3 years ago
parent
commit
dfd9bf36a7
10 changed files with 117 additions and 41 deletions
  1. +4
    -2
      templates/explore/repos/search.tmpl
  2. +12
    -2
      templates/explore/repos/square.tmpl
  3. +1
    -0
      web_src/vuepages/langs/config/en-US.js
  4. +1
    -0
      web_src/vuepages/langs/config/zh-CN.js
  5. +13
    -6
      web_src/vuepages/pages/repos/components/RecommendRepos.vue
  6. +8
    -0
      web_src/vuepages/pages/repos/components/ReposList.vue
  7. +34
    -18
      web_src/vuepages/pages/repos/components/SearchBar.vue
  8. +16
    -3
      web_src/vuepages/pages/repos/components/SquareTop.vue
  9. +13
    -6
      web_src/vuepages/pages/repos/search/index.vue
  10. +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" .}}

+ 1
- 0
web_src/vuepages/langs/config/en-US.js View File

@@ -311,6 +311,7 @@ const en = {
watch: 'Watch', watch: 'Watch',
star: 'Star', star: 'Star',
fork: 'Fork', fork: 'Fork',
noReposfound: 'No matching repositories found.',
} }
} }




+ 1
- 0
web_src/vuepages/langs/config/zh-CN.js View File

@@ -328,6 +328,7 @@ const zh = {
watch: '关注', watch: '关注',
star: '点赞', star: '点赞',
fork: '派生', fork: '派生',
noReposfound: '未找到匹配的项目。',
}, },
} }




+ 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>


+ 8
- 0
web_src/vuepages/pages/repos/components/ReposList.vue View File

@@ -4,6 +4,7 @@
<div class="repos-item-container" v-for="(item, index) in list" :key="item.ID"> <div class="repos-item-container" v-for="(item, index) in list" :key="item.ID">
<ReposItem :data="item" :topic="topic"></ReposItem> <ReposItem :data="item" :topic="topic"></ReposItem>
</div> </div>
<div v-show="(!list.length && !loading)" class="repos-no-data">{{ $t('repos.noReposfound') }}</div>
</div> </div>
<div class="center"> <div class="center">
<el-pagination background @current-change="currentChange" @size-change="sizeChange" :current-page="page" <el-pagination background @current-change="currentChange" @size-change="sizeChange" :current-page="page"
@@ -118,4 +119,11 @@ export default {
.center { .center {
text-align: center; text-align: center;
} }

.repos-no-data {
height: 60px;
display: flex;
justify-content: center;
align-items: center;
}
</style> </style>

+ 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