import Taro from "@tarojs/taro"
import defaultAvatar from "./default-avatar"

const APP_NAME = process.env.TARO_APP_NAME ?? 'miniGreenLeaf'
let appVersion = '1.0.26'
let envVersion:"develop" | "trial" | "release" = 'develop'

// 小程序 api 地址
// let baseUrlDev = 'http://192.168.1.113:3000/'
let baseUrlDev = 'https://dev-api.xiaolvye.cn/'
let baseUrlProd = 'https://api.xiaolvye.cn/'
let baseUrl = baseUrlDev;

//  html5 地址
let homeUrlDev = 'https://dev-m.xiaolvye.cn/'
let homeUrlProd = 'https://xiaolvye.cn/'
let homeUrl = homeUrlDev

if(process.env.TARO_ENV == "weapp"){
	// 根据版本号判断是否为线上版本 ？？
	const accountInfo = Taro.getAccountInfoSync();
	const version = accountInfo.miniProgram.version;
	envVersion = accountInfo.miniProgram.envVersion;

	console.log('app version:', version, envVersion)
	if(version.length){
		baseUrl = baseUrlProd
		appVersion = version
		homeUrl = homeUrlProd
		console.log('online version:', version)
	}	
}

const BASE_URL = baseUrl
const APP_VERSION =  appVersion
const APP_ENV_VERSION =  envVersion
const HOME_URL = homeUrl

const APP_NAME_TEXT = process.env.TARO_APP_NAME_TEXT ?? ''
const TARO_APP_ID = process.env.TARO_APP_ID ?? ''

// 是否是小绿页
const IS_MINI_GREEN_LEAF = APP_NAME === 'miniGreenLeaf'
// 是否允许跳转至vip页面
const ENABLE_UPGRADE_VIP = IS_MINI_GREEN_LEAF

const DEFAULT_AVATAR = defaultAvatar
const DEFAULT_AVATAR_BG = 'https://51saas.oss-cn-hangzhou.aliyuncs.com/u260727532/20250801/79GUqImi7Z_5d0c780219ca44d9a673213424366ab1.png'
const DEFAULT_AVATAR_SHARE_BG = 'https://cdn.wehome.cn/cmn/png/12/META-H8UKWHWU-Q0WXNNJLF5IO3DRNO8GK3-0QDMLMEM-QK.png'

const DEFAULT_AGENT = {
    avatar: DEFAULT_AVATAR,
    name: "小蓝本助手",
  };

export {
	APP_VERSION,
	APP_NAME,
	APP_NAME_TEXT,
	BASE_URL,
	APP_ENV_VERSION,
	HOME_URL,
	TARO_APP_ID,
	ENABLE_UPGRADE_VIP,
	IS_MINI_GREEN_LEAF,
	DEFAULT_AVATAR,
	DEFAULT_AGENT,
	DEFAULT_AVATAR_BG,
	DEFAULT_AVATAR_SHARE_BG,
}
 

// 合作方域名链接，用于 webview
export const CORP_DOMAINS = [
	's.mcdl0.cn',
]
