// voteCommon.js import { ref } from "vue"; export function voteCommon(isVote= false) { const itemList = ref(isVote ? [] : [{ content: "", url: "" }, { content: "", url: "" }]); const addItem = () => { if (itemList.value.length < 10) { itemList.value.push({ content: "", url: "" }); } }; const removeItem = (index) => { if (!isVote && index >= 2) { itemList.value.splice(index, 1); } else if (isVote && itemList.value.length > 0) { itemList.value.splice(index, 1); } }; return { itemList, addItem, removeItem, }; }