Fix: 命名規則など

This commit is contained in:
mattyatea 2024-06-11 19:19:42 +09:00
parent 1ff2117a05
commit 2697917873
6 changed files with 71 additions and 36 deletions

View file

@ -50,11 +50,11 @@ import { defaultStore } from '@/store.js';
import { unisonReload } from '@/scripts/unison-reload.js'; import { unisonReload } from '@/scripts/unison-reload.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import { timelineHeaderItemDef } from '@/timelineHeader.js'; import { timelineHeaderItemDef } from '@/timeline-header.js';
const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default)); const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default));
const items = ref(defaultStore.state.timelineTopBar.map(x => ({ const items = ref(defaultStore.state.timelineHeader.map(x => ({
id: Math.random().toString(), id: Math.random().toString(),
type: x, type: x,
}))); })));
@ -70,7 +70,7 @@ async function reloadAsk() {
} }
async function addItem() { async function addItem() {
const menu = Object.keys(timelineHeaderItemDef).filter(k => !defaultStore.state.timelineTopBar.includes(k)); const menu = Object.keys(timelineHeaderItemDef).filter(k => !defaultStore.state.timelineHeader.includes(k));
const { canceled, result: item } = await os.select({ const { canceled, result: item } = await os.select({
title: i18n.ts.addItem, title: i18n.ts.addItem,
items: [...menu.map(k => ({ items: [...menu.map(k => ({
@ -89,12 +89,12 @@ function removeItem(index: number) {
} }
async function save() { async function save() {
defaultStore.set('timelineTopBar', items.value.map(x => x.type)); defaultStore.set('timelineHeader', items.value.map(x => x.type));
await reloadAsk(); await reloadAsk();
} }
function reset() { function reset() {
items.value = defaultStore.def.timelineTopBar.default.map(x => ({ items.value = defaultStore.def.timelineHeader.default.map(x => ({
id: Math.random().toString(), id: Math.random().toString(),
type: x, type: x,
})); }));

View file

@ -53,12 +53,11 @@ import { deviceKind } from '@/scripts/device-kind.js';
import { deepMerge } from '@/scripts/merge.js'; import { deepMerge } from '@/scripts/merge.js';
import { MenuItem } from '@/types/menu.js'; import { MenuItem } from '@/types/menu.js';
import { miLocalStorage } from '@/local-storage.js'; import { miLocalStorage } from '@/local-storage.js';
import { timelineHeaderItemDef } from '@/timelineHeader.js'; import { timelineHeaderItemDef } from '@/timeline-header.js';
import { isLocalTimelineAvailable, isGlobalTimelineAvailable } from '@/scripts/get-timeline-available.js';
provide('shouldOmitHeaderTitle', true); provide('shouldOmitHeaderTitle', true);
const isLocalTimelineAvailable = ($i == null && instance.policies.ltlAvailable) || ($i != null && $i.policies.ltlAvailable);
const isGlobalTimelineAvailable = ($i == null && instance.policies.gtlAvailable) || ($i != null && $i.policies.gtlAvailable);
const keymap = { const keymap = {
't': focus, 't': focus,
}; };
@ -278,13 +277,25 @@ const headerActions = computed(() => {
} }
return tmp; return tmp;
}); });
let headerTabs = computed(() => defaultStore.reactiveState.timelineTopBar.value.map(tab => ({ const headerTabs = computed(() => defaultStore.reactiveState.timelineHeader.value.map(tab => {
...(tab !== 'lists' && tab !== 'antennas' && tab !== 'channels' ? { if ((tab === 'local' || tab === 'social') && !isLocalTimelineAvailable) {
return {};
} else if (tab === 'global' && !isGlobalTimelineAvailable) {
return {};
}
const tabDef = timelineHeaderItemDef[tab];
if (!tabDef) {
return {};
}
return {
...(!['channels', 'antennas', 'lists'].includes(tab) ? {
key: tab, key: tab,
} : {}), } : {}),
title: timelineHeaderItemDef[tab].title, title: tabDef.title,
icon: timelineHeaderItemDef[tab].icon, icon: tabDef.icon,
iconOnly: timelineHeaderItemDef[tab].iconOnly, iconOnly: tabDef.iconOnly,
...(tab === 'lists' ? { ...(tab === 'lists' ? {
onClick: (ev) => chooseList(ev), onClick: (ev) => chooseList(ev),
} : {}), } : {}),
@ -294,7 +305,9 @@ let headerTabs = computed(() => defaultStore.reactiveState.timelineTopBar.value.
...(tab === 'channels' ? { ...(tab === 'channels' ? {
onClick: (ev) => chooseChannel(ev), onClick: (ev) => chooseChannel(ev),
} : {}), } : {}),
})) as Tab[]); };
}) as Tab[]);
const headerTabsWhenNotLogin = computed(() => [ const headerTabsWhenNotLogin = computed(() => [
...(isLocalTimelineAvailable ? [{ ...(isLocalTimelineAvailable ? [{
key: 'local', key: 'local',

View file

@ -113,7 +113,7 @@ const routes: RouteDef[] = [{
name: 'navbar', name: 'navbar',
component: page(() => import('@/pages/settings/navbar.vue')), component: page(() => import('@/pages/settings/navbar.vue')),
}, { }, {
path: '/timelineheader', path: '/timeline-header',
name: 'timelineHeader', name: 'timelineHeader',
component: page(() => import('@/pages/settings/timelineHeader.vue')), component: page(() => import('@/pages/settings/timelineHeader.vue')),
}, { }, {

View file

@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { $i } from '@/account.js';
import { instance } from '@/instance.js';
export const isLocalTimelineAvailable = ($i == null && instance.policies.ltlAvailable) || ($i != null && $i.policies.ltlAvailable);
export const isGlobalTimelineAvailable = ($i == null && instance.policies.gtlAvailable) || ($i != null && $i.policies.gtlAvailable);

View file

@ -9,7 +9,7 @@ import { miLocalStorage } from './local-storage.js';
import type { SoundType } from '@/scripts/sound.js'; import type { SoundType } from '@/scripts/sound.js';
import { Storage } from '@/pizzax.js'; import { Storage } from '@/pizzax.js';
import { hemisphere } from '@/scripts/intl-const.js'; import { hemisphere } from '@/scripts/intl-const.js';
import { isLocalTimelineAvailable, isGlobalTimelineAvailable } from '@/scripts/get-timeline-available.js';
interface PostFormAction { interface PostFormAction {
title: string, title: string,
handler: <T>(form: T, update: (key: unknown, value: unknown) => void) => void; handler: <T>(form: T, update: (key: unknown, value: unknown) => void) => void;
@ -52,8 +52,6 @@ export type SoundStore = {
volume: number; volume: number;
} }
export const isLocalTimelineAvailable = ($i == null && instance.policies.ltlAvailable) || ($i != null && $i.policies.ltlAvailable);
export const isGlobalTimelineAvailable = ($i == null && instance.policies.gtlAvailable) || ($i != null && $i.policies.gtlAvailable);
export const postFormActions: PostFormAction[] = []; export const postFormActions: PostFormAction[] = [];
export const userActions: UserAction[] = []; export const userActions: UserAction[] = [];
export const noteActions: NoteAction[] = []; export const noteActions: NoteAction[] = [];
@ -149,7 +147,7 @@ export const defaultStore = markRaw(new Storage('base', {
'ui', 'ui',
], ],
}, },
timelineTopBar: { timelineHeader: {
where: 'deviceAccount', where: 'deviceAccount',
default: [ default: [
'home', 'home',
@ -163,7 +161,7 @@ export const defaultStore = markRaw(new Storage('base', {
'lists', 'lists',
'antennas', 'antennas',
'channels', 'channels',
], ] as TimelineHeaderItem[],
}, },
visibility: { visibility: {
where: 'deviceAccount', where: 'deviceAccount',
@ -539,8 +537,7 @@ interface Watcher {
*/ */
import lightTheme from '@/themes/l-light.json5'; import lightTheme from '@/themes/l-light.json5';
import darkTheme from '@/themes/d-green-lime.json5'; import darkTheme from '@/themes/d-green-lime.json5';
import { $i } from '@/account.js'; import { TimelineHeaderItem } from '@/timeline-header.js';
import { instance } from '@/instance.js';
export class ColdDeviceStorage { export class ColdDeviceStorage {
public static default = { public static default = {

View file

@ -6,13 +6,30 @@
import { reactive } from 'vue'; import { reactive } from 'vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { userListsCache } from '@/cache.js'; import { userListsCache } from '@/cache.js';
import { isLocalTimelineAvailable, isGlobalTimelineAvailable } from '@/store.js'; import { isLocalTimelineAvailable, isGlobalTimelineAvailable } from '@/scripts/get-timeline-available.js';
export type TimelineHeaderItem =
'home' |
'local' |
'social' |
'global' |
'lists' |
'antennas' |
'channels' |
`list:${string}`
type TimelineHeaderItemsDef = {
title: string;
icon: string;
iconOnly?: boolean; // わからん
}
const lists = await userListsCache.fetch(); const lists = await userListsCache.fetch();
export const timelineHeaderItemDef = reactive({ export const timelineHeaderItemDef = reactive<Partial<Record<TimelineHeaderItem, TimelineHeaderItemsDef>>>({
home: { home: {
title: i18n.ts._timelines.home, title: i18n.ts._timelines.home,
icon: 'ti ti-home', icon: 'ti ti-home',
iconOnly: false, iconOnly: true,
}, },
...(isLocalTimelineAvailable ? { ...(isLocalTimelineAvailable ? {
local: { local: {