File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed
Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -64,14 +64,30 @@ const installFor = (lang: string, os: string) => {
6464 }
6565} ;
6666
67- export async function currentActions2 ( lang : string ) : Promise < HeroAction > {
68- const userAgent = navigator . userAgent ;
67+ /// 模糊检测下载链接是否可用,不可用使用代理切换
68+ const checkDownloadLink = async ( link : string ) : Promise < string > => {
69+ if ( link . length > 0 ) {
70+ try {
71+ const _ = await fetch ( link , { method : "HEAD" , mode : "no-cors" } ) ;
72+ return link ;
73+ } catch {
74+ return `https://mirror.ghproxy.com/?q=${ link } ` ;
75+ }
76+ }
77+
78+ return link ;
79+ } ;
6980
81+ export async function currentActions2 ( lang : string ) : Promise < HeroAction > {
7082 let action : HeroAction = {
7183 theme : "alt" ,
7284 text : "" ,
73- link : "" ,
85+ link : "javascript:void(0); " ,
7486 } ;
87+
88+ if ( typeof navigator === "undefined" ) return action ;
89+
90+ const userAgent = navigator . userAgent ;
7591 if ( / W i n / i. test ( navigator . platform ) ) {
7692 action . text = downloadFor ( lang , "Windows" ) ;
7793 const arch = await detectPlatformArch ( ) ;
@@ -136,5 +152,7 @@ export async function currentActions2(lang: string): Promise<HeroAction> {
136152 }
137153 }
138154
155+ action . link = await checkDownloadLink ( action . link ) ;
156+
139157 return action ;
140158}
Original file line number Diff line number Diff line change @@ -67,4 +67,11 @@ export default defineConfig({
6767 // ar: { label: "Arabic", ...ar },
6868 } ,
6969 vite,
70+ vue : {
71+ template : {
72+ compilerOptions : {
73+ isCustomElement : ( tag ) => tag === "dweb-wallpaper"
74+ }
75+ }
76+ }
7077} ) ;
You can’t perform that action at this time.
0 commit comments