<template>
<div>
<v-select
v-model="locale"
:items="locales"
item-text="locale"
item-value="locale"
append-icon=""
class="locale"
>
</v-select>
</div>
</template>
<script>
import {loadLanguageAsync} from "@/locales/i18n";
import config from "@/config";
export default {
name: "Locale",
data: function () {
return {
locales: config.locales
}
},
computed: {
locale: {
get: function () {
return {locale: this.$i18n.locale}
},
set: function (locale) {
loadLanguageAsync(locale)
}
},
},
created() {
loadLanguageAsync(localStorage.getItem('lang'))
}
}
</script>
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import axios from 'axios'
import config from "@/config";
import messages from "@/locales/lang/en.js"
Vue.use(VueI18n)
export const i18n = new VueI18n({
locale: "en",
fallbackLocale: "en",
messages: {
"en": messages
}
})
const loadedLanguages = ["en"]
function setLanguage(lang) {
i18n.locale = lang
document.querySelector('html').setAttribute('lang', lang)
return lang
}
export function loadLanguageAsync(lang) {
let language = lang
if (config.locales.findIndex(locale => locale.locale === lang) === -1) {
language = config.defaultLocale
}
localStorage.setItem('lang', language)
// If the same language
if (i18n.locale === language) {
return Promise.resolve(setLanguage(language))
}
// If the language was already loaded
if (loadedLanguages.includes(language)) {
return Promise.resolve(setLanguage(language))
}
// If the language hasn't been loaded yet
return import(`@/locales/lang/${language}.js`).then(
messages => {
i18n.setLocaleMessage(language, messages.default)
loadedLanguages.push(language)
return setLanguage(language)
}
)
}
import Vue from 'vue'
import App from '@/App.vue'
import {i18n} from "@/locales/i18n";
new Vue({
render: h => h(App),
i18n,
}).$mount('#app')
.container {
width: 100%; // Ширина контейнера 100%
max-width: 1320px; // Ширина контента 1300
padding-left: 10px; // Отступ слева
padding-right: 10px; // Отступ справа
margin: 0 auto; // Расположение контейнера посередине
}
const [dateTime, setDateTime] = useState(new Date());
useEffect(() => {
const id = setInterval(() => setDateTime(new Date()), 1000);
return () => {
clearInterval(id);
}
}, []);
import { Fragment, useEffect, useRef, useState } from "react";
import "./styles.css";
export default function App() {
const firstDivRef = useRef();
const [windowScroll, setWindowScroll] = useState(0);
useEffect(() => {
const onScroll = () => {
if (windowScroll === 0) {
setWindowScroll(window.scrollY);
}
firstDivRef.current.scrollTop =
firstDivRef.current.scrollTop + (window.scrollY - windowScroll);
setWindowScroll(window.scrollY);
};
window.removeEventListener("scroll", onScroll);
window.addEventListener("scroll", onScroll);
return () => window.removeEventListener("scroll", onScroll);
}, [windowScroll]);
return (
<Fragment>
<div className="header"></div>
<div
className="App"
style={{
display: "flex",
marginTop: "100px"
}}
>
<div
ref={firstDivRef}
style={{
height: "600px",
overflow: "scroll",
backgroundColor: "#FFDAB9",
position: "sticky",
top: "100px"
}}
>
<div>
<ul className="first-scroll">
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
</ul>
</div>
</div>
<div
style={{
backgroundColor: "#EEE8AA"
}}
>
<div>
<ul className="first-scroll">
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
<li>Scroll text</li>
</ul>
</div>
</div>
</div>
<div className="about-us"></div>
<div className="footer"></div>
</Fragment>
);
}
const downloadBlobFile = (id, fileName) => {
fetch(`${API_URL}/files/download/${id}`)
.then(response => {
return response.blob()
})
.then(blob => {
const link = window.document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = fileName || 'file';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
})
.catch(() => {
//Обработка ошибок
});
}
const groupArr = {}
arr.map(message => ({...message, date: new Date(message.date)}))
.sort((m1, m2) => m1.date - m2.date)
.forEach(message => {
const date = message.date.toISOString().split('T')[0]
if (!groupArr.hasOwnProperty(date)) {
groupArr[date] = []
}
groupArr[date].push(message)
})
Object.keys(groupArr).forEach(key => console.log(groupArr[key]))
file_put_contents($audioFileName, base64_decode($file));
file_put_contents($audioFileName, base64_decode($file));