refactor(client): refactor import-export to use Composition API (#8579)

This commit is contained in:
Andreas Nedbal 2022-05-01 04:55:15 +02:00 committed by GitHub
parent 475b7556d8
commit 274ca6f7e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 63 additions and 91 deletions

View File

@ -37,8 +37,8 @@
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref } from 'vue';
<script lang="ts" setup>
import { defineExpose, ref } from 'vue';
import MkButton from '@/components/ui/button.vue';
import FormSection from '@/components/form/section.vue';
import FormGroup from '@/components/form/group.vue';
@ -48,23 +48,6 @@ import { selectFile } from '@/scripts/select-file';
import * as symbols from '@/symbols';
import { i18n } from '@/i18n';
export default defineComponent({
components: {
FormSection,
FormGroup,
FormSwitch,
MkButton,
},
emits: ['info'],
setup(props, context) {
const INFO = {
title: i18n.ts.importAndExport,
icon: 'fas fa-boxes',
bg: 'var(--bg)',
};
const excludeMutingUsers = ref(false);
const excludeInactiveUsers = ref(false);
@ -82,10 +65,10 @@ export default defineComponent({
});
};
const onError = (e) => {
const onError = (ev) => {
os.alert({
type: 'error',
text: e.message,
text: ev.message,
});
};
@ -133,23 +116,12 @@ export default defineComponent({
os.api('i/import-blocking', { fileId: file.id }).then(onImportSuccess).catch(onError);
};
return {
[symbols.PAGE_INFO]: INFO,
excludeMutingUsers,
excludeInactiveUsers,
exportNotes,
exportFollowing,
exportBlocking,
exportUserLists,
exportMuting,
importFollowing,
importUserLists,
importMuting,
importBlocking,
};
},
defineExpose({
[symbols.PAGE_INFO]: {
title: i18n.ts.importAndExport,
icon: 'fas fa-boxes',
bg: 'var(--bg)',
}
});
</script>