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 => {
return !props.mock && !posting.value && !posted.value &&
(
1 <= textLength.value ||
1 <= textLength.value ||
1 <= files.value.length ||
poll.value != null ||
props.renote != null ||
(props.reply != null && quoteId.value != null)
) &&
) &&
(textLength.value <= maxTextLength.value) &&
(!poll.value || poll.value.choices.length >= 2);
});
@ -857,7 +857,7 @@ async function post(ev?: MouseEvent) {
if (notesCount === 1) {
claimAchievement('notes1');
}
poll.value = null;
if (postData.schedule?.scheduledAt) {
const d = new Date(postData.schedule.scheduledAt);
@ -901,6 +901,7 @@ async function post(ev?: MouseEvent) {
if (m === 0 && s === 0) {
claimAchievement('postedAt0min0sec');
}
clear();
});
}).catch(err => {
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://')"
sandbox="allow-popups allow-scripts allow-storage-access-by-user-activation allow-same-origin"
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"
:src="player.url + (player.url.match(/\?/) ? '&autoplay=1&auto_play=1' : '?autoplay=1&auto_play=1')"
:style="{ border: 0 }"
:src="player.url"
:style="{ border: 0, backgroundColor: 'transparent' }"
allowtransparency="true"
></iframe>
<span v-else>invalid url</span>
</div>
@ -27,14 +28,18 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</template>
<template v-else-if="tweetId && tweetExpanded">
<div ref="twitter">
<div ref="twitter" :class="$style.twitter">
<iframe
ref="tweet"
allow="fullscreen;web-share"
sandbox="allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin"
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}`"
frameborder="0"
allowtransparency="true"
></iframe>
</div>
<div :class="$style.action">
@ -83,7 +88,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<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 { url as local } from '@/config.js';
import { i18n } from '@/i18n.js';
@ -135,6 +140,15 @@ onDeactivated(() => {
playerEnabled.value = false;
});
onMounted(() => {
if (defaultStore.state.alwaysShowPlayer) {
playerEnabled.value = true;
}
if (defaultStore.state.alwaysExpandTweet) {
tweetExpanded.value = true;
}
});
const requestUrl = new URL(props.url);
if (!['http:', 'https:'].includes(requestUrl.protocol)) throw new Error('invalid url');
@ -206,7 +220,13 @@ onUnmounted(() => {
position: relative;
width: 100%;
}
.twitter{
width: 70%;
}
.app{
background: red;
}
.disablePlayer {
position: absolute;
top: -1.5em;

View File

@ -36,6 +36,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="_gaps_s">
<MkSwitch v-model="showFixedPostForm">{{ i18n.ts.showFixedPostForm }}</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>
<template #label>{{ i18n.ts.pinnedList }}</template>
<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 showFixedPostForm = computed(defaultStore.makeGetterSetter('showFixedPostForm'));
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 numberOfGamingSpeed = computed(defaultStore.makeGetterSetter('numberOfGamingSpeed'));
const homeColor = computed(defaultStore.makeGetterSetter('homeColor'));
@ -562,6 +566,8 @@ watch([
disableStreamingTimeline,
enableSeasonalScreenEffect,
alwaysConfirmFollow,
alwaysShowPlayer,
alwaysExpandTweet,
], async () => {
await reloadAsk();
});

View File

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