@@ -4,6 +4,7 @@ import style from './style.less';
4
4
import qrcodeIcon from '@images/qrcode.svg?raw' ;
5
5
import mobileIcon from '@images/mobile.svg?raw' ;
6
6
import closeIcon from '@images/close.svg?raw' ;
7
+ import jumpIcon from '@images/jump.svg?raw' ;
7
8
8
9
function toggleCollapsePhone ( host ) {
9
10
if ( ! host . shadowRoot ) return ;
@@ -20,6 +21,7 @@ function toggleCollapsePhone(host) {
20
21
export default define ( {
21
22
tag : 'td-doc-phone' ,
22
23
headless : false ,
24
+ href : '' ,
23
25
QRCode : ( ) => QRCode ,
24
26
qrCanvas : ( { render } ) => render ( ) . querySelector ( '#qrcode' ) ,
25
27
qrcodeUrl : {
@@ -50,30 +52,38 @@ export default define({
50
52
const { scrollTop, scrollHeight, clientHeight } = document . documentElement ;
51
53
52
54
// 当底部出现时不要超过底部区域
53
- const FOOTER_HEIGHT = parseFloat ( getComputedStyle ( document . documentElement ) . getPropertyValue ( '--footer-height' ) ) ;
55
+ const FOOTER_HEIGHT = parseFloat (
56
+ getComputedStyle ( document . documentElement ) . getPropertyValue ( '--footer-height' ) ,
57
+ ) ;
54
58
const PHONE_HEIGHT = parseFloat ( getComputedStyle ( host ) . getPropertyValue ( '--phone-body-height' ) ) ;
55
59
const TD_HEIGHT = 64 ;
56
60
const maxPhonePos = scrollHeight - FOOTER_HEIGHT - PHONE_HEIGHT - TD_HEIGHT - 64 ; // 预留底部 64 像素间距
57
- const canViewPhoneAndFooter = clientHeight <= ( FOOTER_HEIGHT + PHONE_HEIGHT + 64 ) ;
61
+ const canViewPhoneAndFooter = clientHeight <= FOOTER_HEIGHT + PHONE_HEIGHT + 64 ;
58
62
59
63
if ( scrollTop >= 228 ) {
60
- if ( ( scrollTop + 88 ) >= maxPhonePos && canViewPhoneAndFooter ) {
64
+ if ( scrollTop + 88 >= maxPhonePos && canViewPhoneAndFooter ) {
61
65
Object . assign ( host , {
62
66
[ key ] : {
63
- ...host . fixedStyle , position : 'absolute' , top : `${ maxPhonePos } px` ,
67
+ ...host . fixedStyle ,
68
+ position : 'absolute' ,
69
+ top : `${ maxPhonePos } px` ,
64
70
} ,
65
71
} ) ;
66
72
} else {
67
73
Object . assign ( host , {
68
74
[ key ] : {
69
- ...host . fixedStyle , position : 'fixed' , top : '152px' ,
75
+ ...host . fixedStyle ,
76
+ position : 'fixed' ,
77
+ top : '152px' ,
70
78
} ,
71
79
} ) ;
72
80
}
73
81
} else {
74
82
Object . assign ( host , {
75
83
[ key ] : {
76
- ...host . fixedStyle , position : 'absolute' , top : '316px' ,
84
+ ...host . fixedStyle ,
85
+ position : 'absolute' ,
86
+ top : '316px' ,
77
87
} ,
78
88
} ) ;
79
89
}
@@ -105,10 +115,13 @@ export default define({
105
115
} ;
106
116
} ,
107
117
} ,
108
- render : ( { fixedStyle, headless } ) => html `
118
+ render : ( { fixedStyle, headless, href } ) =>
119
+ html `
109
120
< div class ="TDesign-doc-phone-mask " onclick ="${ toggleCollapsePhone } "> </ div >
110
121
< div class ="TDesign-doc-phone " style =${ fixedStyle } >
111
- ${ headless ? html `` : html `
122
+ ${ headless
123
+ ? html ``
124
+ : html `
112
125
< div class ="TDesign-doc-phone__header ">
113
126
< div class ="TDesign-doc-phone__header-icons ">
114
127
< td-doc-popup placement ="left-start ">
@@ -119,6 +132,8 @@ export default define({
119
132
</ slot >
120
133
</ div >
121
134
</ td-doc-popup >
135
+ ${ href &&
136
+ html `< a href ="${ href } " target ="_blank "> < span class ="icon " innerHTML ="${ jumpIcon } "> </ span > </ a > ` }
122
137
</ div >
123
138
</ div >
124
139
` }
0 commit comments