import { observable } from 'mobx'


type ConfigParamList = {}
export interface AppInfo {
    appCategory: 1|2,//1长篇 2短篇
    appName: string,//小程序名称
    appVersion: string,//小程序版本
    configParamList: ConfigParamList[],//小程序配置
    distributorId: 1,//分销商ID
    enabled: true,//启用状态
    homePage: string,//主页路径
    id: 4,//
    wechatAppId: string,//小程序ID
}
interface AppComponent {
    id: number,
    componentType: string,//组件名称
}
export interface AppInfoStore {
    /**app初始化信息*/
    appInfo?: AppInfo,
    /**主页组件展示信息*/
    appComponent?: AppComponent[],
    /**登录后的token*/
    token?: string,//token
    /**进入的场景*/
    scene?: number,
    /**分享值*/ 
    shareSources?:any,
    /**设置app初始化信息*/
    actionAppInfo: (appInfo: AppInfo) => void
    /**设置登录后的token*/
    actionToken: (token: string) => void
    /**设置组件列表*/
    setAppComponent: (appComponent: AppComponent[]) => void
}
/**
 * APP初始化信息
 * */
const appInfoStore: AppInfoStore = observable({
    appInfo: undefined,
    actionAppInfo(appInfo: AppInfo) {
        if (appInfo) {
            this.appInfo = appInfo
        }
    },
    actionToken(token: string) {
        this.token = token
    },
    setAppComponent(appComponent: AppComponent[]) {
        if (appComponent) {
            this.appComponent = appComponent
        }
    }
})

export default appInfoStore