This commit is contained in:
@@ -1,9 +1,16 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
import { ref, onMounted, onBeforeUnmount, watch } from "vue";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
// Добавляем emit для уведомления родителя об изменениях
|
// Добавляем emit для уведомления родителя об изменениях
|
||||||
const emit = defineEmits(["update:viewed", "update:status"]);
|
const emit = defineEmits([
|
||||||
|
"update:viewed",
|
||||||
|
"update:status",
|
||||||
|
"update:tematik",
|
||||||
|
"update:svodka",
|
||||||
|
"update:donesenie",
|
||||||
|
"update:bilutene",
|
||||||
|
]);
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
url: String,
|
url: String,
|
||||||
@@ -17,14 +24,23 @@ const props = defineProps({
|
|||||||
other: String,
|
other: String,
|
||||||
viewed: Boolean,
|
viewed: Boolean,
|
||||||
status: Boolean,
|
status: Boolean,
|
||||||
|
tematik: Boolean,
|
||||||
|
svodka: Boolean,
|
||||||
|
donesenie: Boolean,
|
||||||
|
bilutene: Boolean,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Делаем viewed и status реактивными для локального обновления
|
// Делаем viewed и status реактивными для локального обновления
|
||||||
const localViewed = ref(props.viewed);
|
const localViewed = ref(props.viewed);
|
||||||
const localStatus = ref(props.status);
|
const localStatus = ref(props.status);
|
||||||
|
|
||||||
|
// Делаем tematik, svodka, donesenie, bilutene реактивными для локального обновления
|
||||||
|
const localTematik = ref(props.tematik);
|
||||||
|
const localSvodka = ref(props.svodka);
|
||||||
|
const localDonesenie = ref(props.donesenie);
|
||||||
|
const localBilutene = ref(props.bilutene);
|
||||||
|
|
||||||
// Следим за изменениями props и обновляем локальные значения
|
// Следим за изменениями props и обновляем локальные значения
|
||||||
import { watch } from "vue";
|
|
||||||
watch(
|
watch(
|
||||||
() => props.viewed,
|
() => props.viewed,
|
||||||
(val) => {
|
(val) => {
|
||||||
@@ -37,6 +53,30 @@ watch(
|
|||||||
localStatus.value = val;
|
localStatus.value = val;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
watch(
|
||||||
|
() => props.tematik,
|
||||||
|
(val) => {
|
||||||
|
localTematik.value = val;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
watch(
|
||||||
|
() => props.svodka,
|
||||||
|
(val) => {
|
||||||
|
localSvodka.value = val;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
watch(
|
||||||
|
() => props.donesenie,
|
||||||
|
(val) => {
|
||||||
|
localDonesenie.value = val;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
watch(
|
||||||
|
() => props.bilutene,
|
||||||
|
(val) => {
|
||||||
|
localBilutene.value = val;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
// Тема
|
// Тема
|
||||||
const isDarkMode = ref(document.documentElement.classList.contains("dark"));
|
const isDarkMode = ref(document.documentElement.classList.contains("dark"));
|
||||||
@@ -102,6 +142,74 @@ const status_b = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const tematik_b = async () => {
|
||||||
|
const newValue = !localTematik.value;
|
||||||
|
localTematik.value = newValue;
|
||||||
|
emit("update:tematik", { url: props.url, tematik: newValue });
|
||||||
|
|
||||||
|
try {
|
||||||
|
await axios.post(
|
||||||
|
"https://allowlgroup.ru/api/8002/update_tematik_status",
|
||||||
|
null,
|
||||||
|
{ params: { url: props.url, tematik: newValue } },
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
localTematik.value = !newValue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const svodka_b = async () => {
|
||||||
|
const newValue = !localSvodka.value;
|
||||||
|
localSvodka.value = newValue;
|
||||||
|
emit("update:svodka", { url: props.url, svodka: newValue });
|
||||||
|
|
||||||
|
try {
|
||||||
|
await axios.post(
|
||||||
|
"https://allowlgroup.ru/api/8002/update_svodka_status",
|
||||||
|
null,
|
||||||
|
{ params: { url: props.url, svodka: newValue } },
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
localSvodka.value = !newValue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const donesenie_b = async () => {
|
||||||
|
const newValue = !localDonesenie.value;
|
||||||
|
localDonesenie.value = newValue;
|
||||||
|
emit("update:donesenie", { url: props.url, donesenie: newValue });
|
||||||
|
|
||||||
|
try {
|
||||||
|
await axios.post(
|
||||||
|
"https://allowlgroup.ru/api/8002/update_donesenie_status",
|
||||||
|
null,
|
||||||
|
{ params: { url: props.url, donesenie: newValue } },
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
localDonesenie.value = !newValue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const bilutene_b = async () => {
|
||||||
|
const newValue = !localBilutene.value;
|
||||||
|
localBilutene.value = newValue;
|
||||||
|
emit("update:bilutene", { url: props.url, bilutene: newValue });
|
||||||
|
|
||||||
|
try {
|
||||||
|
await axios.post(
|
||||||
|
"https://allowlgroup.ru/api/8002/update_bilutene_status",
|
||||||
|
null,
|
||||||
|
{ params: { url: props.url, bilutene: newValue } },
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
localBilutene.value = !newValue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const download = async () => {
|
const download = async () => {
|
||||||
try {
|
try {
|
||||||
const rez = await axios.get(
|
const rez = await axios.get(
|
||||||
@@ -226,7 +334,7 @@ onBeforeUnmount(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<div class="ml-4 mb-4">
|
<div class="ml-4 mb-4 flex items-end gap-2">
|
||||||
<button class="cursor-pointer" @click="viewed_b">
|
<button class="cursor-pointer" @click="viewed_b">
|
||||||
<img
|
<img
|
||||||
v-if="localViewed"
|
v-if="localViewed"
|
||||||
@@ -262,6 +370,55 @@ onBeforeUnmount(() => {
|
|||||||
class="h-12 hover:opacity-75 active:opacity-75"
|
class="h-12 hover:opacity-75 active:opacity-75"
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<!-- Кнопки Т, С, Д, Б -->
|
||||||
|
<button
|
||||||
|
@click="tematik_b"
|
||||||
|
class="w-10 h-10 rounded-lg font-bold text-sm hover:opacity-75 active:opacity-75 transition-colors"
|
||||||
|
:class="
|
||||||
|
localTematik
|
||||||
|
? 'bg-green-500 text-white'
|
||||||
|
: 'bg-gray-300 dark:bg-gray-700 text-gray-700 dark:text-gray-300'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
Т
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
@click="svodka_b"
|
||||||
|
class="w-10 h-10 rounded-lg font-bold text-sm hover:opacity-75 active:opacity-75 transition-colors"
|
||||||
|
:class="
|
||||||
|
localSvodka
|
||||||
|
? 'bg-blue-500 text-white'
|
||||||
|
: 'bg-gray-300 dark:bg-gray-700 text-gray-700 dark:text-gray-300'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
С
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
@click="donesenie_b"
|
||||||
|
class="w-10 h-10 rounded-lg font-bold text-sm hover:opacity-75 active:opacity-75 transition-colors"
|
||||||
|
:class="
|
||||||
|
localDonesenie
|
||||||
|
? 'bg-yellow-500 text-white'
|
||||||
|
: 'bg-gray-300 dark:bg-gray-700 text-gray-700 dark:text-gray-300'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
Д
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
@click="bilutene_b"
|
||||||
|
class="w-10 h-10 rounded-lg font-bold text-sm hover:opacity-75 active:opacity-75 transition-colors"
|
||||||
|
:class="
|
||||||
|
localBilutene
|
||||||
|
? 'bg-purple-500 text-white'
|
||||||
|
: 'bg-gray-300 dark:bg-gray-700 text-gray-700 dark:text-gray-300'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
Б
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
class="hover:opacity-75 active:opacity-75 mr-10 rounded-xl cursor-pointer"
|
class="hover:opacity-75 active:opacity-75 mr-10 rounded-xl cursor-pointer"
|
||||||
|
|||||||
Reference in New Issue
Block a user