File tree Expand file tree Collapse file tree 2 files changed +44
-3
lines changed Expand file tree Collapse file tree 2 files changed +44
-3
lines changed Original file line number Diff line number Diff line change 13
13
repo : '' ,
14
14
detail : { } ,
15
15
repourl : '' ,
16
+ branches : [ ] ,
17
+ branchIndex : 0 ,
16
18
readme : '' ,
17
19
loading : true ,
18
20
no : '暂无描述' ,
44
46
REPO . getRepoInfo ( query ) . then ( res => {
45
47
this . setData ( {
46
48
detail : res ,
47
- loading : false ,
48
49
repourl : `${ res . namespace . html_url } /${ res . path } `
49
50
} )
51
+ this . fetchBranches ( query )
50
52
} ) . catch ( err => {
51
53
console . log ( err )
52
54
this . setData ( {
@@ -64,7 +66,38 @@ Page({
64
66
} )
65
67
} ) . catch ( err => {
66
68
console . log ( err )
69
+ this . setData ( {
70
+ readme : Base64 . decode ( '' ) ,
71
+ } )
72
+ } )
73
+ } ,
74
+
75
+ fetchBranches ( query ) {
76
+ REPO . getRepoBranches ( query ) . then ( res => {
77
+ const index = res . findIndex ( el => el . name === this . data . detail . default_branch )
78
+ this . setData ( {
79
+ branches : res ,
80
+ branchIndex : index ,
81
+ loading : false
82
+ } )
83
+ } ) . catch ( err => {
84
+ console . log ( err )
85
+ this . setData ( {
86
+ loading : false
87
+ } )
88
+ } )
89
+ } ,
90
+
91
+ switchBranch ( e ) {
92
+ this . setData ( {
93
+ branchIndex : e . detail . value
67
94
} )
95
+ const query = {
96
+ owner : this . data . owner ,
97
+ repo : this . data . repo ,
98
+ ref : this . data . branches [ this . data . branchIndex ] . name
99
+ }
100
+ this . fetchReadme ( query )
68
101
} ,
69
102
70
103
copyIt : function ( e ) {
@@ -86,7 +119,7 @@ Page({
86
119
owner : this . data . owner ,
87
120
repo : this . data . repo ,
88
121
name : this . data . detail . human_name ,
89
- sha : this . data . detail . default_branch
122
+ sha : this . data . branches [ this . data . branchIndex ] . name
90
123
}
91
124
wx . navigateTo ( {
92
125
url : `../repo/dir?query=${ JSON . stringify ( query ) } `
Original file line number Diff line number Diff line change 34
34
</view>
35
35
<view class="list">
36
36
<view class="list_title">分支</view>
37
- <view class="list_content">{{ detail.default_branch }}</view>
37
+ <picker bindchange="switchBranch" value="{{branchIndex}}" range="{{branches}}" range-key="name">
38
+ <view class="picker">
39
+ <view class="list_content">
40
+ <text>{{ branches[branchIndex].name }}</text>
41
+ <van-icon name="arrow" />
42
+ </view>
43
+ </view>
44
+ </picker>
45
+ <!-- <view class="list_content">{{ detail.default_branch }}</view> -->
38
46
</view>
39
47
<view wx:if="{{ detail.language }}" class="list">
40
48
<view class="list_title">语言</view>
You can’t perform that action at this time.
0 commit comments