Skip to content

Commit b0c8a91

Browse files
committed
update lang
1 parent 285bfc7 commit b0c8a91

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

cloudfunctions/trending/fetch.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ const GITEE_URL = 'https://gitee.com';
66
async function fetchData({ lang = '', page = 1 } = {}) {
77
const data = await fetch(`${GITEE_URL}/explore/all?lang=${lang}&page=${page}`);
88
const $ = cheerio.load(await data.text());
9-
const langs = $('.explore-languagues__container .menu a').get().map(a => {
9+
10+
var langs = $('.explore-project__selection-container .actions .dropdown:nth-of-type(2) .menu a').get().map(a => {
1011
const queryArr = $(a).attr('href').split('=');
1112
return {
1213
query: queryArr.length === 2 ? queryArr[1] : '',
13-
val: $(a).find('span:first-child').text()
14+
val: $(a).text()
1415
};
1516
})
17+
// if (!lang && langs[0].val !== '全部语言') {
18+
// langs.unshift({query: '', val: '全部语言'})
19+
// }
1620

1721
const trending = {
1822
daily: [],

miniprogram/pages/explore/explore.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Page({
88
active: 0,
99
index: 0,
1010
lang: '',
11+
currLang: '全部语言',
1112
page: 1,
1213
total_pages: 100,
1314
langArr: [],
@@ -68,11 +69,13 @@ Page({
6869
},
6970
bindPickerChange: function(e) {
7071
this.setData({
71-
index: e.detail.value,
72+
index: 0,
73+
// index: e.detail.value,
7274
lang: this.data.langArr[e.detail.value].query,
7375
page: 1,
7476
repos: [],
75-
loading: true
77+
loading: true,
78+
currLang: this.data.langArr[e.detail.value].val
7679
})
7780
this.getTrending()
7881
},

miniprogram/pages/explore/explore.wxml

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,15 @@
4040

4141
<image class="btm-loading" hidden="{{ !btmloading }}" src="../../assets/loading.gif"></image>
4242

43-
<picker bindchange="bindPickerChange" value="{{index}}" range="{{langArr}}" range-key="val">
43+
<!-- <picker bindchange="bindPickerChange" value="{{index}}" range="{{langArr}}" range-key="val">
4444
<view class="picker">
4545
<view wx:if="{{langArr.length > 0}}" class="mybtn-primary fixed-btn">选择语言: {{langArr[index].val}}</view>
4646
</view>
47+
</picker> -->
48+
49+
<picker bindchange="bindPickerChange" value="{{index}}" range="{{langArr}}" range-key="val">
50+
<view class="picker">
51+
<view wx:if="{{langArr.length > 0}}" class="mybtn-primary fixed-btn">选择语言: {{currLang}}</view>
52+
</view>
4753
</picker>
4854

0 commit comments

Comments
 (0)