From 10cd4754fd5b1e30e46bfdeb0ad43901b6fbd449 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 17 Feb 2021 21:34:20 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF?= =?UTF-8?q?=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/components/emoji-picker.vue | 5 +++-- src/client/components/post-form.vue | 3 ++- src/client/init.ts | 11 ++++++----- src/client/os.ts | 3 --- src/client/scripts/is-mobile.ts | 2 ++ src/client/ui/chat/post-form.vue | 3 ++- 6 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 src/client/scripts/is-mobile.ts diff --git a/src/client/components/emoji-picker.vue b/src/client/components/emoji-picker.vue index c2d1008e1..9a261ef83 100644 --- a/src/client/components/emoji-picker.vue +++ b/src/client/components/emoji-picker.vue @@ -99,7 +99,8 @@ import { faHeart, faFlag, faLaugh } from '@fortawesome/free-regular-svg-icons'; import MkModal from '@/components/ui/modal.vue'; import Particle from '@/components/particle.vue'; import * as os from '@/os'; -import { isDeviceTouch } from '../scripts/is-device-touch'; +import { isDeviceTouch } from '@/scripts/is-device-touch'; +import { isMobile } from '@/scripts/is-mobile'; import { emojiCategories } from '@/instance'; export default defineComponent({ @@ -322,7 +323,7 @@ export default defineComponent({ }, mounted() { - if (!os.isMobile) { + if (!isMobile && !isDeviceTouch) { this.$refs.search.focus({ preventScroll: true }); diff --git a/src/client/components/post-form.vue b/src/client/components/post-form.vue index d2c0cffa1..fa9aeff8a 100644 --- a/src/client/components/post-form.vue +++ b/src/client/components/post-form.vue @@ -69,6 +69,7 @@ import { noteVisibilities } from '../../types'; import * as os from '@/os'; import { selectFile } from '@/scripts/select-file'; import { notePostInterruptors, postFormActions } from '@/store'; +import { isMobile } from '@/scripts/is-mobile'; export default defineComponent({ components: { @@ -554,7 +555,7 @@ export default defineComponent({ localOnly: this.localOnly, visibility: this.visibility, visibleUserIds: this.visibility == 'specified' ? this.visibleUsers.map(u => u.id) : undefined, - viaMobile: os.isMobile + viaMobile: isMobile }; // plugin diff --git a/src/client/init.ts b/src/client/init.ts index c3be85a85..146c54fa6 100644 --- a/src/client/init.ts +++ b/src/client/init.ts @@ -49,15 +49,16 @@ import { router } from '@/router'; import { applyTheme } from '@/scripts/theme'; import { isDeviceDarkmode } from '@/scripts/is-device-darkmode'; import { i18n } from '@/i18n'; -import { stream, isMobile, dialog, post } from '@/os'; +import { stream, dialog, post } from '@/os'; import * as sound from '@/scripts/sound'; import { $i, refreshAccount, login, updateAccount, signout } from '@/account'; import { defaultStore, ColdDeviceStorage } from '@/store'; import { fetchInstance, instance } from '@/instance'; -import { makeHotkey } from './scripts/hotkey'; -import { search } from './scripts/search'; -import { getThemes } from './theme-store'; -import { initializeSw } from './scripts/initialize-sw'; +import { makeHotkey } from '@/scripts/hotkey'; +import { search } from '@/scripts/search'; +import { isMobile } from '@/scripts/is-mobile'; +import { getThemes } from '@/theme-store'; +import { initializeSw } from '@/scripts/initialize-sw'; console.info(`Misskey v${version}`); diff --git a/src/client/os.ts b/src/client/os.ts index 95dcd3eb6..59ee3617e 100644 --- a/src/client/os.ts +++ b/src/client/os.ts @@ -9,9 +9,6 @@ import { resolve } from '@/router'; import { $i } from '@/account'; import { defaultStore } from '@/store'; -const ua = navigator.userAgent.toLowerCase(); -export const isMobile = /mobile|iphone|ipad|android/.test(ua); - export const stream = markRaw(new Stream()); export const pendingApiRequestsCount = ref(0); diff --git a/src/client/scripts/is-mobile.ts b/src/client/scripts/is-mobile.ts new file mode 100644 index 000000000..60cb59f91 --- /dev/null +++ b/src/client/scripts/is-mobile.ts @@ -0,0 +1,2 @@ +const ua = navigator.userAgent.toLowerCase(); +export const isMobile = /mobile|iphone|ipad|android/.test(ua); diff --git a/src/client/ui/chat/post-form.vue b/src/client/ui/chat/post-form.vue index 833c4b406..38fe48cc6 100644 --- a/src/client/ui/chat/post-form.vue +++ b/src/client/ui/chat/post-form.vue @@ -64,6 +64,7 @@ import { noteVisibilities } from '../../../types'; import * as os from '@/os'; import { selectFile } from '@/scripts/select-file'; import { notePostInterruptors, postFormActions } from '@/store'; +import { isMobile } from '@/scripts/is-mobile'; export default defineComponent({ components: { @@ -541,7 +542,7 @@ export default defineComponent({ localOnly: this.localOnly, visibility: this.visibility, visibleUserIds: this.visibility == 'specified' ? this.visibleUsers.map(u => u.id) : undefined, - viaMobile: os.isMobile + viaMobile: isMobile }; // plugin