enhance(frontend): deckをpreferences管理に
This commit is contained in:
@@ -36,7 +36,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</div>
|
||||
<div :class="$style.sideMenu">
|
||||
<div :class="$style.sideMenuTop">
|
||||
<button v-tooltip.noDelay.left="`${i18n.ts._deck.profile}: ${store.s['deck.profile']}`" :class="$style.sideMenuButton" class="_button" @click="changeProfile"><i class="ti ti-caret-down"></i></button>
|
||||
<button v-tooltip.noDelay.left="`${i18n.ts._deck.profile}: ${prefer.s['deck.profile']}`" :class="$style.sideMenuButton" class="_button" @click="switchProfileMenu"><i class="ti ti-caret-down"></i></button>
|
||||
<button v-tooltip.noDelay.left="i18n.ts._deck.deleteProfile" :class="$style.sideMenuButton" class="_button" @click="deleteProfile"><i class="ti ti-trash"></i></button>
|
||||
</div>
|
||||
<div :class="$style.sideMenuMiddle">
|
||||
@@ -95,7 +95,6 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
import { computed, defineAsyncComponent, ref, watch, shallowRef } from 'vue';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import XCommon from './_common_/common.vue';
|
||||
import type { MenuItem } from '@/types/menu.js';
|
||||
import XSidebar from '@/ui/_common_/navbar.vue';
|
||||
import XDrawerMenu from '@/ui/_common_/navbar-for-mobile.vue';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
@@ -103,7 +102,6 @@ import * as os from '@/os.js';
|
||||
import { navbarItemDef } from '@/navbar.js';
|
||||
import { $i } from '@/account.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { unisonReload } from '@/utility/unison-reload.js';
|
||||
import { deviceKind } from '@/utility/device-kind.js';
|
||||
import { prefer } from '@/preferences.js';
|
||||
import XMainColumn from '@/ui/deck/main-column.vue';
|
||||
@@ -117,8 +115,7 @@ import XMentionsColumn from '@/ui/deck/mentions-column.vue';
|
||||
import XDirectColumn from '@/ui/deck/direct-column.vue';
|
||||
import XRoleTimelineColumn from '@/ui/deck/role-timeline-column.vue';
|
||||
import { mainRouter } from '@/router/main.js';
|
||||
import { store } from '@/store.js';
|
||||
import { columnTypes, forceSaveDeck, getProfiles, loadDeck, addColumn as addColumnToStore, deleteProfile as deleteProfile_ } from '@/deck.js';
|
||||
import { columns, layout, columnTypes, switchProfileMenu, addColumn as addColumnToStore, deleteProfile as deleteProfile_ } from '@/deck.js';
|
||||
const XStatusBars = defineAsyncComponent(() => import('@/ui/_common_/statusbars.vue'));
|
||||
const XAnnouncements = defineAsyncComponent(() => import('@/ui/_common_/announcements.vue'));
|
||||
|
||||
@@ -137,7 +134,7 @@ const columnComponents = {
|
||||
|
||||
mainRouter.navHook = (path, flag): boolean => {
|
||||
if (flag === 'forcePage') return false;
|
||||
const noMainColumn = !store.s['deck.columns'].some(x => x.type === 'main');
|
||||
const noMainColumn = !columns.value.some(x => x.type === 'main');
|
||||
if (prefer.s['deck.navWindow'] || noMainColumn) {
|
||||
os.pageWindow(path);
|
||||
return true;
|
||||
@@ -160,8 +157,6 @@ watch(route, () => {
|
||||
});
|
||||
*/
|
||||
|
||||
const columns = store.r['deck.columns'];
|
||||
const layout = store.r['deck.layout'];
|
||||
const menuIndicated = computed(() => {
|
||||
if ($i == null) return false;
|
||||
for (const def in navbarItemDef) {
|
||||
@@ -210,65 +205,20 @@ function onWheel(ev: WheelEvent) {
|
||||
document.documentElement.style.overflowY = 'hidden';
|
||||
document.documentElement.style.scrollBehavior = 'auto';
|
||||
|
||||
loadDeck();
|
||||
|
||||
function changeProfile(ev: MouseEvent) {
|
||||
let items: MenuItem[] = [{
|
||||
text: store.s['deck.profile'],
|
||||
active: true,
|
||||
action: () => {},
|
||||
}];
|
||||
getProfiles().then(profiles => {
|
||||
items.push(...(profiles.filter(k => k !== store.s['deck.profile']).map(k => ({
|
||||
text: k,
|
||||
action: () => {
|
||||
store.set('deck.profile', k);
|
||||
unisonReload();
|
||||
},
|
||||
}))), { type: 'divider' as const }, {
|
||||
text: i18n.ts._deck.newProfile,
|
||||
icon: 'ti ti-plus',
|
||||
action: async () => {
|
||||
const { canceled, result: name } = await os.inputText({
|
||||
title: i18n.ts._deck.profile,
|
||||
minLength: 1,
|
||||
});
|
||||
|
||||
if (canceled || name == null) return;
|
||||
|
||||
os.promiseDialog((async () => {
|
||||
await store.set('deck.profile', name);
|
||||
await forceSaveDeck();
|
||||
})(), () => {
|
||||
unisonReload();
|
||||
});
|
||||
},
|
||||
});
|
||||
}).then(() => {
|
||||
os.popupMenu(items, ev.currentTarget ?? ev.target);
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteProfile() {
|
||||
if (prefer.s['deck.profile'] == null) return;
|
||||
|
||||
const { canceled } = await os.confirm({
|
||||
type: 'warning',
|
||||
text: i18n.tsx.deleteAreYouSure({ x: store.s['deck.profile'] }),
|
||||
text: i18n.tsx.deleteAreYouSure({ x: prefer.s['deck.profile'] }),
|
||||
});
|
||||
if (canceled) return;
|
||||
|
||||
os.promiseDialog((async () => {
|
||||
if (store.s['deck.profile'] === 'default') {
|
||||
await store.set('deck.columns', []);
|
||||
await store.set('deck.layout', []);
|
||||
await forceSaveDeck();
|
||||
} else {
|
||||
await deleteProfile_(store.s['deck.profile']);
|
||||
}
|
||||
await store.set('deck.profile', 'default');
|
||||
})(), () => {
|
||||
unisonReload();
|
||||
});
|
||||
await deleteProfile_(prefer.s['deck.profile']);
|
||||
|
||||
os.success();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
@@ -100,7 +100,7 @@ function onOtherDragEnd() {
|
||||
function toggleActive() {
|
||||
if (!props.isStacked) return;
|
||||
updateColumn(props.column.id, {
|
||||
active: !props.column.active,
|
||||
active: props.column.active == null ? false : !props.column.active,
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user