1- import { $platform , Lodash as _ , URL , Storage , fetch , notification , log , logError , wait , done , getScript , runScript } from "@nsnanocat/util" ;
1+ import { $app , Console , done , fetch , Lodash as _ , notification , Storage , wait } from "@nsnanocat/util" ;
22import database from "./function/database.mjs" ;
33import setENV from "./function/setENV.mjs" ;
44const $request = {
@@ -15,26 +15,17 @@ const $request = {
1515 * @type {{Settings: import('./types').Settings} }
1616 */
1717 const { Settings, Caches, Configs } = setENV ( "DualSubs" , [ "Translate" , "API" ] , database ) ;
18- log ( `⚠ Settings.Switch: ${ Settings ?. Switch } ` , "" ) ;
19- switch ( Settings . Switch ) {
20- case true :
21- default : {
22- const $response = await fetch ( $request ) ;
23- _ . set ( Settings , "Vendor" , "Microsoft" ) ;
24- _ . set ( Settings , "Microsoft.Version" , "Azure" ) ;
25- _ . set ( Settings , "Microsoft.Mode" , "Token" ) ;
26- _ . set ( Settings , "Microsoft.Token" , $response ?. body ) ;
27- log ( `⚠ Settings: ${ JSON . stringify ( Settings ) } ` , "" ) ;
28- // 写入缓存
29- Storage . setItem ( "@DualSubs.Translate.Settings.Vendor" , Settings . Vendor ) ;
30- Storage . setItem ( "@DualSubs.API.Settings.Microsoft.Version" , Settings . Microsoft . Version ) ;
31- Storage . setItem ( "@DualSubs.API.Settings.Microsoft.Mode" , Settings . Microsoft . Mode ) ;
32- Storage . setItem ( "@DualSubs.API.Settings.Microsoft.Token" , Settings . Microsoft . Token ) ;
33- break ;
34- }
35- case false :
36- break ;
37- }
18+ const $response = await fetch ( $request ) ;
19+ _ . set ( Settings , "Vendor" , "Microsoft" ) ;
20+ _ . set ( Settings , "Microsoft.Version" , "Azure" ) ;
21+ _ . set ( Settings , "Microsoft.Mode" , "Token" ) ;
22+ _ . set ( Settings , "Microsoft.Token" , $response ?. body ) ;
23+ lConsole . info ( `Settings: ${ JSON . stringify ( Settings ) } ` ) ;
24+ // 写入缓存
25+ Storage . setItem ( "@DualSubs.Translate.Settings.Vendor" , Settings . Vendor ) ;
26+ Storage . setItem ( "@DualSubs.API.Settings.Microsoft.Version" , Settings . Microsoft . Version ) ;
27+ Storage . setItem ( "@DualSubs.API.Settings.Microsoft.Mode" , Settings . Microsoft . Mode ) ;
28+ Storage . setItem ( "@DualSubs.API.Settings.Microsoft.Token" , Settings . Microsoft . Token ) ;
3829} ) ( )
39- . catch ( e => logError ( e ) )
30+ . catch ( e => Console . error ( e ) )
4031 . finally ( ( ) => done ( ) ) ;
0 commit comments