/** * 数学页面专用的 Mixin * 基于通用 pageMixin,提供数学模块特定的配置 */ import { getPageCommonMethods, applyPageMixin, createPage, CanvasDataState, PageCanvasInstance, InitCanvasOptions, ShareOptions, PageCommonMethodsConfig, } from '../../../base/pageMixin'; import { MATH_FUNCTION_TYPES, MathFunctionType, } from '../../../constants/mathFunctions'; /** * 数学模块的页面实例类型(向后兼容) */ export type MathPageCanvasInstance = PageCanvasInstance; /** * 数学模块的分享配置 */ const mathShareConfig = { title: '涂鸦丫-数学学习涂鸦卡', imageUrl: 'https://cdn.joeyone.cn/doodle/share-img/index-share-v2.png', }; /** * 数学模块的页面信息查找函数 */ function mathPageInfoLookup(functionId: string) { const functionItem = MATH_FUNCTION_TYPES.find( (item: MathFunctionType) => item.id === functionId, ); if (functionItem) { return { title: functionItem.title, desc: functionItem.desc, }; } return undefined; } /** * 获取数学页面的公共方法 * 这些方法可以在所有数学页面中复用 * @deprecated 使用 getMathPageCommonMethods() 即可,会自动应用数学模块配置 */ export function getMathPageCommonMethods() { const config: PageCommonMethodsConfig = { shareConfig: mathShareConfig, pageInfoLookup: mathPageInfoLookup, }; return getPageCommonMethods(config); } /** * 应用数学页面公共方法的辅助函数 * 自动混入公共方法,简化页面代码 * @param pageOptions 页面选项 * @returns 合并后的页面选项 * @deprecated 使用 applyMathPageMixin() 即可,会自动应用数学模块配置 */ export function applyMathPageMixin(pageOptions: any) { const config: PageCommonMethodsConfig = { shareConfig: mathShareConfig, pageInfoLookup: mathPageInfoLookup, }; return applyPageMixin(pageOptions, config); } /** * 创建数学页面的便捷函数 * 自动应用公共方法并注册为页面 * @param pageOptions 页面选项 */ export function createMathPage(pageOptions: any) { const config: PageCommonMethodsConfig = { shareConfig: mathShareConfig, pageInfoLookup: mathPageInfoLookup, }; createPage(pageOptions, config); } // 导出类型,保持向后兼容 export type { CanvasDataState, InitCanvasOptions, ShareOptions };