UNPKG

tav-ui

Version:
42 lines (39 loc) 1.39 kB
import { computed } from 'vue'; import { useGlobalConfig } from '../../../../hooks/global/useGlobalConfig2.mjs'; function useGlobalConfigProps() { const globalConfigAppId = useGlobalConfig("appId").value; const globalConfigFile = useGlobalConfig("components").value; return computed(() => ({ appId: globalConfigAppId || "", ...globalConfigFile || {} })); } function useMergedProps(props, componentName, apiParamsDefault) { const globalConfigProps = useGlobalConfigProps(); return computed(() => { const result = {}; const globalConfigComponentProps = globalConfigProps.value[componentName]; const globalConfigAppId = globalConfigProps.value.appId; Object.keys(props).forEach((key) => { const _p = globalConfigComponentProps && globalConfigComponentProps[key] ? globalConfigComponentProps[key] : void 0; result[key] = props[key] ?? _p; }); apiParamsDefault && Object.keys(apiParamsDefault).forEach((key) => { if (result["apiParams"]) { result["apiParams"][key] = result["apiParams"][key] ?? apiParamsDefault[key]; } else { result["apiParams"] = {}; } }); return { ...props, ...result, apiParams: { ...props.apiParams, appId: props.apiParams?.appId ?? globalConfigAppId } }; }); } export { useMergedProps }; //# sourceMappingURL=use-props2.mjs.map