From 4a6d517a853ab2fdafe66338c783cdf9dd8bd54f Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Tue, 16 Jan 2024 21:03:49 +0900 Subject: [PATCH 01/10] =?UTF-8?q?(add)=20=E6=A8=AA=E3=82=B9=E3=83=AF?= =?UTF-8?q?=E3=82=A4=E3=83=97=E3=81=A7=E3=82=BF=E3=83=96=E3=82=92=E5=88=87?= =?UTF-8?q?=E3=82=8A=E6=9B=BF=E3=81=88=E3=82=8B=E6=A9=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/index.d.ts | 1 + locales/ja-JP.yml | 1 + .../frontend/src/components/MkLRSwipe.vue | 167 ++++++++++++++ packages/frontend/src/pages/about.vue | 175 +++++++-------- packages/frontend/src/pages/announcements.vue | 61 +++--- packages/frontend/src/pages/channel.vue | 88 ++++---- packages/frontend/src/pages/channels.vue | 81 +++---- packages/frontend/src/pages/drive.file.vue | 21 +- packages/frontend/src/pages/explore.vue | 15 +- .../frontend/src/pages/flash/flash-index.vue | 45 ++-- packages/frontend/src/pages/gallery/index.vue | 11 +- packages/frontend/src/pages/instance-info.vue | 204 +++++++++--------- .../frontend/src/pages/my-clips/index.vue | 32 +-- packages/frontend/src/pages/notifications.vue | 32 ++- packages/frontend/src/pages/pages.vue | 51 +++-- packages/frontend/src/pages/search.vue | 31 +-- .../frontend/src/pages/settings/general.vue | 2 + packages/frontend/src/pages/timeline.vue | 53 +++-- packages/frontend/src/pages/user/index.vue | 34 +-- packages/frontend/src/store.ts | 4 + 20 files changed, 698 insertions(+), 411 deletions(-) create mode 100644 packages/frontend/src/components/MkLRSwipe.vue diff --git a/locales/index.d.ts b/locales/index.d.ts index 71134544d943..84e79abc4de2 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -1204,6 +1204,7 @@ export interface Locale { "ranking": string; "lastNDays": string; "backToTitle": string; + "enableXSwipe": string; "_bubbleGame": { "howToPlay": string; "_howToPlay": { diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 743a3ca38ea2..909670c071a7 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1201,6 +1201,7 @@ replaying: "リプレイ中" ranking: "ランキング" lastNDays: "直近{n}日" backToTitle: "タイトルへ" +enableXSwipe: "スワイプしてタブを切り替える" _bubbleGame: howToPlay: "遊び方" diff --git a/packages/frontend/src/components/MkLRSwipe.vue b/packages/frontend/src/components/MkLRSwipe.vue new file mode 100644 index 000000000000..ff20badab144 --- /dev/null +++ b/packages/frontend/src/components/MkLRSwipe.vue @@ -0,0 +1,167 @@ + + + + + + diff --git a/packages/frontend/src/pages/about.vue b/packages/frontend/src/pages/about.vue index f402b26ad8e7..bb1c771ef2ea 100644 --- a/packages/frontend/src/pages/about.vue +++ b/packages/frontend/src/pages/about.vue @@ -6,98 +6,100 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -114,6 +116,7 @@ import FormSplit from '@/components/form/split.vue'; import MkFolder from '@/components/MkFolder.vue'; import MkKeyValue from '@/components/MkKeyValue.vue'; import MkInstanceStats from '@/components/MkInstanceStats.vue'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; import { misskeyApi } from '@/scripts/misskey-api.js'; import number from '@/filters/number.js'; import { i18n } from '@/i18n.js'; @@ -130,6 +133,10 @@ const props = withDefaults(defineProps<{ const stats = ref(null); const tab = ref(props.initialTab); +function onSwipe(key: string) { + tab.value = key; +} + watch(tab, () => { if (tab.value === 'charts') { claimAchievement('viewInstanceChart'); diff --git a/packages/frontend/src/pages/announcements.vue b/packages/frontend/src/pages/announcements.vue index 5632bf7caf2b..2768ff531699 100644 --- a/packages/frontend/src/pages/announcements.vue +++ b/packages/frontend/src/pages/announcements.vue @@ -7,34 +7,36 @@ SPDX-License-Identifier: AGPL-3.0-only -
- {{ i18n.ts.youHaveUnreadAnnouncements }} - -
-
{{ i18n.ts.forYou }}
-
- 🆕 - - - - - - - {{ announcement.title }} -
-
- - -
- + +
+ {{ i18n.ts.youHaveUnreadAnnouncements }} + +
+
{{ i18n.ts.forYou }}
+
+ 🆕 + + + + + + + {{ announcement.title }}
-
-
- {{ i18n.ts.gotIt }} -
-
-
-
+
+ + +
+ +
+
+
+ {{ i18n.ts.gotIt }} +
+ + + +
@@ -44,6 +46,7 @@ import { ref, computed } from 'vue'; import MkPagination from '@/components/MkPagination.vue'; import MkButton from '@/components/MkButton.vue'; import MkInfo from '@/components/MkInfo.vue'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js'; import { i18n } from '@/i18n.js'; @@ -70,6 +73,10 @@ const paginationEl = ref>(); const tab = ref('current'); +function onSwipe(newKey: string) { + tab.value = newKey; +} + async function read(announcement) { if (announcement.needConfirmationToRead) { const confirm = await os.confirm({ diff --git a/packages/frontend/src/pages/channel.vue b/packages/frontend/src/pages/channel.vue index e698098f3505..6b57c52b8026 100644 --- a/packages/frontend/src/pages/channel.vue +++ b/packages/frontend/src/pages/channel.vue @@ -7,53 +7,55 @@ SPDX-License-Identifier: AGPL-3.0-only -
-
- - - -
-
-
-
+ +
+
+ + + +
+
+
+
+
+
{{ i18n.ts.sensitive }}
+
+
+
+
-
{{ i18n.ts.sensitive }}
-
-
-
-
-
- - -
- -
-
-
-
- {{ i18n.ts.thisChannelArchived }} + + +
+ +
+
+
+
+ {{ i18n.ts.thisChannelArchived }} - - + + - -
-
- -
-
-
-
- - - - {{ i18n.ts.search }} + +
+
+ +
+
+
+
+ + + + {{ i18n.ts.search }} +
+
-
-
+ @@ -58,6 +60,7 @@ import MkInput from '@/components/MkInput.vue'; import MkRadios from '@/components/MkRadios.vue'; import MkButton from '@/components/MkButton.vue'; import MkFoldableSection from '@/components/MkFoldableSection.vue'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { i18n } from '@/i18n.js'; import { useRouter } from '@/global/router/supplier.js'; @@ -75,6 +78,10 @@ const searchQuery = ref(''); const searchType = ref('nameAndDescription'); const channelPagination = ref(); +function onSwipe(newKey: string) { + tab.value = newKey; +} + onMounted(() => { searchQuery.value = props.query ?? ''; searchType.value = props.type ?? 'nameAndDescription'; diff --git a/packages/frontend/src/pages/drive.file.vue b/packages/frontend/src/pages/drive.file.vue index 2c1e5d20a77e..fbaec7211f96 100644 --- a/packages/frontend/src/pages/drive.file.vue +++ b/packages/frontend/src/pages/drive.file.vue @@ -9,13 +9,15 @@ SPDX-License-Identifier: AGPL-3.0-only - - - - - - - + + + + + + + + + @@ -23,6 +25,7 @@ SPDX-License-Identifier: AGPL-3.0-only import { computed, ref, defineAsyncComponent } from 'vue'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; const props = defineProps<{ fileId: string; @@ -33,6 +36,10 @@ const XNotes = defineAsyncComponent(() => import('./drive.file.notes.vue')); const tab = ref('info'); +function onSwipe(key: string) { + tab.value = key; +} + const headerActions = computed(() => []); const headerTabs = computed(() => [{ diff --git a/packages/frontend/src/pages/explore.vue b/packages/frontend/src/pages/explore.vue index f068de888025..e1735e848c9b 100644 --- a/packages/frontend/src/pages/explore.vue +++ b/packages/frontend/src/pages/explore.vue @@ -6,17 +6,17 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -26,6 +26,7 @@ import XFeatured from './explore.featured.vue'; import XUsers from './explore.users.vue'; import XRoles from './explore.roles.vue'; import MkFoldableSection from '@/components/MkFoldableSection.vue'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { i18n } from '@/i18n.js'; @@ -39,6 +40,10 @@ const props = withDefaults(defineProps<{ const tab = ref(props.initialTab); const tagsEl = shallowRef>(); +function onSwipe(newKey: string) { + tab.value = newKey; +} + watch(() => props.tag, () => { if (tagsEl.value) tagsEl.value.toggleContent(props.tag == null); }); diff --git a/packages/frontend/src/pages/flash/flash-index.vue b/packages/frontend/src/pages/flash/flash-index.vue index 785201889403..a0b8387ac6bf 100644 --- a/packages/frontend/src/pages/flash/flash-index.vue +++ b/packages/frontend/src/pages/flash/flash-index.vue @@ -7,32 +7,34 @@ SPDX-License-Identifier: AGPL-3.0-only -
- -
- -
-
-
- -
-
- - + +
+
-
-
- -
- +
+
+ + +
+ +
+
- -
+
+ +
+ +
+ +
+
+
+ @@ -42,6 +44,7 @@ import { computed, ref } from 'vue'; import MkFlashPreview from '@/components/MkFlashPreview.vue'; import MkPagination from '@/components/MkPagination.vue'; import MkButton from '@/components/MkButton.vue'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { useRouter } from '@/global/router/supplier.js'; @@ -50,6 +53,10 @@ const router = useRouter(); const tab = ref('featured'); +function onSwipe(key: string) { + tab.value = key; +} + const featuredFlashsPagination = { endpoint: 'flash/featured' as const, noPaging: true, diff --git a/packages/frontend/src/pages/gallery/index.vue b/packages/frontend/src/pages/gallery/index.vue index 0198ab9700f6..9f5d50878247 100644 --- a/packages/frontend/src/pages/gallery/index.vue +++ b/packages/frontend/src/pages/gallery/index.vue @@ -7,8 +7,8 @@ SPDX-License-Identifier: AGPL-3.0-only -
-
+ +
@@ -26,14 +26,14 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
-
+
{{ i18n.ts.postToGallery }}
@@ -41,7 +41,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+ @@ -51,6 +51,7 @@ import { watch, ref, computed } from 'vue'; import MkFoldableSection from '@/components/MkFoldableSection.vue'; import MkPagination from '@/components/MkPagination.vue'; import MkGalleryPostPreview from '@/components/MkGalleryPostPreview.vue'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { i18n } from '@/i18n.js'; import { useRouter } from '@/global/router/supplier.js'; diff --git a/packages/frontend/src/pages/instance-info.vue b/packages/frontend/src/pages/instance-info.vue index c8a0eeeeaa0b..83d7c70b7dc1 100644 --- a/packages/frontend/src/pages/instance-info.vue +++ b/packages/frontend/src/pages/instance-info.vue @@ -7,111 +7,113 @@ SPDX-License-Identifier: AGPL-3.0-only -
-
- - {{ instance.name || `(${i18n.ts.unknown})` }} -
-
- - - - - - - - - - - + +
+
+ + {{ instance.name || `(${i18n.ts.unknown})` }} +
+
+ + + + + + + + + + + + +
+ + + -
- - - - - - -
- {{ i18n.ts.stopActivityDelivery }} - {{ i18n.ts.blockThisInstance }} - {{ i18n.ts.silenceThisInstance }} - Refresh metadata -
-
+ + +
+ {{ i18n.ts.stopActivityDelivery }} + {{ i18n.ts.blockThisInstance }} + {{ i18n.ts.silenceThisInstance }} + Refresh metadata +
+
- - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - host-meta - host-meta.json - nodeinfo - robots.txt - manifest.json - -
-
-
-
- - - - - - - - - - - - - -
-
-
{{ i18n.t('recentNHours', { n: 90 }) }}
- -
{{ i18n.t('recentNDays', { n: 90 }) }}
- + + + host-meta + host-meta.json + nodeinfo + robots.txt + manifest.json + +
+
+
+
+ + + + + + + + + + + + + +
+
+
{{ i18n.t('recentNHours', { n: 90 }) }}
+ +
{{ i18n.t('recentNDays', { n: 90 }) }}
+ +
-
-
- - - - - -
-
- - -
+
+ + + + + +
+
+ + +
+ @@ -136,6 +138,7 @@ import { definePageMetadata } from '@/scripts/page-metadata.js'; import { i18n } from '@/i18n.js'; import MkUserCardMini from '@/components/MkUserCardMini.vue'; import MkPagination from '@/components/MkPagination.vue'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; import { getProxiedImageUrlNullable } from '@/scripts/media-proxy.js'; import { dateString } from '@/filters/date.js'; @@ -144,6 +147,11 @@ const props = defineProps<{ }>(); const tab = ref('overview'); + +function onSwipe(key: string) { + tab.value = key; +} + const chartSrc = ref('instance-requests'); const meta = ref(null); const instance = ref(null); diff --git a/packages/frontend/src/pages/my-clips/index.vue b/packages/frontend/src/pages/my-clips/index.vue index 850222708e37..7d0900b7770e 100644 --- a/packages/frontend/src/pages/my-clips/index.vue +++ b/packages/frontend/src/pages/my-clips/index.vue @@ -7,20 +7,22 @@ SPDX-License-Identifier: AGPL-3.0-only -
- {{ i18n.ts.add }} - - - + +
+ {{ i18n.ts.add }} + + + + + + +
+
+ - -
-
- - - -
+
+
@@ -36,6 +38,7 @@ import { misskeyApi } from '@/scripts/misskey-api.js'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { clipsCache } from '@/cache.js'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; const pagination = { endpoint: 'clips/list' as const, @@ -44,6 +47,11 @@ const pagination = { }; const tab = ref('my'); + +function onSwipe(tab: string) { + tab.value = tab; +} + const favorites = ref(null); const pagingComponent = shallowRef>(); diff --git a/packages/frontend/src/pages/notifications.vue b/packages/frontend/src/pages/notifications.vue index d57bda41b5ac..693bf9650b1a 100644 --- a/packages/frontend/src/pages/notifications.vue +++ b/packages/frontend/src/pages/notifications.vue @@ -7,15 +7,17 @@ SPDX-License-Identifier: AGPL-3.0-only -
- -
-
- -
-
- -
+ +
+ +
+
+ +
+
+ +
+
@@ -24,6 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only import { computed, ref } from 'vue'; import XNotifications from '@/components/MkNotifications.vue'; import MkNotes from '@/components/MkNotes.vue'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; import * as os from '@/os.js'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; @@ -46,6 +49,10 @@ const directNotesPagination = { }, }; +function onSwipe(newKey: string) { + tab.value = newKey; +} + function setFilter(ev) { const typeItems = notificationTypes.map(t => ({ text: i18n.t(`_notification._types.${t}`), @@ -96,3 +103,10 @@ definePageMetadata(computed(() => ({ icon: 'ti ti-bell', }))); + + diff --git a/packages/frontend/src/pages/pages.vue b/packages/frontend/src/pages/pages.vue index 22ab9ced092f..3a541de1c35a 100644 --- a/packages/frontend/src/pages/pages.vue +++ b/packages/frontend/src/pages/pages.vue @@ -7,30 +7,32 @@ SPDX-License-Identifier: AGPL-3.0-only -
- -
- -
-
-
+ +
+ +
+ +
+
+
-
- - -
- -
-
-
+
+ + +
+ +
+
+
-
- -
- -
-
-
+
+ +
+ +
+
+
+
@@ -40,6 +42,7 @@ import { computed, ref } from 'vue'; import MkPagePreview from '@/components/MkPagePreview.vue'; import MkPagination from '@/components/MkPagination.vue'; import MkButton from '@/components/MkButton.vue'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { useRouter } from '@/global/router/supplier.js'; @@ -48,6 +51,10 @@ const router = useRouter(); const tab = ref('featured'); +function onSwipe(key: string) { + tab.value = key; +} + const featuredPagesPagination = { endpoint: 'pages/featured' as const, noPaging: true, diff --git a/packages/frontend/src/pages/search.vue b/packages/frontend/src/pages/search.vue index 9d5e5697ceca..00d21f720e2e 100644 --- a/packages/frontend/src/pages/search.vue +++ b/packages/frontend/src/pages/search.vue @@ -7,18 +7,20 @@ SPDX-License-Identifier: AGPL-3.0-only - -
- -
-
- {{ i18n.ts.notesSearchNotAvailable }} -
-
- - - - + + +
+ +
+
+ {{ i18n.ts.notesSearchNotAvailable }} +
+
+ + + + +
@@ -29,12 +31,17 @@ import { definePageMetadata } from '@/scripts/page-metadata.js'; import { $i } from '@/account.js'; import { instance } from '@/instance.js'; import MkInfo from '@/components/MkInfo.vue'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; const XNote = defineAsyncComponent(() => import('./search.note.vue')); const XUser = defineAsyncComponent(() => import('./search.user.vue')); const tab = ref('note'); +function onSwipe(newKey: string) { + tab.value = newKey; +} + const notesSearchAvailable = (($i == null && instance.policies.canSearchNotes) || ($i != null && $i.policies.canSearchNotes)); const headerActions = computed(() => []); diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 607aaec52191..d1b7423e2c0a 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -155,6 +155,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.enableInfiniteScroll }} {{ i18n.ts.keepScreenOn }} {{ i18n.ts.disableStreamingTimeline }} + {{ i18n.ts.enableXSwipe }}
@@ -296,6 +297,7 @@ const keepScreenOn = computed(defaultStore.makeGetterSetter('keepScreenOn')); const disableStreamingTimeline = computed(defaultStore.makeGetterSetter('disableStreamingTimeline')); const useGroupedNotifications = computed(defaultStore.makeGetterSetter('useGroupedNotifications')); const enableSeasonalScreenEffect = computed(defaultStore.makeGetterSetter('enableSeasonalScreenEffect')); +const enableXSwipe = computed(defaultStore.makeGetterSetter('enableXSwipe')); watch(lang, () => { miLocalStorage.setItem('lang', lang.value as string); diff --git a/packages/frontend/src/pages/timeline.vue b/packages/frontend/src/pages/timeline.vue index 6fe8963f5162..0a62b29cfb48 100644 --- a/packages/frontend/src/pages/timeline.vue +++ b/packages/frontend/src/pages/timeline.vue @@ -7,27 +7,28 @@ SPDX-License-Identifier: AGPL-3.0-only -
- - {{ i18n.ts._timelineDescription[src] }} - - - -
-
- + +
+ + {{ i18n.ts._timelineDescription[src] }} + + +
+
+ +
-
+ @@ -38,6 +39,7 @@ import type { Tab } from '@/components/global/MkPageHeader.tabs.vue'; import MkTimeline from '@/components/MkTimeline.vue'; import MkInfo from '@/components/MkInfo.vue'; import MkPostForm from '@/components/MkPostForm.vue'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; import { scroll } from '@/scripts/scroll.js'; import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js'; @@ -69,7 +71,16 @@ const withRenotes = ref(true); const withReplies = ref($i ? defaultStore.state.tlWithReplies : false); const onlyFiles = ref(false); -watch(src, () => queue.value = 0); +function onSwipe(newKey: string): void { + const index = headerTabs.value.findIndex(tab => tab.key === newKey); + if (index === -1) return; + const tab = headerTabs.value[index]; + src.value = tab.key; +} + +watch(src, () => { + queue.value = 0; +}); watch(withReplies, (x) => { if ($i) defaultStore.set('tlWithReplies', x); diff --git a/packages/frontend/src/pages/user/index.vue b/packages/frontend/src/pages/user/index.vue index 95869e7b8cf6..5f3318566346 100644 --- a/packages/frontend/src/pages/user/index.vue +++ b/packages/frontend/src/pages/user/index.vue @@ -8,19 +8,21 @@ SPDX-License-Identifier: AGPL-3.0-only
- - - - - - - - - - - - - + + + + + + + + + + + + + + +
@@ -36,6 +38,7 @@ import { misskeyApi } from '@/scripts/misskey-api.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { i18n } from '@/i18n.js'; import { $i } from '@/account.js'; +import MkLRSwipe from '@/components/MkLRSwipe.vue'; const XHome = defineAsyncComponent(() => import('./home.vue')); const XTimeline = defineAsyncComponent(() => import('./index.timeline.vue')); @@ -57,6 +60,11 @@ const props = withDefaults(defineProps<{ }); const tab = ref(props.page); + +function onSwipe(key: string) { + tab.value = key; +} + const user = ref(null); const error = ref(null); diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index e3a85377d852..7eee999daf94 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -427,6 +427,10 @@ export const defaultStore = markRaw(new Storage('base', { sfxVolume: 1, }, }, + enableXSwipe: { + where: 'device', + default: true, + }, sound_masterVolume: { where: 'device', From 36de5438bcbf6f245c05ebea4b4e7d811ec3edfb Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Tue, 16 Jan 2024 21:08:02 +0900 Subject: [PATCH 02/10] Change Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 945b6ac1ad16..c891ed2971d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Feat: 音声・映像プレイヤーを追加 - Feat: 絵文字の詳細ダイアログを追加 - Feat: 枠線をつけるMFM`$[border.width=1,style=solid,color=fff,radius=0 ...]`を追加 +- Feat: スワイプでタブを切り替えられるように - Enhance: ハッシュタグ入力時に、本文の末尾の行に何も書かれていない場合は新たにスペースを追加しないように - Enhance: チャンネルノートのピン留めをノートのメニューからできるように - Enhance: 管理者の場合はAPI tokenの発行画面で管理機能に関する権限を付与できるように From e7939e06ff476cdb5a6ef44dcb896ff6e45c4140 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Wed, 17 Jan 2024 18:03:35 +0900 Subject: [PATCH 03/10] =?UTF-8?q?y=E6=96=B9=E5=90=91=E3=81=AE=E7=A7=BB?= =?UTF-8?q?=E5=8B=95=E3=81=8C=E4=B8=80=E5=AE=9A=E9=87=8F=E3=82=92=E8=B6=85?= =?UTF-8?q?=E3=81=88=E3=81=9F=E3=82=89=E3=82=B9=E3=83=AF=E3=82=A4=E3=83=97?= =?UTF-8?q?=E3=82=92=E4=B8=AD=E6=96=AD=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/src/components/MkLRSwipe.vue | 53 +++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/packages/frontend/src/components/MkLRSwipe.vue b/packages/frontend/src/components/MkLRSwipe.vue index ff20badab144..a3a58e47aa1c 100644 --- a/packages/frontend/src/components/MkLRSwipe.vue +++ b/packages/frontend/src/components/MkLRSwipe.vue @@ -34,17 +34,31 @@ const emit = defineEmits<{ (ev: 'swiped', newKey: string, direction: 'left' | 'right'): void; }>(); +// ▼ しきい値 ▼ // + +// スワイプと判定される最小の距離 const MIN_SWIPE_DISTANCE = 50; + +// スワイプ時の動作を発火する最小の距離 const SWIPE_DISTANCE_THRESHOLD = 150; + +// スワイプを中断するY方向の移動距離 +const SWIPE_ABORT_Y_THRESHOLD = 50; + +// スワイプできる最大の距離 const MAX_SWIPE_DISTANCE = 200; +// ▲ しきい値 ▲ // + let startScreenX: number | null = null; +let startScreenY: number | null = null; const currentTabIndex = computed(() => props.tabs.findIndex(tab => tab.key === props.tab)); const pullDistance = ref(0); const isSwiping = ref(false); const isSwipingForClass = ref(false); +let swipeAborted = false; function touchStart(event: TouchEvent) { if (!defaultStore.reactiveState.enableXSwipe.value) return; @@ -52,6 +66,7 @@ function touchStart(event: TouchEvent) { if (event.touches.length !== 1) return; startScreenX = event.touches[0].screenX; + startScreenY = event.touches[0].screenY; } function touchMove(event: TouchEvent) { @@ -59,31 +74,51 @@ function touchMove(event: TouchEvent) { if (event.touches.length !== 1) return; - if (startScreenX == null) return; + if (startScreenX == null || startScreenY == null) return; + + if (swipeAborted) return; - let distance = event.touches[0].screenX - startScreenX; + let distanceX = event.touches[0].screenX - startScreenX; + let distanceY = event.touches[0].screenY - startScreenY; - if (Math.abs(distance) < MIN_SWIPE_DISTANCE) return; - if (Math.abs(distance) > MAX_SWIPE_DISTANCE) return; + if (Math.abs(distanceY) > SWIPE_ABORT_Y_THRESHOLD) { + swipeAborted = true; + + pullDistance.value = 0; + isSwiping.value = false; + setTimeout(() => { + isSwipingForClass.value = false; + }, 400); + + return; + } + + if (Math.abs(distanceX) < MIN_SWIPE_DISTANCE) return; + if (Math.abs(distanceX) > MAX_SWIPE_DISTANCE) return; if (currentTabIndex.value === 0 || props.tabs[currentTabIndex.value - 1].onClick) { - distance = Math.min(distance, 0); + distanceX = Math.min(distanceX, 0); } if (currentTabIndex.value === props.tabs.length - 1 || props.tabs[currentTabIndex.value + 1].onClick) { - distance = Math.max(distance, 0); + distanceX = Math.max(distanceX, 0); } - if (distance === 0) return; + if (distanceX === 0) return; isSwiping.value = true; isSwipingForClass.value = true; nextTick(() => { // グリッチを控えるため、1.5px以上の差がないと更新しない - if (Math.abs(distance - pullDistance.value) < 1.5) return; - pullDistance.value = distance; + if (Math.abs(distanceX - pullDistance.value) < 1.5) return; + pullDistance.value = distanceX; }); } function touchEnd(event: TouchEvent) { + if (swipeAborted) { + swipeAborted = false; + return; + } + if (!defaultStore.reactiveState.enableXSwipe.value) return; if (event.touches.length !== 0) return; From 5ee3c92f2d424b10e9d5e562eafe864f79a02647 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Wed, 17 Jan 2024 18:09:18 +0900 Subject: [PATCH 04/10] Update swipe distance thresholds --- packages/frontend/src/components/MkLRSwipe.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/components/MkLRSwipe.vue b/packages/frontend/src/components/MkLRSwipe.vue index a3a58e47aa1c..e94fb3890b43 100644 --- a/packages/frontend/src/components/MkLRSwipe.vue +++ b/packages/frontend/src/components/MkLRSwipe.vue @@ -40,13 +40,13 @@ const emit = defineEmits<{ const MIN_SWIPE_DISTANCE = 50; // スワイプ時の動作を発火する最小の距離 -const SWIPE_DISTANCE_THRESHOLD = 150; +const SWIPE_DISTANCE_THRESHOLD = 125; // スワイプを中断するY方向の移動距離 const SWIPE_ABORT_Y_THRESHOLD = 50; // スワイプできる最大の距離 -const MAX_SWIPE_DISTANCE = 200; +const MAX_SWIPE_DISTANCE = 150; // ▲ しきい値 ▲ // From ff41cbb64a50d4d8542d159012e202fb0a5668fd Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Wed, 17 Jan 2024 18:10:43 +0900 Subject: [PATCH 05/10] Remove console.log --- packages/frontend/src/components/MkLRSwipe.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/frontend/src/components/MkLRSwipe.vue b/packages/frontend/src/components/MkLRSwipe.vue index e94fb3890b43..1e47d384990d 100644 --- a/packages/frontend/src/components/MkLRSwipe.vue +++ b/packages/frontend/src/components/MkLRSwipe.vue @@ -134,12 +134,10 @@ function touchEnd(event: TouchEvent) { if (props.tabs[currentTabIndex.value - 1] && !props.tabs[currentTabIndex.value - 1].onClick) { emit('swiped', props.tabs[currentTabIndex.value - 1].key, 'right'); } - console.log('swiped right'); } else { if (props.tabs[currentTabIndex.value + 1] && !props.tabs[currentTabIndex.value + 1].onClick) { emit('swiped', props.tabs[currentTabIndex.value + 1].key, 'left'); } - console.log('swiped left'); } } From 88e5ba84248fb5977120ebeb5e26b7c6e89a1068 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Wed, 17 Jan 2024 19:33:48 +0900 Subject: [PATCH 06/10] adjust threshold --- packages/frontend/src/components/MkLRSwipe.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/components/MkLRSwipe.vue b/packages/frontend/src/components/MkLRSwipe.vue index 1e47d384990d..5f90da0bb4d2 100644 --- a/packages/frontend/src/components/MkLRSwipe.vue +++ b/packages/frontend/src/components/MkLRSwipe.vue @@ -43,7 +43,7 @@ const MIN_SWIPE_DISTANCE = 50; const SWIPE_DISTANCE_THRESHOLD = 125; // スワイプを中断するY方向の移動距離 -const SWIPE_ABORT_Y_THRESHOLD = 50; +const SWIPE_ABORT_Y_THRESHOLD = 75; // スワイプできる最大の距離 const MAX_SWIPE_DISTANCE = 150; From 870da21f243ca38b4df4125327a413b0f6385495 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Wed, 17 Jan 2024 22:07:59 +0900 Subject: [PATCH 07/10] rename, use v-model --- locales/index.d.ts | 2 +- locales/ja-JP.yml | 2 +- .../{MkLRSwipe.vue => MkHorizontalSwipe.vue} | 10 +++++++--- packages/frontend/src/pages/about.vue | 10 +++------- packages/frontend/src/pages/announcements.vue | 10 +++------- packages/frontend/src/pages/channel.vue | 10 +++------- packages/frontend/src/pages/channels.vue | 10 +++------- packages/frontend/src/pages/drive.file.vue | 10 +++------- packages/frontend/src/pages/explore.vue | 10 +++------- packages/frontend/src/pages/flash/flash-index.vue | 10 +++------- packages/frontend/src/pages/gallery/index.vue | 6 +++--- packages/frontend/src/pages/instance-info.vue | 10 +++------- packages/frontend/src/pages/my-clips/index.vue | 10 +++------- packages/frontend/src/pages/notifications.vue | 10 +++------- packages/frontend/src/pages/pages.vue | 10 +++------- packages/frontend/src/pages/search.vue | 10 +++------- packages/frontend/src/pages/settings/general.vue | 4 ++-- packages/frontend/src/pages/timeline.vue | 13 +++---------- packages/frontend/src/pages/user/index.vue | 10 +++------- packages/frontend/src/store.ts | 2 +- 20 files changed, 57 insertions(+), 112 deletions(-) rename packages/frontend/src/components/{MkLRSwipe.vue => MkHorizontalSwipe.vue} (95%) diff --git a/locales/index.d.ts b/locales/index.d.ts index 84e79abc4de2..a659e790cc49 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -1204,7 +1204,7 @@ export interface Locale { "ranking": string; "lastNDays": string; "backToTitle": string; - "enableXSwipe": string; + "enableHorizontalSwipe": string; "_bubbleGame": { "howToPlay": string; "_howToPlay": { diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 909670c071a7..8749a5f49f09 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1201,7 +1201,7 @@ replaying: "リプレイ中" ranking: "ランキング" lastNDays: "直近{n}日" backToTitle: "タイトルへ" -enableXSwipe: "スワイプしてタブを切り替える" +enableHorizontalSwipe: "スワイプしてタブを切り替える" _bubbleGame: howToPlay: "遊び方" diff --git a/packages/frontend/src/components/MkLRSwipe.vue b/packages/frontend/src/components/MkHorizontalSwipe.vue similarity index 95% rename from packages/frontend/src/components/MkLRSwipe.vue rename to packages/frontend/src/components/MkHorizontalSwipe.vue index 5f90da0bb4d2..c43e83d0caac 100644 --- a/packages/frontend/src/components/MkLRSwipe.vue +++ b/packages/frontend/src/components/MkHorizontalSwipe.vue @@ -25,8 +25,10 @@ import { defaultStore } from '@/store.js'; const rootEl = shallowRef(); +// eslint-disable-next-line no-undef +const tabModel = defineModel('tab'); + const props = defineProps<{ - tab: string; tabs: Tab[]; }>(); @@ -53,7 +55,7 @@ const MAX_SWIPE_DISTANCE = 150; let startScreenX: number | null = null; let startScreenY: number | null = null; -const currentTabIndex = computed(() => props.tabs.findIndex(tab => tab.key === props.tab)); +const currentTabIndex = computed(() => props.tabs.findIndex(tab => tab.key === tabModel.value)); const pullDistance = ref(0); const isSwiping = ref(false); @@ -132,10 +134,12 @@ function touchEnd(event: TouchEvent) { if (Math.abs(distance) > SWIPE_DISTANCE_THRESHOLD) { if (distance > 0) { if (props.tabs[currentTabIndex.value - 1] && !props.tabs[currentTabIndex.value - 1].onClick) { + tabModel.value = props.tabs[currentTabIndex.value - 1].key; emit('swiped', props.tabs[currentTabIndex.value - 1].key, 'right'); } } else { if (props.tabs[currentTabIndex.value + 1] && !props.tabs[currentTabIndex.value + 1].onClick) { + tabModel.value = props.tabs[currentTabIndex.value + 1].key; emit('swiped', props.tabs[currentTabIndex.value + 1].key, 'left'); } } @@ -150,7 +154,7 @@ function touchEnd(event: TouchEvent) { const transitionName = ref<'swipeAnimationLeft' | 'swipeAnimationRight' | undefined>(undefined); -watch(() => props.tab, (newTab, oldTab) => { +watch(tabModel, (newTab, oldTab) => { const newIndex = props.tabs.findIndex(tab => tab.key === newTab); const oldIndex = props.tabs.findIndex(tab => tab.key === oldTab); diff --git a/packages/frontend/src/pages/about.vue b/packages/frontend/src/pages/about.vue index bb1c771ef2ea..4ba1b6da768d 100644 --- a/packages/frontend/src/pages/about.vue +++ b/packages/frontend/src/pages/about.vue @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -116,7 +116,7 @@ import FormSplit from '@/components/form/split.vue'; import MkFolder from '@/components/MkFolder.vue'; import MkKeyValue from '@/components/MkKeyValue.vue'; import MkInstanceStats from '@/components/MkInstanceStats.vue'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; import { misskeyApi } from '@/scripts/misskey-api.js'; import number from '@/filters/number.js'; import { i18n } from '@/i18n.js'; @@ -133,10 +133,6 @@ const props = withDefaults(defineProps<{ const stats = ref(null); const tab = ref(props.initialTab); -function onSwipe(key: string) { - tab.value = key; -} - watch(tab, () => { if (tab.value === 'charts') { claimAchievement('viewInstanceChart'); diff --git a/packages/frontend/src/pages/announcements.vue b/packages/frontend/src/pages/announcements.vue index 2768ff531699..c31c6d090326 100644 --- a/packages/frontend/src/pages/announcements.vue +++ b/packages/frontend/src/pages/announcements.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only - +
{{ i18n.ts.youHaveUnreadAnnouncements }} @@ -36,7 +36,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
@@ -46,7 +46,7 @@ import { ref, computed } from 'vue'; import MkPagination from '@/components/MkPagination.vue'; import MkButton from '@/components/MkButton.vue'; import MkInfo from '@/components/MkInfo.vue'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js'; import { i18n } from '@/i18n.js'; @@ -73,10 +73,6 @@ const paginationEl = ref>(); const tab = ref('current'); -function onSwipe(newKey: string) { - tab.value = newKey; -} - async function read(announcement) { if (announcement.needConfirmationToRead) { const confirm = await os.confirm({ diff --git a/packages/frontend/src/pages/channel.vue b/packages/frontend/src/pages/channel.vue index a55ea0af7d87..4cdf2eea7d65 100644 --- a/packages/frontend/src/pages/channel.vue +++ b/packages/frontend/src/pages/channel.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only - +
@@ -55,7 +55,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
@@ -60,7 +60,7 @@ import MkInput from '@/components/MkInput.vue'; import MkRadios from '@/components/MkRadios.vue'; import MkButton from '@/components/MkButton.vue'; import MkFoldableSection from '@/components/MkFoldableSection.vue'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { i18n } from '@/i18n.js'; import { useRouter } from '@/global/router/supplier.js'; @@ -78,10 +78,6 @@ const searchQuery = ref(''); const searchType = ref('nameAndDescription'); const channelPagination = ref(); -function onSwipe(newKey: string) { - tab.value = newKey; -} - onMounted(() => { searchQuery.value = props.query ?? ''; searchType.value = props.type ?? 'nameAndDescription'; diff --git a/packages/frontend/src/pages/drive.file.vue b/packages/frontend/src/pages/drive.file.vue index fbaec7211f96..6a9e9079637e 100644 --- a/packages/frontend/src/pages/drive.file.vue +++ b/packages/frontend/src/pages/drive.file.vue @@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only - + @@ -17,7 +17,7 @@ SPDX-License-Identifier: AGPL-3.0-only - +
@@ -25,7 +25,7 @@ SPDX-License-Identifier: AGPL-3.0-only import { computed, ref, defineAsyncComponent } from 'vue'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; const props = defineProps<{ fileId: string; @@ -36,10 +36,6 @@ const XNotes = defineAsyncComponent(() => import('./drive.file.notes.vue')); const tab = ref('info'); -function onSwipe(key: string) { - tab.value = key; -} - const headerActions = computed(() => []); const headerTabs = computed(() => [{ diff --git a/packages/frontend/src/pages/explore.vue b/packages/frontend/src/pages/explore.vue index e1735e848c9b..1b80014366c9 100644 --- a/packages/frontend/src/pages/explore.vue +++ b/packages/frontend/src/pages/explore.vue @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -26,7 +26,7 @@ import XFeatured from './explore.featured.vue'; import XUsers from './explore.users.vue'; import XRoles from './explore.roles.vue'; import MkFoldableSection from '@/components/MkFoldableSection.vue'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { i18n } from '@/i18n.js'; @@ -40,10 +40,6 @@ const props = withDefaults(defineProps<{ const tab = ref(props.initialTab); const tagsEl = shallowRef>(); -function onSwipe(newKey: string) { - tab.value = newKey; -} - watch(() => props.tag, () => { if (tagsEl.value) tagsEl.value.toggleContent(props.tag == null); }); diff --git a/packages/frontend/src/pages/flash/flash-index.vue b/packages/frontend/src/pages/flash/flash-index.vue index a0b8387ac6bf..53510ea232f8 100644 --- a/packages/frontend/src/pages/flash/flash-index.vue +++ b/packages/frontend/src/pages/flash/flash-index.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only - +
@@ -34,7 +34,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
@@ -44,7 +44,7 @@ import { computed, ref } from 'vue'; import MkFlashPreview from '@/components/MkFlashPreview.vue'; import MkPagination from '@/components/MkPagination.vue'; import MkButton from '@/components/MkButton.vue'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { useRouter } from '@/global/router/supplier.js'; @@ -53,10 +53,6 @@ const router = useRouter(); const tab = ref('featured'); -function onSwipe(key: string) { - tab.value = key; -} - const featuredFlashsPagination = { endpoint: 'flash/featured' as const, noPaging: true, diff --git a/packages/frontend/src/pages/gallery/index.vue b/packages/frontend/src/pages/gallery/index.vue index 9f5d50878247..9749888fe952 100644 --- a/packages/frontend/src/pages/gallery/index.vue +++ b/packages/frontend/src/pages/gallery/index.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only - +
@@ -41,7 +41,7 @@ SPDX-License-Identifier: AGPL-3.0-only
- + @@ -51,7 +51,7 @@ import { watch, ref, computed } from 'vue'; import MkFoldableSection from '@/components/MkFoldableSection.vue'; import MkPagination from '@/components/MkPagination.vue'; import MkGalleryPostPreview from '@/components/MkGalleryPostPreview.vue'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { i18n } from '@/i18n.js'; import { useRouter } from '@/global/router/supplier.js'; diff --git a/packages/frontend/src/pages/instance-info.vue b/packages/frontend/src/pages/instance-info.vue index 83d7c70b7dc1..4211dc0d8734 100644 --- a/packages/frontend/src/pages/instance-info.vue +++ b/packages/frontend/src/pages/instance-info.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only - +
@@ -113,7 +113,7 @@ SPDX-License-Identifier: AGPL-3.0-only
- + @@ -138,7 +138,7 @@ import { definePageMetadata } from '@/scripts/page-metadata.js'; import { i18n } from '@/i18n.js'; import MkUserCardMini from '@/components/MkUserCardMini.vue'; import MkPagination from '@/components/MkPagination.vue'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; import { getProxiedImageUrlNullable } from '@/scripts/media-proxy.js'; import { dateString } from '@/filters/date.js'; @@ -148,10 +148,6 @@ const props = defineProps<{ const tab = ref('overview'); -function onSwipe(key: string) { - tab.value = key; -} - const chartSrc = ref('instance-requests'); const meta = ref(null); const instance = ref(null); diff --git a/packages/frontend/src/pages/my-clips/index.vue b/packages/frontend/src/pages/my-clips/index.vue index 7d0900b7770e..468e46838b45 100644 --- a/packages/frontend/src/pages/my-clips/index.vue +++ b/packages/frontend/src/pages/my-clips/index.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only - +
{{ i18n.ts.add }} @@ -22,7 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
@@ -38,7 +38,7 @@ import { misskeyApi } from '@/scripts/misskey-api.js'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { clipsCache } from '@/cache.js'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; const pagination = { endpoint: 'clips/list' as const, @@ -48,10 +48,6 @@ const pagination = { const tab = ref('my'); -function onSwipe(tab: string) { - tab.value = tab; -} - const favorites = ref(null); const pagingComponent = shallowRef>(); diff --git a/packages/frontend/src/pages/notifications.vue b/packages/frontend/src/pages/notifications.vue index 693bf9650b1a..8913a89adbdf 100644 --- a/packages/frontend/src/pages/notifications.vue +++ b/packages/frontend/src/pages/notifications.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only - +
@@ -17,7 +17,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
@@ -26,7 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only import { computed, ref } from 'vue'; import XNotifications from '@/components/MkNotifications.vue'; import MkNotes from '@/components/MkNotes.vue'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; import * as os from '@/os.js'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; @@ -49,10 +49,6 @@ const directNotesPagination = { }, }; -function onSwipe(newKey: string) { - tab.value = newKey; -} - function setFilter(ev) { const typeItems = notificationTypes.map(t => ({ text: i18n.t(`_notification._types.${t}`), diff --git a/packages/frontend/src/pages/pages.vue b/packages/frontend/src/pages/pages.vue index 3a541de1c35a..8b57b1af9f18 100644 --- a/packages/frontend/src/pages/pages.vue +++ b/packages/frontend/src/pages/pages.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only - +
@@ -32,7 +32,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
@@ -42,7 +42,7 @@ import { computed, ref } from 'vue'; import MkPagePreview from '@/components/MkPagePreview.vue'; import MkPagination from '@/components/MkPagination.vue'; import MkButton from '@/components/MkButton.vue'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { useRouter } from '@/global/router/supplier.js'; @@ -51,10 +51,6 @@ const router = useRouter(); const tab = ref('featured'); -function onSwipe(key: string) { - tab.value = key; -} - const featuredPagesPagination = { endpoint: 'pages/featured' as const, noPaging: true, diff --git a/packages/frontend/src/pages/search.vue b/packages/frontend/src/pages/search.vue index 00d21f720e2e..b68de805cfd9 100644 --- a/packages/frontend/src/pages/search.vue +++ b/packages/frontend/src/pages/search.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only - +
@@ -20,7 +20,7 @@ SPDX-License-Identifier: AGPL-3.0-only - + @@ -31,17 +31,13 @@ import { definePageMetadata } from '@/scripts/page-metadata.js'; import { $i } from '@/account.js'; import { instance } from '@/instance.js'; import MkInfo from '@/components/MkInfo.vue'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; const XNote = defineAsyncComponent(() => import('./search.note.vue')); const XUser = defineAsyncComponent(() => import('./search.user.vue')); const tab = ref('note'); -function onSwipe(newKey: string) { - tab.value = newKey; -} - const notesSearchAvailable = (($i == null && instance.policies.canSearchNotes) || ($i != null && $i.policies.canSearchNotes)); const headerActions = computed(() => []); diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index d1b7423e2c0a..e52a5ee04fca 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -155,7 +155,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.enableInfiniteScroll }} {{ i18n.ts.keepScreenOn }} {{ i18n.ts.disableStreamingTimeline }} - {{ i18n.ts.enableXSwipe }} + {{ i18n.ts.enableHorizontalSwipe }}
@@ -297,7 +297,7 @@ const keepScreenOn = computed(defaultStore.makeGetterSetter('keepScreenOn')); const disableStreamingTimeline = computed(defaultStore.makeGetterSetter('disableStreamingTimeline')); const useGroupedNotifications = computed(defaultStore.makeGetterSetter('useGroupedNotifications')); const enableSeasonalScreenEffect = computed(defaultStore.makeGetterSetter('enableSeasonalScreenEffect')); -const enableXSwipe = computed(defaultStore.makeGetterSetter('enableXSwipe')); +const enableHorizontalSwipe = computed(defaultStore.makeGetterSetter('enableHorizontalSwipe')); watch(lang, () => { miLocalStorage.setItem('lang', lang.value as string); diff --git a/packages/frontend/src/pages/timeline.vue b/packages/frontend/src/pages/timeline.vue index 0a62b29cfb48..666a9968b219 100644 --- a/packages/frontend/src/pages/timeline.vue +++ b/packages/frontend/src/pages/timeline.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only - +
{{ i18n.ts._timelineDescription[src] }} @@ -28,7 +28,7 @@ SPDX-License-Identifier: AGPL-3.0-only />
-
+
@@ -39,7 +39,7 @@ import type { Tab } from '@/components/global/MkPageHeader.tabs.vue'; import MkTimeline from '@/components/MkTimeline.vue'; import MkInfo from '@/components/MkInfo.vue'; import MkPostForm from '@/components/MkPostForm.vue'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; import { scroll } from '@/scripts/scroll.js'; import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js'; @@ -71,13 +71,6 @@ const withRenotes = ref(true); const withReplies = ref($i ? defaultStore.state.tlWithReplies : false); const onlyFiles = ref(false); -function onSwipe(newKey: string): void { - const index = headerTabs.value.findIndex(tab => tab.key === newKey); - if (index === -1) return; - const tab = headerTabs.value[index]; - src.value = tab.key; -} - watch(src, () => { queue.value = 0; }); diff --git a/packages/frontend/src/pages/user/index.vue b/packages/frontend/src/pages/user/index.vue index 5f3318566346..603f1bef33b0 100644 --- a/packages/frontend/src/pages/user/index.vue +++ b/packages/frontend/src/pages/user/index.vue @@ -8,7 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only
- + @@ -22,7 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only - +
@@ -38,7 +38,7 @@ import { misskeyApi } from '@/scripts/misskey-api.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { i18n } from '@/i18n.js'; import { $i } from '@/account.js'; -import MkLRSwipe from '@/components/MkLRSwipe.vue'; +import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue'; const XHome = defineAsyncComponent(() => import('./home.vue')); const XTimeline = defineAsyncComponent(() => import('./index.timeline.vue')); @@ -61,10 +61,6 @@ const props = withDefaults(defineProps<{ const tab = ref(props.page); -function onSwipe(key: string) { - tab.value = key; -} - const user = ref(null); const error = ref(null); diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index 7eee999daf94..21b796caa1aa 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -427,7 +427,7 @@ export const defaultStore = markRaw(new Storage('base', { sfxVolume: 1, }, }, - enableXSwipe: { + enableHorizontalSwipe: { where: 'device', default: true, }, From 03e58c46c5d734c8897044f49eeb3e215c23bca4 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Wed, 17 Jan 2024 22:14:48 +0900 Subject: [PATCH 08/10] fix --- packages/frontend/src/components/MkHorizontalSwipe.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/components/MkHorizontalSwipe.vue b/packages/frontend/src/components/MkHorizontalSwipe.vue index c43e83d0caac..850162ed8135 100644 --- a/packages/frontend/src/components/MkHorizontalSwipe.vue +++ b/packages/frontend/src/components/MkHorizontalSwipe.vue @@ -63,7 +63,7 @@ const isSwipingForClass = ref(false); let swipeAborted = false; function touchStart(event: TouchEvent) { - if (!defaultStore.reactiveState.enableXSwipe.value) return; + if (!defaultStore.reactiveState.enableHorizontalSwipe.value) return; if (event.touches.length !== 1) return; @@ -72,7 +72,7 @@ function touchStart(event: TouchEvent) { } function touchMove(event: TouchEvent) { - if (!defaultStore.reactiveState.enableXSwipe.value) return; + if (!defaultStore.reactiveState.enableHorizontalSwipe.value) return; if (event.touches.length !== 1) return; @@ -121,7 +121,7 @@ function touchEnd(event: TouchEvent) { return; } - if (!defaultStore.reactiveState.enableXSwipe.value) return; + if (!defaultStore.reactiveState.enableHorizontalSwipe.value) return; if (event.touches.length !== 0) return; From 92eb53997e87cacac53924017deb36cb5d5d5900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:46:08 +0900 Subject: [PATCH 09/10] Update MkHorizontalSwipe.vue Co-authored-by: syuilo --- packages/frontend/src/components/MkHorizontalSwipe.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/components/MkHorizontalSwipe.vue b/packages/frontend/src/components/MkHorizontalSwipe.vue index 850162ed8135..fddced4eeee0 100644 --- a/packages/frontend/src/components/MkHorizontalSwipe.vue +++ b/packages/frontend/src/components/MkHorizontalSwipe.vue @@ -164,7 +164,7 @@ watch(tabModel, (newTab, oldTab) => { transitionName.value = 'swipeAnimationRight'; } - setTimeout(() => { + window.setTimeout(() => { transitionName.value = undefined; }, 400); }); From 3b87bc8eada84789fbfb9f7bc4cfda0157808ea7 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Thu, 18 Jan 2024 17:59:41 +0900 Subject: [PATCH 10/10] use css module --- .../src/components/MkHorizontalSwipe.vue | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/frontend/src/components/MkHorizontalSwipe.vue b/packages/frontend/src/components/MkHorizontalSwipe.vue index fddced4eeee0..2c62aadbf4cd 100644 --- a/packages/frontend/src/components/MkHorizontalSwipe.vue +++ b/packages/frontend/src/components/MkHorizontalSwipe.vue @@ -11,7 +11,14 @@ SPDX-License-Identifier: AGPL-3.0-only @touchmove="touchMove" @touchend="touchEnd" > - + @@ -179,20 +186,18 @@ watch(tabModel, (newTab, oldTab) => { grid-area: 1 / 1 / 2 / 2; transform: translateX(var(--swipe)); - &:global(.swipeAnimationLeft-enter-active), - &:global(.swipeAnimationRight-enter-active), - &:global(.swipeAnimationLeft-leave-active), - &:global(.swipeAnimationRight-leave-active) { + &.swipeAnimation_enterActive, + &.swipeAnimation_leaveActive { transition: transform .3s cubic-bezier(0.65, 0.05, 0.36, 1); } - &:global(.swipeAnimationRight-leave-to), - &:global(.swipeAnimationLeft-enter-from) { + &.swipeAnimationRight_leaveTo, + &.swipeAnimationLeft_enterFrom { transform: translateX(calc(100% + 24px)); } - &:global(.swipeAnimationRight-enter-from), - &:global(.swipeAnimationLeft-leave-to) { + &.swipeAnimationRight_enterFrom, + &.swipeAnimationLeft_leaveTo { transform: translateX(calc(-100% - 24px)); } }