import{ref,getCurrentInstance,unref}from'vue';import{isProdMode}from'/@/utils/env';importtype{DescOptions,DescInstance,UseDescReturnType}from'./types';exportfunctionuseDescription(props?:Partial<DescOptions>):UseDescReturnType{if(!getCurrentInstance()){thrownewError('Please put useDescription function in the setup function!');}constdescRef=ref<DescInstance|null>(null);constloadedRef=ref(false);functiongetDescription(instance:DescInstance){if(unref(loadedRef)&&isProdMode()){return;}descRef.value=instance;props&&instance.setDescProps(props);loadedRef.value=true;}constmethods:DescInstance={setDescProps:(descProps:Partial<DescOptions>):void=>{unref(descRef)!.setDescProps(descProps);},};return[getDescription,methods];}