import type { CustomConfigValue, GetCustomConfigParams } from './type'; interface GetCustomConfig { (options: GetCustomConfigParams): void; (): Promise>; } /** * 获取小程序自定义配置信息。此接口用于获取在开发者后台配置的自定义业务配置,支持多种数据类型(链接、布尔值、数字、字符串)。 * * 自定义配置支持模板配置和实例配置的分层管理,实例配置优先于模板配置。配置修改后会自动同步到云端,小程序可以通过此接口获取最新的配置信息。 * * @public * @since 基础库 2.0.0 * @since @ray-js/ray 1.7.29 * @param options - 参数对象,包含 success / fail / complete 回调;不传时返回 Promise * @returns 不传回调时返回 Promise,resolve 值为自定义配置键值对对象 * @error {7} API Internal processing failed * @example 回调方式 * ```tsx * import React from 'react'; * import { View, Button, Text, getCustomConfig } from '@ray-js/ray'; * * export default function Demo() { * const handleGetConfig = () => { * getCustomConfig({ * success(config) { * console.log('自定义配置:', config); * }, * fail(err) { * console.error('获取失败:', err.errorMsg); * }, * }); * }; * * return ( * * * * ); * } * ``` * @example Promise 方式 * ```tsx * import React, { useState } from 'react'; * import { View, Button, Text, getCustomConfig } from '@ray-js/ray'; * * export default function Demo() { * const [config, setConfig] = useState(''); * * const handleGetConfig = async () => { * try { * const result = await getCustomConfig(); * setConfig(JSON.stringify(result)); * console.log('自定义配置:', result); * } catch (err) { * console.error('获取失败:', err); * } * }; * * return ( * * * {config && {config}} * * ); * } * ``` */ declare const getCustomConfig: GetCustomConfig; export default getCustomConfig;