fix type errors of components

This commit is contained in:
Lhcfl 2024-04-13 15:37:23 +08:00
parent 393ab2590d
commit 2b88ef18a5
5 changed files with 32 additions and 31 deletions

View File

@ -414,7 +414,7 @@ function onContextmenu(ev: MouseEvent): void {
os.pageWindow(notePage(appearNote.value));
},
},
notePage(appearNote.value) != location.pathname
notePage(appearNote.value) !== location.pathname
? {
icon: `${icon("ph-arrows-out-simple")}`,
text: i18n.ts.showInPage,

View File

@ -145,9 +145,10 @@ import * as os from "@/os";
import { signIn } from "@/account";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
import type { entities } from "firefish-js";
const signing = ref(false);
const user = ref(null);
const user = ref<entities.UserDetailed | null>(null);
const username = ref("");
const password = ref("");
const token = ref("");
@ -249,7 +250,7 @@ function queryKey() {
function onSubmit() {
signing.value = true;
console.log("submit");
if (window.PublicKeyCredential && user.value.securityKeys) {
if (window.PublicKeyCredential && user.value?.securityKeys) {
os.api("signin", {
username: username.value,
password: password.value,
@ -263,7 +264,7 @@ function onSubmit() {
return queryKey();
})
.catch(loginFailed);
} else if (!totpLogin.value && user.value && user.value.twoFactorEnabled) {
} else if (!totpLogin.value && user.value?.twoFactorEnabled) {
totpLogin.value = true;
signing.value = false;
} else {
@ -272,8 +273,7 @@ function onSubmit() {
password: password.value,
"hcaptcha-response": hCaptchaResponse.value,
"g-recaptcha-response": reCaptchaResponse.value,
token:
user.value && user.value.twoFactorEnabled ? token.value : undefined,
token: user.value?.twoFactorEnabled ? token.value : undefined,
})
.then((res) => {
emit("login", res);

View File

@ -305,12 +305,12 @@ const host = toUnicode(config.host);
const hcaptcha = ref();
const recaptcha = ref();
const username: string = ref("");
const password: string = ref("");
const retypedPassword: string = ref("");
const invitationCode: string = ref("");
const username = ref<string>("");
const password = ref<string>("");
const retypedPassword = ref<string>("");
const invitationCode = ref<string>("");
const email = ref("");
const usernameState:
const usernameState = ref<
| null
| "wait"
| "ok"
@ -318,9 +318,10 @@ const usernameState:
| "error"
| "invalid-format"
| "min-range"
| "max-range" = ref(null);
const invitationState: null | "entered" = ref(null);
const emailState:
| "max-range"
>(null);
const invitationState = ref<null | "entered">(null);
const emailState = ref<
| null
| "wait"
| "ok"
@ -330,11 +331,11 @@ const emailState:
| "unavailable:mx"
| "unavailable:smtp"
| "unavailable"
| "error" = ref(null);
const passwordStrength: "" | "low" | "medium" | "high" = ref("");
const passwordRetypeState: null | "match" | "not-match" = ref(null);
const submitting: boolean = ref(false);
const ToSAgreement: boolean = ref(false);
| "error">(null);
const passwordStrength = ref<"" | "low" | "medium" | "high">("");
const passwordRetypeState = ref<null | "match" | "not-match" >(null);
const submitting = ref(false);
const ToSAgreement = ref(false);
const hCaptchaResponse = ref(null);
const reCaptchaResponse = ref(null);

View File

@ -98,16 +98,16 @@ import { defaultStore } from "@/store";
import { i18n } from "@/i18n";
const emit = defineEmits<{
(ev: "ok", selected: entities.UserDetailed): void;
(ev: "cancel"): void;
(ev: "closed"): void;
ok: [selected: entities.UserDetailed];
cancel: [];
closed: [];
}>();
const username = ref("");
const host = ref("");
const users: entities.UserDetailed[] = ref([]);
const recentUsers: entities.UserDetailed[] = ref([]);
const selected: entities.UserDetailed | null = ref(null);
const users = ref<entities.UserDetailed[]>([]);
const recentUsers = ref<entities.UserDetailed[]>([]);
const selected = ref<entities.UserDetailed | null>(null);
const dialogEl = ref();
const search = () => {
@ -132,7 +132,7 @@ const ok = () => {
// 使
let recents = defaultStore.state.recentlyUsedUsers;
recents = recents.filter((x) => x !== selected.value.id);
recents = recents.filter((x) => x !== selected.value!.id);
recents.unshift(selected.value.id);
defaultStore.set("recentlyUsedUsers", recents.splice(0, 16));
};

View File

@ -3,7 +3,7 @@
ref="modal"
:z-priority="'high'"
:src="src"
@click="modal.close()"
@click="modal!.close()"
@closed="emit('closed')"
>
<div class="_popup" :class="$style.root">
@ -159,9 +159,9 @@ const props = withDefaults(
);
const emit = defineEmits<{
(ev: "changeVisibility", v: NoteVisibility): void;
(ev: "changeLocalOnly", v: boolean): void;
(ev: "closed"): void;
changeVisibility: [v: NoteVisibility];
changeLocalOnly: [v: boolean];
closed: [];
}>();
const v = ref(props.currentVisibility);
@ -175,7 +175,7 @@ function choose(visibility: NoteVisibility): void {
v.value = visibility;
emit("changeVisibility", visibility);
nextTick(() => {
modal.value.close();
modal.value!.close();
});
}
</script>