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 === '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 === '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"/>
</div>
<header v-if="title" :class="$style.title"><Mfm :text="title"/></header>

View File

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

View File

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