getters.ts 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/**
 * 获取应用视图数据
 * 
 * @param state 
 */
export const getAppView = (state: any) => (viewtag: string) => {
    const createdview = state.createdviews.find((appview: any) => Object.is(appview.secondtag, viewtag));
    if (!createdview) {
        console.warn(`获取应用视图实例,,视图「${viewtag}」不存在`)
        return null;
    }
    return createdview;
}

/**
 * 获取视图数据变化状态
 * 
 * @param state 
 */
export const getViewDataChangeState = (state:any) => (viewtag: string) => {
    const createdview = state.createdviews.find((appview: any) => Object.is(appview.secondtag, viewtag));
    if (!createdview) {
        console.warn(`获取视图数据状态,,视图「${viewtag}」不存在`)
        return false;
    }
    return createdview.viewdatachange;
}

/**
 * 获取视图是否需要刷新
 * 
 * @param state 
 */
export const getRefreshData = (state: any) => (viewtag: string) => {
    const createdview = state.createdviews.find((appview: any) => Object.is(appview.secondtag, viewtag));
    if (!createdview) {
        console.warn(`获取数据刷新状态,视图「${viewtag}」不存在`)
        return null;
    }
    return createdview.refreshdata;
}