This commit is contained in:
syuilo 2025-05-06 16:51:01 +09:00
parent 1d79fc9092
commit 925dd76f00
2 changed files with 58 additions and 51 deletions

View File

@ -4,20 +4,14 @@ SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<Transition :name="prefer.s.animation ? '_transition_zoom' : ''" appear> <MkResult type="error">
<div :class="$style.root"> <MkButton :class="$style.button" rounded @click="() => emit('retry')">{{ i18n.ts.retry }}</MkButton>
<img v-if="instance.serverErrorImageUrl" :class="$style.img" :src="instance.serverErrorImageUrl" draggable="false"/> </MkResult>
<p :class="$style.text"><i class="ti ti-alert-triangle"></i> {{ i18n.ts.somethingHappened }}</p>
<MkButton :class="$style.button" @click="() => emit('retry')">{{ i18n.ts.retry }}</MkButton>
</div>
</Transition>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { prefer } from '@/preferences.js';
import { instance } from '@/instance.js';
const emit = defineEmits<{ const emit = defineEmits<{
(ev: 'retry'): void; (ev: 'retry'): void;
@ -25,25 +19,7 @@ const emit = defineEmits<{
</script> </script>
<style lang="scss" module> <style lang="scss" module>
.root {
padding: 32px;
text-align: center;
align-items: center;
}
.text {
margin: 0 0 8px 0;
}
.button { .button {
margin: 0 auto; margin: 0 auto;
} }
.img {
vertical-align: bottom;
width: 128px;
height: 128px;
margin-bottom: 16px;
border-radius: 16px;
}
</style> </style>

View File

@ -4,37 +4,56 @@ SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<div :class="[$style.root]" class="_gaps_m"> <Transition :name="prefer.s.animation ? '_transition_zoom' : ''" appear>
<img v-if="type === 'empty' && instance.infoImageUrl" :src="instance.infoImageUrl" draggable="false" :class="$style.img"/> <div :class="[$style.root, { [$style.warn]: type === 'notFound', [$style.error]: type === 'error' }]" class="_gaps_m">
<svg v-else-if="type === 'empty'" :class="$style.icon" viewBox="0 0 128 128" style="stroke-linecap:round;"> <img v-if="type === 'empty' && instance.infoImageUrl" :src="instance.infoImageUrl" draggable="false" :class="$style.img"/>
<path d="M64,0C99.323,0 128,28.677 128,64C128,99.323 99.323,128 64,128C28.677,128 0,99.323 0,64C0,28.677 28.677,0 64,0ZM64,8C33.093,8 8,33.093 8,64C8,94.907 33.093,120 64,120C94.907,120 120,94.907 120,64C120,33.093 94.907,8 64,8Z" style="fill:currentColor;"/> <svg v-else-if="type === 'empty'" :class="$style.icon" viewBox="0 0 128 128" style="stroke-linecap:round;">
<g transform="matrix(1,0,0,1,0,8)"> <g transform="matrix(1,0,0,0.9,0,12.8)">
<path d="M64,88L64,48" style="fill:none;stroke:currentColor;stroke-width:8px;"/> <path d="M64,88L64,48" style="fill:none;stroke:currentColor;stroke-width:8.41px;"/>
</g> </g>
<g transform="matrix(1,0,0,1,-4,4)"> <g transform="matrix(1,0,0,1,-4,8)">
<circle cx="68" cy="28" r="4" style="fill:currentColor;"/> <circle cx="68" cy="28" r="4" style="fill:currentColor;"/>
</g> </g>
</svg> <g transform="matrix(0.875,0,0,0.875,8,8)">
<img v-if="type === 'notFound' && instance.notFoundImageUrl" :src="instance.notFoundImageUrl" draggable="false" :class="$style.img"/> <circle cx="64" cy="64" r="64" style="fill:none;stroke:currentColor;stroke-width:9.14px;"/>
<svg v-else-if="type === 'notFound'" :class="$style.icon" viewBox="0 0 128 128" style="stroke-linecap:round;"> </g>
<path d="M64,0C99.323,0 128,28.677 128,64C128,99.323 99.323,128 64,128C28.677,128 0,99.323 0,64C0,28.677 28.677,0 64,0ZM64,8C33.093,8 8,33.093 8,64C8,94.907 33.093,120 64,120C94.907,120 120,94.907 120,64C120,33.093 94.907,8 64,8Z" style="fill:currentColor;"/> </svg>
<g transform="matrix(1,0,0,1,0,8)"> <img v-if="type === 'notFound' && instance.notFoundImageUrl" :src="instance.notFoundImageUrl" draggable="false" :class="$style.img"/>
<path d="M64,72L64,56C72.533,55.777 80,49.333 80,40C80,31.667 73.333,24 64,24C55.667,24 47.556,31.667 48,40" style="fill:none;stroke:currentColor;stroke-width:8px;"/> <svg v-else-if="type === 'notFound'" :class="$style.icon" viewBox="0 0 128 128" style="stroke-linecap:round;">
</g> <g transform="matrix(1,0,0,1,0,12)">
<g transform="matrix(1,0,0,1,-4,68)"> <path d="M64,64L64,56C72.533,55.777 80,49.333 80,40C80,31.667 73.333,24 64,24C55.667,24 47.556,31.667 48,40" style="fill:none;stroke:currentColor;stroke-width:8px;"/>
<circle cx="68" cy="28" r="4" style="fill:currentColor;"/> </g>
</g> <g transform="matrix(1,0,0,1,-4,64)">
</svg> <circle cx="68" cy="28" r="4" style="fill:currentColor;"/>
</g>
<g transform="matrix(0.875,0,0,0.875,8,8)">
<circle cx="64" cy="64" r="64" style="fill:none;stroke:currentColor;stroke-width:9.14px;"/>
</g>
</svg>
<img v-if="type === 'error' && instance.serverErrorImageUrl" :src="instance.serverErrorImageUrl" draggable="false" :class="$style.img"/>
<svg v-else-if="type === 'error'" :class="$style.icon" viewBox="0 0 128 128" style="stroke-linecap:round;">
<g transform="matrix(0.707107,0.707107,-0.636396,0.636396,62.0201,-24.5298)">
<path d="M64,94.667L64,41.333" style="fill:none;stroke:currentColor;stroke-width:8.41px;"/>
</g>
<g transform="matrix(0.707107,-0.707107,0.636396,0.636396,-24.5298,65.9799)">
<path d="M64,94.667L64,41.333" style="fill:none;stroke:currentColor;stroke-width:8.41px;"/>
</g>
<g transform="matrix(0.875,0,0,0.875,8,8)">
<circle cx="64" cy="64" r="64" style="fill:none;stroke:currentColor;stroke-width:9.14px;"/>
</g>
</svg>
<div style="opacity: 0.7;">{{ props.text ?? (type === 'empty' ? i18n.ts.nothing : type === 'notFound' ? i18n.ts.notFound : null) }}</div> <div style="opacity: 0.7;">{{ props.text ?? (type === 'empty' ? i18n.ts.nothing : type === 'notFound' ? i18n.ts.notFound : type === 'error' ? i18n.ts.somethingHappened : null) }}</div>
<slot></slot> <slot></slot>
</div> </div>
</Transition>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import {} from 'vue'; import {} from 'vue';
import { instance } from '@/instance.js'; import { instance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { prefer } from '@/preferences.js';
const props = defineProps<{ const props = defineProps<{
type: 'empty' | 'notFound' | 'error'; type: 'empty' | 'notFound' | 'error';
@ -47,6 +66,18 @@ const props = defineProps<{
position: relative; position: relative;
text-align: center; text-align: center;
padding: 32px; padding: 32px;
&.error {
.icon {
color: var(--MI_THEME-error);
}
}
&.warn {
.icon {
color: var(--MI_THEME-warn);
}
}
} }
.img { .img {