This commit is contained in:
mattyatea 2024-05-17 19:23:34 +09:00
parent fb6154957f
commit ceee4800b8
4 changed files with 44 additions and 9 deletions

View file

@ -274,12 +274,12 @@ const maxTextLength = computed((): number => {
const canPost = computed((): boolean => { const canPost = computed((): boolean => {
return !props.mock && !posting.value && !posted.value && return !props.mock && !posting.value && !posted.value &&
( (
1 <= textLength.value || 1 <= textLength.value ||
1 <= files.value.length || 1 <= files.value.length ||
poll.value != null || poll.value != null ||
props.renote != null || props.renote != null ||
(props.reply != null && quoteId.value != null) (props.reply != null && quoteId.value != null)
) && ) &&
(textLength.value <= maxTextLength.value) && (textLength.value <= maxTextLength.value) &&
(!poll.value || poll.value.choices.length >= 2); (!poll.value || poll.value.choices.length >= 2);
}); });
@ -857,7 +857,7 @@ async function post(ev?: MouseEvent) {
if (notesCount === 1) { if (notesCount === 1) {
claimAchievement('notes1'); claimAchievement('notes1');
} }
poll.value = null;
if (postData.schedule?.scheduledAt) { if (postData.schedule?.scheduledAt) {
const d = new Date(postData.schedule.scheduledAt); const d = new Date(postData.schedule.scheduledAt);
@ -901,6 +901,7 @@ async function post(ev?: MouseEvent) {
if (m === 0 && s === 0) { if (m === 0 && s === 0) {
claimAchievement('postedAt0min0sec'); claimAchievement('postedAt0min0sec');
} }
clear();
}); });
}).catch(err => { }).catch(err => {
posting.value = false; posting.value = false;

View file

@ -13,10 +13,11 @@ SPDX-License-Identifier: AGPL-3.0-only
v-if="player.url.startsWith('http://') || player.url.startsWith('https://')" v-if="player.url.startsWith('http://') || player.url.startsWith('https://')"
sandbox="allow-popups allow-scripts allow-storage-access-by-user-activation allow-same-origin" sandbox="allow-popups allow-scripts allow-storage-access-by-user-activation allow-same-origin"
scrolling="no" scrolling="no"
:allow="player.allow == null ? 'autoplay;encrypted-media;fullscreen' : player.allow.filter(x => ['autoplay', 'clipboard-write', 'fullscreen', 'encrypted-media', 'picture-in-picture', 'web-share'].includes(x)).join(';')" :allow="player.allow == null ? 'encrypted-media;fullscreen' : player.allow.filter(x => ['autoplay', 'clipboard-write', 'fullscreen', 'encrypted-media', 'picture-in-picture', 'web-share'].includes(x)).join(';')"
:class="$style.playerIframe" :class="$style.playerIframe"
:src="player.url + (player.url.match(/\?/) ? '&autoplay=1&auto_play=1' : '?autoplay=1&auto_play=1')" :src="player.url"
:style="{ border: 0 }" :style="{ border: 0, backgroundColor: 'transparent' }"
allowtransparency="true"
></iframe> ></iframe>
<span v-else>invalid url</span> <span v-else>invalid url</span>
</div> </div>
@ -27,14 +28,18 @@ SPDX-License-Identifier: AGPL-3.0-only
</div> </div>
</template> </template>
<template v-else-if="tweetId && tweetExpanded"> <template v-else-if="tweetId && tweetExpanded">
<div ref="twitter"> <div ref="twitter" :class="$style.twitter">
<iframe <iframe
ref="tweet" ref="tweet"
allow="fullscreen;web-share" allow="fullscreen;web-share"
sandbox="allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin" sandbox="allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin"
scrolling="no" scrolling="no"
:style="{ position: 'relative', width: '100%', height: `${tweetHeight}px`, border: 0 }" data-transparent="true"
:style="{ position: 'relative', width: '100%', height: `${tweetHeight}px`, border: 0,borderRadius: '14px'}"
:src="`https://platform.twitter.com/embed/index.html?embedId=${embedId}&amp;hideCard=false&amp;hideThread=false&amp;lang=en&amp;theme=${defaultStore.state.darkMode ? 'dark' : 'light'}&amp;id=${tweetId}`" :src="`https://platform.twitter.com/embed/index.html?embedId=${embedId}&amp;hideCard=false&amp;hideThread=false&amp;lang=en&amp;theme=${defaultStore.state.darkMode ? 'dark' : 'light'}&amp;id=${tweetId}`"
frameborder="0"
allowtransparency="true"
></iframe> ></iframe>
</div> </div>
<div :class="$style.action"> <div :class="$style.action">
@ -83,7 +88,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { defineAsyncComponent, onDeactivated, onUnmounted, ref } from 'vue'; import { defineAsyncComponent, onDeactivated, onMounted, onUnmounted, ref } from 'vue';
import type { summaly } from '@misskey-dev/summaly'; import type { summaly } from '@misskey-dev/summaly';
import { url as local } from '@/config.js'; import { url as local } from '@/config.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -135,6 +140,15 @@ onDeactivated(() => {
playerEnabled.value = false; playerEnabled.value = false;
}); });
onMounted(() => {
if (defaultStore.state.alwaysShowPlayer) {
playerEnabled.value = true;
}
if (defaultStore.state.alwaysExpandTweet) {
tweetExpanded.value = true;
}
});
const requestUrl = new URL(props.url); const requestUrl = new URL(props.url);
if (!['http:', 'https:'].includes(requestUrl.protocol)) throw new Error('invalid url'); if (!['http:', 'https:'].includes(requestUrl.protocol)) throw new Error('invalid url');
@ -206,7 +220,13 @@ onUnmounted(() => {
position: relative; position: relative;
width: 100%; width: 100%;
} }
.twitter{
width: 70%;
}
.app{
background: red;
}
.disablePlayer { .disablePlayer {
position: absolute; position: absolute;
top: -1.5em; top: -1.5em;

View file

@ -36,6 +36,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="_gaps_s"> <div class="_gaps_s">
<MkSwitch v-model="showFixedPostForm">{{ i18n.ts.showFixedPostForm }}</MkSwitch> <MkSwitch v-model="showFixedPostForm">{{ i18n.ts.showFixedPostForm }}</MkSwitch>
<MkSwitch v-model="showFixedPostFormInChannel">{{ i18n.ts.showFixedPostFormInChannel }}</MkSwitch> <MkSwitch v-model="showFixedPostFormInChannel">{{ i18n.ts.showFixedPostFormInChannel }}</MkSwitch>
<MkSwitch v-model="alwaysShowPlayer">Youtube.comやnicovideo.jpのプレイヤーを全て開いた状態にする</MkSwitch>
<MkSwitch v-model="alwaysExpandTweet">Xのポストを常時表示させる</MkSwitch>
<MkFolder> <MkFolder>
<template #label>{{ i18n.ts.pinnedList }}</template> <template #label>{{ i18n.ts.pinnedList }}</template>
<div v-for="pinnedLists in defaultStore.reactiveState.pinnedUserLists.value" class="_margin"> <div v-for="pinnedLists in defaultStore.reactiveState.pinnedUserLists.value" class="_margin">
@ -433,6 +435,8 @@ const imageNewTab = computed(defaultStore.makeGetterSetter('imageNewTab'));
const nsfw = computed(defaultStore.makeGetterSetter('nsfw')); const nsfw = computed(defaultStore.makeGetterSetter('nsfw'));
const showFixedPostForm = computed(defaultStore.makeGetterSetter('showFixedPostForm')); const showFixedPostForm = computed(defaultStore.makeGetterSetter('showFixedPostForm'));
const showFixedPostFormInChannel = computed(defaultStore.makeGetterSetter('showFixedPostFormInChannel')); const showFixedPostFormInChannel = computed(defaultStore.makeGetterSetter('showFixedPostFormInChannel'));
const alwaysShowPlayer = computed(defaultStore.makeGetterSetter('alwaysShowPlayer'));
const alwaysExpandTweet = computed(defaultStore.makeGetterSetter('alwaysExpandTweet'));
const numberOfPageCache = computed(defaultStore.makeGetterSetter('numberOfPageCache')); const numberOfPageCache = computed(defaultStore.makeGetterSetter('numberOfPageCache'));
const numberOfGamingSpeed = computed(defaultStore.makeGetterSetter('numberOfGamingSpeed')); const numberOfGamingSpeed = computed(defaultStore.makeGetterSetter('numberOfGamingSpeed'));
const homeColor = computed(defaultStore.makeGetterSetter('homeColor')); const homeColor = computed(defaultStore.makeGetterSetter('homeColor'));
@ -562,6 +566,8 @@ watch([
disableStreamingTimeline, disableStreamingTimeline,
enableSeasonalScreenEffect, enableSeasonalScreenEffect,
alwaysConfirmFollow, alwaysConfirmFollow,
alwaysShowPlayer,
alwaysExpandTweet,
], async () => { ], async () => {
await reloadAsk(); await reloadAsk();
}); });

View file

@ -314,6 +314,14 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device', where: 'device',
default: false, default: false,
}, },
alwaysShowPlayer: {
where: 'device',
default: true,
},
alwaysExpandTweet: {
where: 'device',
default: false,
},
enableQuickAddMfmFunction: { enableQuickAddMfmFunction: {
where: 'device', where: 'device',
default: false, default: false,