From 8789bb2e0969463c94b1470e138c555d7756f39c Mon Sep 17 00:00:00 2001 From: Norbaev Date: Thu, 4 Jul 2024 18:14:40 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D1=82=D0=B0=D0=BA=D1=82=D0=BE=D0=B2=20(=D0=B1?= =?UTF-8?q?=D0=B5=D0=B7=20=D1=81=D0=BE=D1=86=D0=B8=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D1=85=20=D1=81=D0=B5=D1=82=D0=B5=D0=B9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/router/index.js | 4 +- client/src/views/contacts.vue | 103 ++++++++++++++++++++++------------ 2 files changed, 69 insertions(+), 38 deletions(-) diff --git a/client/src/router/index.js b/client/src/router/index.js index 200f989..9e29984 100644 --- a/client/src/router/index.js +++ b/client/src/router/index.js @@ -49,7 +49,9 @@ export default route(function (/* { store, ssrContext } */) { }); Router.beforeEach((to, from, next) => { - if (to.meta.isAuth) { + console.log(process.env.SERVER); + //уточнить зачем нужен process.env.SERVER + if (to.meta.isAuth && !process.env.SERVER) { if (store.state.user) { next(); } else { diff --git a/client/src/views/contacts.vue b/client/src/views/contacts.vue index 5296bd5..081af6f 100644 --- a/client/src/views/contacts.vue +++ b/client/src/views/contacts.vue @@ -9,36 +9,14 @@

Контакты

-
- Телефон - {{ phone }} -
-
- Почта - {{ email }} -
-
- Адрес - {{ address }} -
-
- Соц. сети -
{ - console.log([...responce]); this.contacts = { ...responce }; }); }, + mounted() {}, methods: { submitHandler() {}, + // Метод удаляет из объекта ключи с null + removeNullFields(obj) { + const result = {}; + + for (const key in obj) { + if (obj[key] !== null) { + if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) { + result[key] = this.removeNullFields(obj[key]); + } else { + result[key] = obj[key]; + } + } + } + + return result; + }, + + // Метод формирует массив, на основе словаря и объекта + createArrayContacts(dictionary, fields) { + const result = []; + + for (const key in fields) { + if (dictionary[key]) { + result.push({ title: dictionary[key], data: fields[key] }); + } + } + + return result; + }, }, };