const dirtyValue = [{"id":1,"name":"Проект1","parent":null,
"children":[{"id":3,"name":"Задача1.1","parent":1,
"children":[ {"id":2,"name":"Задача 1_1_1","parent":3,"children":[]},
{"id":8,"name":"Задача 1_1_2","parent":3, "children":[]}
]}]}];
const formatJson = item => {
const result = { ...item, Rec: { children: item?.children?.map?.(formatJson) } };
delete result?.children;
return result;
};
const value = dirtyValue.map(formatJson);
console.log(value);
const readline = require('readline-sync');
const key = '';
function hydrusTags(tags){
let url = 'http://127.0.0.1:45869/get_files/search_files?Hydrus-Client-API-Access-Key='+key+'&tags=%5B%22'+tags+'%22%5D';
return fetch(url).then(res => res.json());
}
var query = readline.question('Enter tags:\n');
hydrusTags(query).then(foundIds => console.log(foundIds));
new Swiper(".mySwiper2", {
loop: true,
pagination: {
el: ".pg2",
dynamicBullets: true,
},
})
var swiper = new Swiper(".mySwiper", {
-- loop: true,
spaceBetween : '5px',
pagination: {
el: ".pg1",
dynamicBullets: true,
},
breakpoints : {
0: {
slidesPerView: 2,
},
800: {
slidesPerView: 3,
},
1200: {
slidesPerView: 4,
},
1600: {
slidesPerView: 5,
}
},
});
<template>
<v-app>
<v-container>
<v-stepper v-model="step" :items="items">
<!--...-->
<template v-slot:item.3>
<!-- Последний item-->
<!--...-->
</template>
<template v-slot:next>
<v-btn @click="nextOrSubmit" :disabled="false">
{{ isLastItem ? 'Submit' : 'Next' }}
</v-btn>
</template>
</v-stepper>
</v-container>
</v-app>
</template>
<script setup>
import { ref, reactive, computed } from 'vue'
const items = reactive(['Название и авторы', 'Описания', 'Изображение'])
const step = ref(1)
const isLastItem = computed(() => step.value === items.length)
const nextOrSubmit = () => {
if (isLastItem.value) {
// submit
alert('submit')
return
}
step.value++
}
</script>
const tasks = [{ path: 'http://domain.com/api/1', data: {} }, { path: 'http://domain.com/api/2', data: {} }, { path: 'http://domain.com/api/3', data: {} }];
const delay = () => new Promise(resolve => setTimeout(resolve, 1000));
const createRequest = async (path, data) => {
await delay();
return axios.post(path, data)
.then((response) => ({ postData: data, result: response?.data }))
.catch((err) => {
console.log(err);
return err;
});
}
const processTasks = async (array) => {
for (const item of array) {
const result = await createRequest(item?.path, item?.data);
console.log('result:', result);
}
}
processTasks(tasks);
addProductToCart(context, {
productId,
colorId,
sizeId,
amount,
}) {
// Тут наверное не лишним будет доп. проверку повесить, раз setTimeout используете, иначе при повторных запросах у вас могут прошлые setTimeout переводить `updateisAddLoadingEnded` в false
++ if (context.state.updateisAddLoadingEnded) return;
context.commit('updateAddLoading', true);
context.commit('updateAddLoadingFailed', false);
context.commit('updateisAddLoadingEnded', false);
return axios.post('url', {
productId: productId,
colorId: colorId,
sizeId: sizeId,
quantity: amount,
}, {
params: {
userAccessKey: context.state.userAccessKey,
},
})
.then((response) => {
context.commit('updateProductsCartData', response.data.items);
context.commit('syncProductsCart');
})
.catch(() => {
-- context.commit('updateAddLoading', false);
context.commit('updateAddLoadingFailed', true);
})
.finally(() => {
context.commit('updateAddLoading', false);
context.commit('updateisAddLoadingEnded', true);
++ setTimeout(() => context.commit('updateisAddLoadingEnded', false), 3000);
});
},