import { onMounted, ref } from 'vue'; import { getPersonOptions } from '../api/personApi'; export function usePersonTargetOptions(withAll = true) { const targetOptions = ref>( withAll ? [{ label: '全部', value: 'all' }] : [], ); const loadTargetOptions = async () => { try { targetOptions.value = await getPersonOptions(withAll); } catch (error) { targetOptions.value = withAll ? [{ label: '全部', value: 'all' }] : []; } }; onMounted(() => { loadTargetOptions(); }); return { targetOptions, loadTargetOptions, }; }