2020-10-17 20:12:00 +09:00
|
|
|
<template>
|
2020-11-25 21:31:34 +09:00
|
|
|
<div>
|
|
|
|
<MkTab v-model:value="tab">
|
|
|
|
<option value="soft">{{ $t('_wordMute.soft') }}</option>
|
|
|
|
<option value="hard">{{ $t('_wordMute.hard') }}</option>
|
|
|
|
</MkTab>
|
|
|
|
<FormBase>
|
|
|
|
<div class="_formItem">
|
2020-10-17 20:12:00 +09:00
|
|
|
<div v-show="tab === 'soft'">
|
|
|
|
<MkInfo>{{ $t('_wordMute.softDescription') }}</MkInfo>
|
2020-11-25 21:31:34 +09:00
|
|
|
<FormTextarea v-model:value="softMutedWords">
|
2020-10-17 20:12:00 +09:00
|
|
|
<span>{{ $t('_wordMute.muteWords') }}</span>
|
|
|
|
<template #desc>{{ $t('_wordMute.muteWordsDescription') }}<br>{{ $t('_wordMute.muteWordsDescription2') }}</template>
|
2020-11-25 21:31:34 +09:00
|
|
|
</FormTextarea>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
|
|
|
<div v-show="tab === 'hard'">
|
|
|
|
<MkInfo>{{ $t('_wordMute.hardDescription') }}</MkInfo>
|
2020-11-25 21:31:34 +09:00
|
|
|
<FormTextarea v-model:value="hardMutedWords">
|
2020-10-17 20:12:00 +09:00
|
|
|
<span>{{ $t('_wordMute.muteWords') }}</span>
|
|
|
|
<template #desc>{{ $t('_wordMute.muteWordsDescription') }}<br>{{ $t('_wordMute.muteWordsDescription2') }}</template>
|
2020-11-25 21:31:34 +09:00
|
|
|
</FormTextarea>
|
|
|
|
<FormKeyValueView v-if="hardWordMutedNotesCount != null">
|
|
|
|
<template #key>{{ $t('_wordMute.mutedNotes') }}</template>
|
|
|
|
<template #value>{{ number(hardWordMutedNotesCount) }}</template>
|
|
|
|
</FormKeyValueView>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-25 21:31:34 +09:00
|
|
|
<FormButton @click="save()" primary inline :disabled="!changed"><Fa :icon="faSave"/> {{ $t('save') }}</FormButton>
|
|
|
|
</FormBase>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
import { faCommentSlash, faSave } from '@fortawesome/free-solid-svg-icons';
|
2020-11-25 21:31:34 +09:00
|
|
|
import FormTextarea from '@/components/form/textarea.vue';
|
|
|
|
import FormBase from '@/components/form/base.vue';
|
|
|
|
import FormKeyValueView from '@/components/form/key-value-view.vue';
|
|
|
|
import FormButton from '@/components/form/button.vue';
|
2020-10-17 20:12:00 +09:00
|
|
|
import MkTab from '@/components/tab.vue';
|
|
|
|
import MkInfo from '@/components/ui/info.vue';
|
|
|
|
import * as os from '@/os';
|
2020-11-25 21:31:34 +09:00
|
|
|
import number from '@/filters/number';
|
2020-10-17 20:12:00 +09:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-11-25 21:31:34 +09:00
|
|
|
FormBase,
|
|
|
|
FormButton,
|
|
|
|
FormTextarea,
|
|
|
|
FormKeyValueView,
|
2020-10-17 20:12:00 +09:00
|
|
|
MkTab,
|
|
|
|
MkInfo,
|
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
INFO: {
|
2020-11-03 20:36:12 +09:00
|
|
|
title: this.$t('wordMute'),
|
|
|
|
icon: faCommentSlash
|
2020-10-17 20:12:00 +09:00
|
|
|
},
|
|
|
|
tab: 'soft',
|
|
|
|
softMutedWords: '',
|
|
|
|
hardMutedWords: '',
|
|
|
|
hardWordMutedNotesCount: null,
|
|
|
|
changed: false,
|
|
|
|
faSave,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
softMutedWords: {
|
|
|
|
handler() {
|
|
|
|
this.changed = true;
|
|
|
|
},
|
|
|
|
deep: true
|
|
|
|
},
|
|
|
|
hardMutedWords: {
|
|
|
|
handler() {
|
|
|
|
this.changed = true;
|
|
|
|
},
|
|
|
|
deep: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
async created() {
|
|
|
|
this.softMutedWords = this.$store.state.settings.mutedWords.map(x => x.join(' ')).join('\n');
|
|
|
|
this.hardMutedWords = this.$store.state.i.mutedWords.map(x => x.join(' ')).join('\n');
|
|
|
|
|
|
|
|
this.hardWordMutedNotesCount = (await os.api('i/get-word-muted-notes-count', {})).count;
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.$emit('info', this.INFO);
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async save() {
|
|
|
|
this.$store.dispatch('settings/set', { key: 'mutedWords', value: this.softMutedWords.trim().split('\n').map(x => x.trim().split(' ')) });
|
|
|
|
await os.api('i/update', {
|
|
|
|
mutedWords: this.hardMutedWords.trim().split('\n').map(x => x.trim().split(' ')),
|
|
|
|
});
|
|
|
|
this.changed = false;
|
|
|
|
},
|
2020-11-25 21:31:34 +09:00
|
|
|
|
|
|
|
number
|
2020-10-17 20:12:00 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|