This commit is contained in:
ThatOneCalculator 2023-02-18 19:48:25 -08:00
parent f625e4c40b
commit 302e452572
No known key found for this signature in database
GPG key ID: 8703CACD01000000
3 changed files with 42 additions and 19 deletions

View file

@ -9,7 +9,7 @@
<i v-else-if="type === 'error'" :class="$style.iconInner" class="ph-circle-wavy-warning-bold ph-lg"></i> <i v-else-if="type === 'error'" :class="$style.iconInner" class="ph-circle-wavy-warning-bold ph-lg"></i>
<i v-else-if="type === 'warning'" :class="$style.iconInner" class="ph-warning-bold ph-lg"></i> <i v-else-if="type === 'warning'" :class="$style.iconInner" class="ph-warning-bold ph-lg"></i>
<i v-else-if="type === 'info'" :class="$style.iconInner" class="ph-info-bold ph-lg"></i> <i v-else-if="type === 'info'" :class="$style.iconInner" class="ph-info-bold ph-lg"></i>
<i v-else-if="type === 'question'" :class="$style.iconInner" class="ph-circle-notch-bold ph-lg"></i> <i v-else-if="type === 'question'" :class="$style.iconInner" class="ph-circle-question-bold ph-lg"></i>
<MkLoading v-else-if="type === 'waiting'" :class="$style.iconInner" :em="true"/> <MkLoading v-else-if="type === 'waiting'" :class="$style.iconInner" :em="true"/>
</div> </div>
<header v-if="title" :class="$style.title"><Mfm :text="title"/></header> <header v-if="title" :class="$style.title"><Mfm :text="title"/></header>

View file

@ -15,10 +15,12 @@ const props = withDefaults(defineProps<{
inline?: boolean; inline?: boolean;
colored?: boolean; colored?: boolean;
mini?: boolean; mini?: boolean;
em?: boolean;
}>(), { }>(), {
inline: false, inline: false,
colored: true, colored: true,
mini: false, mini: false,
em: false,
}); });
</script> </script>
@ -70,6 +72,12 @@ const props = withDefaults(defineProps<{
padding: 16px; padding: 16px;
--size: 32px; --size: 32px;
} }
&.em {
display: inline-block;
vertical-align: middle;
padding: 0;
--size: 1em;
}
} }
.container { .container {

View file

@ -7,8 +7,8 @@ import * as Misskey from "calckey-js";
import { apiUrl, url } from "@/config"; import { apiUrl, url } from "@/config";
import MkPostFormDialog from "@/components/MkPostFormDialog.vue"; import MkPostFormDialog from "@/components/MkPostFormDialog.vue";
import MkWaitingDialog from "@/components/MkWaitingDialog.vue"; import MkWaitingDialog from "@/components/MkWaitingDialog.vue";
import MkToast from '@/components/MkToast.vue'; import MkToast from "@/components/MkToast.vue";
import MkDialog from '@/components/MkDialog.vue'; import MkDialog from "@/components/MkDialog.vue";
import { MenuItem } from "@/types/menu"; import { MenuItem } from "@/types/menu";
import { $i } from "@/account"; import { $i } from "@/account";
@ -248,41 +248,56 @@ export function modalPageWindow(path: string) {
} }
export function toast(message: string) { export function toast(message: string) {
popup(MkToast, { popup(
MkToast,
{
message, message,
}, {}, 'closed'); },
{},
"closed",
);
} }
export function alert(props: { export function alert(props: {
type?: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question'; type?: "error" | "info" | "success" | "warning" | "waiting" | "question";
title?: string | null; title?: string | null;
text?: string | null; text?: string | null;
}): Promise<void> { }): Promise<void> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
popup(MkDialog, props, { popup(
done: result => { MkDialog,
props,
{
done: (result) => {
resolve(); resolve();
}, },
}, 'closed'); },
"closed",
);
}); });
} }
export function confirm(props: { export function confirm(props: {
type: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question'; type: "error" | "info" | "success" | "warning" | "waiting" | "question";
title?: string | null; title?: string | null;
text?: string | null; text?: string | null;
okText?: string; okText?: string;
cancelText?: string; cancelText?: string;
}): Promise<{ canceled: boolean }> { }): Promise<{ canceled: boolean }> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
popup(MkDialog, { popup(
MkDialog,
{
...props, ...props,
showCancelButton: true, showCancelButton: true,
}, { },
done: result => { {
done: (result) => {
resolve(result ? result : { canceled: true }); resolve(result ? result : { canceled: true });
}, },
}, 'closed'); },
"closed",
);
}); });
} }