P-55 localstorage
This commit is contained in:
1 parent
ec35771276
commit
66be6d5059
2 files changed
+19
-23
No files matched your search
@@ -124,6 +124,7 @@ export default {
|
||||
axiosApiInstance
|
||||
.get("api/calendar_of_events/get_calendars/")
|
||||
.then((res) => {
|
||||
console.log(accountStore.calendar,"lo\d");
|
||||
res.data.forEach(e => e.visible = accountStore.calendar.includes(e.id)?false: true)
|
||||
calendarForMy.value = res.data;
|
||||
|
||||
|
||||
@@ -8,8 +8,12 @@ import { useAppStore } from "@/store/app.js";
|
||||
|
||||
export const useAccountStore = defineStore("AccountStore", () => {
|
||||
const AppStore = useAppStore();
|
||||
const user = ref({});
|
||||
const settingsStorage = computed({
|
||||
get() {
|
||||
if (Object.keys(user.value).length==0){
|
||||
getuserFromStorage()
|
||||
}
|
||||
return JSON.parse(localStorage.getItem(user.value.is_idEmployee));
|
||||
},
|
||||
});
|
||||
@@ -19,11 +23,10 @@ export const useAccountStore = defineStore("AccountStore", () => {
|
||||
};
|
||||
|
||||
function get_setting(key) {
|
||||
return settingsStorage.value === null
|
||||
? defaultSettings[key]
|
||||
: settingsStorage.value[key];
|
||||
console.log(settingsStorage.value);
|
||||
return settingsStorage.value === null? defaultSettings[key]: settingsStorage.value[key];
|
||||
}
|
||||
const user = ref({});
|
||||
|
||||
const cod2user = ref(false);
|
||||
const calendar = ref(get_setting("calendar")
|
||||
);
|
||||
@@ -37,30 +40,24 @@ export const useAccountStore = defineStore("AccountStore", () => {
|
||||
//
|
||||
// геттер бывший
|
||||
// const getUser=computed(()=> uyser.value)
|
||||
function getuserFromStorage(){
|
||||
let u = VueJwtDecode.decode(localStorage.getItem("refresh"));
|
||||
u.user.photo = checkremote(`${spravURL}${u.user.login}.jpg`);
|
||||
user.value = u.user;
|
||||
|
||||
}
|
||||
const logging = async (anon) => {
|
||||
AppStore.loading = true;
|
||||
const result = await clearAxios.post("api/accounts/token/", anon);
|
||||
// .then(result => {
|
||||
|
||||
localStorage.setItem("access", result.data.access);
|
||||
localStorage.setItem("refresh", result.data.refresh);
|
||||
|
||||
let u = VueJwtDecode.decode(result.data.refresh);
|
||||
u.user.photo = checkremote(`${spravURL}${u.user.login}.jpg`);
|
||||
// `${spravURL}${u.user.login}.jpg`
|
||||
user.value = u.user;
|
||||
//
|
||||
getuserFromStorage()
|
||||
|
||||
if (settingsStorage.value === null) {
|
||||
settingsUp(defaultSettings)
|
||||
}
|
||||
else{
|
||||
console.log(settingsStorage.value, "ddddddds");
|
||||
for (let[key,val] of Object.entries(settingsStorage.value)){
|
||||
[key].value=val
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(JSON.parse(localStorage[107]), 'localStoragelocalStoragelocalStorage'); Прочитать строку
|
||||
|
||||
AppStore.loading = false;
|
||||
};
|
||||
|
||||
@@ -85,14 +82,12 @@ export const useAccountStore = defineStore("AccountStore", () => {
|
||||
|
||||
function settingsUp(newSet) {
|
||||
|
||||
localStorage.setItem(
|
||||
user.value.is_idEmployee,
|
||||
JSON.stringify(newSet)
|
||||
localStorage.setItem(user.value.is_idEmployee, JSON.stringify(newSet)
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
// console.log(newSet,'ddddddddddddddddddd');
|
||||
|
||||
|
||||
|
||||
watch(() => calendar.value, (newValue) => {
|
||||
|
||||
Reference in new issue
Block a user