This commit is contained in:
fly_mc 2024-12-12 06:22:18 +08:00
parent 10a95d00c4
commit c3f821fe0a
2 changed files with 8 additions and 5 deletions

View file

@ -98,7 +98,7 @@ SPDX-License-Identifier: AGPL-3.0-only
:enableEmojiMenu="true" :enableEmojiMenu="true"
:enableEmojiMenuReaction="true" :enableEmojiMenuReaction="true"
/> />
<div v-if="defaultStore.state.autoTranslateButton && $i.policies.canUseTranslator && appearNote.text && isUnexpectedLanguage" style="padding-top: 5px; color: var(--MI_THEME-accent);"> <div v-if="autoTranslateButton && $i.policies.canUseTranslator && appearNote.text && isUnexpectedLanguage" style="padding-top: 5px; color: var(--MI_THEME-accent);">
<button v-if="!(translating || translation)" ref="translateButton" class="_button" @click.stop="translate()"><i class="ti ti-language-hiragana"></i>{{ i18n.ts.translate }}</button> <button v-if="!(translating || translation)" ref="translateButton" class="_button" @click.stop="translate()"><i class="ti ti-language-hiragana"></i>{{ i18n.ts.translate }}</button>
<button v-else class="_button" @click.stop="translation= null">{{ i18n.ts.close }}</button> <button v-else class="_button" @click.stop="translation= null">{{ i18n.ts.close }}</button>
</div> </div>
@ -320,24 +320,26 @@ const renoteCollapsed = ref(
const defaultLike = computed(() => defaultStore.state.like ?? '❤️'); const defaultLike = computed(() => defaultStore.state.like ?? '❤️');
const autoTranslateButton = ref(defaultStore.state.autoTranslateButton);
const inReplyToCollapsed = ref(defaultStore.state.collapseNotesRepliedTo); const inReplyToCollapsed = ref(defaultStore.state.collapseNotesRepliedTo);
const disableReactionsViewer = ref(defaultStore.reactiveState.disableReactionsViewer); const disableReactionsViewer = ref(defaultStore.reactiveState.disableReactionsViewer);
const collapsedUnexpectedLangs = ref(defaultStore.reactiveState.collapsedUnexpectedLangs); const collapsedUnexpectedLangs = ref(defaultStore.reactiveState.collapsedUnexpectedLangs);
const expectedLangs = computed(() => { const expectedLangs = computed(() => {
if (!collapsedUnexpectedLangs.value) return new Set(); if (!collapsedUnexpectedLangs.value && !autoTranslateButton.value) return new Set();
return new Set([ return new Set([
(miLocalStorage.getItem('lang') ?? navigator.language).slice(0, 2), (miLocalStorage.getItem('lang') ?? navigator.language).slice(0, 2),
navigator.language.slice(0, 2), navigator.language.slice(0, 2),
]); ]);
}); });
const noteLanguage = computed(() => { const noteLanguage = computed(() => {
if (!collapsedUnexpectedLangs.value) return ''; if (!collapsedUnexpectedLangs.value && !autoTranslateButton.value) return '';
if (!appearNote.value.text || appearNote.value.text.length < 10) return ''; if (!appearNote.value.text || appearNote.value.text.length < 10) return '';
return detectLanguage(appearNote.value.text); return detectLanguage(appearNote.value.text);
}); });
const isUnexpectedLanguage = computed(() => { const isUnexpectedLanguage = computed(() => {
if (!collapsedUnexpectedLangs.value) return false; if (!collapsedUnexpectedLangs.value && !autoTranslateButton.value) return false;
const lang = noteLanguage.value; const lang = noteLanguage.value;
return lang !== '' && !expectedLangs.value.has(lang); return lang !== '' && !expectedLangs.value.has(lang);
}); });

View file

@ -103,7 +103,7 @@ SPDX-License-Identifier: AGPL-3.0-only
:enableEmojiMenuReaction="true" :enableEmojiMenuReaction="true"
/> />
<a v-if="appearNote.renote != null" :class="$style.rn">RN:</a> <a v-if="appearNote.renote != null" :class="$style.rn">RN:</a>
<div v-if="defaultStore.state.autoTranslateButton && $i.policies.canUseTranslator && appearNote.text && isUnexpectedLanguage" style="padding-top: 5px; color: var(--MI_THEME-accent);"> <div v-if="autoTranslateButton && $i.policies.canUseTranslator && appearNote.text && isUnexpectedLanguage" style="padding-top: 5px; color: var(--MI_THEME-accent);">
<button v-if="!(translating || translation)" ref="translateButton" class="_button" @click.stop="translate()"><i class="ti ti-language-hiragana"></i>{{ i18n.ts.translate }}</button> <button v-if="!(translating || translation)" ref="translateButton" class="_button" @click.stop="translate()"><i class="ti ti-language-hiragana"></i>{{ i18n.ts.translate }}</button>
<button v-else class="_button" @click.stop="translation= null">{{ i18n.ts.close }}</button> <button v-else class="_button" @click.stop="translation= null">{{ i18n.ts.close }}</button>
</div> </div>
@ -359,6 +359,7 @@ const showingNoteHistoryRef = ref<ShowingNoteHistoryState>(null);
const disableReactionsViewer = ref(defaultStore.reactiveState.disableReactionsViewer); const disableReactionsViewer = ref(defaultStore.reactiveState.disableReactionsViewer);
const autoTranslateButton = ref(defaultStore.state.autoTranslateButton);
const expectedLangs = computed(() => new Set([ const expectedLangs = computed(() => new Set([
(miLocalStorage.getItem('lang') ?? navigator.language).slice(0, 2), (miLocalStorage.getItem('lang') ?? navigator.language).slice(0, 2),