mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-09 04:03:09 +02:00
Refactor settings/general to use Composition API (#8578)
* refactor(client): refactor settings/general to use Composition API * fix(client): turn watcher callback asynchronous
This commit is contained in:
parent
60010bdb0f
commit
247a9deb02
1 changed files with 114 additions and 149 deletions
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="_formRoot">
|
<div class="_formRoot">
|
||||||
<FormSelect v-model="lang" class="_formBlock">
|
<FormSelect v-model="lang" class="_formBlock">
|
||||||
<template #label>{{ $ts.uiLanguage }}</template>
|
<template #label>{{ i18n.ts.uiLanguage }}</template>
|
||||||
<option v-for="x in langs" :key="x[0]" :value="x[0]">{{ x[1] }}</option>
|
<option v-for="x in langs" :key="x[0]" :value="x[0]">{{ x[1] }}</option>
|
||||||
<template #caption>
|
<template #caption>
|
||||||
<I18n :src="$ts.i18nInfo" tag="span">
|
<I18n :src="i18n.ts.i18nInfo" tag="span">
|
||||||
<template #link>
|
<template #link>
|
||||||
<MkLink url="https://crowdin.com/project/misskey">Crowdin</MkLink>
|
<MkLink url="https://crowdin.com/project/misskey">Crowdin</MkLink>
|
||||||
</template>
|
</template>
|
||||||
|
@ -13,48 +13,48 @@
|
||||||
</FormSelect>
|
</FormSelect>
|
||||||
|
|
||||||
<FormRadios v-model="overridedDeviceKind" class="_formBlock">
|
<FormRadios v-model="overridedDeviceKind" class="_formBlock">
|
||||||
<template #label>{{ $ts.overridedDeviceKind }}</template>
|
<template #label>{{ i18n.ts.overridedDeviceKind }}</template>
|
||||||
<option :value="null">{{ $ts.auto }}</option>
|
<option :value="null">{{ i18n.ts.auto }}</option>
|
||||||
<option value="smartphone"><i class="fas fa-mobile-alt"/> {{ $ts.smartphone }}</option>
|
<option value="smartphone"><i class="fas fa-mobile-alt"/> {{ i18n.ts.smartphone }}</option>
|
||||||
<option value="tablet"><i class="fas fa-tablet-alt"/> {{ $ts.tablet }}</option>
|
<option value="tablet"><i class="fas fa-tablet-alt"/> {{ i18n.ts.tablet }}</option>
|
||||||
<option value="desktop"><i class="fas fa-desktop"/> {{ $ts.desktop }}</option>
|
<option value="desktop"><i class="fas fa-desktop"/> {{ i18n.ts.desktop }}</option>
|
||||||
</FormRadios>
|
</FormRadios>
|
||||||
|
|
||||||
<FormSwitch v-model="showFixedPostForm" class="_formBlock">{{ $ts.showFixedPostForm }}</FormSwitch>
|
<FormSwitch v-model="showFixedPostForm" class="_formBlock">{{ i18n.ts.showFixedPostForm }}</FormSwitch>
|
||||||
|
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<template #label>{{ $ts.behavior }}</template>
|
<template #label>{{ i18n.ts.behavior }}</template>
|
||||||
<FormSwitch v-model="imageNewTab" class="_formBlock">{{ $ts.openImageInNewTab }}</FormSwitch>
|
<FormSwitch v-model="imageNewTab" class="_formBlock">{{ i18n.ts.openImageInNewTab }}</FormSwitch>
|
||||||
<FormSwitch v-model="enableInfiniteScroll" class="_formBlock">{{ $ts.enableInfiniteScroll }}</FormSwitch>
|
<FormSwitch v-model="enableInfiniteScroll" class="_formBlock">{{ i18n.ts.enableInfiniteScroll }}</FormSwitch>
|
||||||
<FormSwitch v-model="useReactionPickerForContextMenu" class="_formBlock">{{ $ts.useReactionPickerForContextMenu }}</FormSwitch>
|
<FormSwitch v-model="useReactionPickerForContextMenu" class="_formBlock">{{ i18n.ts.useReactionPickerForContextMenu }}</FormSwitch>
|
||||||
<FormSwitch v-model="disablePagesScript" class="_formBlock">{{ $ts.disablePagesScript }}</FormSwitch>
|
<FormSwitch v-model="disablePagesScript" class="_formBlock">{{ i18n.ts.disablePagesScript }}</FormSwitch>
|
||||||
|
|
||||||
<FormSelect v-model="serverDisconnectedBehavior" class="_formBlock">
|
<FormSelect v-model="serverDisconnectedBehavior" class="_formBlock">
|
||||||
<template #label>{{ $ts.whenServerDisconnected }}</template>
|
<template #label>{{ i18n.ts.whenServerDisconnected }}</template>
|
||||||
<option value="reload">{{ $ts._serverDisconnectedBehavior.reload }}</option>
|
<option value="reload">{{ i18n.ts._serverDisconnectedBehavior.reload }}</option>
|
||||||
<option value="dialog">{{ $ts._serverDisconnectedBehavior.dialog }}</option>
|
<option value="dialog">{{ i18n.ts._serverDisconnectedBehavior.dialog }}</option>
|
||||||
<option value="quiet">{{ $ts._serverDisconnectedBehavior.quiet }}</option>
|
<option value="quiet">{{ i18n.ts._serverDisconnectedBehavior.quiet }}</option>
|
||||||
</FormSelect>
|
</FormSelect>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<template #label>{{ $ts.appearance }}</template>
|
<template #label>{{ i18n.ts.appearance }}</template>
|
||||||
<FormSwitch v-model="disableAnimatedMfm" class="_formBlock">{{ $ts.disableAnimatedMfm }}</FormSwitch>
|
<FormSwitch v-model="disableAnimatedMfm" class="_formBlock">{{ i18n.ts.disableAnimatedMfm }}</FormSwitch>
|
||||||
<FormSwitch v-model="reduceAnimation" class="_formBlock">{{ $ts.reduceUiAnimation }}</FormSwitch>
|
<FormSwitch v-model="reduceAnimation" class="_formBlock">{{ i18n.ts.reduceUiAnimation }}</FormSwitch>
|
||||||
<FormSwitch v-model="useBlurEffect" class="_formBlock">{{ $ts.useBlurEffect }}</FormSwitch>
|
<FormSwitch v-model="useBlurEffect" class="_formBlock">{{ i18n.ts.useBlurEffect }}</FormSwitch>
|
||||||
<FormSwitch v-model="useBlurEffectForModal" class="_formBlock">{{ $ts.useBlurEffectForModal }}</FormSwitch>
|
<FormSwitch v-model="useBlurEffectForModal" class="_formBlock">{{ i18n.ts.useBlurEffectForModal }}</FormSwitch>
|
||||||
<FormSwitch v-model="showGapBetweenNotesInTimeline" class="_formBlock">{{ $ts.showGapBetweenNotesInTimeline }}</FormSwitch>
|
<FormSwitch v-model="showGapBetweenNotesInTimeline" class="_formBlock">{{ i18n.ts.showGapBetweenNotesInTimeline }}</FormSwitch>
|
||||||
<FormSwitch v-model="loadRawImages" class="_formBlock">{{ $ts.loadRawImages }}</FormSwitch>
|
<FormSwitch v-model="loadRawImages" class="_formBlock">{{ i18n.ts.loadRawImages }}</FormSwitch>
|
||||||
<FormSwitch v-model="disableShowingAnimatedImages" class="_formBlock">{{ $ts.disableShowingAnimatedImages }}</FormSwitch>
|
<FormSwitch v-model="disableShowingAnimatedImages" class="_formBlock">{{ i18n.ts.disableShowingAnimatedImages }}</FormSwitch>
|
||||||
<FormSwitch v-model="squareAvatars" class="_formBlock">{{ $ts.squareAvatars }}</FormSwitch>
|
<FormSwitch v-model="squareAvatars" class="_formBlock">{{ i18n.ts.squareAvatars }}</FormSwitch>
|
||||||
<FormSwitch v-model="useSystemFont" class="_formBlock">{{ $ts.useSystemFont }}</FormSwitch>
|
<FormSwitch v-model="useSystemFont" class="_formBlock">{{ i18n.ts.useSystemFont }}</FormSwitch>
|
||||||
<FormSwitch v-model="useOsNativeEmojis" class="_formBlock">{{ $ts.useOsNativeEmojis }}
|
<FormSwitch v-model="useOsNativeEmojis" class="_formBlock">{{ i18n.ts.useOsNativeEmojis }}
|
||||||
<div><Mfm :key="useOsNativeEmojis" text="🍮🍦🍭🍩🍰🍫🍬🥞🍪"/></div>
|
<div><Mfm :key="useOsNativeEmojis" text="🍮🍦🍭🍩🍰🍫🍬🥞🍪"/></div>
|
||||||
</FormSwitch>
|
</FormSwitch>
|
||||||
<FormSwitch v-model="disableDrawer" class="_formBlock">{{ $ts.disableDrawer }}</FormSwitch>
|
<FormSwitch v-model="disableDrawer" class="_formBlock">{{ i18n.ts.disableDrawer }}</FormSwitch>
|
||||||
|
|
||||||
<FormRadios v-model="fontSize" class="_formBlock">
|
<FormRadios v-model="fontSize" class="_formBlock">
|
||||||
<template #label>{{ $ts.fontSize }}</template>
|
<template #label>{{ i18n.ts.fontSize }}</template>
|
||||||
<option value="small"><span style="font-size: 14px;">Aa</span></option>
|
<option value="small"><span style="font-size: 14px;">Aa</span></option>
|
||||||
<option :value="null"><span style="font-size: 16px;">Aa</span></option>
|
<option :value="null"><span style="font-size: 16px;">Aa</span></option>
|
||||||
<option value="large"><span style="font-size: 18px;">Aa</span></option>
|
<option value="large"><span style="font-size: 18px;">Aa</span></option>
|
||||||
|
@ -63,36 +63,36 @@
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<FormSwitch v-model="aiChanMode">{{ $ts.aiChanMode }}</FormSwitch>
|
<FormSwitch v-model="aiChanMode">{{ i18n.ts.aiChanMode }}</FormSwitch>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
<FormSelect v-model="instanceTicker" class="_formBlock">
|
<FormSelect v-model="instanceTicker" class="_formBlock">
|
||||||
<template #label>{{ $ts.instanceTicker }}</template>
|
<template #label>{{ i18n.ts.instanceTicker }}</template>
|
||||||
<option value="none">{{ $ts._instanceTicker.none }}</option>
|
<option value="none">{{ i18n.ts._instanceTicker.none }}</option>
|
||||||
<option value="remote">{{ $ts._instanceTicker.remote }}</option>
|
<option value="remote">{{ i18n.ts._instanceTicker.remote }}</option>
|
||||||
<option value="always">{{ $ts._instanceTicker.always }}</option>
|
<option value="always">{{ i18n.ts._instanceTicker.always }}</option>
|
||||||
</FormSelect>
|
</FormSelect>
|
||||||
|
|
||||||
<FormSelect v-model="nsfw" class="_formBlock">
|
<FormSelect v-model="nsfw" class="_formBlock">
|
||||||
<template #label>{{ $ts.nsfw }}</template>
|
<template #label>{{ i18n.ts.nsfw }}</template>
|
||||||
<option value="respect">{{ $ts._nsfw.respect }}</option>
|
<option value="respect">{{ i18n.ts._nsfw.respect }}</option>
|
||||||
<option value="ignore">{{ $ts._nsfw.ignore }}</option>
|
<option value="ignore">{{ i18n.ts._nsfw.ignore }}</option>
|
||||||
<option value="force">{{ $ts._nsfw.force }}</option>
|
<option value="force">{{ i18n.ts._nsfw.force }}</option>
|
||||||
</FormSelect>
|
</FormSelect>
|
||||||
|
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<template #label>{{ $ts.defaultNavigationBehaviour }}</template>
|
<template #label>{{ i18n.ts.defaultNavigationBehaviour }}</template>
|
||||||
<FormSwitch v-model="defaultSideView">{{ $ts.openInSideView }}</FormSwitch>
|
<FormSwitch v-model="defaultSideView">{{ i18n.ts.openInSideView }}</FormSwitch>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|
||||||
<FormLink to="/settings/deck" class="_formBlock">{{ $ts.deck }}</FormLink>
|
<FormLink to="/settings/deck" class="_formBlock">{{ i18n.ts.deck }}</FormLink>
|
||||||
|
|
||||||
<FormLink to="/settings/custom-css" class="_formBlock"><template #icon><i class="fas fa-code"></i></template>{{ $ts.customCss }}</FormLink>
|
<FormLink to="/settings/custom-css" class="_formBlock"><template #icon><i class="fas fa-code"></i></template>{{ i18n.ts.customCss }}</FormLink>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent } from 'vue';
|
import { computed, defineExpose, ref, watch } from 'vue';
|
||||||
import FormSwitch from '@/components/form/switch.vue';
|
import FormSwitch from '@/components/form/switch.vue';
|
||||||
import FormSelect from '@/components/form/select.vue';
|
import FormSelect from '@/components/form/select.vue';
|
||||||
import FormRadios from '@/components/form/radios.vue';
|
import FormRadios from '@/components/form/radios.vue';
|
||||||
|
@ -102,122 +102,87 @@ import FormLink from '@/components/form/link.vue';
|
||||||
import MkLink from '@/components/link.vue';
|
import MkLink from '@/components/link.vue';
|
||||||
import { langs } from '@/config';
|
import { langs } from '@/config';
|
||||||
import { defaultStore } from '@/store';
|
import { defaultStore } from '@/store';
|
||||||
import { ColdDeviceStorage } from '@/store';
|
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { unisonReload } from '@/scripts/unison-reload';
|
import { unisonReload } from '@/scripts/unison-reload';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
|
import { i18n } from '@/i18n';
|
||||||
|
|
||||||
export default defineComponent({
|
const lang = ref(localStorage.getItem('lang'));
|
||||||
components: {
|
const fontSize = ref(localStorage.getItem('fontSize'));
|
||||||
MkLink,
|
const useSystemFont = ref(localStorage.getItem('useSystemFont') != null);
|
||||||
FormSwitch,
|
|
||||||
FormSelect,
|
|
||||||
FormRadios,
|
|
||||||
FormGroup,
|
|
||||||
FormLink,
|
|
||||||
FormSection,
|
|
||||||
},
|
|
||||||
|
|
||||||
emits: ['info'],
|
async function reloadAsk() {
|
||||||
|
const { canceled } = await os.confirm({
|
||||||
|
type: 'info',
|
||||||
|
text: i18n.ts.reloadToApplySetting,
|
||||||
|
});
|
||||||
|
if (canceled) return;
|
||||||
|
|
||||||
data() {
|
unisonReload();
|
||||||
return {
|
}
|
||||||
[symbols.PAGE_INFO]: {
|
|
||||||
title: this.$ts.general,
|
|
||||||
icon: 'fas fa-cogs',
|
|
||||||
bg: 'var(--bg)'
|
|
||||||
},
|
|
||||||
langs,
|
|
||||||
lang: localStorage.getItem('lang'),
|
|
||||||
fontSize: localStorage.getItem('fontSize'),
|
|
||||||
useSystemFont: localStorage.getItem('useSystemFont') != null,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
const overridedDeviceKind = computed(defaultStore.makeGetterSetter('overridedDeviceKind'));
|
||||||
overridedDeviceKind: defaultStore.makeGetterSetter('overridedDeviceKind'),
|
const serverDisconnectedBehavior = computed(defaultStore.makeGetterSetter('serverDisconnectedBehavior'));
|
||||||
serverDisconnectedBehavior: defaultStore.makeGetterSetter('serverDisconnectedBehavior'),
|
const reduceAnimation = computed(defaultStore.makeGetterSetter('animation', v => !v, v => !v));
|
||||||
reduceAnimation: defaultStore.makeGetterSetter('animation', v => !v, v => !v),
|
const useBlurEffectForModal = computed(defaultStore.makeGetterSetter('useBlurEffectForModal'));
|
||||||
useBlurEffectForModal: defaultStore.makeGetterSetter('useBlurEffectForModal'),
|
const useBlurEffect = computed(defaultStore.makeGetterSetter('useBlurEffect'));
|
||||||
useBlurEffect: defaultStore.makeGetterSetter('useBlurEffect'),
|
const showGapBetweenNotesInTimeline = computed(defaultStore.makeGetterSetter('showGapBetweenNotesInTimeline'));
|
||||||
showGapBetweenNotesInTimeline: defaultStore.makeGetterSetter('showGapBetweenNotesInTimeline'),
|
const disableAnimatedMfm = computed(defaultStore.makeGetterSetter('animatedMfm', v => !v, v => !v));
|
||||||
disableAnimatedMfm: defaultStore.makeGetterSetter('animatedMfm', v => !v, v => !v),
|
const useOsNativeEmojis = computed(defaultStore.makeGetterSetter('useOsNativeEmojis'));
|
||||||
useOsNativeEmojis: defaultStore.makeGetterSetter('useOsNativeEmojis'),
|
const disableDrawer = computed(defaultStore.makeGetterSetter('disableDrawer'));
|
||||||
disableDrawer: defaultStore.makeGetterSetter('disableDrawer'),
|
const disableShowingAnimatedImages = computed(defaultStore.makeGetterSetter('disableShowingAnimatedImages'));
|
||||||
disableShowingAnimatedImages: defaultStore.makeGetterSetter('disableShowingAnimatedImages'),
|
const loadRawImages = computed(defaultStore.makeGetterSetter('loadRawImages'));
|
||||||
loadRawImages: defaultStore.makeGetterSetter('loadRawImages'),
|
const imageNewTab = computed(defaultStore.makeGetterSetter('imageNewTab'));
|
||||||
imageNewTab: defaultStore.makeGetterSetter('imageNewTab'),
|
const nsfw = computed(defaultStore.makeGetterSetter('nsfw'));
|
||||||
nsfw: defaultStore.makeGetterSetter('nsfw'),
|
const disablePagesScript = computed(defaultStore.makeGetterSetter('disablePagesScript'));
|
||||||
disablePagesScript: defaultStore.makeGetterSetter('disablePagesScript'),
|
const showFixedPostForm = computed(defaultStore.makeGetterSetter('showFixedPostForm'));
|
||||||
showFixedPostForm: defaultStore.makeGetterSetter('showFixedPostForm'),
|
const defaultSideView = computed(defaultStore.makeGetterSetter('defaultSideView'));
|
||||||
defaultSideView: defaultStore.makeGetterSetter('defaultSideView'),
|
const instanceTicker = computed(defaultStore.makeGetterSetter('instanceTicker'));
|
||||||
instanceTicker: defaultStore.makeGetterSetter('instanceTicker'),
|
const enableInfiniteScroll = computed(defaultStore.makeGetterSetter('enableInfiniteScroll'));
|
||||||
enableInfiniteScroll: defaultStore.makeGetterSetter('enableInfiniteScroll'),
|
const useReactionPickerForContextMenu = computed(defaultStore.makeGetterSetter('useReactionPickerForContextMenu'));
|
||||||
useReactionPickerForContextMenu: defaultStore.makeGetterSetter('useReactionPickerForContextMenu'),
|
const squareAvatars = computed(defaultStore.makeGetterSetter('squareAvatars'));
|
||||||
squareAvatars: defaultStore.makeGetterSetter('squareAvatars'),
|
const aiChanMode = computed(defaultStore.makeGetterSetter('aiChanMode'));
|
||||||
aiChanMode: defaultStore.makeGetterSetter('aiChanMode'),
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
watch(lang, () => {
|
||||||
lang() {
|
localStorage.setItem('lang', lang.value as string);
|
||||||
localStorage.setItem('lang', this.lang);
|
localStorage.removeItem('locale');
|
||||||
localStorage.removeItem('locale');
|
});
|
||||||
this.reloadAsk();
|
|
||||||
},
|
|
||||||
|
|
||||||
fontSize() {
|
watch(fontSize, () => {
|
||||||
if (this.fontSize == null) {
|
if (fontSize.value == null) {
|
||||||
localStorage.removeItem('fontSize');
|
localStorage.removeItem('fontSize');
|
||||||
} else {
|
} else {
|
||||||
localStorage.setItem('fontSize', this.fontSize);
|
localStorage.setItem('fontSize', fontSize.value);
|
||||||
}
|
}
|
||||||
this.reloadAsk();
|
});
|
||||||
},
|
|
||||||
|
|
||||||
useSystemFont() {
|
watch(useSystemFont, () => {
|
||||||
if (this.useSystemFont) {
|
if (useSystemFont.value) {
|
||||||
localStorage.setItem('useSystemFont', 't');
|
localStorage.setItem('useSystemFont', 't');
|
||||||
} else {
|
} else {
|
||||||
localStorage.removeItem('useSystemFont');
|
localStorage.removeItem('useSystemFont');
|
||||||
}
|
}
|
||||||
this.reloadAsk();
|
});
|
||||||
},
|
|
||||||
|
|
||||||
enableInfiniteScroll() {
|
watch([
|
||||||
this.reloadAsk();
|
lang,
|
||||||
},
|
fontSize,
|
||||||
|
useSystemFont,
|
||||||
|
enableInfiniteScroll,
|
||||||
|
squareAvatars,
|
||||||
|
aiChanMode,
|
||||||
|
showGapBetweenNotesInTimeline,
|
||||||
|
instanceTicker,
|
||||||
|
overridedDeviceKind
|
||||||
|
], async () => {
|
||||||
|
await reloadAsk();
|
||||||
|
});
|
||||||
|
|
||||||
squareAvatars() {
|
defineExpose({
|
||||||
this.reloadAsk();
|
[symbols.PAGE_INFO]: {
|
||||||
},
|
title: i18n.ts.general,
|
||||||
|
icon: 'fas fa-cogs',
|
||||||
aiChanMode() {
|
bg: 'var(--bg)'
|
||||||
this.reloadAsk();
|
|
||||||
},
|
|
||||||
|
|
||||||
showGapBetweenNotesInTimeline() {
|
|
||||||
this.reloadAsk();
|
|
||||||
},
|
|
||||||
|
|
||||||
instanceTicker() {
|
|
||||||
this.reloadAsk();
|
|
||||||
},
|
|
||||||
|
|
||||||
overridedDeviceKind() {
|
|
||||||
this.reloadAsk();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
async reloadAsk() {
|
|
||||||
const { canceled } = await os.confirm({
|
|
||||||
type: 'info',
|
|
||||||
text: this.$ts.reloadToApplySetting,
|
|
||||||
});
|
|
||||||
if (canceled) return;
|
|
||||||
|
|
||||||
unisonReload();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue