/**
 * 专注力页面专用的 Mixin
 * 基于通用 pageMixin，提供专注力模块特定的配置
 */

import { createPage, PageCommonMethodsConfig } from '../../../base/pageMixin';
import { FOCUS_FUNCTION_TYPES } from '../../../constants/focusFunctions';
import { defaultShareConfig } from '../../../config/config';
/**
 * 专注力模块的函数类型定义
 */
export interface FocusFunctionType {
    id: string;
    title: string;
    desc: string;
}

/**
 * 专注力模块的页面信息查找函数
 */
function focusPageInfoLookup(functionId: string) {
    const functionItem = FOCUS_FUNCTION_TYPES.find(
        (item) => item.id === functionId,
    );

    if (functionItem) {
        return {
            title: functionItem.title,
            desc: functionItem.desc,
        };
    }

    return undefined;
}

/**
 * 专注力模块的配置
 */
const focusConfig: PageCommonMethodsConfig = {
    shareConfig: defaultShareConfig,
    pageInfoLookup: focusPageInfoLookup,
};

/**
 * 创建专注力页面的便捷函数
 * 自动应用公共方法并注册为页面
 * @param pageOptions 页面选项
 */
export function createFocusPage(pageOptions: any) {
    createPage(pageOptions, focusConfig);
}
