feat: added router for Timer
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { createRouter, createWebHistory } from '@ionic/vue-router';
|
import { createRouter, createWebHistory } from '@ionic/vue-router';
|
||||||
import type { RouteRecordRaw } from 'vue-router';
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
import TimersList from '@/views/TimersList/TimersList.vue';
|
import TimersList from '@/views/TimersList/TimersList.vue';
|
||||||
|
import Timer from '@/views/Timer/Timer.vue';
|
||||||
|
|
||||||
const routes: RouteRecordRaw[] = [
|
const routes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
@@ -11,6 +12,11 @@ const routes: RouteRecordRaw[] = [
|
|||||||
path: '/timers',
|
path: '/timers',
|
||||||
name: 'Timers',
|
name: 'Timers',
|
||||||
component: TimersList
|
component: TimersList
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/timer/:id',
|
||||||
|
name: 'Timer',
|
||||||
|
component: Timer
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
<ion-page>
|
||||||
|
<ion-content>
|
||||||
<div class="timers-container">
|
<div class="timers-container">
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1>Таймеры</h1>
|
<h1>Таймеры</h1>
|
||||||
@@ -61,7 +63,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<button class="btn btn-primary">
|
<button @click="goToTimer(timer.id)" class="btn btn-secondary">
|
||||||
<ion-icon :icon="playCircleOutline"></ion-icon>
|
<ion-icon :icon="playCircleOutline"></ion-icon>
|
||||||
Открыть
|
Открыть
|
||||||
</button>
|
</button>
|
||||||
@@ -79,3 +81,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</ion-content>
|
||||||
|
</ion-page>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { defineComponent, onMounted, ref } from 'vue'
|
import { defineComponent, onMounted, ref } from 'vue'
|
||||||
import { IonIcon } from '@ionic/vue'
|
import { IonIcon, IonPage, IonContent } from '@ionic/vue'
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
import {
|
import {
|
||||||
timerOutline,
|
timerOutline,
|
||||||
chevronUp,
|
chevronUp,
|
||||||
@@ -14,13 +15,19 @@ import type { TimersRow } from '@/types/timerType'
|
|||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'TimersList',
|
name: 'TimersList',
|
||||||
components: { IonIcon },
|
components: { IonIcon, IonPage, IonContent },
|
||||||
setup() {
|
setup() {
|
||||||
const timers = ref<TimersRow[]>([])
|
const timers = ref<TimersRow[]>([])
|
||||||
const loading = ref<boolean>(true)
|
const loading = ref<boolean>(true)
|
||||||
const error = ref<string | null>(null)
|
const error = ref<string | null>(null)
|
||||||
const expandedId = ref<number | null>(null)
|
const expandedId = ref<number | null>(null)
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const goToTimer = (id: number) => {
|
||||||
|
router.push(`/timer/${id}`);
|
||||||
|
};
|
||||||
|
|
||||||
const loadTimers = async (): Promise<void> => {
|
const loadTimers = async (): Promise<void> => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
error.value = null
|
error.value = null
|
||||||
@@ -55,6 +62,7 @@ export default defineComponent({
|
|||||||
playCircleOutline,
|
playCircleOutline,
|
||||||
pencilOutline,
|
pencilOutline,
|
||||||
trashOutline,
|
trashOutline,
|
||||||
|
goToTimer
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user