refactor: fix type errors of MkAnnouncements

This commit is contained in:
Lhcfl 2024-04-10 20:10:43 +08:00
parent b6baded2e3
commit 6ac6a4cfa9
4 changed files with 10 additions and 7 deletions

View File

@ -18,8 +18,8 @@ import { initChart } from "@/scripts/init-chart";
initChart();
const rootEl = shallowRef<HTMLDivElement>();
const chartEl = shallowRef<HTMLCanvasElement>();
const rootEl = shallowRef<HTMLDivElement | null>(null);
const chartEl = shallowRef<HTMLCanvasElement | null>(null);
const now = new Date();
let chartInstance: Chart | null = null;
const fetching = ref(true);
@ -33,8 +33,8 @@ async function renderActiveUsersChart() {
chartInstance.destroy();
}
const wide = rootEl.value.offsetWidth > 700;
const narrow = rootEl.value.offsetWidth < 400;
const wide = rootEl.value!.offsetWidth > 700;
const narrow = rootEl.value!.offsetWidth < 400;
const weeks = wide ? 50 : narrow ? 10 : 25;
const chartLimit = 7 * weeks;

View File

@ -35,9 +35,10 @@ import MkSparkle from "@/components/MkSparkle.vue";
import MkButton from "@/components/MkButton.vue";
import { i18n } from "@/i18n";
import * as os from "@/os";
import type { entities } from "firefish-js";
const props = defineProps<{
announcement: Announcement;
announcement: entities.Announcement;
}>();
const { id, text, title, imageUrl, isGoodNews } = props.announcement;
@ -45,7 +46,7 @@ const { id, text, title, imageUrl, isGoodNews } = props.announcement;
const modal = shallowRef<InstanceType<typeof MkModal>>();
const gotIt = () => {
modal.value.close();
modal.value!.close();
os.api("i/read-announcement", { announcementId: id });
};
</script>

View File

@ -190,7 +190,7 @@ const transitionDuration = computed(() =>
let contentClicking = false;
const focusedElement = document.activeElement;
function close(_ev, opts: { useSendAnimation?: boolean } = {}) {
function close(_ev?, opts: { useSendAnimation?: boolean } = {}) {
// removeEventListener("popstate", close);
// if (props.preferType == "dialog") {
// history.forward();

View File

@ -422,6 +422,8 @@ export type Announcement = {
title: string;
imageUrl: string | null;
isRead?: boolean;
isGoodNews?: boolean;
showPopUp?: boolean;
};
export type Antenna = {