1+ import styles from './index.module.less' ;
2+ import { useFetch } from '../../hook/useFetch'
3+
4+ type ContributorsProps = {
5+ path ?: string
6+ }
7+
8+ export default function Contributors ( props : ContributorsProps ) {
9+ const { path } = props ;
10+ if ( ! path ) return null ;
11+ return (
12+ < div className = { styles . warpper } >
13+ < a className = { styles . edit } href = { `https://github.com/uiwjs/react-native-uiw/edit/master/${ path . replace ( / ^ \/ / , '' ) } ` } target = "__blank" >
14+ < svg viewBox = "0 0 1024 1024" width = "14" height = "14" fill = "#757575" >
15+ < path d = "M837.818182 0H186.181818C134.981818 0 93.090909 41.890909 93.090909 93.090909v837.818182c0 51.2 41.890909 93.090909 93.090909 93.090909h651.636364c51.2 0 93.090909-41.890909 93.090909-93.090909V93.090909c0-51.2-41.890909-93.090909-93.090909-93.090909z m46.545454 912.290909c0 37.236364-27.927273 65.163636-65.163636 65.163636H204.8c-37.236364 0-65.163636-27.927273-65.163636-65.163636V111.709091C139.636364 74.472727 167.563636 46.545455 204.8 46.545455h614.4c37.236364 0 65.163636 27.927273 65.163636 65.163636v800.581818z" />
16+ < path d = "M256 139.636364h418.909091c13.963636 0 23.272727 9.309091 23.272727 23.272727s-9.309091 23.272727-23.272727 23.272727h-418.909091c-13.963636 0-23.272727-9.309091-23.272727-23.272727s9.309091-23.272727 23.272727-23.272727zM256 279.272727h279.272727c13.963636 0 23.272727 9.309091 23.272728 23.272728s-9.309091 23.272727-23.272728 23.272727h-279.272727c-13.963636 0-23.272727-9.309091-23.272727-23.272727s9.309091-23.272727 23.272727-23.272728zM256 418.909091h139.636364c13.963636 0 23.272727 9.309091 23.272727 23.272727s-9.309091 23.272727-23.272727 23.272727h-139.636364c-13.963636 0-23.272727-9.309091-23.272727-23.272727s9.309091-23.272727 23.272727-23.272727z" />
17+ < path d = "M256 581.818182m-23.272727 0a23.272727 23.272727 0 1 0 46.545454 0 23.272727 23.272727 0 1 0-46.545454 0Z" />
18+ < path d = "M721.454545 558.545455h46.545455c13.963636 0 23.272727 9.309091 23.272727 23.272727s-9.309091 23.272727-23.272727 23.272727h-46.545455c-13.963636 0-23.272727-9.309091-23.272727-23.272727s9.309091-23.272727 23.272727-23.272727z" />
19+ < path d = "M404.945455 768l-102.4-97.745455L781.963636 190.836364c27.927273-27.927273 69.818182-27.927273 97.745455 0s27.927273 69.818182 0 97.745454" />
20+ < path d = "M339.781818 833.163636l-116.363636 18.618182 18.618182-116.363636 32.581818-32.581818L372.363636 800.581818" />
21+ </ svg >
22+ 在 GitHub 上编译此页
23+ </ a >
24+ < AvatarList path = { path } />
25+ </ div >
26+ )
27+ }
28+
29+ type Response = Array < {
30+ username : string ;
31+ url : string ;
32+ } >
33+
34+ function AvatarList ( props : { path : string } ) {
35+ const { path } = props ;
36+ const fetchurl = `https://proapi.azurewebsites.net/doc/getAvatarList?filename=${ path . replace ( / ^ \/ / , '' ) } &owner=uiwjs&repo=react-native-uiw` ;
37+ const res = useFetch < Response > ( fetchurl ) ;
38+ if ( ! res . response ) {
39+ return < span className = { styles . avatar } > Loading...</ span > ;
40+ }
41+ return (
42+ < span className = { styles . avatar } >
43+ { res . response . map ( ( item , idx ) => {
44+ return (
45+ < a href = { `https://github.com/${ item . username } ` } key = { idx } target = "__blank" >
46+ < img src = { item . url } alt = { item . username } />
47+ </ a >
48+ ) ;
49+ } ) }
50+ </ span >
51+ ) ;
52+ }
0 commit comments