<script setup>
import { useRouter } from 'vue-router';
import { computed, watch } from 'vue';
import { useAuthStore } from '@/stores/auth'; // Пример с Pinia
const router = useRouter();
const authStore = useAuthStore();
const userRole = computed(() => authStore.role);
watch(userRole, (newRole) => {
if (newRole !== 'admin') {
router.push('/');
}
});
</script>
router.beforeEach((to, from, next) => {
const hasAccess = checkUserAccess(to);
if (!hasAccess) {
next('/');
} else {
next();
}
});
$.ajax({
url: '/ajax.php', // URL для обработки клика
type: 'POST',
data: {
action: 'increment_click', // Действие для обработки
notification_id: notificationDetails[i]['id'] // ID уведомления
},
success: function(response) {
console.log('Click counter updated.');
},
error: function() {
// Обработка ошибок, если нужно
console.log('Error updating click counter.');
}
});
if ($_POST['action'] == 'increment_click' && isset($_POST['notification_id'])) {
.....
логика обновления по инкрименту нотификатору
}
interface reqiestType = {
name?:string;
age?:number;
}
interface reqiestType {
name:string;
age:number;
}
const data:Partial<reqiestType> = {};
router.beforeEach((to, from, next) => {
const auth = getAuth()
auth.onAuthStateChanged(user => {
if (!user && to.path !== '/auth') {
next('/auth')
}
else if (user && to.path === '/auth') {
next(from.path)
}
next()
})
})
<FormKit v-for="(deadline_type, idx) in data.deadline_types" key="deadline_type.id"
type="date"
v-model="form[idx]deadline_type.code"
:label="deadline_type.name"
/>