refactor: `popup()`の`props`に`ref`な値を入れるのを許可するように

This commit is contained in:
zyoshoka 2024-02-10 17:31:43 +09:00
parent 931199ae6a
commit d688de597e
No known key found for this signature in database
GPG Key ID: 0C2CB8FBA309A5B8
3 changed files with 10 additions and 7 deletions

View File

@ -185,7 +185,7 @@ export async function refreshAccount() {
export async function login(token: Account['token'], redirect?: string) {
const showing = ref(true);
popup(defineAsyncComponent(() => import('@/components/MkWaitingDialog.vue')), {
success: ref(false),
success: false,
showing: showing,
}, {}, 'closed');
if (_DEV_) console.log('logging as token ', token);

View File

@ -14,14 +14,14 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { Ref, watch, shallowRef } from 'vue';
import { watch, shallowRef } from 'vue';
import MkModal from '@/components/MkModal.vue';
const modal = shallowRef<InstanceType<typeof MkModal>>();
const props = defineProps<{
success: Ref<boolean>;
showing: Ref<boolean>;
success: boolean;
showing: boolean;
text?: string;
}>();

View File

@ -8,7 +8,7 @@
import { Component, markRaw, Ref, ref, defineAsyncComponent } from 'vue';
import { EventEmitter } from 'eventemitter3';
import * as Misskey from 'misskey-js';
import type { ComponentProps } from 'vue-component-type-helpers';
import type { ComponentProps as CP } from 'vue-component-type-helpers';
import type { Form, GetFormResultType } from '@/scripts/form.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
@ -159,6 +159,9 @@ type ComponentEmit<T> = T extends new () => { $props: infer Props }
: never
: never;
// props に ref を許可するようにする
type ComponentProps<T extends Component> = { [K in keyof CP<T>]: CP<T>[K] | Ref<CP<T>[K]> };
type EmitsExtractor<T> = {
[K in keyof T as K extends `onVnode${string}` ? never : K extends `on${infer E}` ? Uncapitalize<E> : K extends string ? never : K]: T[K];
};
@ -416,7 +419,7 @@ export function success(): Promise<void> {
showing.value = false;
}, 1000);
popup(MkWaitingDialog, {
success: ref(true),
success: true,
showing: showing,
}, {
done: () => resolve(),
@ -428,7 +431,7 @@ export function waiting(): Promise<void> {
return new Promise(resolve => {
const showing = ref(true);
popup(MkWaitingDialog, {
success: ref(false),
success: false,
showing: showing,
}, {
done: () => resolve(),