feat: page title
This commit is contained in:
@@ -11,7 +11,7 @@ import { relativeTime } from "@/lib/dates";
|
|||||||
import { useAlertStore } from "@/stores/alerts";
|
import { useAlertStore } from "@/stores/alerts";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
const emit = defineEmits<(e: "clone" | "delete", task: Task) => void>();
|
const emit = defineEmits<(e: "clone" | "delete" | "updated", task: Task) => void>();
|
||||||
|
|
||||||
const task = defineModel<Task>({ required: true });
|
const task = defineModel<Task>({ required: true });
|
||||||
defineProps<{ showLastChecked: boolean; showNextReset: boolean }>();
|
defineProps<{ showLastChecked: boolean; showNextReset: boolean }>();
|
||||||
@@ -39,6 +39,7 @@ function onSave() {
|
|||||||
})
|
})
|
||||||
.then((newTask) => {
|
.then((newTask) => {
|
||||||
task.value = newTask;
|
task.value = newTask;
|
||||||
|
emit("updated", newTask);
|
||||||
alertSuccess(i18n.t("alerts.task_updated"));
|
alertSuccess(i18n.t("alerts.task_updated"));
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@@ -57,6 +58,7 @@ function onCheck() {
|
|||||||
})
|
})
|
||||||
.then((newTask) => {
|
.then((newTask) => {
|
||||||
task.value = newTask;
|
task.value = newTask;
|
||||||
|
emit("updated", newTask);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
alertError(i18n.t("alerts.task_update_error"));
|
alertError(i18n.t("alerts.task_update_error"));
|
||||||
@@ -68,6 +70,7 @@ function onCheck() {
|
|||||||
})
|
})
|
||||||
.then((newTask) => {
|
.then((newTask) => {
|
||||||
task.value = newTask;
|
task.value = newTask;
|
||||||
|
emit("updated", newTask);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
alertError(i18n.t("alerts.task_update_error"));
|
alertError(i18n.t("alerts.task_update_error"));
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ArrowBigRightDashIcon, DicesIcon } from "@lucide/vue";
|
import { ArrowBigRightDashIcon, DicesIcon } from "@lucide/vue";
|
||||||
import { generateSlug } from "random-word-slugs";
|
import { generateSlug } from "random-word-slugs";
|
||||||
import { ref } from "vue";
|
import { onBeforeMount, ref } from "vue";
|
||||||
|
import { onBeforeRouteUpdate } from "vue-router";
|
||||||
|
|
||||||
const listNameInput = ref<string>(generateSlug(4));
|
const listNameInput = ref<string>(generateSlug(4));
|
||||||
|
|
||||||
@@ -16,6 +17,13 @@ function onInput() {
|
|||||||
.replace(/[^a-z0-9-]/g, "")
|
.replace(/[^a-z0-9-]/g, "")
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateTitle() {
|
||||||
|
document.title = 'Tout Doux';
|
||||||
|
}
|
||||||
|
|
||||||
|
onBeforeMount(updateTitle)
|
||||||
|
onBeforeRouteUpdate(updateTitle);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ function fetchTasks() {
|
|||||||
|
|
||||||
function reSortTasks() {
|
function reSortTasks() {
|
||||||
tasks.value = sortTasks(tasks.value, sortType.value, sortReverse.value);
|
tasks.value = sortTasks(tasks.value, sortType.value, sortReverse.value);
|
||||||
|
updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onNewTask() {
|
function onNewTask() {
|
||||||
@@ -124,6 +125,12 @@ function onChangeSortReverse() {
|
|||||||
reSortTasks();
|
reSortTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateTitle() {
|
||||||
|
if (list.value !== null) {
|
||||||
|
document.title = `Tout Doux - ${list.value} (${completedCount.value.toFixed(0)}/${taskCount.value.toFixed(0)})`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
list.value = route.params.list as string;
|
list.value = route.params.list as string;
|
||||||
fetchTasks();
|
fetchTasks();
|
||||||
@@ -147,6 +154,7 @@ onBeforeRouteUpdate((to) => {
|
|||||||
v-model="tasks[i]"
|
v-model="tasks[i]"
|
||||||
:show-last-checked="showLastChecked"
|
:show-last-checked="showLastChecked"
|
||||||
:show-next-reset="showNextReset"
|
:show-next-reset="showNextReset"
|
||||||
|
@updated="updateTitle"
|
||||||
@clone="onCloneTask"
|
@clone="onCloneTask"
|
||||||
@delete="onDeleteTask"
|
@delete="onDeleteTask"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { CircleQuestionMarkIcon } from "@lucide/vue";
|
import { CircleQuestionMarkIcon } from "@lucide/vue";
|
||||||
|
import { onBeforeMount } from "vue";
|
||||||
|
import { onBeforeRouteUpdate } from "vue-router";
|
||||||
|
|
||||||
|
function updateTitle() {
|
||||||
|
document.title = 'Tout Doux - Not Found';
|
||||||
|
}
|
||||||
|
|
||||||
|
onBeforeMount(updateTitle)
|
||||||
|
onBeforeRouteUpdate(updateTitle);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
Reference in New Issue
Block a user