@@ -61,7 +61,7 @@ if (typeof window !== 'undefined') {
6161 }
6262 }
6363
64- function checkStar ( owner , repo ) {
64+ function checkStar ( owner , repo , failCallback ) {
6565 //文档首页不校验
6666 if ( location . pathname === repo || location . pathname === repo + '/' ) {
6767 return ;
@@ -80,19 +80,23 @@ if (typeof window !== 'undefined') {
8080 localStorage . removeItem ( "access_token" )
8181 checkStar ( owner , repo )
8282 } else if ( response . status == 404 ) {
83- //替换 html body中 class为 content-wrapper 中的内容,适配vuepress
84- replaceHtml ( `
83+ if ( failCallback != null ) {
84+ failCallback ( )
85+ } else {
86+ //替换 html body中 class为 content-wrapper 中的内容,适配vuepress
87+ replaceHtml ( `
8588 <div>
8689 检测到您还未 Star 本项目,暂时无法访问本页面。<br/>
8790 请先前往:<a target="_blank" href="https://gitee.com/${ owner } /${ repo } ">https://gitee.com/${ owner } /${ repo } </a> 完成操作,再尝试刷新当前页面。
8891 </div>
8992 ` )
93+ }
9094 }
9195 } )
9296 . catch ( error => console . error ( error ) ) ;
9397 }
9498
95- function checkAuthorize ( owner , repo , file ) {
99+ function checkAuthorize ( owner , repo , file , failCallback ) {
96100 let access_token = checkAccessToken ( )
97101 if ( access_token == null ) {
98102 return
@@ -118,10 +122,14 @@ if (typeof window !== 'undefined') {
118122 if ( json [ user ?. login ] != null ) {
119123 console . log ( "check result" , "ok" ) ;
120124 } else {
121- replaceHtml ( `<div>
125+ if ( failCallback != null ) {
126+ failCallback ( )
127+ } else {
128+ replaceHtml ( `<div>
122129 未经授权暂时无法访问该页面。<br/>
123130 </div>
124131 ` )
132+ }
125133 }
126134 } ) ;
127135 } else {
0 commit comments