2020-10-17 05:12:00 -06:00
|
|
|
<template>
|
2022-06-20 02:38:49 -06:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
|
|
|
<MkSpacer :content-max="900" :margin-min="20" :margin-max="32">
|
|
|
|
<div ref="el" class="vvcocwet" :class="{ wide: !narrow }">
|
|
|
|
<div class="body">
|
|
|
|
<div v-if="!narrow || initialPage == null" class="nav">
|
|
|
|
<div class="baaadecd">
|
|
|
|
<MkInfo v-if="emailNotConfigured" warn class="info">{{ $ts.emailNotConfiguredWarning }} <MkA to="/settings/email" class="_link">{{ $ts.configure }}</MkA></MkInfo>
|
|
|
|
<MkSuperMenu :def="menuDef" :grid="initialPage == null"></MkSuperMenu>
|
|
|
|
</div>
|
2021-12-09 19:56:23 -07:00
|
|
|
</div>
|
2022-06-20 02:38:49 -06:00
|
|
|
<div v-if="!(narrow && initialPage == null)" class="main">
|
|
|
|
<div class="bkzroven">
|
|
|
|
<component :is="component" :key="initialPage" v-bind="pageProps"/>
|
|
|
|
</div>
|
2021-12-09 19:56:23 -07:00
|
|
|
</div>
|
2021-11-28 04:07:37 -07:00
|
|
|
</div>
|
2021-12-09 19:56:23 -07:00
|
|
|
</div>
|
2022-06-20 02:38:49 -06:00
|
|
|
</MkSpacer>
|
|
|
|
</mkstickycontainer>
|
2020-10-17 05:12:00 -06:00
|
|
|
</template>
|
|
|
|
|
2022-03-06 03:17:43 -07:00
|
|
|
<script setup lang="ts">
|
2022-06-20 02:38:49 -06:00
|
|
|
import { computed, defineAsyncComponent, inject, nextTick, onMounted, onUnmounted, provide, ref, watch } from 'vue';
|
2021-11-11 10:02:25 -07:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import MkInfo from '@/components/ui/info.vue';
|
|
|
|
import MkSuperMenu from '@/components/ui/super-menu.vue';
|
|
|
|
import { scroll } from '@/scripts/scroll';
|
2022-06-20 02:38:49 -06:00
|
|
|
import { signout , $i } from '@/account';
|
2021-11-11 10:02:25 -07:00
|
|
|
import { unisonReload } from '@/scripts/unison-reload';
|
|
|
|
import { instance } from '@/instance';
|
2022-06-20 02:38:49 -06:00
|
|
|
import { useRouter } from '@/router';
|
|
|
|
import { definePageMetadata, provideMetadataReceiver, setPageMetadata } from '@/scripts/page-metadata';
|
2020-10-17 05:12:00 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
initialPage?: string;
|
|
|
|
}>(), {
|
|
|
|
});
|
2020-11-25 05:31:34 -07:00
|
|
|
|
2022-03-06 03:17:43 -07:00
|
|
|
const indexInfo = {
|
|
|
|
title: i18n.ts.settings,
|
|
|
|
icon: 'fas fa-cog',
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
hideHeader: true,
|
|
|
|
};
|
|
|
|
const INFO = ref(indexInfo);
|
|
|
|
const el = ref<HTMLElement | null>(null);
|
|
|
|
const childInfo = ref(null);
|
2022-04-23 04:17:15 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
const router = useRouter();
|
2022-04-23 04:17:15 -06:00
|
|
|
|
|
|
|
const narrow = ref(false);
|
|
|
|
const NARROW_THRESHOLD = 600;
|
|
|
|
|
|
|
|
const ro = new ResizeObserver((entries, observer) => {
|
|
|
|
if (entries.length === 0) return;
|
|
|
|
narrow.value = entries[0].borderBoxSize[0].inlineSize < NARROW_THRESHOLD;
|
|
|
|
});
|
|
|
|
|
2022-03-06 03:17:43 -07:00
|
|
|
const menuDef = computed(() => [{
|
|
|
|
title: i18n.ts.basicSettings,
|
|
|
|
items: [{
|
|
|
|
icon: 'fas fa-user',
|
|
|
|
text: i18n.ts.profile,
|
|
|
|
to: '/settings/profile',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'profile',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-lock-open',
|
|
|
|
text: i18n.ts.privacy,
|
|
|
|
to: '/settings/privacy',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'privacy',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-laugh',
|
|
|
|
text: i18n.ts.reaction,
|
|
|
|
to: '/settings/reaction',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'reaction',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-cloud',
|
|
|
|
text: i18n.ts.drive,
|
|
|
|
to: '/settings/drive',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'drive',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-bell',
|
|
|
|
text: i18n.ts.notifications,
|
|
|
|
to: '/settings/notifications',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'notifications',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-envelope',
|
|
|
|
text: i18n.ts.email,
|
|
|
|
to: '/settings/email',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'email',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-share-alt',
|
|
|
|
text: i18n.ts.integration,
|
|
|
|
to: '/settings/integration',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'integration',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-lock',
|
|
|
|
text: i18n.ts.security,
|
|
|
|
to: '/settings/security',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'security',
|
2022-03-06 03:17:43 -07:00
|
|
|
}],
|
|
|
|
}, {
|
|
|
|
title: i18n.ts.clientSettings,
|
|
|
|
items: [{
|
|
|
|
icon: 'fas fa-cogs',
|
|
|
|
text: i18n.ts.general,
|
|
|
|
to: '/settings/general',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'general',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-palette',
|
|
|
|
text: i18n.ts.theme,
|
|
|
|
to: '/settings/theme',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'theme',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-list-ul',
|
|
|
|
text: i18n.ts.menu,
|
|
|
|
to: '/settings/menu',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'menu',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-music',
|
|
|
|
text: i18n.ts.sounds,
|
|
|
|
to: '/settings/sounds',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'sounds',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-plug',
|
|
|
|
text: i18n.ts.plugins,
|
|
|
|
to: '/settings/plugin',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'plugin',
|
2022-03-06 03:17:43 -07:00
|
|
|
}],
|
|
|
|
}, {
|
|
|
|
title: i18n.ts.otherSettings,
|
|
|
|
items: [{
|
|
|
|
icon: 'fas fa-boxes',
|
|
|
|
text: i18n.ts.importAndExport,
|
|
|
|
to: '/settings/import-export',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'import-export',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-volume-mute',
|
|
|
|
text: i18n.ts.instanceMute,
|
|
|
|
to: '/settings/instance-mute',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'instance-mute',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-ban',
|
|
|
|
text: i18n.ts.muteAndBlock,
|
|
|
|
to: '/settings/mute-block',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'mute-block',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-comment-slash',
|
|
|
|
text: i18n.ts.wordMute,
|
|
|
|
to: '/settings/word-mute',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'word-mute',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-key',
|
|
|
|
text: 'API',
|
|
|
|
to: '/settings/api',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'api',
|
2022-04-02 00:28:49 -06:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-bolt',
|
|
|
|
text: 'Webhook',
|
|
|
|
to: '/settings/webhook',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'webhook',
|
2022-03-06 03:17:43 -07:00
|
|
|
}, {
|
|
|
|
icon: 'fas fa-ellipsis-h',
|
|
|
|
text: i18n.ts.other,
|
|
|
|
to: '/settings/other',
|
2022-04-23 04:17:15 -06:00
|
|
|
active: props.initialPage === 'other',
|
2022-03-06 03:17:43 -07:00
|
|
|
}],
|
|
|
|
}, {
|
|
|
|
items: [{
|
|
|
|
type: 'button',
|
|
|
|
icon: 'fas fa-trash',
|
|
|
|
text: i18n.ts.clearCache,
|
|
|
|
action: () => {
|
|
|
|
localStorage.removeItem('locale');
|
|
|
|
localStorage.removeItem('theme');
|
|
|
|
unisonReload();
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
type: 'button',
|
|
|
|
icon: 'fas fa-sign-in-alt fa-flip-horizontal',
|
|
|
|
text: i18n.ts.logout,
|
|
|
|
action: () => {
|
|
|
|
signout();
|
|
|
|
},
|
|
|
|
danger: true,
|
2022-06-20 02:38:49 -06:00
|
|
|
}],
|
2022-03-06 03:17:43 -07:00
|
|
|
}]);
|
2021-10-08 21:33:08 -06:00
|
|
|
|
2022-03-06 03:17:43 -07:00
|
|
|
const pageProps = ref({});
|
|
|
|
const component = computed(() => {
|
2022-04-23 04:17:15 -06:00
|
|
|
if (props.initialPage == null) return null;
|
|
|
|
switch (props.initialPage) {
|
2022-03-06 03:17:43 -07:00
|
|
|
case 'accounts': return defineAsyncComponent(() => import('./accounts.vue'));
|
|
|
|
case 'profile': return defineAsyncComponent(() => import('./profile.vue'));
|
|
|
|
case 'privacy': return defineAsyncComponent(() => import('./privacy.vue'));
|
|
|
|
case 'reaction': return defineAsyncComponent(() => import('./reaction.vue'));
|
|
|
|
case 'drive': return defineAsyncComponent(() => import('./drive.vue'));
|
|
|
|
case 'notifications': return defineAsyncComponent(() => import('./notifications.vue'));
|
|
|
|
case 'mute-block': return defineAsyncComponent(() => import('./mute-block.vue'));
|
|
|
|
case 'word-mute': return defineAsyncComponent(() => import('./word-mute.vue'));
|
|
|
|
case 'instance-mute': return defineAsyncComponent(() => import('./instance-mute.vue'));
|
|
|
|
case 'integration': return defineAsyncComponent(() => import('./integration.vue'));
|
|
|
|
case 'security': return defineAsyncComponent(() => import('./security.vue'));
|
|
|
|
case '2fa': return defineAsyncComponent(() => import('./2fa.vue'));
|
|
|
|
case 'api': return defineAsyncComponent(() => import('./api.vue'));
|
2022-04-02 00:28:49 -06:00
|
|
|
case 'webhook': return defineAsyncComponent(() => import('./webhook.vue'));
|
|
|
|
case 'webhook/new': return defineAsyncComponent(() => import('./webhook.new.vue'));
|
|
|
|
case 'webhook/edit': return defineAsyncComponent(() => import('./webhook.edit.vue'));
|
2022-03-06 03:17:43 -07:00
|
|
|
case 'apps': return defineAsyncComponent(() => import('./apps.vue'));
|
|
|
|
case 'other': return defineAsyncComponent(() => import('./other.vue'));
|
|
|
|
case 'general': return defineAsyncComponent(() => import('./general.vue'));
|
|
|
|
case 'email': return defineAsyncComponent(() => import('./email.vue'));
|
|
|
|
case 'theme': return defineAsyncComponent(() => import('./theme.vue'));
|
|
|
|
case 'theme/install': return defineAsyncComponent(() => import('./theme.install.vue'));
|
|
|
|
case 'theme/manage': return defineAsyncComponent(() => import('./theme.manage.vue'));
|
|
|
|
case 'menu': return defineAsyncComponent(() => import('./menu.vue'));
|
|
|
|
case 'sounds': return defineAsyncComponent(() => import('./sounds.vue'));
|
|
|
|
case 'custom-css': return defineAsyncComponent(() => import('./custom-css.vue'));
|
|
|
|
case 'deck': return defineAsyncComponent(() => import('./deck.vue'));
|
|
|
|
case 'plugin': return defineAsyncComponent(() => import('./plugin.vue'));
|
|
|
|
case 'plugin/install': return defineAsyncComponent(() => import('./plugin.install.vue'));
|
|
|
|
case 'import-export': return defineAsyncComponent(() => import('./import-export.vue'));
|
|
|
|
case 'account-info': return defineAsyncComponent(() => import('./account-info.vue'));
|
|
|
|
case 'delete-account': return defineAsyncComponent(() => import('./delete-account.vue'));
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
});
|
2020-10-17 05:12:00 -06:00
|
|
|
|
2022-03-06 03:17:43 -07:00
|
|
|
watch(component, () => {
|
|
|
|
pageProps.value = {};
|
2021-01-11 04:38:34 -07:00
|
|
|
|
2022-03-06 03:17:43 -07:00
|
|
|
nextTick(() => {
|
|
|
|
scroll(el.value, { top: 0 });
|
|
|
|
});
|
|
|
|
}, { immediate: true });
|
2020-11-25 05:31:34 -07:00
|
|
|
|
2022-03-06 03:17:43 -07:00
|
|
|
watch(() => props.initialPage, () => {
|
|
|
|
if (props.initialPage == null && !narrow.value) {
|
2022-06-20 02:38:49 -06:00
|
|
|
router.push('/settings/profile');
|
2022-03-06 03:17:43 -07:00
|
|
|
} else {
|
|
|
|
if (props.initialPage == null) {
|
|
|
|
INFO.value = indexInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2021-04-11 06:09:35 -06:00
|
|
|
|
2022-04-23 04:17:15 -06:00
|
|
|
watch(narrow, () => {
|
|
|
|
if (props.initialPage == null && !narrow.value) {
|
2022-06-20 02:38:49 -06:00
|
|
|
router.push('/settings/profile');
|
2022-04-23 04:17:15 -06:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-03-06 03:17:43 -07:00
|
|
|
onMounted(() => {
|
2022-04-23 04:17:15 -06:00
|
|
|
ro.observe(el.value);
|
|
|
|
|
|
|
|
narrow.value = el.value.offsetWidth < NARROW_THRESHOLD;
|
|
|
|
if (props.initialPage == null && !narrow.value) {
|
2022-06-20 02:38:49 -06:00
|
|
|
router.push('/settings/profile');
|
2022-03-06 03:17:43 -07:00
|
|
|
}
|
|
|
|
});
|
2020-10-17 05:12:00 -06:00
|
|
|
|
2022-04-23 04:17:15 -06:00
|
|
|
onUnmounted(() => {
|
|
|
|
ro.disconnect();
|
|
|
|
});
|
|
|
|
|
2022-03-06 03:17:43 -07:00
|
|
|
const emailNotConfigured = computed(() => instance.enableEmail && ($i.email == null || !$i.emailVerified));
|
2021-05-04 02:09:57 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
provideMetadataReceiver((info) => {
|
|
|
|
if (info == null) {
|
2022-04-23 04:17:15 -06:00
|
|
|
childInfo.value = null;
|
|
|
|
} else {
|
2022-06-20 02:38:49 -06:00
|
|
|
childInfo.value = info;
|
2022-04-23 04:17:15 -06:00
|
|
|
}
|
2020-10-17 05:12:00 -06:00
|
|
|
});
|
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
const headerActions = $computed(() => []);
|
2021-10-02 08:11:21 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
const headerTabs = $computed(() => []);
|
2021-10-01 09:51:37 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
definePageMetadata(INFO);
|
|
|
|
</script>
|
2021-11-28 04:07:37 -07:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.vvcocwet {
|
2021-12-09 19:56:23 -07:00
|
|
|
> .body {
|
2020-10-17 05:12:00 -06:00
|
|
|
> .nav {
|
2021-10-24 05:16:55 -06:00
|
|
|
.baaadecd {
|
2021-12-09 19:56:23 -07:00
|
|
|
> .info {
|
|
|
|
margin: 16px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .accounts {
|
|
|
|
> .avatar {
|
|
|
|
display: block;
|
|
|
|
width: 50px;
|
|
|
|
height: 50px;
|
|
|
|
margin: 8px auto 16px auto;
|
|
|
|
}
|
2021-10-24 05:16:55 -06:00
|
|
|
}
|
2021-10-16 00:00:55 -06:00
|
|
|
}
|
2020-10-17 05:12:00 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
> .main {
|
2021-11-28 04:07:37 -07:00
|
|
|
.bkzroven {
|
2021-12-09 19:56:23 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.wide {
|
|
|
|
> .body {
|
|
|
|
display: flex;
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
> .nav {
|
|
|
|
width: 34%;
|
|
|
|
padding-right: 32px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .main {
|
|
|
|
flex: 1;
|
|
|
|
min-width: 0;
|
|
|
|
overflow: auto;
|
2021-11-28 04:07:37 -07:00
|
|
|
}
|
2020-10-17 05:12:00 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|