@@ -12,25 +12,39 @@ export default {
1212 // ── IndoLearn API endpoints ──────────────────────────────────────────────
1313
1414 if ( path === '/indolearn/version.json' ) {
15- return new Response ( JSON . stringify ( {
16- version_code : 16 ,
17- version : "1.0.16" ,
18- apk_url : "https://1232131.xyz/indolearn/app.apk" ,
19- changelog : "v1.0.16: 词根词缀分析+联想记忆升级;设置页简化(无需配置 Gemini Key)"
20- } , null , 2 ) , { headers : { ...cors , 'Content-Type' : 'application/json' } } ) ;
15+ // Always fetch live from GitHub — no Worker redeploy needed on version bumps
16+ try {
17+ const ghUrl = 'https://raw.githubusercontent.com/Haydendddda/indolearn-android/main/version.json' ;
18+ const ghResp = await fetch ( ghUrl , { cf : { cacheEverything : true , cacheTtl : 60 } } ) ;
19+ if ( ! ghResp . ok ) throw new Error ( 'GitHub fetch failed: ' + ghResp . status ) ;
20+ const data = await ghResp . text ( ) ;
21+ return new Response ( data , { headers : { ...cors , 'Content-Type' : 'application/json' } } ) ;
22+ } catch ( e ) {
23+ // Fallback to last known version if GitHub unreachable
24+ return new Response ( JSON . stringify ( {
25+ version_code : 16 ,
26+ version : "1.0.16" ,
27+ apk_url : "https://1232131.xyz/indolearn/app.apk" ,
28+ changelog : "v1.0.16: 词根词缀分析+联想记忆升级;设置页简化(无需配置 Gemini Key)"
29+ } , null , 2 ) , { headers : { ...cors , 'Content-Type' : 'application/json' } } ) ;
30+ }
2131 }
2232
2333 if ( path === '/indolearn/app.apk' ) {
24- const apkUrl = 'https://github.com/Haydendddda/indolearn-android/releases/download/v1.0.15/IndoLearn-v1.0.16.apk' ;
34+ // Read version dynamically from GitHub — no Worker redeploy needed on version bumps
2535 try {
36+ const vResp = await fetch ( 'https://raw.githubusercontent.com/Haydendddda/indolearn-android/main/version.json' ) ;
37+ const vData = await vResp . json ( ) ;
38+ const version = vData . version ;
39+ const apkUrl = `https://github.com/Haydendddda/indolearn-android/releases/download/v${ version } /IndoLearn-v${ version } .apk` ;
2640 const resp = await fetch ( apkUrl , { redirect : 'follow' } ) ;
2741 if ( ! resp . ok ) return new Response ( 'APK fetch failed: ' + resp . status , { status : 502 } ) ;
2842 return new Response ( resp . body , {
2943 headers : {
3044 'Content-Type' : 'application/vnd.android.package-archive' ,
31- 'Content-Disposition' : ' attachment; filename="IndoLearn-v1.0.16. apk"' ,
45+ 'Content-Disposition' : ` attachment; filename="IndoLearn-v ${ version } . apk"` ,
3246 'Access-Control-Allow-Origin' : '*' ,
33- 'Cache-Control' : 'public, max-age=86400 '
47+ 'Cache-Control' : 'no-cache '
3448 }
3549 } ) ;
3650 } catch ( e ) { return new Response ( 'APK error: ' + e . message , { status : 502 } ) ; }
0 commit comments