import { ref, computed } from 'vue'; const user = ref({ id: 0, username: '', nickname: '', }); const roles = ref([]); export function useState() { function getUser() { return computed(() => { return { id: user.value.id, username: user.value.username, nickname: user.value.nickname, }; }); } function setUser(data) { user.value = { id: data.id, username: data.username, nickname: data.nickname, }; } function getRoles() { return computed(() => { return roles.value; }); } function setRoles(data) { roles.value = data; } return { getUser, setUser, getRoles, setRoles, }; }