1
- import { html , define } from " hybrids" ;
2
- import style from " ./style.less" ;
3
- import infoIcon from " @images/info.svg?raw" ;
4
- import checkIcon from " @images/check.svg?raw" ;
5
- import addIcon from " @images/add.svg?raw" ;
6
- import { isIntranet } from " @utils/index" ;
1
+ import { html , define } from ' hybrids' ;
2
+ import style from ' ./style.less' ;
3
+ import infoIcon from ' @images/info.svg?raw' ;
4
+ import checkIcon from ' @images/check.svg?raw' ;
5
+ import addIcon from ' @images/add.svg?raw' ;
6
+ import { isIntranet } from ' @utils/index' ;
7
7
8
- const getIssueHelper = ( framework ) =>
9
- `https://github.com/Tencent/tdesign-${ framework } /issues/new/choose` ;
8
+ const getIssueHelper = ( framework ) => `https://github.com/Tencent/tdesign-${ framework } /issues/new/choose` ;
10
9
11
10
// 已开源的不区分内外网 统一去外网 GitHub
12
11
const issueUrlMap = {
13
12
vue : `https://github.com/Tencent/tdesign-vue/issues` ,
14
13
react : `https://github.com/Tencent/tdesign-react/issues` ,
15
- " vue-next" : `https://github.com/Tencent/tdesign-vue-next/issues` ,
16
- " mobile-vue" : `https://github.com/Tencent/tdesign-mobile-vue/issues` ,
17
- " mobile-react" : `https://github.com/Tencent/tdesign-mobile-react/issues` ,
14
+ ' vue-next' : `https://github.com/Tencent/tdesign-vue-next/issues` ,
15
+ ' mobile-vue' : `https://github.com/Tencent/tdesign-mobile-vue/issues` ,
16
+ ' mobile-react' : `https://github.com/Tencent/tdesign-mobile-react/issues` ,
18
17
miniprogram : `https://github.com/Tencent/tdesign-miniprogram/issues` ,
19
- flutter : `https://github.com/TDesignOteam/tdesign -flutter/issues` ,
18
+ flutter : `https://github.com/Tencent/tdesing -flutter/issues` ,
20
19
} ;
21
20
22
21
function parseUrl ( ) {
23
22
let urlPath = location . pathname ;
24
23
// 预览站点为hash模式
25
- if ( location . pathname === "/" && location . hash ) {
24
+ if ( location . pathname === '/' && location . hash ) {
26
25
urlPath = location . hash . slice ( 1 ) ;
27
26
}
28
27
const matches = urlPath . match ( / ( [ \w - ] + ) \/ c o m p o n e n t s \/ ( [ \w - ] + ) / ) || [ ] ;
@@ -34,9 +33,7 @@ function getCurrentIssueUrl() {
34
33
const [ , framework , componentName ] = parseUrl ( ) ;
35
34
36
35
return {
37
- newUrl : isIntranet ( )
38
- ? `${ issueUrlMap [ framework ] } /new`
39
- : getIssueHelper ( framework ) ,
36
+ newUrl : isIntranet ( ) ? `${ issueUrlMap [ framework ] } /new` : getIssueHelper ( framework ) ,
40
37
openUrl : isIntranet ( )
41
38
? `${ issueUrlMap [ framework ] } ?issue_search=${ componentName } `
42
39
: `${ issueUrlMap [ framework ] } ?q=is:issue+is:open+${ componentName } ` ,
@@ -49,7 +46,7 @@ function getCurrentIssueUrl() {
49
46
function handleIssueClick ( e , issueInfo , type ) {
50
47
e . preventDefault ( ) ;
51
48
const url = issueInfo [ `${ type } Url` ] ;
52
- window . open ( url , " _blank" ) ;
49
+ window . open ( url , ' _blank' ) ;
53
50
}
54
51
55
52
function renderIssue ( host ) {
@@ -67,35 +64,26 @@ function renderIssue(host) {
67
64
68
65
return html `
69
66
< section id ="issue " class ="TDesign-component-issue ">
70
- < a
71
- onclick ="${ ( host , e ) => handleIssueClick ( e , issueInfo , "new" ) } "
72
- class ="item "
73
- >
67
+ < a onclick ="${ ( host , e ) => handleIssueClick ( e , issueInfo , 'new' ) } " class ="item ">
74
68
< i innerHTML =${ addIcon } > </ i >
75
69
< span > Issue</ span >
76
70
</ a >
77
- < a
78
- onclick ="${ ( host , e ) => handleIssueClick ( e , issueInfo , "open" ) } "
79
- class ="item "
80
- >
71
+ < a onclick ="${ ( host , e ) => handleIssueClick ( e , issueInfo , 'open' ) } " class ="item ">
81
72
< i innerHTML =${ infoIcon } > </ i >
82
- < span > ${ issueInfo ?. openNum || "" } Open</ span >
73
+ < span > ${ issueInfo ?. openNum || '' } Open</ span >
83
74
</ a >
84
- < a
85
- onclick ="${ ( host , e ) => handleIssueClick ( e , issueInfo , "closed" ) } "
86
- class ="item "
87
- >
75
+ < a onclick ="${ ( host , e ) => handleIssueClick ( e , issueInfo , 'closed' ) } " class ="item ">
88
76
< i innerHTML =${ checkIcon } > </ i >
89
- < span > ${ issueInfo ?. closedNum || "" } Closed</ span >
77
+ < span > ${ issueInfo ?. closedNum || '' } Closed</ span >
90
78
</ a >
91
79
</ section >
92
80
` ;
93
81
}
94
82
95
83
// 获取 github issue 数量
96
- const getGithubIssueUrl = ( name , state = " open" , repo ) =>
84
+ const getGithubIssueUrl = ( name , state = ' open' , repo ) =>
97
85
`https://api.github.com/search/issues?q=is:issue+is:${ state } +${ name } +repo:Tencent/${ repo } ` ;
98
- function fetchGithubIssueNum ( host , name , state = " open" , framework ) {
86
+ function fetchGithubIssueNum ( host , name , state = ' open' , framework ) {
99
87
const issueUrl = getGithubIssueUrl ( name , state , `tdesign-${ framework } ` ) ;
100
88
const cacheKey = `__tdesign_${ framework } _${ name } _${ state } __` ;
101
89
const cache = sessionStorage . getItem ( cacheKey ) ;
@@ -117,23 +105,23 @@ function fetchGithubIssueNum(host, name, state = "open", framework) {
117
105
}
118
106
119
107
export default define ( {
120
- tag : " td-doc-issue" ,
108
+ tag : ' td-doc-issue' ,
121
109
openNum : {
122
- get : ( _host , lastValue ) => lastValue || "" ,
110
+ get : ( _host , lastValue ) => lastValue || '' ,
123
111
set : ( _host , value ) => value ,
124
112
connect : ( host ) => {
125
113
const [ , framework , componentName ] = parseUrl ( ) ;
126
114
if ( ! componentName ) return ;
127
- fetchGithubIssueNum ( host , componentName , " open" , framework ) ;
115
+ fetchGithubIssueNum ( host , componentName , ' open' , framework ) ;
128
116
} ,
129
117
} ,
130
118
closedNum : {
131
- get : ( _host , lastValue ) => lastValue || "" ,
119
+ get : ( _host , lastValue ) => lastValue || '' ,
132
120
set : ( _host , value ) => value ,
133
121
connect : ( host ) => {
134
122
const [ , framework , componentName ] = parseUrl ( ) ;
135
123
if ( ! componentName ) return ;
136
- fetchGithubIssueNum ( host , componentName , " closed" , framework ) ;
124
+ fetchGithubIssueNum ( host , componentName , ' closed' , framework ) ;
137
125
} ,
138
126
} ,
139
127
render : ( host ) => html `${ renderIssue ( host ) } ` . css `${ style } ` ,
0 commit comments