mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 08:13:43 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			28 lines
		
	
	
		
			615 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			615 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import { BuildConfig, getBuildConfig } from "./build";
 | 
						|
 | 
						|
export function getClientConfig() {
 | 
						|
  if (typeof document !== "undefined") {
 | 
						|
    // client side
 | 
						|
    return JSON.parse(queryMeta("config") || "{}") as BuildConfig;
 | 
						|
  }
 | 
						|
 | 
						|
  if (typeof process !== "undefined") {
 | 
						|
    // server side
 | 
						|
    return getBuildConfig();
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
function queryMeta(key: string, defaultValue?: string): string {
 | 
						|
  let ret: string;
 | 
						|
  if (document) {
 | 
						|
    const meta = document.head.querySelector(
 | 
						|
      `meta[name='${key}']`,
 | 
						|
    ) as HTMLMetaElement;
 | 
						|
    ret = meta?.content ?? "";
 | 
						|
  } else {
 | 
						|
    ret = defaultValue ?? "";
 | 
						|
  }
 | 
						|
 | 
						|
  return ret;
 | 
						|
}
 |