2022-03-24 15:49:33 +00:00
|
|
|
import { ref, computed } from 'vue';
|
|
|
|
|
|
|
|
const user = ref({
|
|
|
|
id: 0,
|
2022-03-25 13:37:14 +00:00
|
|
|
name: '',
|
2022-03-24 15:49:33 +00:00
|
|
|
nickname: '',
|
|
|
|
});
|
|
|
|
|
|
|
|
const roles = ref([]);
|
|
|
|
|
2022-04-19 11:50:54 +00:00
|
|
|
const drawer = ref(true);
|
|
|
|
|
2022-03-24 15:49:33 +00:00
|
|
|
export function useState() {
|
|
|
|
function getUser() {
|
|
|
|
return computed(() => {
|
|
|
|
return {
|
|
|
|
id: user.value.id,
|
2022-03-25 13:37:14 +00:00
|
|
|
name: user.value.name,
|
2022-03-24 15:49:33 +00:00
|
|
|
nickname: user.value.nickname,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setUser(data) {
|
|
|
|
user.value = {
|
|
|
|
id: data.id,
|
2022-03-25 13:37:14 +00:00
|
|
|
name: data.name,
|
2022-03-24 15:49:33 +00:00
|
|
|
nickname: data.nickname,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function getRoles() {
|
|
|
|
return computed(() => {
|
|
|
|
return roles.value;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setRoles(data) {
|
|
|
|
roles.value = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
getUser,
|
|
|
|
setUser,
|
|
|
|
getRoles,
|
|
|
|
setRoles,
|
2022-04-19 11:50:54 +00:00
|
|
|
drawer
|
2022-03-24 15:49:33 +00:00
|
|
|
};
|
|
|
|
}
|