Improve client

This commit is contained in:
syuilo 2021-04-17 14:06:32 +09:00
parent 995dd74f1b
commit 571bd15bc9
6 changed files with 87 additions and 3 deletions

View File

@ -5,9 +5,9 @@
<MkLoading/> <MkLoading/>
</div> </div>
</div> </div>
<div v-else-if="resolved"> <FormGroup v-else-if="resolved" class="_formItem">
<slot :result="result"></slot> <slot :result="result"></slot>
</div> </FormGroup>
<div class="_formItem" v-else> <div class="_formItem" v-else>
<div class="_formPanel"> <div class="_formPanel">
error! error!
@ -20,8 +20,13 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, PropType, ref, watch } from 'vue'; import { defineComponent, PropType, ref, watch } from 'vue';
import './form.scss'; import './form.scss';
import FormGroup from './group.vue';
export default defineComponent({ export default defineComponent({
components: {
FormGroup,
},
props: { props: {
p: { p: {
type: Function as PropType<() => Promise<any>>, type: Function as PropType<() => Promise<any>>,

View File

@ -14,6 +14,10 @@
</FormKeyValueView> </FormKeyValueView>
</FormGroup> </FormGroup>
<FormTextarea readonly :value="instance.description">
<span>{{ $ts.description }}</span>
</FormTextarea>
<FormGroup> <FormGroup>
<FormKeyValueView> <FormKeyValueView>
<template #key>{{ $ts.software }}</template> <template #key>{{ $ts.software }}</template>
@ -99,6 +103,27 @@
<FormLink :to="`https://${host}/.well-known/host-meta.json`" external>host-meta.json</FormLink> <FormLink :to="`https://${host}/.well-known/host-meta.json`" external>host-meta.json</FormLink>
<FormLink :to="`https://${host}/.well-known/nodeinfo`" external>nodeinfo</FormLink> <FormLink :to="`https://${host}/.well-known/nodeinfo`" external>nodeinfo</FormLink>
</FormGroup> </FormGroup>
<FormSuspense :p="dnsPromiseFactory" v-slot="{ result: dns }">
<FormGroup>
<template #label>DNS</template>
<FormKeyValueView v-for="record in dns.a" :key="record">
<template #key>A</template>
<template #value><span class="_monospace">{{ record }}</span></template>
</FormKeyValueView>
<FormKeyValueView v-for="record in dns.aaaa" :key="record">
<template #key>AAAA</template>
<template #value><span class="_monospace">{{ record }}</span></template>
</FormKeyValueView>
<FormKeyValueView v-for="record in dns.cname" :key="record">
<template #key>CNAME</template>
<template #value><span class="_monospace">{{ record }}</span></template>
</FormKeyValueView>
<FormKeyValueView v-for="record in dns.txt">
<template #key>TXT</template>
<template #value><span class="_monospace">{{ record[0] }}</span></template>
</FormKeyValueView>
</FormGroup>
</FormSuspense>
</FormGroup> </FormGroup>
</FormBase> </FormBase>
</template> </template>
@ -167,6 +192,9 @@ export default defineComponent({
}], }],
}, },
instance: null, instance: null,
dnsPromiseFactory: () => os.api('federation/dns', {
host: this.host
}),
now: null, now: null,
canvas: null, canvas: null,
chart: null, chart: null,

View File

@ -22,7 +22,7 @@
</FormKeyValueView> </FormKeyValueView>
<FormKeyValueView> <FormKeyValueView>
<template #key>Shared Inbox</template> <template #key>Shared Inbox</template>
<template #value><span class="_monospace">{{ ap.sharedInbox }}</span></template> <template #value><span class="_monospace">{{ ap.sharedInbox || ap.endpoints.sharedInbox }}</span></template>
</FormKeyValueView> </FormKeyValueView>
<FormKeyValueView> <FormKeyValueView>
<template #key>Outbox</template> <template #key>Outbox</template>

View File

@ -18,6 +18,13 @@
</FormKeyValueView> </FormKeyValueView>
</FormGroup> </FormGroup>
<FormGroup>
<FormKeyValueView>
<template #key>{{ $ts.updatedAt }}</template>
<template #value><MkTime v-if="user.lastFetchedAt" mode="detail" :time="user.lastFetchedAt"/><span v-else>N/A</span></template>
</FormKeyValueView>
</FormGroup>
<FormObjectView tall :value="user"> <FormObjectView tall :value="user">
<span>Raw</span> <span>Raw</span>
</FormObjectView> </FormObjectView>

View File

@ -198,6 +198,7 @@ export class UserRepository extends Repository<User> {
uri: user.uri, uri: user.uri,
createdAt: user.createdAt.toISOString(), createdAt: user.createdAt.toISOString(),
updatedAt: user.updatedAt ? user.updatedAt.toISOString() : null, updatedAt: user.updatedAt ? user.updatedAt.toISOString() : null,
lastFetchedAt: user.lastFetchedAt?.toISOString(),
bannerUrl: user.bannerUrl, bannerUrl: user.bannerUrl,
bannerBlurhash: user.bannerBlurhash, bannerBlurhash: user.bannerBlurhash,
bannerColor: null, // 後方互換性のため bannerColor: null, // 後方互換性のため

View File

@ -0,0 +1,43 @@
import { promises as dns } from 'dns';
import $ from 'cafy';
import define from '../../define';
import { Instances } from '../../../../models';
import { toPuny } from '@/misc/convert-host';
const resolver = new dns.Resolver();
resolver.setServers(['1.1.1.1']);
export const meta = {
tags: ['federation'],
requireCredential: false as const,
params: {
host: {
validator: $.str
}
},
};
export default define(meta, async (ps, me) => {
const instance = await Instances.findOneOrFail({ host: toPuny(ps.host) });
const [
resolved4,
resolved6,
resolvedCname,
resolvedTxt,
] = await Promise.all([
resolver.resolve4(instance.host).catch(() => []),
resolver.resolve6(instance.host).catch(() => []),
resolver.resolveCname(instance.host).catch(() => []),
resolver.resolveTxt(instance.host).catch(() => []),
]);
return {
a: resolved4,
aaaa: resolved6,
cname: resolvedCname,
txt: resolvedTxt,
};
});