1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-03 09:18:58 +09:00

wip: refactor(client): migrate components to composition api

This commit is contained in:
syuilo 2022-01-15 20:35:10 +09:00
parent 41e18aa993
commit daba865a94

View File

@ -47,8 +47,8 @@
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent } from 'vue'; import { } 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 FormSection from '@/components/form/section.vue'; import FormSection from '@/components/form/section.vue';
@ -56,63 +56,39 @@ import FormGroup from '@/components/form/group.vue';
import * as os from '@/os'; import * as os from '@/os';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
import * as symbols from '@/symbols'; import * as symbols from '@/symbols';
import { i18n } from '@/i18n';
import { $i } from '@/account';
export default defineComponent({ let isLocked = $ref($i.isLocked);
components: { let autoAcceptFollowed = $ref($i.autoAcceptFollowed);
FormSelect, let noCrawle = $ref($i.noCrawle);
FormSection, let isExplorable = $ref($i.isExplorable);
FormGroup, let hideOnlineStatus = $ref($i.hideOnlineStatus);
FormSwitch, let publicReactions = $ref($i.publicReactions);
}, let ffVisibility = $ref($i.ffVisibility);
emits: ['info'], let defaultNoteVisibility = $computed(defaultStore.makeGetterSetter('defaultNoteVisibility'));
let defaultNoteLocalOnly = $computed(defaultStore.makeGetterSetter('defaultNoteLocalOnly'));
let rememberNoteVisibility = $computed(defaultStore.makeGetterSetter('rememberNoteVisibility'));
let keepCw = $computed(defaultStore.makeGetterSetter('keepCw'));
data() { function save() {
return { os.api('i/update', {
isLocked: !!isLocked,
autoAcceptFollowed: !!autoAcceptFollowed,
noCrawle: !!noCrawle,
isExplorable: !!isExplorable,
hideOnlineStatus: !!hideOnlineStatus,
publicReactions: !!publicReactions,
ffVisibility: ffVisibility,
});
}
defineExpose({
[symbols.PAGE_INFO]: { [symbols.PAGE_INFO]: {
title: this.$ts.privacy, title: i18n.locale.privacy,
icon: 'fas fa-lock-open', icon: 'fas fa-lock-open',
bg: 'var(--bg)', bg: 'var(--bg)',
}, },
isLocked: false,
autoAcceptFollowed: false,
noCrawle: false,
isExplorable: false,
hideOnlineStatus: false,
publicReactions: false,
ffVisibility: 'public',
}
},
computed: {
defaultNoteVisibility: defaultStore.makeGetterSetter('defaultNoteVisibility'),
defaultNoteLocalOnly: defaultStore.makeGetterSetter('defaultNoteLocalOnly'),
rememberNoteVisibility: defaultStore.makeGetterSetter('rememberNoteVisibility'),
keepCw: defaultStore.makeGetterSetter('keepCw'),
},
created() {
this.isLocked = this.$i.isLocked;
this.autoAcceptFollowed = this.$i.autoAcceptFollowed;
this.noCrawle = this.$i.noCrawle;
this.isExplorable = this.$i.isExplorable;
this.hideOnlineStatus = this.$i.hideOnlineStatus;
this.publicReactions = this.$i.publicReactions;
this.ffVisibility = this.$i.ffVisibility;
},
methods: {
save() {
os.api('i/update', {
isLocked: !!this.isLocked,
autoAcceptFollowed: !!this.autoAcceptFollowed,
noCrawle: !!this.noCrawle,
isExplorable: !!this.isExplorable,
hideOnlineStatus: !!this.hideOnlineStatus,
publicReactions: !!this.publicReactions,
ffVisibility: this.ffVisibility,
});
}
}
}); });
</script> </script>