refactor(frontend): 非推奨となったReactivity Transformを使わないように (#12539)
* refactor(frontend): 非推奨となったReactivity Transformを使わないように * refactor: 不要な括弧を除去 * fix: 不要なアノテーションを除去 * fix: Refの配列をrefしている部分の対応 * refactor: 不要な括弧を除去 * fix: lint * refactor: Ref、ShallowRef、ComputedRefの変数の宣言をletからconstに置換 * fix: type error * chore: drop reactivity transform from eslint configuration * refactor: remove unnecessary import * fix: 対応漏れ
This commit is contained in:
@@ -28,7 +28,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onActivated, onMounted, onUnmounted, provide, watch } from 'vue';
|
||||
import { onActivated, onMounted, onUnmounted, provide, watch, ref, computed } from 'vue';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import MkSuperMenu from '@/components/MkSuperMenu.vue';
|
||||
import MkInfo from '@/components/MkInfo.vue';
|
||||
@@ -50,32 +50,32 @@ const indexInfo = {
|
||||
|
||||
provide('shouldOmitHeaderTitle', false);
|
||||
|
||||
let INFO = $ref(indexInfo);
|
||||
let childInfo = $ref(null);
|
||||
let narrow = $ref(false);
|
||||
let view = $ref(null);
|
||||
let el = $ref(null);
|
||||
let pageProps = $ref({});
|
||||
const INFO = ref(indexInfo);
|
||||
const childInfo = ref(null);
|
||||
const narrow = ref(false);
|
||||
const view = ref(null);
|
||||
const el = ref(null);
|
||||
const pageProps = ref({});
|
||||
let noMaintainerInformation = isEmpty(instance.maintainerName) || isEmpty(instance.maintainerEmail);
|
||||
let noBotProtection = !instance.disableRegistration && !instance.enableHcaptcha && !instance.enableRecaptcha && !instance.enableTurnstile;
|
||||
let noEmailServer = !instance.enableEmail;
|
||||
let thereIsUnresolvedAbuseReport = $ref(false);
|
||||
let currentPage = $computed(() => router.currentRef.value.child);
|
||||
const thereIsUnresolvedAbuseReport = ref(false);
|
||||
const currentPage = computed(() => router.currentRef.value.child);
|
||||
|
||||
os.api('admin/abuse-user-reports', {
|
||||
state: 'unresolved',
|
||||
limit: 1,
|
||||
}).then(reports => {
|
||||
if (reports.length > 0) thereIsUnresolvedAbuseReport = true;
|
||||
if (reports.length > 0) thereIsUnresolvedAbuseReport.value = true;
|
||||
});
|
||||
|
||||
const NARROW_THRESHOLD = 600;
|
||||
const ro = new ResizeObserver((entries, observer) => {
|
||||
if (entries.length === 0) return;
|
||||
narrow = entries[0].borderBoxSize[0].inlineSize < NARROW_THRESHOLD;
|
||||
narrow.value = entries[0].borderBoxSize[0].inlineSize < NARROW_THRESHOLD;
|
||||
});
|
||||
|
||||
const menuDef = $computed(() => [{
|
||||
const menuDef = computed(() => [{
|
||||
title: i18n.ts.quickAction,
|
||||
items: [{
|
||||
type: 'button',
|
||||
@@ -94,67 +94,67 @@ const menuDef = $computed(() => [{
|
||||
icon: 'ti ti-dashboard',
|
||||
text: i18n.ts.dashboard,
|
||||
to: '/admin/overview',
|
||||
active: currentPage?.route.name === 'overview',
|
||||
active: currentPage.value?.route.name === 'overview',
|
||||
}, {
|
||||
icon: 'ti ti-users',
|
||||
text: i18n.ts.users,
|
||||
to: '/admin/users',
|
||||
active: currentPage?.route.name === 'users',
|
||||
active: currentPage.value?.route.name === 'users',
|
||||
}, {
|
||||
icon: 'ti ti-user-plus',
|
||||
text: i18n.ts.invite,
|
||||
to: '/admin/invites',
|
||||
active: currentPage?.route.name === 'invites',
|
||||
active: currentPage.value?.route.name === 'invites',
|
||||
}, {
|
||||
icon: 'ti ti-badges',
|
||||
text: i18n.ts.roles,
|
||||
to: '/admin/roles',
|
||||
active: currentPage?.route.name === 'roles',
|
||||
active: currentPage.value?.route.name === 'roles',
|
||||
}, {
|
||||
icon: 'ti ti-icons',
|
||||
text: i18n.ts.customEmojis,
|
||||
to: '/admin/emojis',
|
||||
active: currentPage?.route.name === 'emojis',
|
||||
active: currentPage.value?.route.name === 'emojis',
|
||||
}, {
|
||||
icon: 'ti ti-sparkles',
|
||||
text: i18n.ts.avatarDecorations,
|
||||
to: '/admin/avatar-decorations',
|
||||
active: currentPage?.route.name === 'avatarDecorations',
|
||||
active: currentPage.value?.route.name === 'avatarDecorations',
|
||||
}, {
|
||||
icon: 'ti ti-whirl',
|
||||
text: i18n.ts.federation,
|
||||
to: '/admin/federation',
|
||||
active: currentPage?.route.name === 'federation',
|
||||
active: currentPage.value?.route.name === 'federation',
|
||||
}, {
|
||||
icon: 'ti ti-clock-play',
|
||||
text: i18n.ts.jobQueue,
|
||||
to: '/admin/queue',
|
||||
active: currentPage?.route.name === 'queue',
|
||||
active: currentPage.value?.route.name === 'queue',
|
||||
}, {
|
||||
icon: 'ti ti-cloud',
|
||||
text: i18n.ts.files,
|
||||
to: '/admin/files',
|
||||
active: currentPage?.route.name === 'files',
|
||||
active: currentPage.value?.route.name === 'files',
|
||||
}, {
|
||||
icon: 'ti ti-speakerphone',
|
||||
text: i18n.ts.announcements,
|
||||
to: '/admin/announcements',
|
||||
active: currentPage?.route.name === 'announcements',
|
||||
active: currentPage.value?.route.name === 'announcements',
|
||||
}, {
|
||||
icon: 'ti ti-ad',
|
||||
text: i18n.ts.ads,
|
||||
to: '/admin/ads',
|
||||
active: currentPage?.route.name === 'ads',
|
||||
active: currentPage.value?.route.name === 'ads',
|
||||
}, {
|
||||
icon: 'ti ti-exclamation-circle',
|
||||
text: i18n.ts.abuseReports,
|
||||
to: '/admin/abuses',
|
||||
active: currentPage?.route.name === 'abuses',
|
||||
active: currentPage.value?.route.name === 'abuses',
|
||||
}, {
|
||||
icon: 'ti ti-list-search',
|
||||
text: i18n.ts.moderationLogs,
|
||||
to: '/admin/modlog',
|
||||
active: currentPage?.route.name === 'modlog',
|
||||
active: currentPage.value?.route.name === 'modlog',
|
||||
}],
|
||||
}, {
|
||||
title: i18n.ts.settings,
|
||||
@@ -162,57 +162,57 @@ const menuDef = $computed(() => [{
|
||||
icon: 'ti ti-settings',
|
||||
text: i18n.ts.general,
|
||||
to: '/admin/settings',
|
||||
active: currentPage?.route.name === 'settings',
|
||||
active: currentPage.value?.route.name === 'settings',
|
||||
}, {
|
||||
icon: 'ti ti-paint',
|
||||
text: i18n.ts.branding,
|
||||
to: '/admin/branding',
|
||||
active: currentPage?.route.name === 'branding',
|
||||
active: currentPage.value?.route.name === 'branding',
|
||||
}, {
|
||||
icon: 'ti ti-shield',
|
||||
text: i18n.ts.moderation,
|
||||
to: '/admin/moderation',
|
||||
active: currentPage?.route.name === 'moderation',
|
||||
active: currentPage.value?.route.name === 'moderation',
|
||||
}, {
|
||||
icon: 'ti ti-mail',
|
||||
text: i18n.ts.emailServer,
|
||||
to: '/admin/email-settings',
|
||||
active: currentPage?.route.name === 'email-settings',
|
||||
active: currentPage.value?.route.name === 'email-settings',
|
||||
}, {
|
||||
icon: 'ti ti-cloud',
|
||||
text: i18n.ts.objectStorage,
|
||||
to: '/admin/object-storage',
|
||||
active: currentPage?.route.name === 'object-storage',
|
||||
active: currentPage.value?.route.name === 'object-storage',
|
||||
}, {
|
||||
icon: 'ti ti-lock',
|
||||
text: i18n.ts.security,
|
||||
to: '/admin/security',
|
||||
active: currentPage?.route.name === 'security',
|
||||
active: currentPage.value?.route.name === 'security',
|
||||
}, {
|
||||
icon: 'ti ti-planet',
|
||||
text: i18n.ts.relays,
|
||||
to: '/admin/relays',
|
||||
active: currentPage?.route.name === 'relays',
|
||||
active: currentPage.value?.route.name === 'relays',
|
||||
}, {
|
||||
icon: 'ti ti-ban',
|
||||
text: i18n.ts.instanceBlocking,
|
||||
to: '/admin/instance-block',
|
||||
active: currentPage?.route.name === 'instance-block',
|
||||
active: currentPage.value?.route.name === 'instance-block',
|
||||
}, {
|
||||
icon: 'ti ti-ghost',
|
||||
text: i18n.ts.proxyAccount,
|
||||
to: '/admin/proxy-account',
|
||||
active: currentPage?.route.name === 'proxy-account',
|
||||
active: currentPage.value?.route.name === 'proxy-account',
|
||||
}, {
|
||||
icon: 'ti ti-link',
|
||||
text: i18n.ts.externalServices,
|
||||
to: '/admin/external-services',
|
||||
active: currentPage?.route.name === 'external-services',
|
||||
active: currentPage.value?.route.name === 'external-services',
|
||||
}, {
|
||||
icon: 'ti ti-adjustments',
|
||||
text: i18n.ts.other,
|
||||
to: '/admin/other-settings',
|
||||
active: currentPage?.route.name === 'other-settings',
|
||||
active: currentPage.value?.route.name === 'other-settings',
|
||||
}],
|
||||
}, {
|
||||
title: i18n.ts.info,
|
||||
@@ -220,28 +220,28 @@ const menuDef = $computed(() => [{
|
||||
icon: 'ti ti-database',
|
||||
text: i18n.ts.database,
|
||||
to: '/admin/database',
|
||||
active: currentPage?.route.name === 'database',
|
||||
active: currentPage.value?.route.name === 'database',
|
||||
}],
|
||||
}]);
|
||||
|
||||
watch(narrow, () => {
|
||||
if (currentPage?.route.name == null && !narrow) {
|
||||
watch(narrow.value, () => {
|
||||
if (currentPage.value?.route.name == null && !narrow.value) {
|
||||
router.push('/admin/overview');
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
ro.observe(el);
|
||||
ro.observe(el.value);
|
||||
|
||||
narrow = el.offsetWidth < NARROW_THRESHOLD;
|
||||
if (currentPage?.route.name == null && !narrow) {
|
||||
narrow.value = el.value.offsetWidth < NARROW_THRESHOLD;
|
||||
if (currentPage.value?.route.name == null && !narrow.value) {
|
||||
router.push('/admin/overview');
|
||||
}
|
||||
});
|
||||
|
||||
onActivated(() => {
|
||||
narrow = el.offsetWidth < NARROW_THRESHOLD;
|
||||
if (currentPage?.route.name == null && !narrow) {
|
||||
narrow.value = el.value.offsetWidth < NARROW_THRESHOLD;
|
||||
if (currentPage.value?.route.name == null && !narrow.value) {
|
||||
router.push('/admin/overview');
|
||||
}
|
||||
});
|
||||
@@ -251,16 +251,16 @@ onUnmounted(() => {
|
||||
});
|
||||
|
||||
watch(router.currentRef, (to) => {
|
||||
if (to.route.path === '/admin' && to.child?.route.name == null && !narrow) {
|
||||
if (to.route.path === '/admin' && to.child?.route.name == null && !narrow.value) {
|
||||
router.replace('/admin/overview');
|
||||
}
|
||||
});
|
||||
|
||||
provideMetadataReceiver((info) => {
|
||||
if (info == null) {
|
||||
childInfo = null;
|
||||
childInfo.value = null;
|
||||
} else {
|
||||
childInfo = info;
|
||||
childInfo.value = info;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -312,11 +312,11 @@ function lookup(ev: MouseEvent) {
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
}
|
||||
|
||||
const headerActions = $computed(() => []);
|
||||
const headerActions = computed(() => []);
|
||||
|
||||
const headerTabs = $computed(() => []);
|
||||
const headerTabs = computed(() => []);
|
||||
|
||||
definePageMetadata(INFO);
|
||||
definePageMetadata(INFO.value);
|
||||
|
||||
defineExpose({
|
||||
header: {
|
||||
|
Reference in New Issue
Block a user