fix type errors of components
This commit is contained in:
parent
8e28f0e97c
commit
e6b7eca775
10 changed files with 88 additions and 66 deletions
|
@ -2,16 +2,16 @@
|
||||||
<MkModal
|
<MkModal
|
||||||
ref="modal"
|
ref="modal"
|
||||||
:z-priority="'middle'"
|
:z-priority="'middle'"
|
||||||
@click="modal.close()"
|
@click="modal!.close()"
|
||||||
@closed="emit('closed')"
|
@closed="emit('closed')"
|
||||||
>
|
>
|
||||||
<div class="xubzgfga">
|
<div class="xubzgfga">
|
||||||
<header>{{ image.name }}</header>
|
<header>{{ image.name }}</header>
|
||||||
<img
|
<img
|
||||||
:src="image.url"
|
:src="image.url"
|
||||||
:alt="image.comment"
|
:alt="image.comment || undefined"
|
||||||
:title="image.comment"
|
:title="image.comment || undefined"
|
||||||
@click="modal.close()"
|
@click="modal!.close()"
|
||||||
/>
|
/>
|
||||||
<footer>
|
<footer>
|
||||||
<span>{{ image.type }}</span>
|
<span>{{ image.type }}</span>
|
||||||
|
@ -33,7 +33,7 @@ import bytes from "@/filters/bytes";
|
||||||
import number from "@/filters/number";
|
import number from "@/filters/number";
|
||||||
import MkModal from "@/components/MkModal.vue";
|
import MkModal from "@/components/MkModal.vue";
|
||||||
|
|
||||||
const props = withDefaults(
|
withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
image: entities.DriveFile;
|
image: entities.DriveFile;
|
||||||
}>(),
|
}>(),
|
||||||
|
@ -41,10 +41,10 @@ const props = withDefaults(
|
||||||
);
|
);
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(ev: "closed"): void;
|
closed: [];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const modal = ref<InstanceType<typeof MkModal>>();
|
const modal = ref<InstanceType<typeof MkModal> | null>(null);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -4,20 +4,20 @@
|
||||||
ref="canvas"
|
ref="canvas"
|
||||||
:width="size"
|
:width="size"
|
||||||
:height="size"
|
:height="size"
|
||||||
:title="title"
|
:title="title || undefined"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
v-if="src"
|
v-if="src"
|
||||||
:src="src"
|
:src="src"
|
||||||
:title="title"
|
:title="title || undefined"
|
||||||
:type="type"
|
:type="type"
|
||||||
:alt="alt"
|
:alt="alt || undefined"
|
||||||
:class="{
|
:class="{
|
||||||
cover,
|
cover,
|
||||||
wide: largestDimension === 'width',
|
wide: largestDimension === 'width',
|
||||||
tall: largestDimension === 'height',
|
tall: largestDimension === 'height',
|
||||||
}"
|
}"
|
||||||
:style="{ 'object-fit': cover ? 'cover' : null }"
|
:style="{ 'object-fit': cover ? 'cover' : undefined }"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
@load="onLoad"
|
@load="onLoad"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -23,17 +23,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from "vue";
|
|
||||||
|
|
||||||
import type { entities } from "firefish-js";
|
import type { entities } from "firefish-js";
|
||||||
import * as os from "@/os";
|
|
||||||
import { getProxiedImageUrlNullable } from "@/scripts/media-proxy";
|
import { getProxiedImageUrlNullable } from "@/scripts/media-proxy";
|
||||||
|
|
||||||
const props = defineProps<{
|
defineProps<{
|
||||||
instance: entities.Instance;
|
instance: entities.Instance;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
function getInstanceIcon(instance): string {
|
function getInstanceIcon(instance: entities.Instance): string {
|
||||||
return (
|
return (
|
||||||
getProxiedImageUrlNullable(instance.faviconUrl, "preview") ??
|
getProxiedImageUrlNullable(instance.faviconUrl, "preview") ??
|
||||||
getProxiedImageUrlNullable(instance.iconUrl, "preview") ??
|
getProxiedImageUrlNullable(instance.iconUrl, "preview") ??
|
||||||
|
|
|
@ -65,14 +65,14 @@ import * as os from "@/os";
|
||||||
import { i18n } from "@/i18n";
|
import { i18n } from "@/i18n";
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(ev: "ok", selected: entities.Instance): void;
|
ok: [selected: entities.Instance];
|
||||||
(ev: "cancel"): void;
|
cancel: [];
|
||||||
(ev: "closed"): void;
|
closed: [];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const hostname = ref("");
|
const hostname = ref("");
|
||||||
const instances = ref<entities.Instance[]>([]);
|
const instances = ref<entities.Instance[]>([]);
|
||||||
const selected = ref<entities.Instance | null>();
|
const selected = ref<entities.Instance | null>(null);
|
||||||
const dialogEl = ref<InstanceType<typeof XModalWindow>>();
|
const dialogEl = ref<InstanceType<typeof XModalWindow>>();
|
||||||
|
|
||||||
let searchOrderLatch = 0;
|
let searchOrderLatch = 0;
|
||||||
|
|
|
@ -52,6 +52,7 @@ import { i18n } from "@/i18n";
|
||||||
import MkActiveUsersHeatmap from "@/components/MkActiveUsersHeatmap.vue";
|
import MkActiveUsersHeatmap from "@/components/MkActiveUsersHeatmap.vue";
|
||||||
import MkFolder from "@/components/MkFolder.vue";
|
import MkFolder from "@/components/MkFolder.vue";
|
||||||
import { initChart } from "@/scripts/init-chart";
|
import { initChart } from "@/scripts/init-chart";
|
||||||
|
import type { entities } from "firefish-js";
|
||||||
|
|
||||||
initChart();
|
initChart();
|
||||||
|
|
||||||
|
@ -67,7 +68,18 @@ const { handler: externalTooltipHandler2 } = useChartTooltip({
|
||||||
position: "middle",
|
position: "middle",
|
||||||
});
|
});
|
||||||
|
|
||||||
function createDoughnut(chartEl, tooltip, data) {
|
interface ColorData {
|
||||||
|
name: string;
|
||||||
|
color: string | undefined;
|
||||||
|
value: number;
|
||||||
|
onClick?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDoughnut(
|
||||||
|
chartEl: HTMLCanvasElement,
|
||||||
|
tooltip: typeof externalTooltipHandler1,
|
||||||
|
data: ColorData[],
|
||||||
|
) {
|
||||||
const chartInstance = new Chart(chartEl, {
|
const chartInstance = new Chart(chartEl, {
|
||||||
type: "doughnut",
|
type: "doughnut",
|
||||||
data: {
|
data: {
|
||||||
|
@ -96,13 +108,13 @@ function createDoughnut(chartEl, tooltip, data) {
|
||||||
},
|
},
|
||||||
onClick: (ev) => {
|
onClick: (ev) => {
|
||||||
const hit = chartInstance.getElementsAtEventForMode(
|
const hit = chartInstance.getElementsAtEventForMode(
|
||||||
ev,
|
ev as unknown as Event,
|
||||||
"nearest",
|
"nearest",
|
||||||
{ intersect: true },
|
{ intersect: true },
|
||||||
false,
|
false,
|
||||||
)[0];
|
)[0];
|
||||||
if (hit && data[hit.index].onClick) {
|
if (hit) {
|
||||||
data[hit.index].onClick();
|
data[hit.index].onClick?.();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugins: {
|
plugins: {
|
||||||
|
@ -124,21 +136,23 @@ function createDoughnut(chartEl, tooltip, data) {
|
||||||
return chartInstance;
|
return chartInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
function instance2ColorData(x: entities.Instance): ColorData {
|
||||||
os.apiGet("federation/stats", { limit: 30 }).then((fedStats) => {
|
return {
|
||||||
createDoughnut(
|
|
||||||
subDoughnutEl.value,
|
|
||||||
externalTooltipHandler1,
|
|
||||||
fedStats.topSubInstances
|
|
||||||
.map((x) => ({
|
|
||||||
name: x.host,
|
name: x.host,
|
||||||
color: x.themeColor,
|
color: x.themeColor || undefined,
|
||||||
value: x.followersCount,
|
value: x.followersCount,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
os.pageWindow(`/instance-info/${x.host}`);
|
os.pageWindow(`/instance-info/${x.host}`);
|
||||||
},
|
},
|
||||||
}))
|
};
|
||||||
.concat([
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
os.apiGet("federation/stats", { limit: 30 }).then((fedStats) => {
|
||||||
|
createDoughnut(
|
||||||
|
subDoughnutEl.value!,
|
||||||
|
externalTooltipHandler1,
|
||||||
|
fedStats.topSubInstances.map(instance2ColorData).concat([
|
||||||
{
|
{
|
||||||
name: "(other)",
|
name: "(other)",
|
||||||
color: "#80808080",
|
color: "#80808080",
|
||||||
|
@ -148,18 +162,9 @@ onMounted(() => {
|
||||||
);
|
);
|
||||||
|
|
||||||
createDoughnut(
|
createDoughnut(
|
||||||
pubDoughnutEl.value,
|
pubDoughnutEl.value!,
|
||||||
externalTooltipHandler2,
|
externalTooltipHandler2,
|
||||||
fedStats.topPubInstances
|
fedStats.topPubInstances.map(instance2ColorData).concat([
|
||||||
.map((x) => ({
|
|
||||||
name: x.host,
|
|
||||||
color: x.themeColor,
|
|
||||||
value: x.followingCount,
|
|
||||||
onClick: () => {
|
|
||||||
os.pageWindow(`/instance-info/${x.host}`);
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
.concat([
|
|
||||||
{
|
{
|
||||||
name: "(other)",
|
name: "(other)",
|
||||||
color: "#80808080",
|
color: "#80808080",
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
:anchor="anchor"
|
:anchor="anchor"
|
||||||
:transparent-bg="true"
|
:transparent-bg="true"
|
||||||
:src="src"
|
:src="src"
|
||||||
@click="modal.close()"
|
@click="modal!.close()"
|
||||||
@closed="emit('closed')"
|
@closed="emit('closed')"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
@ -109,7 +109,7 @@ const items = Object.keys(navbarItemDef)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
modal.value.close();
|
modal.value!.close();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,8 @@ const url = computed(() => {
|
||||||
return char2filePath(char.value);
|
return char2filePath(char.value);
|
||||||
} else {
|
} else {
|
||||||
return defaultStore.state.disableShowingAnimatedImages
|
return defaultStore.state.disableShowingAnimatedImages
|
||||||
? getStaticImageUrl(customEmoji.value.url)
|
? getStaticImageUrl(customEmoji.value!.url)
|
||||||
: customEmoji.value.url;
|
: customEmoji.value!.url;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const alt = computed(() =>
|
const alt = computed(() =>
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
import { onDeactivated, onUnmounted, ref } from "vue";
|
import { onDeactivated, onUnmounted, ref } from "vue";
|
||||||
import * as os from "@/os";
|
import * as os from "@/os";
|
||||||
import MkChartTooltip from "@/components/MkChartTooltip.vue";
|
import MkChartTooltip from "@/components/MkChartTooltip.vue";
|
||||||
|
import type { Color, TooltipOptions } from "chart.js";
|
||||||
|
|
||||||
|
type ToolTipSerie = {
|
||||||
|
backgroundColor: Color;
|
||||||
|
borderColor: Color;
|
||||||
|
text: string;
|
||||||
|
};
|
||||||
|
|
||||||
export function useChartTooltip(
|
export function useChartTooltip(
|
||||||
opts: { position: "top" | "middle" } = { position: "top" },
|
opts: { position: "top" | "middle" } = { position: "top" },
|
||||||
|
@ -8,9 +15,9 @@ export function useChartTooltip(
|
||||||
const tooltipShowing = ref(false);
|
const tooltipShowing = ref(false);
|
||||||
const tooltipX = ref(0);
|
const tooltipX = ref(0);
|
||||||
const tooltipY = ref(0);
|
const tooltipY = ref(0);
|
||||||
const tooltipTitle = ref(null);
|
const tooltipTitle = ref<string | null>(null);
|
||||||
const tooltipSeries = ref(null);
|
const tooltipSeries = ref<ToolTipSerie[] | null>(null);
|
||||||
let disposeTooltipComponent;
|
let disposeTooltipComponent: () => void;
|
||||||
|
|
||||||
os.popup(
|
os.popup(
|
||||||
MkChartTooltip,
|
MkChartTooltip,
|
||||||
|
@ -34,7 +41,7 @@ export function useChartTooltip(
|
||||||
tooltipShowing.value = false;
|
tooltipShowing.value = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
function handler(context) {
|
const handler: TooltipOptions["external"] = (context) => {
|
||||||
if (context.tooltip.opacity === 0) {
|
if (context.tooltip.opacity === 0) {
|
||||||
tooltipShowing.value = false;
|
tooltipShowing.value = false;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -405,6 +405,17 @@ export type Endpoints = {
|
||||||
res: Instance[];
|
res: Instance[];
|
||||||
};
|
};
|
||||||
"federation/show-instance": { req: { host: string }; res: Instance };
|
"federation/show-instance": { req: { host: string }; res: Instance };
|
||||||
|
"federation/stats": {
|
||||||
|
req: {
|
||||||
|
limit?: number;
|
||||||
|
};
|
||||||
|
res: {
|
||||||
|
topSubInstances: Instance[];
|
||||||
|
otherFollowersCount: number;
|
||||||
|
topPubInstances: Instance[];
|
||||||
|
otherFollowingCount: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
"federation/update-remote-user": { req: { userId: User["id"] }; res: null };
|
"federation/update-remote-user": { req: { userId: User["id"] }; res: null };
|
||||||
"federation/users": {
|
"federation/users": {
|
||||||
req: {
|
req: {
|
||||||
|
|
|
@ -539,6 +539,8 @@ export type Instance = {
|
||||||
lastCommunicatedAt: DateString;
|
lastCommunicatedAt: DateString;
|
||||||
isNotResponding: boolean;
|
isNotResponding: boolean;
|
||||||
isSuspended: boolean;
|
isSuspended: boolean;
|
||||||
|
isBlocked: boolean;
|
||||||
|
isSilenced: boolean;
|
||||||
softwareName: string | null;
|
softwareName: string | null;
|
||||||
softwareVersion: string | null;
|
softwareVersion: string | null;
|
||||||
openRegistrations: boolean | null;
|
openRegistrations: boolean | null;
|
||||||
|
|
Loading…
Reference in a new issue