This commit is contained in:
jxxghp
2023-07-21 11:12:52 +08:00
parent 7da9f53043
commit 5eebe087b2
3 changed files with 39 additions and 42 deletions
+6 -12
View File
@@ -1,26 +1,20 @@
<script setup lang="ts"> <script setup lang="ts">
interface Props { interface Props {
errorCode?: string errorCode?: string;
errorTitle?: string errorTitle?: string;
errorDescription?: string errorDescription?: string;
} }
const props = defineProps<Props>() const props = defineProps<Props>();
</script> </script>
<template> <template>
<div class="text-center mb-4"> <div class="text-center mb-4">
<!-- 👉 Title and subtitle --> <!-- 👉 Title and subtitle -->
<h1 <h1 v-if="props.errorCode" class="text-h1 font-weight-medium">
v-if="props.errorCode"
class="text-h1 font-weight-medium"
>
{{ props.errorCode }} {{ props.errorCode }}
</h1> </h1>
<h5 <h5 v-if="props.errorTitle" class="text-h5 font-weight-medium mb-3">
v-if="props.errorTitle"
class="text-h5 font-weight-medium mb-3"
>
{{ props.errorTitle }} {{ props.errorTitle }}
</h5> </h5>
<p v-if="props.errorDescription"> <p v-if="props.errorDescription">
+5 -12
View File
@@ -1,25 +1,18 @@
<script lang="ts" setup> <script lang="ts" setup>
interface Props { interface Props {
menuList?: unknown[] menuList?: unknown[];
itemProps?: boolean itemProps?: boolean;
} }
const props = defineProps<Props>() const props = defineProps<Props>();
</script> </script>
<template> <template>
<IconBtn> <IconBtn>
<VIcon icon="mdi-dots-vertical" /> <VIcon icon="mdi-dots-vertical" />
<VMenu <VMenu v-if="props.menuList" activator="parent" close-on-content-click>
v-if="props.menuList" <VList :items="props.menuList" :item-props="props.itemProps" />
activator="parent"
close-on-content-click
>
<VList
:items="props.menuList"
:item-props="props.itemProps"
/>
</VMenu> </VMenu>
</IconBtn> </IconBtn>
</template> </template>
+28 -18
View File
@@ -1,35 +1,45 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch } from 'vue' import type { ThemeSwitcherTheme } from "@layouts/types";
import { useTheme } from 'vuetify' import { ref, watch } from "vue";
import type { ThemeSwitcherTheme } from '@layouts/types' import { useTheme } from "vuetify";
const props = defineProps<{ const props = defineProps<{
themes: ThemeSwitcherTheme[] themes: ThemeSwitcherTheme[];
}>() }>();
const { name: themeName, global: globalTheme } = useTheme() const { name: themeName, global: globalTheme } = useTheme();
const savedTheme = ref(localStorage.getItem('theme') ?? themeName) const savedTheme = ref(localStorage.getItem("theme") ?? themeName);
const { state: currentThemeName, next: getNextThemeName, index: currentThemeIndex } = useCycleList(props.themes.map(t => t.name), { initialValue: savedTheme.value }) const {
state: currentThemeName,
next: getNextThemeName,
index: currentThemeIndex,
} = useCycleList(
props.themes.map((t) => t.name),
{ initialValue: savedTheme.value }
);
const changeTheme = () => { const changeTheme = () => {
const nextTheme = getNextThemeName() const nextTheme = getNextThemeName();
globalTheme.name.value = nextTheme globalTheme.name.value = nextTheme;
savedTheme.value = nextTheme savedTheme.value = nextTheme;
localStorage.setItem('theme', nextTheme) localStorage.setItem("theme", nextTheme);
} };
// Update icon if theme is changed from other sources // Update icon if theme is changed from other sources
watch(() => globalTheme.name.value, val => { watch(
currentThemeName.value = val () => globalTheme.name.value,
}) (val) => {
currentThemeName.value = val;
}
);
// Apply saved theme on page load // Apply saved theme on page load
onMounted(() => { onMounted(() => {
globalTheme.name.value = savedTheme.value globalTheme.name.value = savedTheme.value;
}) });
</script> </script>
<template> <template>